|
|
@@ -28,8 +28,6 @@ bool CBoxAlgorithmTactiloController::initialize() |
|
|
|
//get Box Settings |
|
|
|
m_PortName = FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 0); |
|
|
|
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 |
|
|
|
//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()) |
|
|
|
{ |
|
|
|
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; |
|
|
@@ -50,8 +48,8 @@ bool CBoxAlgorithmTactiloController::initialize() |
|
|
|
|
|
|
|
bool CBoxAlgorithmTactiloController::uninitialize() |
|
|
|
{ |
|
|
|
this->getLogManager() << LogLevel_Info << "Close Serial Port: " << m_PortName << "\n"; |
|
|
|
m_Port.write_some(boost::asio::buffer("0")); |
|
|
|
this->getLogManager() << LogLevel_Info << "Disconnect from Serial Port: " << m_PortName << "\n"; |
|
|
|
m_Port.write_some(boost::asio::buffer("e")); |
|
|
|
m_Port.close(); |
|
|
|
|
|
|
|
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) |
|
|
|
IBoxIO& boxContext = this->getDynamicBoxContext(); |
|
|
|
|
|
|
|
uint64_t TactiloNr = 0; |
|
|
|
uint64_t StimulationID = 0; |
|
|
|
uint64_t ChunkStartTime = 0; |
|
|
|
uint64_t ChunkEndTime = 0; |
|
|
@@ -93,28 +90,29 @@ bool CBoxAlgorithmTactiloController::process() |
|
|
|
{ |
|
|
|
// decode the chunk i |
|
|
|
m_StimDecoder.decode(i); |
|
|
|
|
|
|
|
if(m_StimDecoder.isBufferReceived()) |
|
|
|
{ |
|
|
|
//check received stimulations |
|
|
|
IStimulationSet* StimSet = m_StimDecoder.getOutputStimulationSet(); |
|
|
|
for(uint64_t j=0; j<StimSet->getStimulationCount(); j++) |
|
|
|
{ |
|
|
|
StimulationID = StimSet->getStimulationIdentifier(j); |
|
|
|
for(uint64_t j=0; j<StimSet->getStimulationCount(); j++) |
|
|
|
{ |
|
|
|
StimulationID = StimSet->getStimulationIdentifier(j); |
|
|
|
|
|
|
|
if(StimulationID >= m_RowBase && StimulationID < (m_RowBase + m_NumberofTactilos)) |
|
|
|
{ |
|
|
|
TactiloNr = StimulationID-m_RowBase+1; |
|
|
|
m_TactiloNr = StimulationID-m_RowBase+1; |
|
|
|
} |
|
|
|
if(StimulationID == OVTK_StimulationId_VisualStimulationStart) |
|
|
|
{ |
|
|
|
this->getLogManager() << LogLevel_Info << "Tactilo Nr. " << m_TactiloNr << " ON\n"; |
|
|
|
m_Port.write_some(boost::asio::buffer(std::to_string(m_TactiloNr))); |
|
|
|
} |
|
|
|
if(StimulationID == m_StartStimulation || StimulationID == m_StopStimulation) |
|
|
|
if(StimulationID == OVTK_StimulationId_VisualStimulationStop) |
|
|
|
{ |
|
|
|
this->getLogManager() << LogLevel_Debug << "Tactilo Nr. " << TactiloNr << " ON\n"; |
|
|
|
m_Port.write_some(boost::asio::buffer(std::to_string(TactiloNr))); |
|
|
|
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 |