-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access simulation parameters through probes #4
Comments
Then, a probe has to cast the engine to ExtendedEngineWrapper to access the simulation parameters. This raises another question : should be add a type parameter to probes (the type of engine) ? |
Nevermind, it is more complicated than that to implement. Problem: When the methods of the probe are called, the engine provided as a parameter is the wrapped engine, and not the wrapper : the call to probes in the simulation process is made by the wrapped engine, with To cope with this problem, a reference to the engine should be stored inside the probe when it is added to an engine. The methods of the probe should be call with that value instead of the engine. Example: public interface IProbe {
...
ISimulationEngine getHost();
void setHost( ISimulationEngine e );
}
public EngineImplementation implements ISimulationEngine {
...
public void addProbe(String k, IProbe p) {
this.probes.put( k, p );
p.setHost( this );
}
public runNewSimulation( ISimulationModel model ) {
...
// After the initialization of the simulation, in the loop over the probes
probe.observeAtInitialTimes( initialTimestamp, probe.getHost() );
...
}
}
public class ExtendedEngineWrapper implements ISimulationEngine {
...
public void addProbe(String arg0, IProbe arg1) {
this.engine.addProbe(arg0, arg1);
arg1.setHost( this );
}
} |
In the end, very complicated thing for very little benefits. In simple cases (when the engines runs with the same instance of the model), it is easier to provide the parameters as an attribute of the probe. It still raises one philosophical question : are parameters part of the model, or only a means to initialize the content of the model ? In the latter, providing the parameters as an attribute of the probe is not a breach of the similar philosophy. Else, it introduces an unwanted hard link between model and view (probes). |
Issue witnessed in commit: 52c5843
Issue description
Probes cannot access neither the simulation parameters, nor the simulation model.
Issue location
In the interface
ISimulationEngine
(no such methods can be found).Possible solutions
Add a wrapper for simulation engines, adding such methods :
Edit: A proper implementation can be found here. Note that it does not work appropriately (see the comments below).
The text was updated successfully, but these errors were encountered: