Good day, Currently, there are 6 edit boxes, which are connected to specific parameters in the model (and the user can edit these boxes in the model runtime) and a button that doesn't do anything. I want to make this button to restart the simulation, yet if the user previously changed some contents in edit boxes, the new simulation will run based on the user input values. The model name is Simulation. If anyone knows an example (or specific code) it would be highly appreciated.
Asked
Active
Viewed 430 times
2 Answers
2
Adding to Artem's reply on issue 1: it is actually possible, but you will create a new thread, so a bit advanced. This code will stop the current experiment and restart it:
new Thread() {
public void run() {
getExperiment().stop(); // stops the model
getExperiment().run(); // runs it again
getExperimentHost().setPresentable( getEngine().getRoot() );
}
}.start();
You can make sure to set your params for the new run as Artem discussed.
PS: Would be better to simply make the user press the stop button, feed the values to the experiment page, let the user re-adjust them if needed and let her restart the model as usual.

Benjamin
- 10,603
- 3
- 16
- 28
0
To clarify, there are two questions:
- How to have the button in model that restarts the simulation? - this isn't possible. But what can be done is have a button that calls
stopSimulation()
and returns the user into the Simulation set up - How to have changes made in model during runtime propagate to the next Simulation run? - save the values from edit fields into internal properties of the model and then access them in Simulation's
After simulation run
Java action by checkingroot
object