|
|
|
|
|
|
|
|
//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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CBoxAlgorithmTactiloController::uninitialize() |
|
|
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_Port.close(); |
|
|
|
|
|
|
|
|
m_StimDecoder.uninitialize(); |
|
|
m_StimDecoder.uninitialize(); |
|
|
|
|
|
|
|
|
// 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; |
|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
// 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++) |
|
|
|
|
|
{ |
|
|
|
|
|
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)) |
|
|
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 |
|
|
// forward input chunks |