Dateien hochladen nach „src/TactiloController“

This commit is contained in:
Tobias Baumann 2022-05-23 16:31:36 +00:00
parent 70d5a8043d
commit 1840fc3e99
2 changed files with 151 additions and 139 deletions

View File

@ -11,7 +11,6 @@
//includes
#include "ovpCBoxAlgorithmTactiloController.h"
#include <string>
using namespace OpenViBE;
using namespace /*OpenViBE::*/Kernel;
@ -89,7 +88,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 StimulationID = 0;
uint64_t ChunkStartTime = 0;
uint64_t ChunkEndTime = 0;
uint64_t Size = 0;
@ -104,10 +102,10 @@ bool CBoxAlgorithmTactiloController::process()
if(m_StimDecoder.isBufferReceived())
{
//check received stimulations
IStimulationSet* StimSet = m_StimDecoder.getOutputStimulationSet();
for(uint64_t j=0; j<StimSet->getStimulationCount(); j++)
CStimulationSet* StimSet = m_StimDecoder.getOutputStimulationSet();
for(uint64_t j=0; j<StimSet->size(); j++)
{
StimulationID = StimSet->getStimulationIdentifier(j);
uint64_t StimulationID = StimSet->getId(j);
if(StimulationID >= m_RowBase && StimulationID < (m_RowBase + m_nTactilos))
{
@ -116,23 +114,33 @@ bool CBoxAlgorithmTactiloController::process()
if(StimulationID == OVTK_StimulationId_VisualStimulationStart)
{
this->getLogManager() << LogLevel_Debug << "Tactilo Nr. " << m_currTactiloNr << " ON\n";
m_Port.write_some(boost::asio::buffer(std::to_string(m_currTactiloNr-1)));
boost::asio::async_write(m_Port, boost::asio::buffer(std::to_string(m_currTactiloNr-1), 1), boost::bind(&CBoxAlgorithmTactiloController::handler, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}
if(StimulationID == OVTK_StimulationId_VisualStimulationStop)
{
this->getLogManager() << LogLevel_Debug << "Tactilo Nr. " << m_currTactiloNr << " OFF\n";
m_Port.write_some(boost::asio::buffer(std::to_string(m_currTactiloNr-1)));
boost::asio::async_write(m_Port, boost::asio::buffer(std::to_string(m_currTactiloNr-1), 1), boost::bind(&CBoxAlgorithmTactiloController::handler, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}
}
}
// forward input chunks
boxContext.getInputChunk(0, i, ChunkStartTime, ChunkEndTime, Size, Buffer);
boxContext.appendOutputChunkData(0, Buffer, Size);
boxContext.markOutputAsReadyToSend(0, ChunkStartTime, ChunkEndTime);
boxContext.markInputAsDeprecated(0, i);
}
return true;
}
/*******************************************************************************/
void CBoxAlgorithmTactiloController::handler(const boost::system::error_code& error, std::size_t bytes_transferred)
{
if(error)
{
this->getLogManager() << LogLevel_Warning << error.message() << "\n";
}
}

View File

@ -17,6 +17,7 @@
#include <openvibe/ov_all.h>
#include <toolkit/ovtk_all.h>
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <string>
namespace OpenViBE
@ -36,6 +37,9 @@ namespace OpenViBE
bool processInput(const size_t index) override;
bool process() override;
// write handler
void handler(const boost::system::error_code& error, std::size_t bytes_transferred);
// As we do with any class in openvibe, we use the macro below to associate this box to an unique identifier.
// The inheritance information is also made available, as we provide the superclass Toolkit::TBoxAlgorithm < IBoxAlgorithm >
_IsDerivedFromClass_Final_(Toolkit::TBoxAlgorithm<IBoxAlgorithm>, OVP_ClassId_BoxAlgorithm_TactiloController)