TaskCallRoutine Method (String) |
Namespace: ABB.Robotics.Controllers.RapidDomain
public StartResult CallRoutine( string routine )
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.
Using the method requires special attention due to the fact that the routine might be stopped before it is finished. To enable normal execution again CancelRoutinemust be called. See the FlexPendant Program Editor for an idea about how this can be implemented.
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; } ...