Clean way to resume simulation

Hy,

how is it possible to resume a paused simulation?

image

Thx & Regards
Feature

Check ISimulationService.
You can get it from [Import] or from IoC.Get<ISimulationService>();

Hy @TSy ,

I did but I can’t make it happen, which method from the ISimulationService makes the magic happen?

Thx & Regards
Feature

So did you try these methods?
Note that pausing and running might not be synchronous, and these might not work as expected in certain scopes like from simulation start or stop event handlers.

void PauseSimulation();
void RunSimulation();

Hy @TSy ,

I tried everything, and jes it’s in an eventhandler! I would like resume the simulation like the user do it by click on Play when simulation is paused…

Is there a (synchronous) way??

Thx & Regards
Feature

Why would it need to be synchronous?
You can try using the Dispatcher to schedule an asynchronous call to the the RunSimulation() method, and then do something on the ISimulation.SimulationStarted event once the simulation has actually started running again.

Hy @TSy ,

may you have an example to call this over the dispatcher?

Thx & Regards
Feature

If you have a reference to Caliburn.Micro in your plugin then the least-code approach is probably this:

Execute.BeginOnUIThread(() =>
{
	IoC.Get<ISimulationService>().RunSimulation();
});

Hy @TSy ,

EDIT: I could make it work! → thx @TSy :slight_smile:

But if the Simulation stops couse of “stop axes in program-tab” it doesn’t work, why?

image

Thx & Regards
Feature

Hy @TSy ,

the problem, that the paused simulation can’t be run again is definetly reproducable:

Execute.BeginOnUIThread(() =>
{
	IoC.Get<ISimulationService>().RunSimulation();
});

Execute.BeginOnUIThread(() =>
{
	IoC.Get<ISimulationService>().PauseSimulation();
});

Execute.BeginOnUIThread(() =>
{
	IoC.Get<ISimulationService>().RunSimulation();
});

If you do this you get the message:

image

What must be done that the simulation runs again?

Thx & Regards
Feature

Try this instead of RunSimulation()

IoC.Get<ISimulationControlViewModel>().SwitchRunState();
1 Like

Can i do this via the python script?