I tried with the following code, but the simulation doesn’t start (the time stays 0:00:00). When I hover over the play button, the text is changed from “play” to “pause”, so the code does something.
var runTime = IoC.Get<ISimulationSettingViewModel>().SimulationRunTime;
IoC.Get<ISimulationService>().SwitchRunState(runTime, 0);
Can someone help me how to start the simulation from code?
I guess the simulation doesn’t run because you didn’t set the runTime value. Try the following. Note the last line of code is used if you do not want to set the duration of the simulation run.
public void RunSimulation()
{
IoC.Get<ISimulationService>().ResetSimulation();
// Default simulation run time is 9999 years
var simulationRunTime = 315328464000; // 60*60*24*365*9999 (9999 years in second)
IoC.Get<ISimulationService>().SwitchRunState(simulationRunTime, 0);
IoC.Get<ISimulationService>().RunSimulation();
}