Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

How to check if a simulation is running?

#1
Is there a function call that can be used to see if a simulation is currently running or some other way for RoboDK to tell me if a simulation has completed?
#2
Yes, you can check if a robot or a program is running by calling the procedure Busy.

You can find more information and an example here:
https://robodk.com/doc/en/PythonAPI/robo....Item.Busy
#3
Thanks!  Here's some C# code that Runs a program if it is not running, or un-pauses it if it was already running but paused by setting speed to 0:
Code:
private void RunSimulation( string prog_name )
{
        if (Check_RDK())
        {
               IItem prog = _rdk.GetItemByName( prog_name, ItemType.Program);
               if (prog.Valid())
               {
                   m_paused = false;
                   _rdk.SetSimulationSpeed(5);
                   if (prog.Busy())
                       return;
                   else
                       prog.RunProgram();
               }
       }
}
#4
Thank you for sharing. You could also check if the Simulation Speed is 0 or too small before overriding this value.

Example:
Code:
if (RDK.SimulationSpeed() < 0.001) {
    RDK.SetSimulationSpeed(5);
}
Also, you can trigger Stop on a program or a robot to stop it. This has the same effect as pressing the Escape key.
  




Users browsing this thread:
1 Guest(s)