Save model when the model is stop

Save model when the model is stop

s1125413
Advocate Advocate
313 Views
4 Replies
Message 1 of 5

Save model when the model is stop

s1125413
Advocate
Advocate

Hello FlexSim forum and @FelixMoehlmann 

As the title mentions, I'm trying to save the model using FlexScript when the model stops. It works when I execute the script manually, but it crashes to desktop when I place it in the On Model Stop event. I don't understand what causes this issue. Is there any method to solve this problem?

Thank you in advance.

s1125413_0-1778489301998.png

 

0 Likes
Accepted solutions (1)
314 Views
4 Replies
Replies (4)
Message 2 of 5

FelixMoehlmann
Collaborator
Collaborator

Saving the model resets the model. Resetting the model executes the On Run Stop code. You have created an infinite loop.

Might I ask what your goal is? Saving the model when it stops seems like a weird functionality to want to implement.

0 Likes
Message 3 of 5

s1125413
Advocate
Advocate

Dear @FelixMoehlmann ,

 

In my primary model, I plan to set the model runtime to about one month. However, when the time is up, the model will stop. I will then import a series of indicators into the database and would like to save the model for future use.

0 Likes
Message 4 of 5

FelixMoehlmann
Collaborator
Collaborator
Accepted solution

I guess your best bet would be to run that code just ahead of the stop time. You can use "Model.nextStopTime" to get the stop time if you want a dynamic approach. 

0 Likes
Message 5 of 5

joerg_vogel_HsH
Mentor
Mentor

You can try to save parts of your model as tree files. And probabaly you can save the statistic as well. It is not as elegant as saving a complete state but you get near as possible to a snapshot a of current model state.  

0 Likes