minute read

Commands

You are reading our Automation1 API documentation for the .NET programming language.

The Basics

In the .NET API, Commands lets you execute AeroScript commands on the Automation1 controller. You can also command your Automation1 controller by running AeroScript programs with Tasks or by using a Command Queue in the .NET API.

When you execute AeroScript commands through the .NET API, a quantity of fixed overhead occurs. There will be some delay between commands when you execute two of them, one right after the other. This delay averages from 3 to 5 milliseconds, based on the performance of the PC. It also includes all the network latency delays that might occur. If this delay is not compatible with your production environment, use Command Queue.

Command Queue lets you queue up multiple commands on the controller to prevent overhead and delay. Some AeroScript commands are available only in Command Queue because they cannot accept this overhead and delay. These commands include all the AeroScript commands that require Lookahead Synchronization, such as velocity blending, cutter radius compensation, and corner rounding. If you execute a series of MovePt() or MovePvt() commands, this process also requires a command queue. If you do not use one, your profile will stutter and drop out because of the delay that occurs between commands.

All .NET methods have the same blocking behavior as their AeroScript function equivalents. Thus if the AeroScript function blocks, the .NET method will too.

All .NET methods will apply relative paths as absolute paths, which is different from their AeroScript function equivalents.

All AeroScript commands execute on a controller task. By default, AeroScript commands executed through the .NET API will execute on task 1. You can change the task to execute on by specifying the executionTaskName argument in one of the method overloads.

How to Use

In the .NET API, Commands is part of the Controller.Runtime property. For all the APIs that operate under this property, the Automation1 controller must be running before you can execute commands. For more information about this property, see the Controller page.

To execute an AeroScript command, call the .NET method with the same arguments as the corresponding AeroScript function. To see a list of all the .NET methods that you can use for Commands, refer to the Full Reference section. Some commands accept either axes or tasks. You can specify an axis by axis name or axis index. You can specify a task by task name or task index. Refer to the example that follows.

Copy
controller.Runtime.Commands.Motion.Enable(string axis);
controller.Runtime.Commands.Motion.MoveLinear(string axis, double distance, double coordinatedSpeed);
controller.Runtime.Commands.Motion.Disable(string axis);

You can execute almost every AeroScript command through the .NET API. But there might be some special cases where you want to execute custom AeroScript. If this occurs, use the Controller.Runtime.Commands.Execute method to specify arbitrary AeroScript to execute. Refer to the example that follows.

Copy
controller.Runtime.Commands.Execute(string stringAeroScript);

By default, AeroScript commands that are executed through the .NET API will execute on task 1. You can change the task to execute on by specifying the executionTaskName argument. You can specify a task by task name or task index. Refer to the example that follows.

Copy
controller.Runtime.Commands.Motion.Enable(string axis, string executionTaskName);
controller.Runtime.Commands.Motion.MoveLinear(string axis, double distance, double coordinatedSpeed, string executionTaskName);
controller.Runtime.Commands.Motion.Disable(string axis);

Example Code

Copy
// Enable the X axis, move it 10 mm at 5 mm/s for a 2 second move, then disable it.
// All on task 1, the default task.
controller.Runtime.Commands.Motion.Enable("X");
controller.Runtime.Commands.Motion.MoveLinear("X", 10, 5);
controller.Runtime.Commands.Motion.Disable("X");

Thread Safety

All the methods that operate under the Controller.Runtime.Commands property are thread safe. You can call them from two or more threads without interference.

But because the .NET API is thread safe, this does not mean the controller can process the AeroScript commands that you are trying to execute. A single controller task can execute only one AeroScript command at a time. Thus if you try to execute multiple commands on the same task from different .NET threads, an exception will occur. Similarly, a single axis can do motion only from one AeroScript command. Thus if you try to execute a motion command on an axis that is currently executing a previous motion command, an exception will occur. To prevent controller errors from occurring, you must synchronize or coordinate your process.

For Example

You can make a single .NET thread responsible for a single controller task and some number of motion axes.

Full Reference

For more information about the methods that are available for Commands, refer to the list that follows.

Controller.Runtime.Commands Methods