RobotStudio event

VirtualPanel - ChangeMode method hanging


Hi,

I have a problem with the ControllerOperatingMode and the ControllerState changing to ManualReducedSpeed and GuardStop respectively. I am using both RAB API and RS API. Here is the code:

RapidData rd = null;
Task[] tasks = null;
bool collfree = false;
tasks = controller.Rapid.GetTasks();

//for loop starts, i<2

if (controller.OperatingMode != ControllerOperatingMode.Auto && controller.State != ControllerState.MotorsOn)
{
    //code not executed when i=0

          VirtualPanel vp = VirtualPanel.Attach(controller);

        //when i=1, this line of code causes state change to MotorsOff and mode to AutoChange - program then hangs
          vp.ChangeMode(ControllerOperatingMode.Auto);    
}

try
{
          tasks[0].LoadProgramFromFile(edgeTestPgf, RapidLoadMode.Replace);
}
catch (ArgumentException ex)
{
    Trace.WriteLine("LoadProgramFromFile Exception..." );
}


Simulator.Start();
Thread.Sleep(2000);


//read value of RAPID variable after program runs in RS - this line of code causes state change to GuardStop  and mode to ManulaReducedSpeed...
rd = controller.Rapid.GetTask("T_ROB1").GetModule("MainModule").G etRapidData("coll_free");

collfree = Convert.ToBoolean(rd.Value.ToString());
            
//for loop ends


  • why does the state change to GuardStop when I try to read a RAPID variable?
  • why does the ChangeMode method cause the program to hang?
Thanks in advance,
Neil
neil2008-9-3 18:44:11

Comments

  • try setting AcknowledgeModeChanges to true, I think you are hanging up because the controller is waiting you to OK the mode change. Maybe calling GetRapidData forces the controller to return back to a stable state, e.g. ManualReducedSpeed, rather than a transition state like auto change?? RussD2008-9-3 19:17:4
    Russell Drown


  • Thanks for the reply.

    Setting the AcknowledgeModeChanges to TRUE fixed the problem. The ChangeMode method no longer hangs. However.....

    ...my original post didn't explain that the problem was actually with the LoadProgramFromFile method. This method would not execute because the controller was in ManualReducedSpeed mode and GuardStop state (I think).


    With the code below, I get: "ModeRejectException - The operation is not allowed in current
    operation mode.For example, a remote user may not be allowed to perform
    the operation in manual mode".

    Sometimes I get the error "Operation is illegal in current execution state".

    Both errors occur at **


    //for loop starts
    using (Mastership m = Mastership.Request(controllerR.Rapid))
    {
        while (controllerR.Rapid.ExecutionStatus != ExecutionStatus.Stopped)
                 {
                    Thread.Sleep(100);
                  }
             if (controllerR.Rapid.ExecutionStatus == ExecutionStatus.Stopped)
              {
                     if (controllerR.OperatingMode != ControllerOperatingMode.Auto && controllerR.State != ControllerState.MotorsOn)
                      {
                              VirtualPanel vp = VirtualPanel.Attach(controllerR);
                              vp.AcknowledgeModeChanges = true;
                              vp.ChangeMode(ControllerOperatingMode.Auto);
                              controllerR.State = ControllerState.MotorsOn;                               
                       }                           
                       tasks[0].LoadProgramFromFile(edgeTestPgf, RapidLoadMode.Replace); **                 
              }
            }
                     Simulator.Start();
                     m.Release();
      }
    //for loop ends

    The symptoms are similar to the post below. I have tried to putting a Thread.Sleep(3000) method before and after the LoadProgramFromFile method, but the error stil occurs.

     (http://forums.robotstudio.com/forum_post s.asp?TID=1850&KW=loadprogramfromfile)

    It seems there is a problem with loading a number of different program files within a for loop....is there any way of overcoming this problem?

    Thanks,
    Neil

    neil2008-9-5 14:3:34
  • Hello,

    Does this description in the "Known limitations" section in the coming 5.11 Release Notes clarify anything?

              In the PC SDK, the execution of this program sequence throws the exception "Operation is illegal in current execution state" when the second statement is executed:
    task1.DeleteProgram();
    task1.LoadProgramFromFile(...);

    The reason is that the predefined RAPID event routine SYS_RESET executes for a short while when a program is deleted, and it may still be executing when the controller program server is asked to load a program in the second statement. There is no way for the RAB programmer to find out exactly when the event routine has stopped executing, and when it is safe to call LoadProgramFromFile.  Listening to the event Rapid.ExecutionStatusChanged or reading the property Rapid.ExecutionStatus does no good, as these do not react to the start and stop of event routines. The suggested workaround is to use a time delay between the first and the second statement. <?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

    The same problem may occur when a request to load a RAPID program is directly followed by a request to start RAPID execution for example. Here, as well, a short delay may be necessary before calling the controller program server again. 

    The same problem may occur in the FlexPendant SDK as well. This limitation  exists in earlier releases as well.

    Best regards,

    Ingela Brorsson
    Software Engineer
    ABB Robotics, Sweden