Simulation.Run() method

Hello, i am trying to start a VC Simulation by pressing a Button in a Web Interface like this.

IMessageService msservice = IoC.Get<IMessageService>();
_connection.On("StartSimulation", () =>
{
          
    _app.Simulation.Run(10.00);
    if (_app.Simulation.IsRunning == true) { msservice.AppendMessage("Simulation started", MessageLevel.Warning); }

});

The Run() method gets invoked and “Simulation started” also gets printed when i press the Web button which means the Simulation should be running, right? However in VC, i can’t see the Simulation starting. If i start it manually in VC, it stops after 10 seconds, so simulation time of the method works.

Am i looking for a different method? I couldn’t find anything that works.

Any help would be appreciated.

Its a bit complicated. See this topic, and I think there are others too.

1 Like

In what environment are you running this code (VC, VC + KUKA OLP, Kuka.Sim, OEM app)? I tested the method and it works in vanilla VC. However if I have KUKA OLP enabled and try to simulate Kuka robot with KRL Executor it does not work. I don’t know what method would work also with Kuka.

-k

Thanks for the responses,

I’m using VC 4.6 Professional.
I’m running the code in my Initialize() of the IPlugin, could that be the problems cause? The Initialize should run on the main thread, right? As an alternative, I am thinking of putting everything in a IActionItem.

It could be the problem. I tested only using action item.

-k

Still doesn’t work, weird. :confused:

UPDATE:

I got it to work. I’ve tried this before but it wouldn’t recognize the Execute, now it does

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

Now it ensures the code is running on the main thread which was the cause of all problems

Thanks for you guys help!