Devices Tutorial

NameLocation
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

  1. An input that is sent to the device
  2. 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

  1. Open Tutorials solution
  2. Compile the project MyDevicePlugin
  3. 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).
  4. Start the Vortex Editor
  5. Add the module MyDeviceModule the editor setup
    1. From the home page, click on Options
    2. Click on Setup
    3. In the Application Setup section, click on the Editor icon next to the editor.vxc file­­. This will open the setup document.
    4. In the toolbox, search for MyDeviceModule, and add the a module to the setup.
    5. Configure the module IP address and port.
      1. The implementation only opens a socket to LocalAddress:LocalPort, Data will be read from that address.
      2. 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.
    6. Save the setup file
  6. From the home menu, create a new control interface document.
    1. Add an input and an output of type double
    2. In the Explorer, right-click on the ControlInterface object and select "Add Device...".
    3. You should be able to add the My Device Extension device to the Control Interface
    4. Map it following the Control Interface documentation.
    5. save it.
  7. The interface can be added to a mechanism and be work normally.