Click or drag to resize

TaskCallRoutine Method (String, RegainMode)

Starts executing the specified routine.

Namespace:  ABB.Robotics.Controllers.RapidDomain
Assembly:  ABB.Robotics.Controllers (in ABB.Robotics.Controllers.dll) Version: 6.5.129.0
Syntax
C#
public StartResult CallRoutine(
	string routine,
	RegainMode regainMode
)

Parameters

routine
Type: SystemString
The routine to execute. NOTE: Valid routines are service routines and ordinary routines that do not take any parameters.
regainMode
Type: ABB.Robotics.Controllers.RapidDomainRegainMode
RegainMode to start execution with

Return Value

Type: StartResult
The result of the start as a StartResult object.
Exceptions
ExceptionCondition
InvalidOperationExceptionIf any task is executing.
GeneralExceptionIf the routine is missing, mastership is held by another client, wrong execution level (pp is already inside a service routine, which has been stopped without a succeeding call to CancelRoutine ) etc.
Remarks

The method works in both manual and automatic operating mode.

Any previous execution stack will be kept and after the routine is executed the program pointer will be restored to its previous location.

NOTE: Using this method requires special attention due to the fact that the routine might be stopped before it is finished. If this happens CancelRoutine must be called before it is possible to continue normal execution again. (See also how this is done in the FlexPendant Program Editor view).

Examples
This example starts execution of the routine "TestMove" in task T_ROB1
using ABB.Robotics;
using ABB.Robotics.Controllers;
using ABB.Robotics.Controllers.RapidDomain;
...
Controller c = null;
Task tRob1 = null;
...

try
{
  c = new Controller();
  tRob1 = c.Rapid.GetTask("T_ROB1");

  if (c.Rapid.ExecutionStatus == ExecutionStatus.Stopped)
  {
    StartResult sRes = StartResult.Ok;
    sRes = tRob1.CallRoutine("TestMove");

    if (sRes != StartResult.Ok)
    {
      // Take action depending on StartResult
      if (sRes == StartResult.RegainRequest || sRes == StartResult.RegainRequestNoClear)
      {
        sRes = tRob1.CallRoutine("TestMove", RegainMode.Regain);
      }
      else
      {
        ...
      }
    }
      //Set up subscription to be able to check whether the service routine is ready or not when execution stops
      tRob1.ExecutionStateChanged += new ExecutionStateChangedEventHandler(tRob1_ExecutionStateChanged);
  }
}
catch (System.Exception se)
{
  // Exception handling
  ...
}
finally
{
  // Clean up all temporary resources
  if (tRob1 != null)
    tRob1.Dispose();
  tRob1 = null;

  if (c != null)
    c.Dispose();
  c = null;
}
...
See Also