Reputation: 133
I would like to give the user a button that allows them to skip ahead 1 hour in the simulation and then continue running the model if play is clicked. The code below allows the user to skip ahead an hour, however they are unable to resume the simulation when play is clicked.
double nextHour = time() + 60;
pauseSimulation();
getEngine().runFast(nextHour); //Runs the model to the next hour when button is clicked
Any help much appreciated.
Upvotes: 2
Views: 622
Reputation: 133
AnyLogic Support suggested the following solution, which I have used:
Unfortunately, Ben's suggestion didn't didn't work; it seems to cause an issue when pauseSimulation()
is used.
Upvotes: 2
Reputation: 1
Try adding runSimulation()
after the last line. But probably, that does not work. In that case:
Create a dynamic event (not the normal event) with the line runSimulation()
in its action code.
In the button code, before the runFast...
line, write create_MyDynamicEvent(1, HOUR)
. This will trigger the even 1 hour later and unpause the model.
Upvotes: 3