Commit 0a35969d authored by Jussi Lindgren's avatar Jussi Lindgren

Plugins: Port can now be specified for VRPN server boxes

Note that all the VRPN server boxes in the scenarios require an update after this.
parent 0ba33790
<OpenViBE-Scenario>
<Boxes>
<Box>
<Identifier>(0x00001e4a, 0x000028f9)</Identifier>
<Name>Analog VRPN Server</Name>
<AlgorithmClassIdentifier>(0x0ddc3a7e, 0x6f6e6401)</AlgorithmClassIdentifier>
<Inputs>
<Input>
<TypeIdentifier>(0x544a003e, 0x6dcba5f6)</TypeIdentifier>
<Name>Input 1</Name>
</Input>
</Inputs>
<Identifier>(0x0000391a, 0x00002733)</Identifier>
<Name>Keyboard stimulator</Name>
<AlgorithmClassIdentifier>(0x00d317b9, 0x6324c3ff)</AlgorithmClassIdentifier>
<Outputs>
<Output>
<TypeIdentifier>(0x6f752dd0, 0x082a321e)</TypeIdentifier>
<Name>Outgoing Stimulations</Name>
</Output>
</Outputs>
<Settings>
<Setting>
<TypeIdentifier>(0x79a9edeb, 0x245d83fc)</TypeIdentifier>
<Name>Peripheral name</Name>
<DefaultValue>openvibe-vrpn</DefaultValue>
<Value>openvibe_vrpn_analog</Value>
<TypeIdentifier>(0x330306dd, 0x74a95f98)</TypeIdentifier>
<Name>Filename</Name>
<DefaultValue>${Path_Data}/plugins/stimulation/simple-keyboard-to-stimulations.txt</DefaultValue>
<Value>${Path_Data}/plugins/stimulation/simple-keyboard-to-stimulations.txt</Value>
</Setting>
</Settings>
<Attributes>
<Attribute>
<Identifier>(0x1fa7a38f, 0x54edbe0b)</Identifier>
<Value>400</Value>
<Value>144</Value>
</Attribute>
<Attribute>
<Identifier>(0x1fa963f5, 0x1a638cd4)</Identifier>
<Value>33</Value>
<Value>25</Value>
</Attribute>
<Attribute>
<Identifier>(0x207c9054, 0x3c841b63)</Identifier>
<Value>176</Value>
<Value>448</Value>
</Attribute>
<Attribute>
<Identifier>(0x4e7b798a, 0x183beafb)</Identifier>
<Value>(0x2f4c9e00, 0x5dc619e4)</Value>
<Value>(0x8d89d3b7, 0x8339d210)</Value>
</Attribute>
<Attribute>
<Identifier>(0xad100179, 0xa3c984ab)</Identifier>
<Value>136</Value>
<Value>161</Value>
</Attribute>
<Attribute>
<Identifier>(0xce18836a, 0x9c0eb403)</Identifier>
<Identifier>(0xc80ce8af, 0xf699f813)</Identifier>
<Value>1</Value>
</Attribute>
<Attribute>
<Identifier>(0xcfad85b0, 0x7c6d841c)</Identifier>
<Identifier>(0xce18836a, 0x9c0eb403)</Identifier>
<Value>1</Value>
</Attribute>
<Attribute>
<Identifier>(0xfba64161, 0x65304e21)</Identifier>
<Value></Value>
</Attribute>
</Attributes>
</Box>
<Box>
<Identifier>(0x0000300d, 0x0000752a)</Identifier>
<Identifier>(0x00004299, 0x000039c3)</Identifier>
<Name>Button VRPN Server</Name>
<AlgorithmClassIdentifier>(0x0e382e6f, 0x5be1f00c)</AlgorithmClassIdentifier>
<Inputs>
......@@ -74,6 +70,12 @@
<DefaultValue>openvibe-vrpn</DefaultValue>
<Value>openvibe_vrpn_button</Value>
</Setting>
<Setting>
<TypeIdentifier>(0x007deef9, 0x2f3e95c6)</TypeIdentifier>
<Name>Server port</Name>
<DefaultValue>3883</DefaultValue>
<Value>3883</Value>
</Setting>
<Setting>
<TypeIdentifier>(0x2c132d6e, 0x44ab0d97)</TypeIdentifier>
<Name>Button 1 ON</Name>
......@@ -102,11 +104,11 @@
<Attributes>
<Attribute>
<Identifier>(0x1fa7a38f, 0x54edbe0b)</Identifier>
<Value>400</Value>
<Value>464</Value>
</Attribute>
<Attribute>
<Identifier>(0x1fa963f5, 0x1a638cd4)</Identifier>
<Value>33</Value>
<Value>38</Value>
</Attribute>
<Attribute>
<Identifier>(0x207c9054, 0x3c841b63)</Identifier>
......@@ -114,15 +116,86 @@
</Attribute>
<Attribute>
<Identifier>(0x4e7b798a, 0x183beafb)</Identifier>
<Value>(0x1473765a, 0x12eb3520)</Value>
<Value>(0x810e985a, 0xebd5f30f)</Value>
</Attribute>
<Attribute>
<Identifier>(0xad100179, 0xa3c984ab)</Identifier>
<Value>135</Value>
<Value>157</Value>
</Attribute>
<Attribute>
<Identifier>(0xc67a01dc, 0x28ce06c1)</Identifier>
<Value></Value>
</Attribute>
<Attribute>
<Identifier>(0xc73e83ec, 0xf855c5bc)</Identifier>
<Value>false</Value>
</Attribute>
<Attribute>
<Identifier>(0xce18836a, 0x9c0eb403)</Identifier>
<Value>3</Value>
<Value>4</Value>
</Attribute>
<Attribute>
<Identifier>(0xcfad85b0, 0x7c6d841c)</Identifier>
<Value>1</Value>
</Attribute>
<Attribute>
<Identifier>(0xfba64161, 0x65304e21)</Identifier>
<Value></Value>
</Attribute>
</Attributes>
</Box>
<Box>
<Identifier>(0x0000644d, 0x0000444f)</Identifier>
<Name>Analog VRPN Server</Name>
<AlgorithmClassIdentifier>(0x0ddc3a7e, 0x6f6e6401)</AlgorithmClassIdentifier>
<Inputs>
<Input>
<TypeIdentifier>(0x544a003e, 0x6dcba5f6)</TypeIdentifier>
<Name>Input 1</Name>
</Input>
</Inputs>
<Settings>
<Setting>
<TypeIdentifier>(0x79a9edeb, 0x245d83fc)</TypeIdentifier>
<Name>Peripheral name</Name>
<DefaultValue>openvibe-vrpn</DefaultValue>
<Value>openvibe_vrpn_analog</Value>
</Setting>
<Setting>
<TypeIdentifier>(0x007deef9, 0x2f3e95c6)</TypeIdentifier>
<Name>Server port</Name>
<DefaultValue>3883</DefaultValue>
<Value>3883</Value>
</Setting>
</Settings>
<Attributes>
<Attribute>
<Identifier>(0x1fa7a38f, 0x54edbe0b)</Identifier>
<Value>464</Value>
</Attribute>
<Attribute>
<Identifier>(0x1fa963f5, 0x1a638cd4)</Identifier>
<Value>38</Value>
</Attribute>
<Attribute>
<Identifier>(0x207c9054, 0x3c841b63)</Identifier>
<Value>160</Value>
</Attribute>
<Attribute>
<Identifier>(0x4e7b798a, 0x183beafb)</Identifier>
<Value>(0xba317000, 0xa4f8dfcb)</Value>
</Attribute>
<Attribute>
<Identifier>(0xad100179, 0xa3c984ab)</Identifier>
<Value>159</Value>
</Attribute>
<Attribute>
<Identifier>(0xc73e83ec, 0xf855c5bc)</Identifier>
<Value>false</Value>
</Attribute>
<Attribute>
<Identifier>(0xce18836a, 0x9c0eb403)</Identifier>
<Value>2</Value>
</Attribute>
<Attribute>
<Identifier>(0xcfad85b0, 0x7c6d841c)</Identifier>
......@@ -135,7 +208,7 @@
</Attributes>
</Box>
<Box>
<Identifier>(0x000032fa, 0x00004868)</Identifier>
<Identifier>(0x00007ac0, 0x0000780b)</Identifier>
<Name>Sinus oscillator</Name>
<AlgorithmClassIdentifier>(0x7e33bdb8, 0x68194a4a)</AlgorithmClassIdentifier>
<Outputs>
......@@ -171,7 +244,7 @@
</Attribute>
<Attribute>
<Identifier>(0x1fa963f5, 0x1a638cd4)</Identifier>
<Value>23</Value>
<Value>25</Value>
</Attribute>
<Attribute>
<Identifier>(0x207c9054, 0x3c841b63)</Identifier>
......@@ -183,7 +256,7 @@
</Attribute>
<Attribute>
<Identifier>(0xad100179, 0xa3c984ab)</Identifier>
<Value>109</Value>
<Value>121</Value>
</Attribute>
<Attribute>
<Identifier>(0xc80ce8af, 0xf699f813)</Identifier>
......@@ -196,7 +269,7 @@
</Attributes>
</Box>
<Box>
<Identifier>(0x00006611, 0x00000c6c)</Identifier>
<Identifier>(0x00007d51, 0x0000566f)</Identifier>
<Name>Signal display</Name>
<AlgorithmClassIdentifier>(0x0055be5f, 0x087bdd12)</AlgorithmClassIdentifier>
<Inputs>
......@@ -242,7 +315,7 @@
</Attribute>
<Attribute>
<Identifier>(0x1fa963f5, 0x1a638cd4)</Identifier>
<Value>23</Value>
<Value>25</Value>
</Attribute>
<Attribute>
<Identifier>(0x207c9054, 0x3c841b63)</Identifier>
......@@ -254,7 +327,7 @@
</Attribute>
<Attribute>
<Identifier>(0xad100179, 0xa3c984ab)</Identifier>
<Value>100</Value>
<Value>113</Value>
</Attribute>
<Attribute>
<Identifier>(0xce18836a, 0x9c0eb403)</Identifier>
......@@ -266,71 +339,22 @@
</Attribute>
</Attributes>
</Box>
<Box>
<Identifier>(0x0000686d, 0x00007683)</Identifier>
<Name>Keyboard stimulator</Name>
<AlgorithmClassIdentifier>(0x00d317b9, 0x6324c3ff)</AlgorithmClassIdentifier>
<Outputs>
<Output>
<TypeIdentifier>(0x6f752dd0, 0x082a321e)</TypeIdentifier>
<Name>Outgoing Stimulations</Name>
</Output>
</Outputs>
<Settings>
<Setting>
<TypeIdentifier>(0x330306dd, 0x74a95f98)</TypeIdentifier>
<Name>Filename</Name>
<DefaultValue>${Path_Data}/plugins/stimulation/simple-keyboard-to-stimulations.txt</DefaultValue>
<Value>${Path_Data}/plugins/stimulation/simple-keyboard-to-stimulations.txt</Value>
</Setting>
</Settings>
<Attributes>
<Attribute>
<Identifier>(0x1fa7a38f, 0x54edbe0b)</Identifier>
<Value>144</Value>
</Attribute>
<Attribute>
<Identifier>(0x1fa963f5, 0x1a638cd4)</Identifier>
<Value>23</Value>
</Attribute>
<Attribute>
<Identifier>(0x207c9054, 0x3c841b63)</Identifier>
<Value>448</Value>
</Attribute>
<Attribute>
<Identifier>(0x4e7b798a, 0x183beafb)</Identifier>
<Value>(0x8d89d3b7, 0x8339d210)</Value>
</Attribute>
<Attribute>
<Identifier>(0xad100179, 0xa3c984ab)</Identifier>
<Value>140</Value>
</Attribute>
<Attribute>
<Identifier>(0xc80ce8af, 0xf699f813)</Identifier>
<Value>1</Value>
</Attribute>
<Attribute>
<Identifier>(0xce18836a, 0x9c0eb403)</Identifier>
<Value>1</Value>
</Attribute>
</Attributes>
</Box>
</Boxes>
<Links>
<Link>
<Identifier>(0x00001a75, 0x00004fe4)</Identifier>
<Identifier>(0x00001e9b, 0x00000fcc)</Identifier>
<Source>
<BoxIdentifier>(0x0000686d, 0x00007683)</BoxIdentifier>
<BoxIdentifier>(0x0000391a, 0x00002733)</BoxIdentifier>
<BoxOutputIndex>0</BoxOutputIndex>
</Source>
<Target>
<BoxIdentifier>(0x0000300d, 0x0000752a)</BoxIdentifier>
<BoxInputIndex>0</BoxInputIndex>
<BoxIdentifier>(0x00004299, 0x000039c3)</BoxIdentifier>
<BoxInputIndex>1</BoxInputIndex>
</Target>
<Attributes>
<Attribute>
<Identifier>(0x1b32c44c, 0x1905e0e9)</Identifier>
<Value>162</Value>
<Value>163</Value>
</Attribute>
<Attribute>
<Identifier>(0x358ae8b5, 0x0f8bacd1)</Identifier>
......@@ -338,57 +362,57 @@
</Attribute>
<Attribute>
<Identifier>(0x3f0a3b27, 0x570913d2)</Identifier>
<Value>379</Value>
<Value>440</Value>
</Attribute>
<Attribute>
<Identifier>(0x6267b5c5, 0x676e3e42)</Identifier>
<Value>472</Value>
<Value>487</Value>
</Attribute>
</Attributes>
</Link>
<Link>
<Identifier>(0x0000471a, 0x00001d2f)</Identifier>
<Identifier>(0x00003931, 0x00007ecc)</Identifier>
<Source>
<BoxIdentifier>(0x000032fa, 0x00004868)</BoxIdentifier>
<BoxIdentifier>(0x0000391a, 0x00002733)</BoxIdentifier>
<BoxOutputIndex>0</BoxOutputIndex>
</Source>
<Target>
<BoxIdentifier>(0x00001e4a, 0x000028f9)</BoxIdentifier>
<BoxIdentifier>(0x00004299, 0x000039c3)</BoxIdentifier>
<BoxInputIndex>0</BoxInputIndex>
</Target>
<Attributes>
<Attribute>
<Identifier>(0x1b32c44c, 0x1905e0e9)</Identifier>
<Value>162</Value>
<Value>163</Value>
</Attribute>
<Attribute>
<Identifier>(0x358ae8b5, 0x0f8bacd1)</Identifier>
<Value>224</Value>
<Value>448</Value>
</Attribute>
<Attribute>
<Identifier>(0x3f0a3b27, 0x570913d2)</Identifier>
<Value>379</Value>
<Value>440</Value>
</Attribute>
<Attribute>
<Identifier>(0x6267b5c5, 0x676e3e42)</Identifier>
<Value>176</Value>
<Value>472</Value>
</Attribute>
</Attributes>
</Link>
<Link>
<Identifier>(0x00004834, 0x00003f43)</Identifier>
<Identifier>(0x0000483d, 0x00003582)</Identifier>
<Source>
<BoxIdentifier>(0x0000686d, 0x00007683)</BoxIdentifier>
<BoxIdentifier>(0x0000391a, 0x00002733)</BoxIdentifier>
<BoxOutputIndex>0</BoxOutputIndex>
</Source>
<Target>
<BoxIdentifier>(0x00006611, 0x00000c6c)</BoxIdentifier>
<BoxIdentifier>(0x00007d51, 0x0000566f)</BoxIdentifier>
<BoxInputIndex>1</BoxInputIndex>
</Target>
<Attributes>
<Attribute>
<Identifier>(0x1b32c44c, 0x1905e0e9)</Identifier>
<Value>162</Value>
<Value>163</Value>
</Attribute>
<Attribute>
<Identifier>(0x358ae8b5, 0x0f8bacd1)</Identifier>
......@@ -396,7 +420,7 @@
</Attribute>
<Attribute>
<Identifier>(0x3f0a3b27, 0x570913d2)</Identifier>
<Value>304</Value>
<Value>303</Value>
</Attribute>
<Attribute>
<Identifier>(0x6267b5c5, 0x676e3e42)</Identifier>
......@@ -405,48 +429,48 @@
</Attributes>
</Link>
<Link>
<Identifier>(0x00004d58, 0x000024c8)</Identifier>
<Identifier>(0x000064b4, 0x00003470)</Identifier>
<Source>
<BoxIdentifier>(0x0000686d, 0x00007683)</BoxIdentifier>
<BoxIdentifier>(0x00007ac0, 0x0000780b)</BoxIdentifier>
<BoxOutputIndex>0</BoxOutputIndex>
</Source>
<Target>
<BoxIdentifier>(0x0000300d, 0x0000752a)</BoxIdentifier>
<BoxInputIndex>1</BoxInputIndex>
<BoxIdentifier>(0x00007d51, 0x0000566f)</BoxIdentifier>
<BoxInputIndex>0</BoxInputIndex>
</Target>
<Attributes>
<Attribute>
<Identifier>(0x1b32c44c, 0x1905e0e9)</Identifier>
<Value>162</Value>
<Value>163</Value>
</Attribute>
<Attribute>
<Identifier>(0x358ae8b5, 0x0f8bacd1)</Identifier>
<Value>448</Value>
<Value>224</Value>
</Attribute>
<Attribute>
<Identifier>(0x3f0a3b27, 0x570913d2)</Identifier>
<Value>379</Value>
<Value>303</Value>
</Attribute>
<Attribute>
<Identifier>(0x6267b5c5, 0x676e3e42)</Identifier>
<Value>487</Value>
<Value>312</Value>
</Attribute>
</Attributes>
</Link>
<Link>
<Identifier>(0x00006e0a, 0x000010ad)</Identifier>
<Identifier>(0x00007e87, 0x00000be8)</Identifier>
<Source>
<BoxIdentifier>(0x000032fa, 0x00004868)</BoxIdentifier>
<BoxIdentifier>(0x00007ac0, 0x0000780b)</BoxIdentifier>
<BoxOutputIndex>0</BoxOutputIndex>
</Source>
<Target>
<BoxIdentifier>(0x00006611, 0x00000c6c)</BoxIdentifier>
<BoxIdentifier>(0x0000644d, 0x0000444f)</BoxIdentifier>
<BoxInputIndex>0</BoxInputIndex>
</Target>
<Attributes>
<Attribute>
<Identifier>(0x1b32c44c, 0x1905e0e9)</Identifier>
<Value>162</Value>
<Value>163</Value>
</Attribute>
<Attribute>
<Identifier>(0x358ae8b5, 0x0f8bacd1)</Identifier>
......@@ -454,11 +478,11 @@
</Attribute>
<Attribute>
<Identifier>(0x3f0a3b27, 0x570913d2)</Identifier>
<Value>304</Value>
<Value>440</Value>
</Attribute>
<Attribute>
<Identifier>(0x6267b5c5, 0x676e3e42)</Identifier>
<Value>312</Value>
<Value>160</Value>
</Attribute>
</Attributes>
</Link>
......@@ -466,7 +490,7 @@
<MessageLinks></MessageLinks>
<Comments>
<Comment>
<Identifier>(0x00002b03, 0x00001ff7)</Identifier>
<Identifier>(0x00000262, 0x00000891)</Identifier>
<Text>This scenario is described in
http://openvibe.inria.fr/vrpn-tutorial-sending-data-from-openvibe-to-an-external-application/
......@@ -486,21 +510,14 @@ Its used together with &lt;b&gt;openvibe-examples-openvibe-to-vrpn&lt;/b&gt; app
</Comments>
<VisualisationTree>
<VisualisationWidget>
<Identifier>(0x000059b0, 0x000064b0)</Identifier>
<Identifier>(0x0000037e, 0x00002d40)</Identifier>
<Type>3</Type>
<ParentIdentifier>(0xffffffff, 0xffffffff)</ParentIdentifier>
<BoxIdentifier>(0x00006611, 0x00000c6c)</BoxIdentifier>
<BoxIdentifier>(0x0000391a, 0x00002733)</BoxIdentifier>
<NumChildren>0</NumChildren>
</VisualisationWidget>
<VisualisationWidget>
<Identifier>(0x000072c6, 0x00004718)</Identifier>
<Type>3</Type>
<ParentIdentifier>(0xffffffff, 0xffffffff)</ParentIdentifier>
<BoxIdentifier>(0x0000686d, 0x00007683)</BoxIdentifier>
<NumChildren>0</NumChildren>
</VisualisationWidget>
<VisualisationWidget>
<Identifier>(0x00007efa, 0x00001bec)</Identifier>
<Identifier>(0x00000887, 0x00000d47)</Identifier>
<Name>Default window</Name>
<Type>1</Type>
<ParentIdentifier>(0xffffffff, 0xffffffff)</ParentIdentifier>
......@@ -518,19 +535,26 @@ Its used together with &lt;b&gt;openvibe-examples-openvibe-to-vrpn&lt;/b&gt; app
</Attributes>
</VisualisationWidget>
<VisualisationWidget>
<Identifier>(0x0000670b, 0x000072da)</Identifier>
<Identifier>(0x00006f54, 0x0000583d)</Identifier>
<Type>3</Type>
<ParentIdentifier>(0xffffffff, 0xffffffff)</ParentIdentifier>
<BoxIdentifier>(0x00007d51, 0x0000566f)</BoxIdentifier>
<NumChildren>0</NumChildren>
</VisualisationWidget>
<VisualisationWidget>
<Identifier>(0x00007a1c, 0x00004e8f)</Identifier>
<Name>Default tab</Name>
<Type>2</Type>
<ParentIdentifier>(0x00007efa, 0x00001bec)</ParentIdentifier>
<ParentIdentifier>(0x00000887, 0x00000d47)</ParentIdentifier>
<Index>0</Index>
<BoxIdentifier>(0xffffffff, 0xffffffff)</BoxIdentifier>
<NumChildren>1</NumChildren>
</VisualisationWidget>
<VisualisationWidget>
<Identifier>(0x00005ffc, 0x00004b5a)</Identifier>
<Identifier>(0x00001bd6, 0x000041d2)</Identifier>
<Name>Empty</Name>
<Type>0</Type>
<ParentIdentifier>(0x0000670b, 0x000072da)</ParentIdentifier>
<ParentIdentifier>(0x00007a1c, 0x00004e8f)</ParentIdentifier>
<Index>0</Index>
<BoxIdentifier>(0xffffffff, 0xffffffff)</BoxIdentifier>
<NumChildren>0</NumChildren>
......
......@@ -6,10 +6,13 @@
*/
#include <iostream>
#include <sstream>
#include <vrpn_Button.h>
#include <vrpn_Analog.h>
#define DEFAULT_PORT 3883
void VRPN_CALLBACK vrpn_button_callback(void* user_data, vrpn_BUTTONCB button)
{
std::cout << "Button ID : " << button.button << " / Button State : " << button.state << std::endl;
......@@ -37,14 +40,20 @@ int main(int argc, char** argv)
vrpn_Button_Remote* VRPNButton;
/* Binding of the VRPN Button to a callback */
VRPNButton = new vrpn_Button_Remote( "openvibe_vrpn_button@localhost" );
std::stringstream buttonUrl;
buttonUrl << std::string("openvibe_vrpn_button@localhost:") << (argc>1 ? atoi(argv[1]) : DEFAULT_PORT);
std::cout << "Server button URL = " << buttonUrl.str().c_str() << "\n";
VRPNButton = new vrpn_Button_Remote(buttonUrl.str().c_str());
VRPNButton->register_change_handler( &running, vrpn_button_callback );
/* VRPN Analog object */
vrpn_Analog_Remote* VRPNAnalog;
/* Binding of the VRPN Analog to a callback */
VRPNAnalog = new vrpn_Analog_Remote( "openvibe_vrpn_analog@localhost" );
std::stringstream analogUrl;
analogUrl << std::string("openvibe_vrpn_analog@localhost:") << (argc>1 ? atoi(argv[1]) : DEFAULT_PORT);
std::cout << "Server analog URL = " << analogUrl.str().c_str() << "\n";
VRPNAnalog = new vrpn_Analog_Remote(analogUrl.str().c_str());
VRPNAnalog->register_change_handler( NULL, vrpn_analog_callback );
/* The main loop of the program, each VRPN object must be called in order to process data */
......
......@@ -15,6 +15,7 @@ CVRPNAnalogServer::CVRPNAnalogServer()
{
}
boolean CVRPNAnalogServer::initialize()
{
IBox& l_rStaticBoxContext=this->getStaticBoxContext();
......@@ -23,6 +24,8 @@ boolean CVRPNAnalogServer::initialize()
CString l_oServerName;
l_rStaticBoxContext.getSettingValue(0, l_oServerName);
uint64 l_ui64Port=FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 1);
// Creates the stream decoders
for(uint32 i=0; i<l_rStaticBoxContext.getInputCount(); i++)
{
......@@ -31,7 +34,11 @@ boolean CVRPNAnalogServer::initialize()
}
// Creates the peripheral
IVRPNServerManager::getInstance().initialize();
if(!IVRPNServerManager::getInstance().initialize(static_cast<uint32>(l_ui64Port)))
{
this->getLogManager() << LogLevel_Error << "Server init failed\n";
return false;
}
IVRPNServerManager::getInstance().addServer(l_oServerName, m_oServerIdentifier);
return true;
......
......@@ -91,6 +91,7 @@ namespace OpenViBEPlugins
{
rPrototype.addInput ("Input 1", OV_TypeId_StreamedMatrix);
rPrototype.addSetting("Peripheral name", OV_TypeId_String, "openvibe-vrpn");
rPrototype.addSetting("Server port", OV_TypeId_Integer, "3883");
rPrototype.addFlag (OpenViBE::Kernel::BoxFlag_CanAddInput);
return true;
}
......
......@@ -30,7 +30,14 @@ boolean CVRPNButtonServer::initialize()
CString l_oServerName;
l_pBox->getSettingValue(0, l_oServerName);
IVRPNServerManager::getInstance().initialize();
uint64 l_ui64Port=FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 1);
if(!IVRPNServerManager::getInstance().initialize(static_cast<uint32>(l_ui64Port)))
{
this->getLogManager() << LogLevel_Error << "Server init failed\n";
return false;
}
IVRPNServerManager::getInstance().addServer(l_oServerName, m_oServerIdentifier);
IVRPNServerManager::getInstance().setButtonCount(m_oServerIdentifier, l_pBox->getInputCount());
......@@ -39,8 +46,8 @@ boolean CVRPNButtonServer::initialize()
{
CString l_sOnStimulationIdentifier;
CString l_sOffStimulationIdentifier;
l_pBox->getSettingValue(1+i*2, l_sOnStimulationIdentifier);
l_pBox->getSettingValue(2+i*2, l_sOffStimulationIdentifier);
l_pBox->getSettingValue(2+i*2, l_sOnStimulationIdentifier);
l_pBox->getSettingValue(3+i*2, l_sOffStimulationIdentifier);
m_vStimulationPair[i]=
pair<uint64, uint64>(
getBoxAlgorithmContext()->getPlayerContext()->getTypeManager().getEnumerationEntryValueFromName(OVTK_TypeId_Stimulation, l_sOnStimulationIdentifier),
......
......@@ -49,6 +49,7 @@ namespace OpenViBEPlugins
//Pairs of start/stop stimulations id
std::map<OpenViBE::uint32, std::pair<OpenViBE::uint64, OpenViBE::uint64> > m_vStimulationPair;
};
class CVRPNButtonServerListener : public OpenViBEToolkit::TBoxListener < OpenViBE::Plugins::IBoxListener >
......@@ -70,12 +71,12 @@ namespace OpenViBEPlugins
for(i=0; i<rBox.getInputCount(); i++)
{
sprintf(l_sName, "Button %u ON", i+1);
rBox.setSettingName(i*2+1, l_sName);
rBox.setSettingType(i*2+1, OV_TypeId_Stimulation);
rBox.setSettingName(i*2+2+0, l_sName);
rBox.setSettingType(i*2+2+0, OV_TypeId_Stimulation);
sprintf(l_sName, "Button %u OFF", i+1);
rBox.setSettingName(i*2+2, l_sName);
rBox.setSettingType(i*2+2, OV_TypeId_Stimulation);
rBox.setSettingName(i*2+2+1, l_sName);
rBox.setSettingType(i*2+2+1, OV_TypeId_Stimulation);
}
return true;
......@@ -83,8 +84,9 @@ namespace OpenViBEPlugins
virtual OpenViBE::boolean onInputRemoved(OpenViBE::Kernel::IBox& rBox, const OpenViBE::uint32 ui32Index)
{
rBox.removeSetting(ui32Index*2+1);
rBox.removeSetting(ui32Index*2+1);
// Note that we have the same index in both removes because the first remove changes the indexing
rBox.removeSetting(ui32Index*2+2+0);
rBox.removeSetting(ui32Index*2+2+0);
return this->check(rBox);
};
......@@ -122,6 +124,7 @@ namespace OpenViBEPlugins
{
rPrototype.addInput ("Input 1", OVTK_TypeId_Stimulations);
rPrototype.addSetting("Peripheral name", OV_TypeId_String, "openvibe-vrpn");
rPrototype.addSetting("Server port", OV_TypeId_Integer, "3883");
rPrototype.addSetting("Button 1 ON", OV_TypeId_Stimulation, "OVTK_GDF_Feedback_Continuous");
rPrototype.addSetting("Button 1 OFF", OV_TypeId_Stimulation, "OVTK_GDF_End_Of_Trial");
rPrototype.addFlag (OpenViBE::Kernel::BoxFlag_CanAddInput);
......
......@@ -34,6 +34,7 @@ namespace OpenViBEPlugins
virtual ~CVRPNServerManager(void);
virtual boolean initialize(void);
virtual boolean initialize(uint32 ui32port);
virtual boolean uninitialize(void);
virtual boolean process(void);
......@@ -90,6 +91,7 @@ namespace OpenViBEPlugins
map<CIdentifier, vector<boolean> > m_vButtonCache;