Dateien hochladen nach „src/TactiloController“
This commit is contained in:
parent
baf99aba38
commit
0fe8e96e1d
@ -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 == m_StartStimulation || StimulationID == m_StopStimulation)
|
||||
if(StimulationID == OVTK_StimulationId_VisualStimulationStart)
|
||||
{
|
||||
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 << " ON\n";
|
||||
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
|
||||
|
@ -47,12 +47,12 @@ namespace OpenViBE
|
||||
Toolkit::TStimulationEncoder<CBoxAlgorithmTactiloController> m_StimEncoder;
|
||||
|
||||
private:
|
||||
//variable to store the current TactiloNr
|
||||
uint64_t m_TactiloNr = 0;
|
||||
//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
|
||||
boost::asio::io_service m_IO;
|
||||
@ -97,8 +97,6 @@ namespace OpenViBE
|
||||
//Box Settings
|
||||
prototype.addSetting("Serial Port Name",OV_TypeId_String,"/dev/ttyACM0");
|
||||
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.addFlag(Kernel::BoxFlag_CanModifySetting);
|
||||
|
Loading…
x
Reference in New Issue
Block a user