PDA

View Full Version : Keeping run speed after closing the model


Lydia Franck
04-27-2009, 06:26 AM
When I close my model and open again the run speed is always reset to 4.
If there is a fixed run speed for this model it is possible to code it e.g. in the OnModelOpen trigger. But I think the run speed is not model specific but depends on the situation (presentation, experiments, ...). I would prefer a solution which restores the last value for run speed.

Lydia

Carsten Seehafer
04-27-2009, 09:42 AM
The Run Speed is set in Main://project/exec/step and will not be saved in the model. But you can save the run speed within a model with labels.
I've build a small example which stores the run speed in a label. Just push "Y" to save the run speed and every time the simulation restarts the run speed will loaded from a label "runspeedflag". You have to save the model if you want to keep the last saved speed.

Carsten

Lydia Franck
04-30-2009, 04:30 AM
Thanks a lot! I will test the example as soon as possible (but I'm a bit busy in the moment).

Best wishes, Lydia.

Brandon Peterson
04-30-2009, 10:54 AM
Lydia, Carsten,

Another way to do this is to put the following line of code in the On Model Open trigger. The trigger can be located in the Tools-> Model Triggers -> On Model Open Menu.

runspeed(10);

Where 10 is the speed I want the model to be set to.

Carsten has shown a cleaver and good way of implementing a way to save the runspeed to a label. If you wanted another way to do this using the model triggers, so that you didn't have to conciously save the speed. You could use the On Reset or On Run Stop triggers to store the value every time. This way everytime the model was reset or stopped the current speed would be saved. You do have to remember though that in all three cases if you don't save the model then the speed is not saved as well.

If you don't want to save the speed on a particular object you can create a node in the Tools object and store the number there. You can then set and retrieve the number with the setnodenum and getnodenum commands.

Good Luck,
Brandon

Lydia Franck
05-06-2009, 04:38 AM
Carsten and Brandon,

thank you very much indeed!!

You can even use the OnModelOpen trigger instead of a UserEvent so that the correct run speed is displayed already before pressing Run.

Thanks again and best wishes, Lydia.