roll back slbuild genrated model by one step
24 views (last 30 days)
Show older comments
I have generated a Simscape model to c excutable and code using slbuild and it has produced a main code rt_malloc_main in C which I am editing. I will eventually build that executable with gcc (and where needed g++) and use in Ubuntu 22.04.
For various reasons I need to roll back the model, i.e. reject all the progress made during the last call to rt_OneStep(S). This is a large model with many simscapep multibody library blocks, but also simulink blocks, and some matlab function blocks which use global variables through the persistent command.
What I ideally want would look like this:
save model S
advance one step: rt_OneStep(S)
if condition is not achieved completely roll back everything to how they where before rt_OneStep was called, or in the very least time and states so that a new call to rt_OneStep would give the exact same results: restore(S)
I currently have some ad-hoc lines of code to do save and restore and various efforts have also led me to use the rt_terminate (S) and rt_Init(S) to avoid bad memory allocation problems, and then use restore(S) in the hope that I also change my time and all states in the various blocks.
Is there a formal way to go back one step and cancel the effects of rt_OneStep(S) without starting the simulation from t=0?
The reason behind this roll back is that I am coupling this code with another code that needs the roll-back
3 Comments
Answers (0)
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!