Hi
just following up on this topic after long time,
I was able to use save the systemState feature and use scripting to get the model variables change during runtime.
I was happy until, my model integrated DLL. Now when I resume after changing ModelVar using script “on the fly”, DLL restarts from plecsStart().
Can we have this fixed?
b.t.w my company uses 4.2.6 version, please tell me if this bug/issue is fixed in any updated versions.
More details:
I am scripting a simulation over XML-RPC and need to change a model variable at a specific point in simulation time. As advised in earlier threads, I am doing this by splitting the run into two segments and handing the system state across the boundary:
seg1 = plecs.simulate(MODEL, {
"ModelVars": {"MyVar": 100},
"SolverOpts": {"StartTime": 0.0, "StopTime": 0.5},
})
state = plecs.get(MODEL, "SystemState")
seg2 = plecs.simulate(MODEL, {
"ModelVars": {"MyVar": 120},
"SolverOpts": {"StartTime": 0.5, "StopTime": 1.0,
"InitialSystemState": state},
})
This works: the variable takes the new value in the second segment, and the circuit states continue from where the first segment stopped.
I can see from its log output that plecsStart is called again for the second segment, so the controller re-initialises from scratch while the plant continues from the restored state.
Is the DLL unloaded and reloaded between consecutive simulate() calls in the same PLECS session, or does it stay loaded so that static variables retain their values? This determines whether preserving controller state is possible at all.