First read the “Skemmi-QuickStart.pdf” (how to install OpenInterface and first steps into skemmi environment) and “OpenInterfaceDeveloperComponentGuide.pdf” (how to implement a new component).
Now, here is a step-by-step on how implement OpenVibe VRPN server in OpenInterface.
1) Open a new general project in eclipse (File> new> project> general> project);
call it, for example, “VRPN_OV”
2) Create an OI component folder (right click on the project name);
3) Create a skemmi diagram (right click on the project, new> other> OI Designer> Skemmi Diagram);
4) Open the Diagram and, with the blocks on the right, draw your component;
when you add the input click next on the first screen to modify the input argument.
We will use a string that will represent the VRPN server name (give a Parameter Name and click on “Add”).
When you add the output, click next on the first screen to modify the output arguments.
We will use a “uint” for the number of channels (give a Parameter Name and click on “Add”).
We will use a “double array” for the value of each channels (give a Parameter Name and click on “Add”).
5) Generate a c++ CDIL (right click on the component) and save it into the projet ETC directory;
6) Open the CDIL file (“VRPN_OV.xml” in the ETC directory) and modify the NDims ref for the double array :
Replace
<NDims ref=”### a parameter name giving the size of dimension No0 ###” type=”custom”/>
by
<NDims ref=”number” type=”custom”/>
Where “number” is the name of the argument that represent the size of the array.
VRPN code
Now we have to write the c++ code for the component. To help us, OpenInterface can generate the main structure.
For this, right click on the CDIL file and click on “Generate OI Component Skeleton> C Skeleton”.
We have to modify our VRPN code to comply with this structure.
An other point is that our VRPN code use a “struct” in the callback arguments but OpenInterface only allows primitive types (like int, double, …).
So, we will use the original Analog VRPN callback to call an other callback with the 2 primitive arguments needed (the number of channels and the array who contain the value of each channel).
Here is the final code that we have to implement :
VRPN_OV_Facet.h
VRPN_OV_Facet.cpp
Compile it, as a DLL, with Visual Studio.
In Eclipse, add “VRPN_OV_Facet.h” and “VRPN_OV.dll” in the bin directory of the component.
Install the component (right click on oi.package.manifest> istall OI Package)
Now we will verify the component.
We will use a simple Sinus oscillator in OpenVibe and send the signal with a VRPN server.
In our Skemmi diagram, we will add an array spliter (OI Adapters) and an oscilloscope (Skemmi components). The array splitter is used to split our array into separate data (the OI oscilloscope can’t display an array, it can only displays separate values). There is no offset for the splitter array (we want all the channels).
Feed Input Data (click on the Flash) and give the correct address for the VRPN client (the same as in OpenVibe VRPN server). Mark the “Threaded Execution” for the infinite main loop.
Run OpenVibe and OpenInterface.