Browse Source

Dateien hochladen nach „src/TactiloController“

master
Tobias Baumann 2 years ago
parent
commit
0fe8e96e1d

+ 16
- 18
src/TactiloController/ovpCBoxAlgorithmTactiloController.cpp View File

//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

+ 5
- 7
src/TactiloController/ovpCBoxAlgorithmTactiloController.h View File

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;
uint64_t m_RowBase;
uint64_t m_StartStimulation;
uint64_t m_StopStimulation;
uint64_t m_NumberofTactilos;
CString m_PortName = "";
uint64_t m_RowBase = 0;
uint64_t m_NumberofTactilos = 0;
//Serial Port //Serial Port
boost::asio::io_service m_IO; boost::asio::io_service m_IO;
//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…
Cancel
Save