VAL 3 tasks
List the VAL 3 tasks with their state, program line and runtime error, then suspend, resume or kill a task.
This page shows how to follow and control the VAL 3 tasks of a Staubli CS8 or CS9 controller: list them with their state, their program line and their runtime error, then suspend, resume or kill a task.
List the tasks
GetTasks() returns every task of the controller.
var controller = new StaubliController();controller.Connect("192.168.0.254");ControllerTask[] tasks = controller.Soap.GetTasks();foreach (ControllerTask task in tasks){// State: Idle, Transition, Running, Stepping, StoppedConsole.WriteLine($"{task.Name} ({task.State}), priority {task.Priority}, created by {task.CreatedBy}");// Line of the VAL 3 program that the task executesProgramLine line = task.ProgramLine;if (line != null)Console.WriteLine($" {line.ProgramName}:{line.LineNumber} {line.LineContent}");// Runtime error of the task, 0 when there is noneif (task.RuntimeError != 0)Console.WriteLine($" Error {task.RuntimeError}: {task.RuntimeErrorDescription}");}controller.Disconnect();}
| Property | Meaning |
|---|---|
Name | Name of the task |
CreatedBy | The project that created the task |
State | Idle, Transition, Running, Stepping or Stopped |
Priority | Priority of the task |
ProgramLine | Application, program, line number and text of the current line |
RuntimeError | Code of the runtime error of the task, 0 when there is none |
RuntimeErrorDescription | Text of the runtime error |
RuntimeError is the way to detect that a VAL 3 program stopped on an error. See Monitor the state of the robot.
Suspend, resume and kill
A task is identified by its name and by the project that created it: pass Name and CreatedBy as they come from GetTasks().
var controller = new StaubliController();controller.Connect("192.168.0.254");// A task is identified by its name and by the project that created itControllerTask task = controller.Soap.GetTasks().First(t => t.Name == "myTask");// Pause the taskcontroller.Soap.TaskSuspend(task.Name, task.CreatedBy);// Continue itcontroller.Soap.TaskResume(task.Name, task.CreatedBy);// Stop it for goodcontroller.Soap.TaskKill(task.Name, task.CreatedBy);controller.Disconnect();}
TaskSuspendpauses the task.TaskResumecontinues a suspended task.TaskKillstops the task for good.
When the task does not exist, the method throws a CustomSoapException with the code TaskNotFound.
Try it in the demo application
Everything on this page can be tried without writing code, in the VAL Applications page of the demo application.

The demo application is open source. The C# source of this page is ValApplicationsControl.cs.
Reference
Methods of SoapClientBase :// Get all the tasks available on the controllerControllerTask[] GetTasks();// Kill a task on the controllervoid TaskKill(string taskName, string createdBy);// Resume a task on the controllervoid TaskResume(string taskName, string createdBy);// Suspend a task on the controllervoid TaskSuspend(string taskName, string createdBy);
Represents a task running on the controller.
| Member | Type | Description |
|---|---|---|
ControllerTask() Constructor | Initializes a new instance of the ControllerTask class. | |
CreatedBy Property | string | Name of the entity that created the task. |
Name Property | string | Name of the task. |
Priority Property | int | Priority level of the task. |
ProgramLine Property | ProgramLine | Current program line being executed by the task. |
RuntimeError Property | int | Runtime error code (0 if no error). |
RuntimeErrorDescription Property | string | Human-readable description of the runtime error. |
State Property | ControllerTaskState | Current execution state of the task. |
Equals(object) Method | bool | |
GetHashCode() Method | int | |
ToString() Method | string |
Execution state of a controller task.
| Name | Value | Description |
|---|---|---|
Idle | 0 | Task is idle and not executing. |
Running | 2 | Task is currently running. |
Stepping | 3 | Task is executing step by step. |
Stopped | 4 | Task is stopped. |
Transition | 1 | Task is transitioning between states. |
Represents a line of a VAL3 program being executed on the controller.
| Member | Type | Description |
|---|---|---|
ProgramLine() Constructor | Initializes a new instance of the ProgramLine class. | |
ApplicationName Property | string | Name of the application containing the program. |
LineContent Property | string | Content of the line being executed. |
LineNumber Property | int | Line number currently being executed. |
ProgramName Property | string | Name of the program. |
Equals(object) Method | bool | |
GetHashCode() Method | int | |
ToString() Method | string |