minute read
Controller
You are reading our Automation1 API documentation for the .NET programming language.
The Basics
The .NET API revolves around the Controller class. All interaction with an Automation1 controller is through an instance of this class. To start using the .NET API, you must connect to an Automation1 controller to get an instance of the Controller class. Then the properties on this class will give you access to the various Automation1 controller features.
When you connect to a controller, this process does not automatically start it. You can connect to a non-running Automation1 controller without starting it. When you disconnect a controller, this process does not stop a controller that is running. The Controller.Runtime property represents features that you can access only if the controller is started and running. For more information, refer to the Controller Runtime section below.
You can connect to many Automation1 controllers at the same time in the same custom application. You can also connect to the same Automation1 controller multiple times at the same time.
How to Use
You can connect to multiple controllers at the same time or connect to the same controller multiple times. Call the Controller.Connect method to connect to a specific controller, either a locally installed PC-based controller, a remote PC-based controller, or a remote drive-based controller. Call the Controller.ConnectUsb method to connect to a drive-based controller that is plugged into your computer over USB.
When you are done interacting with the controller, call the Controller.Disconnect method.
Example Code
// Connect to the iSMC that is installed on this PC. You can optionally specify an IP address to connect to a remote controller.
Controller controller = Controller.Connect();
// Start the Automation1 controller that you are connected to, to make sure it is running.
controller.Start();
// With the controller running, you can access the Runtime property.
controller.Runtime.Commands.Motion.Enable("X");
// Disconnect from the controller when you are done interacting with it.
// When you disconnect the controller, this does not stop it. The controller will continue to run.
controller.Disconnect();
Controller Runtime
The Controller.Runtime property represents features that you can access only if the controller is started and running. If the controller is not running or is in the process of resetting, an exception will be thrown. The controller runtime is different from the Controller.Configuration property, which is how you configure the behavior of the controller the next time it starts or is reset. Controller.Configuration requires you to reset the controller while Controller.Runtime changes have an immediate effect.
Controller Information
You can use the Controller.Information property to get information about the Automation1 controller to which you are connected. Refer to the example that follows.
string host = controller.Information.Host;
string controllerName = controller.Information.Name;
string serialNumber = controller.Information.SerialNumber;
Version version = controller.Information.Version;
The Controller.Information property also has some events to which you can subscribe. These events let you know when the controller is started, stopped, or reset. You can also use them to get the state of the Automation1 controller if your custom application needs to change its behavior. Refer to the example that follows.
EventHandler<ControllerEventArgs> ControllerStarted;
EventHandler<ControllerStoppedEventArgs> ControllerStopped;
EventHandler<ControllerEventArgs> ControllerReset;
Machine Controller Definition Files
Machine Controller Definition (MCD) files define an Automation1 controller. These files can include all the parameters, configuration, and files that define your motion control system. MCD files make it easy for you to back up your controller configuration, test parameter changes, and replicate a machine.
You can download and upload MCD files from the .NET API. Refer to the example that follows.
void DownloadMcdToFile(string mdkFilePathToMcd, bool shouldIncludeControllerFiles, bool shouldIncludeConfiguration);
void UploadMcdToController(string mdkFilePathToMcd, bool shouldIncludeControllerFiles, bool shouldIncludeConfiguration, bool eraseController);
For more information, see the Machine Controller Definition Files page.
Thread Safety
The Controller.IsRunning property is thread safe. You can call this property from two or more threads without interference.
The Controller.Connect and Controller.Disconnect methods are thread safe. You can call them from two or more threads without interference.
The Controller.Start, Controller.Stop, and Controller.Reset methods are not thread safe. Only one thread at a time can call these methods. If two or more threads must call these methods, you must use locks to limit access.
For all other properties on the Controller class, see their respective reference pages for information about their thread safety.
Full Reference
For more information about the properties, methods, and events that are available for Controller, refer to the lists that follow.
Controller Properties
Gets a way to compile AeroScript programs and libraries for the Automation1 controller.
Gets a way to change the configuration of the Automation1 controller. Configuration is what defines the behavior of the Automation1 controller. Changes to configuration usually require a controller reset to take effect.
Gets a way to read and write controller files on the Automation1 controller.
Gets general information about the Automation1 controller.
Gets whether or not the Automation1 controller has started and is currently running (that is, running AeroScript programs or performing motion). If the controller is running, you can safely access the controller's runtime components via the Controller.Runtime property.
Gets a way to use the Automation1 controller's runtime components. Accessing this property is only valid if the controller is running. You can check the state of the Automation1 controller with the Controller.IsRunning property.
Controller Methods
Connects to an Automation1 controller. Use this overload to connect to a controller when the controller is installed on the same computer and has access control disabled.
Use this method to create a Controller object in order to interact with an Automation1 controller. Connecting will not change the running state of an Automation1 controller (that is, if it has not started and is not running, it will remain not running), see the Controller.Start method.
Returns: A new Controller object that represents a connection to the Automation1 controller.
Connects to an Automation1 controller, using the specified userName and password. Use this overload to log in to a controller when the controller is installed on the same computer and has access control enabled.
Use this method to create a Controller object in order to interact with an Automation1 controller. Connecting will not change the running state of an Automation1 controller (that is, if it has not started and is not running, it will remain not running). See the Controller.Start method.
userName: The user name for a user with access to the Automation1 controller.
password: The password for the specified user.
Returns: A new Controller object that represents a connection to the Automation1 controller.
Connects to an Automation1 controller running on the specified host. Use this overload to connect to a controller when the controller is installed on a different computer and has access control disabled.
Use this method to create a Controller object in order to interact with an Automation1 controller. Connecting will not change the running state of an Automation1 controller (that is, if it has not started and is not running, it will remain not running). See the Controller.Start method.
host: The host name or host IP address of the Automation1 controller to connect to.
Returns: A new Controller object that represents a connection to the Automation1 controller.
Connects to an Automation1 controller running on the specified host, using the specified userName and password. Use this overload to log in to a controller when the controller is installed on a different computer and has access control enabled.
Use this method to create a Controller object in order to interact with an Automation1 controller. Connecting will not change the running state of an Automation1 controller (that is, if it has not started and is not running, it will remain not running). See the Controller.Start method.
host: The host name or host IP address of the Automation1 controller to connect to.
userName: The user name for a user with access to the Automation1 controller.
password: The password for the specified user.
Returns: A new Controller object that represents a connection to the Automation1 controller.
Returns: A new Controller object that represents a connection to the Automation1 controller.
Disconnects from the Automation1 controller. Disconnecting will not change the running state of the Automation1 controller (that is, if it has started and is running, it will remain running). After calling this method, this Controller object is no longer usable.
Downloads a Machine Controller Definition (.mcd) file from the controller and saves it to the specified MDK file path. A downloaded MCD file can have both controller configuration and controller files. To copy the configuration and files of the controller, you can upload the MCD file to the controller. When you do this, at least one of the parameters that follow must be true: shouldIncludeControllerFiles
and shouldIncludeConfiguration
.
mdkFilePathToMcd
: The MDK file path to which you save the downloaded MCD file.
shouldIncludeControllerFiles
: Defines if controller files should be included or not included in the download.
shouldIncludeConfiguration
: Defines if the controller configuration should be included or not included in the download.
Starts the Automation1 controller if it is not already running. Connecting to the Automation1 controller will not change the running state of the controller. Thus, use this method to start the controller after connecting. If the controller is already running, this method does nothing. You can check the state of the Automation1 controller with the Controller.IsRunning property.
When the Automation1 controller begins to start, the Controller.Information.ControllerStarting event will be raised. When the Automation1 controller completes the start, the Controller.Information.ControllerStarted event will be raised and you can begin any Automation1 controller interaction.
Stops the Automation1 controller if it is currently running. If the controller is already stopped, this method does nothing. You will remain connected to the Automation1 controller after you stop it. Stopping the Automation1 controller does not change your connection.
When the Automation1 controller stops, the Controller.Information.ControllerStopped event will be raised.
Uploads a Machine Controller Definition (.mcd) file to the controller and saves it from the specified MDK file path. When you do this, at least one of the parameters that follow must be true: shouldIncludeControllerFiles
and shouldIncludeConfiguration
. Before you call this method, make sure that the controller does not have important data and information that can be overwritten or erased. You can download an MCD file to save important data and information before you upload a different MCD file.
mdkFilePathToMcd
: The MDK file path to which you save the downloaded MCD file.
shouldIncludeControllerFiles
: Defines if controller files should be included or not included in the download.
shouldIncludeConfiguration
: Defines if the controller configuration should be included or not included in the download.
eraseController
: Defines if the controller should be erased or not before you upload the new files.
Controller.Information Properties
Gets the host name or host IP address that was used to connect to the Automation1 controller. This plus the Controller.Information.Port property identify the network endpoint of the controller.
Gets the name of the Automation1 controller.
Gets the port number that was used to connect to the Automation1 controller. This plus the Controller.Information.Host property identify the network endpoint of the controller.
Gets the serial number of the Automation1 controller.
Gets the version of the Automation1 controller.
Controller.Information Events
An event that is raised when the Automation1 controller begins to reset.
An event that is raised when the Automation1 controller completes a reset.
An event that is raised when the Automation1 controller is in the process of starting.
An event that is raised when the Automation1 controller has started.
An event that is raised when the Automation1 controller has stopped.
Controller.Runtime Properties
Gets the collection of motion axes on the Automation1 controller, accessed by axis name or axis index.
See the Axes page.
Gets a way to execute AeroScript commands on the Automation1 controller.
See the Commands page.
Gets a way to collect data on the Automation1 controller. Data collection is a feature to gather a set of data in a real-time, deterministic way. Data collection is different from status in that status is not real-time and it is not time-series data. Status also has variable latency when retrieving.
See the Data Collection page.
Gets the HyperWire devices that are connected to the Automation1 controller.
See the Devices page.
Gets a way to get and set active controller parameters in use by the Automation1 controller. Changes to active controller parameters are not persisted and the active controller parameter values are lost after a controller reset. To save controller parameters permanently, use the Controller.Configuration property.
See the Active Parameters page.
Gets a way to retrieve status from the Automation1 controller. Retrieved status represents a moment in time. Status is different from data collection in that status is not real-time and it is not time-series data. Status also has variable latency when retrieving.
See the Status page.
Gets the collection of controller tasks on the Automation1 controller, accessed by task name or task index.
See the Tasks page.
Gets a way to get and set controller variables on the Automation1 controller.
See the Controller Variables page.