Dateien hochladen nach „src/TactiloController“
This commit is contained in:
parent
baf99aba38
commit
0fe8e96e1d
@ -28,8 +28,6 @@ bool CBoxAlgorithmTactiloController::initialize()
|
|||||||
//get Box Settings
|
//get Box Settings
|
||||||
m_PortName = FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 0);
|
m_PortName = FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 0);
|
||||||
m_RowBase = FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 1);
|
m_RowBase = FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 1);
|
||||||
m_StartStimulation = FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 2);
|
|
||||||
m_StopStimulation = FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 3);
|
|
||||||
m_NumberofTactilos = 6; //if this value is specified via box settings this line is not needed
|
m_NumberofTactilos = 6; //if this value is specified via box settings this line is not needed
|
||||||
//NumberofTactilos = FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 3); //used if this value is set in box settings
|
//NumberofTactilos = FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 3); //used if this value is set in box settings
|
||||||
|
|
||||||
@ -40,7 +38,7 @@ bool CBoxAlgorithmTactiloController::initialize()
|
|||||||
if(m_Port.is_open())
|
if(m_Port.is_open())
|
||||||
{
|
{
|
||||||
this->getLogManager() << LogLevel_Info << "Connected to Serial Port: " << m_PortName << "\n";
|
this->getLogManager() << LogLevel_Info << "Connected to Serial Port: " << m_PortName << "\n";
|
||||||
m_Port.write_some(boost::asio::buffer("0"));
|
m_Port.write_some(boost::asio::buffer("b"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -50,8 +48,8 @@ bool CBoxAlgorithmTactiloController::initialize()
|
|||||||
|
|
||||||
bool CBoxAlgorithmTactiloController::uninitialize()
|
bool CBoxAlgorithmTactiloController::uninitialize()
|
||||||
{
|
{
|
||||||
this->getLogManager() << LogLevel_Info << "Close Serial Port: " << m_PortName << "\n";
|
this->getLogManager() << LogLevel_Info << "Disconnect from Serial Port: " << m_PortName << "\n";
|
||||||
m_Port.write_some(boost::asio::buffer("0"));
|
m_Port.write_some(boost::asio::buffer("e"));
|
||||||
m_Port.close();
|
m_Port.close();
|
||||||
|
|
||||||
m_StimDecoder.uninitialize();
|
m_StimDecoder.uninitialize();
|
||||||
@ -81,7 +79,6 @@ bool CBoxAlgorithmTactiloController::process()
|
|||||||
// the dynamic box context describes the current state of the box inputs and outputs (i.e. the chunks)
|
// the dynamic box context describes the current state of the box inputs and outputs (i.e. the chunks)
|
||||||
IBoxIO& boxContext = this->getDynamicBoxContext();
|
IBoxIO& boxContext = this->getDynamicBoxContext();
|
||||||
|
|
||||||
uint64_t TactiloNr = 0;
|
|
||||||
uint64_t StimulationID = 0;
|
uint64_t StimulationID = 0;
|
||||||
uint64_t ChunkStartTime = 0;
|
uint64_t ChunkStartTime = 0;
|
||||||
uint64_t ChunkEndTime = 0;
|
uint64_t ChunkEndTime = 0;
|
||||||
@ -93,28 +90,29 @@ bool CBoxAlgorithmTactiloController::process()
|
|||||||
{
|
{
|
||||||
// decode the chunk i
|
// decode the chunk i
|
||||||
m_StimDecoder.decode(i);
|
m_StimDecoder.decode(i);
|
||||||
|
|
||||||
if(m_StimDecoder.isBufferReceived())
|
if(m_StimDecoder.isBufferReceived())
|
||||||
{
|
{
|
||||||
//check received stimulations
|
//check received stimulations
|
||||||
IStimulationSet* StimSet = m_StimDecoder.getOutputStimulationSet();
|
IStimulationSet* StimSet = m_StimDecoder.getOutputStimulationSet();
|
||||||
for(uint64_t j=0; j<StimSet->getStimulationCount(); j++)
|
for(uint64_t j=0; j<StimSet->getStimulationCount(); j++)
|
||||||
{
|
{
|
||||||
StimulationID = StimSet->getStimulationIdentifier(j);
|
StimulationID = StimSet->getStimulationIdentifier(j);
|
||||||
|
|
||||||
if(StimulationID >= m_RowBase && StimulationID < (m_RowBase + m_NumberofTactilos))
|
if(StimulationID >= m_RowBase && StimulationID < (m_RowBase + m_NumberofTactilos))
|
||||||
{
|
{
|
||||||
TactiloNr = StimulationID-m_RowBase+1;
|
m_TactiloNr = StimulationID-m_RowBase+1;
|
||||||
}
|
}
|
||||||
if(StimulationID == m_StartStimulation || StimulationID == m_StopStimulation)
|
if(StimulationID == OVTK_StimulationId_VisualStimulationStart)
|
||||||
{
|
{
|
||||||
this->getLogManager() << LogLevel_Debug << "Tactilo Nr. " << TactiloNr << " ON\n";
|
this->getLogManager() << LogLevel_Info << "Tactilo Nr. " << m_TactiloNr << " ON\n";
|
||||||
m_Port.write_some(boost::asio::buffer(std::to_string(TactiloNr)));
|
m_Port.write_some(boost::asio::buffer(std::to_string(m_TactiloNr)));
|
||||||
|
}
|
||||||
|
if(StimulationID == OVTK_StimulationId_VisualStimulationStop)
|
||||||
|
{
|
||||||
|
this->getLogManager() << LogLevel_Info << "Tactilo Nr. " << m_TactiloNr << " OFF\n";
|
||||||
|
m_Port.write_some(boost::asio::buffer(std::to_string(m_TactiloNr)));
|
||||||
}
|
}
|
||||||
if(StimulationID == m_StopStimulation)
|
|
||||||
{
|
|
||||||
this->getLogManager() << LogLevel_Debug << "Tactilo Nr. " << TactiloNr << " OFF\n";
|
|
||||||
m_Port.write_some(boost::asio::buffer(std::to_string(TactiloNr)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// forward input chunks
|
// forward input chunks
|
||||||
|
@ -47,12 +47,12 @@ namespace OpenViBE
|
|||||||
Toolkit::TStimulationEncoder<CBoxAlgorithmTactiloController> m_StimEncoder;
|
Toolkit::TStimulationEncoder<CBoxAlgorithmTactiloController> m_StimEncoder;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
//variable to store the current TactiloNr
|
||||||
|
uint64_t m_TactiloNr = 0;
|
||||||
//Box Settings
|
//Box Settings
|
||||||
CString m_PortName;
|
CString m_PortName = "";
|
||||||
uint64_t m_RowBase;
|
uint64_t m_RowBase = 0;
|
||||||
uint64_t m_StartStimulation;
|
uint64_t m_NumberofTactilos = 0;
|
||||||
uint64_t m_StopStimulation;
|
|
||||||
uint64_t m_NumberofTactilos;
|
|
||||||
|
|
||||||
//Serial Port
|
//Serial Port
|
||||||
boost::asio::io_service m_IO;
|
boost::asio::io_service m_IO;
|
||||||
@ -97,8 +97,6 @@ namespace OpenViBE
|
|||||||
//Box Settings
|
//Box Settings
|
||||||
prototype.addSetting("Serial Port Name",OV_TypeId_String,"/dev/ttyACM0");
|
prototype.addSetting("Serial Port Name",OV_TypeId_String,"/dev/ttyACM0");
|
||||||
prototype.addSetting("Row Stimulation Base",OV_TypeId_Stimulation,"OVTK_StimulationId_Label_01");
|
prototype.addSetting("Row Stimulation Base",OV_TypeId_Stimulation,"OVTK_StimulationId_Label_01");
|
||||||
prototype.addSetting("Flash Start Stimulation",OV_TypeId_Stimulation,"OVTK_StimulationId_VisualStimulationStart");
|
|
||||||
prototype.addSetting("Flash Stop Stimulation",OV_TypeId_Stimulation,"OVTK_StimulationId_VisualStimulationStop");
|
|
||||||
//prototype.addSetting("Number of Tactilos",OV_TypeId_Integer,"6"); //used to make this setting accessable in the box settings
|
//prototype.addSetting("Number of Tactilos",OV_TypeId_Integer,"6"); //used to make this setting accessable in the box settings
|
||||||
|
|
||||||
//prototype.addFlag(Kernel::BoxFlag_CanModifySetting);
|
//prototype.addFlag(Kernel::BoxFlag_CanModifySetting);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user