TaskCallRoutine Method (String, RegainMode) |
Namespace: ABB.Robotics.Controllers.RapidDomain
public StartResult CallRoutine( string routine, RegainMode regainMode )
Exception | Condition |
---|---|
InvalidOperationException | If any task is executing. |
GeneralException | If 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. |
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).
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; } ...