Devices Tutorial
Name | Location |
---|---|
Devices | <Vortex Studio Installation Folder>\tutorials\MyDevicePlugin |
Sample module and extension that can be used as a base for an extension implementing an IDevice
It shows the basic of having a module creating it own devices and adding them to the simulation.
It implements a device module that communicates thru UDP. It reads/writes a double (8 bytes) every frame.
You need to provide an UDP implementation that will read/write the data.
Classes
2 Vortex objects are included in this plugin: a module and an extension.
MyDeviceModule
This Vortex Module demonstrates how to implement a module that communicates with a device.
It can be used as a template for an implementation of interface ISimulatorModule
.
It shows how to initialize a module with callback onAddToApplication()
.
It shows how to cleanup a module with callback onRemoveFromApplication()
.
A single device is supported by this module, however a module could certainly have support for multiple devices.
The module also spawn it's own device, which is convenient but will only work in a single node simulator such as the editor.
To enable support on multiples nodes, the device must not be spawned by the module but added to the setup file.
It shows how to manage extensions; In this case, the module handle extensions of type MyDeviceExtension and process them each frame.
During the pre update segment, it reads a double from the UDP channel.
During the post update segment, it writes a double in the UDP channel
MyDeviceExtension
A simple extension that is managed by the module MyDeviceModule.
MyDeviceExtension defines how the device is represented in the Vortex world.
It only serves as an interface with the UDP channel, providing 2 data fields
- An input that is sent to the device
- An output to be read from the device.
MyDeviceExtension tells Vortex that it is a device by having this extension derive from IDeviceÂ
and can be used as a template for an implementation of interface IDevice
.
UPD
This namespace collection of a few methods to manage a UDP socket.
See Vortex Studio SDK - Device Mapping for more details about Devices
See Vortex Studio SDK - Customizing Vortex for information about making plugins and extensions.
See C++ Tutorial 1: Plugins for a detailed example of making a plugin.
Using the tutorial
- Open Tutorials solution
- Compile the project MyDevicePlugin
- From the <Vortex Studio Installation Folder>\tutorials\plugins folder, copy the built MyDevicePlugin.vxp into the Vortex Studio plugins folder (<Vortex Studio Installation Folder>\plugins).
- Start the Vortex Editor
- Add the module MyDeviceModule the editor setup
- From the home page, click on Options
- Click on Setup
- In the Application Setup section, click on the Editor icon next to the editor.vxc fileÂÂ. This will open the setup document.
- In the toolbox, search for MyDeviceModule, and add the a module to the setup.
- Configure the module IP address and port.
- The implementation only opens a socket to LocalAddress:LocalPort, Data will be read from that address.
- Data is sent to Device address and Device Port, but it must match the local ones for the send to work. The full implementation is left to the user.
- Save the setup file
- From the home menu, create a new control interface document.
- Add an input and an output of type double
- In the Explorer, right-click on the ControlInterface object and select "Add Device...".
- You should be able to add the My Device Extension device to the Control Interface
- Map it following the Control Interface documentation.
- save it.
- The interface can be added to a mechanism and be work normally.