Use the asynchronous custom device driver template to build the RT Driver VI for a custom device.
You can use most of the Custom Device API VIs when building an asynchronous RT Driver VI. The Asynchronous Device Properties VIs and Asynchronous Device Channels VIs configure functionality exclusive to asynchronous custom devices.
An asynchronous custom device uses a two-loop architecture, one loop for receiving commands and one for transferring data, with sections of code for initialization and cleanup before and after the loops, respectively. The template VI uses a While Loop for data transfer, but you also can use a Timed Loop.In general, you use a While Loop if timing is not important or if you want the loop to run as fast as it can. You use a Timed Loop if you need the loop to execute deterministically or run pseudo-synchronously with the Primary Control Loop.
Controls—The input controls are specially named controls that the VeriStand Engine will use to provide the asynchronous custom device loops with data. To function, the name of each control must match the following names.
Initialization Code—The template includes initialization code to do the following:
If you use a Timed Loop for your data loop, you can also add code here to configure the Timed Loop.
Command Loop—The command loop allows you to send commands to and receive data from your custom device that you can not easily do using a DBL channel value. By using the Send Custom Device Message VI in a LabVIEW VI or calling a corresponding .NET method, you can use, for example, a custom workspace object or NI TestStand automation script to send a command to your custom device, which can then execute a response to that command.
For example, a generic custom device for logging. If you need to change configuration data, such as the file path to which to save log files, at run time, you could create a custom workspace control to send this data to the command loop of the device, and then configure the command loop to update the configuration data when the data is received.
The command loop contains the following three events:
For an example custom device that uses Send Custom Device Message VI in a LabVIEW VI to communicate directly with the custom device, refer to the labview\examples\NI Veristand\Custom Devices\Communication Example directory.
|Data Loop—Use this loop to read input data from the Device Inputs FIFO, update the data, and send the updated data via the Device Outputs FIFO to the rest of VeriStand. The template data loop contains code that reads the input data, adds it to a random number, and writes it back to the output channels. The data loop also executes shutdown if it receives a shut down notification from the command loop.|
|Cleanup Code—Use the optional Status Notifier control to publish the final error state of your device regardless of errors. If a Status Notifier control is present in the RT driver VI, VeriStand this as an indication that the device has shut down. Otherwise the VeriStand provides default status notification for the device.|