|
|
|
|
|
|
|
|
|
|
|
///-------------------------------------------------------------------------------------------------
|
|
|
|
|
|
///
|
|
|
|
|
|
/// \file CBoxAlgorithmUDPStimcodeSender.h
|
|
|
|
|
|
/// \brief Classes of the Box UDPStimcodeSender.
|
|
|
|
|
|
/// \author Tobias Baumann (TH Nuernberg).
|
|
|
|
|
|
/// \version 1.1.
|
|
|
|
|
|
/// \date Mon Oct 04 12:43:53 2021.
|
|
|
|
|
|
/// \copyright <a href="https://choosealicense.com/licenses/agpl-3.0/">GNU Affero General Public License v3.0</a>.
|
|
|
|
|
|
///
|
|
|
|
|
|
///-------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
//includes
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
//You may have to change this path to match your folder organisation
|
|
|
|
|
|
#include "../ovp_defines.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include <openvibe/ov_all.h>
|
|
|
|
|
|
#include <toolkit/ovtk_all.h>
|
|
|
|
|
|
#include <boost/asio.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace OpenViBE
|
|
|
|
|
|
{
|
|
|
|
|
|
namespace Plugins
|
|
|
|
|
|
{
|
|
|
|
|
|
namespace Tactilebci
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary> The class CBoxAlgorithmUDPStimcodeSender describes the box UDPStimcodeSender. </summary>
|
|
|
|
|
|
class CBoxAlgorithmUDPStimcodeSender final : virtual public Toolkit::TBoxAlgorithm<IBoxAlgorithm>
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
void release() override { delete this; }
|
|
|
|
|
|
|
|
|
|
|
|
bool initialize() override;
|
|
|
|
|
|
bool uninitialize() override;
|
|
|
|
|
|
bool processInput(const size_t index) override;
|
|
|
|
|
|
bool process() override;
|
|
|
|
|
|
|
|
|
|
|
|
// 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_UDPStimcodeSender)
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
// Input decoder:
|
|
|
|
|
|
Toolkit::TStimulationDecoder<CBoxAlgorithmUDPStimcodeSender> m_StimDecoder;
|
|
|
|
|
|
// Output decoder:
|
|
|
|
|
|
Toolkit::TStimulationEncoder<CBoxAlgorithmUDPStimcodeSender> m_StimEncoder;
|
|
|
|
|
|
private:
|
|
|
|
|
|
// Box setting variables
|
|
|
|
|
|
CString FeatherIP;
|
|
|
|
|
|
uint64_t FeatherPort;
|
|
|
|
|
|
uint64_t RowStimulationBase;
|
|
|
|
|
|
uint64_t NumberofTactilos;
|
|
|
|
|
|
// Socket
|
|
|
|
|
|
boost::asio::io_service io_service;
|
|
|
|
|
|
boost::asio::ip::udp::socket socket{io_service};
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If you need to implement a box Listener, here is a sekeleton for you.
|
|
|
|
|
|
// Use only the callbacks you need.
|
|
|
|
|
|
// For example, if your box has a variable number of input, but all of them must be stimulation inputs.
|
|
|
|
|
|
// The following listener callback will ensure that any newly added input is stimulations :
|
|
|
|
|
|
/*
|
|
|
|
|
|
bool onInputAdded(Kernel::IBox& box, const size_t index) override
|
|
|
|
|
|
{
|
|
|
|
|
|
box.setInputType(index, OV_TypeId_Stimulations);
|
|
|
|
|
|
};
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
// The box listener can be used to call specific callbacks whenever the box structure changes : input added, name changed, etc.
|
|
|
|
|
|
// Please uncomment below the callbacks you want to use.
|
|
|
|
|
|
/// <summary> Listener of the box UDPStimcodeSender. </summary>
|
|
|
|
|
|
class CBoxAlgorithmUDPStimcodeSenderListener final : public Toolkit::TBoxListener<IBoxListener>
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
//bool onInitialized(Kernel::IBox& box) override { return true; };
|
|
|
|
|
|
//bool onNameChanged(Kernel::IBox& box) override { return true; };
|
|
|
|
|
|
//bool onInputConnected(Kernel::IBox& box, const size_t index) override { return true; };
|
|
|
|
|
|
//bool onInputDisconnected(Kernel::IBox& box, const size_t index) override { return true; };
|
|
|
|
|
|
//bool onInputAdded(Kernel::IBox& box, const size_t index) override { return true; };
|
|
|
|
|
|
//bool onInputRemoved(Kernel::IBox& box, const size_t index) override { return true; };
|
|
|
|
|
|
//bool onInputTypeChanged(Kernel::IBox& box, const size_t index) override { return true; };
|
|
|
|
|
|
//bool onInputNameChanged(Kernel::IBox& box, const size_t index) override { return true; };
|
|
|
|
|
|
//bool onOutputConnected(Kernel::IBox& box, const size_t index) override { return true; };
|
|
|
|
|
|
//bool onOutputDisconnected(Kernel::IBox& box, const size_t index) { return true; };
|
|
|
|
|
|
//bool onOutputAdded(Kernel::IBox& box, const size_t index) override { return true; };
|
|
|
|
|
|
//bool onOutputRemoved(Kernel::IBox& box, const size_t index) override { return true; };
|
|
|
|
|
|
//bool onOutputTypeChanged(Kernel::IBox& box, const size_t index) override override { return true; };
|
|
|
|
|
|
//bool onOutputNameChanged(Kernel::IBox& box, const size_t index) override { return true; };
|
|
|
|
|
|
//bool onSettingAdded(Kernel::IBox& box, const size_t index) override { return true; };
|
|
|
|
|
|
//bool onSettingRemoved(Kernel::IBox& box, const size_t index) override { return true; };
|
|
|
|
|
|
//bool onSettingTypeChanged(Kernel::IBox& box, const size_t index) override { return true; };
|
|
|
|
|
|
//bool onSettingNameChanged(Kernel::IBox& box, const size_t index) override { return true; };
|
|
|
|
|
|
//bool onSettingDefaultValueChanged(Kernel::IBox& box, const size_t index) override { return true; };
|
|
|
|
|
|
//bool onSettingValueChanged(Kernel::IBox& box, const size_t index) override { return true; };
|
|
|
|
|
|
|
|
|
|
|
|
_IsDerivedFromClass_Final_(Toolkit::TBoxListener<IBoxListener>, CIdentifier::undefined())
|
|
|
|
|
|
};
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> Descriptor of the box UDPStimcodeSender. </summary>
|
|
|
|
|
|
class CBoxAlgorithmUDPStimcodeSenderDesc final : virtual public IBoxAlgorithmDesc
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
void release() override { }
|
|
|
|
|
|
|
|
|
|
|
|
CString getName() const override { return CString("UDPStimcodeSender"); }
|
|
|
|
|
|
CString getAuthorName() const override { return CString("Tobias Baumann"); }
|
|
|
|
|
|
CString getAuthorCompanyName() const override { return CString("TH Nuernberg"); }
|
|
|
|
|
|
CString getShortDescription() const override { return CString("Sends Stimulationcodes via UDP"); }
|
|
|
|
|
|
CString getDetailedDescription() const override { return CString("Sends the received Stimulationcodes the Adafruit Feather, using UDP. The Input Stimulation will be passed to the Output unchanged."); }
|
|
|
|
|
|
CString getCategory() const override { return CString("TactileBCI"); }
|
|
|
|
|
|
CString getVersion() const override { return CString("1.1"); }
|
|
|
|
|
|
CString getStockItemName() const override { return CString("gtk-network"); }
|
|
|
|
|
|
|
|
|
|
|
|
CIdentifier getCreatedClass() const override { return OVP_ClassId_BoxAlgorithm_UDPStimcodeSender; }
|
|
|
|
|
|
IPluginObject* create() override { return new CBoxAlgorithmUDPStimcodeSender; }
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
IBoxListener* createBoxListener() const override { return new CBoxAlgorithmUDPStimcodeSenderListener; }
|
|
|
|
|
|
void releaseBoxListener(IBoxListener* listener) const override { delete listener; }
|
|
|
|
|
|
*/
|
|
|
|
|
|
bool getBoxPrototype(Kernel::IBoxProto& prototype) const override
|
|
|
|
|
|
{
|
|
|
|
|
|
prototype.addInput("StimcodeIn",OV_TypeId_Stimulations);
|
|
|
|
|
|
|
|
|
|
|
|
//prototype.addFlag(Kernel::BoxFlag_CanModifyInput);
|
|
|
|
|
|
//prototype.addFlag(Kernel::BoxFlag_CanAddInput);
|
|
|
|
|
|
|
|
|
|
|
|
prototype.addOutput("StimcodeOut",OV_TypeId_Stimulations);
|
|
|
|
|
|
|
|
|
|
|
|
//prototype.addFlag(Kernel::BoxFlag_CanModifyOutput);
|
|
|
|
|
|
//prototype.addFlag(Kernel::BoxFlag_CanAddOutput);
|
|
|
|
|
|
|
|
|
|
|
|
prototype.addSetting("FeatherIP",OV_TypeId_String,"192.168.4.1");
|
|
|
|
|
|
prototype.addSetting("FeatherPort",OV_TypeId_Integer,"8888");
|
|
|
|
|
|
prototype.addSetting("RowStimulationBase",OV_TypeId_Stimulation,"OVTK_StimulationId_Label_01");
|
|
|
|
|
|
//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_CanAddSetting);
|
|
|
|
|
|
|
|
|
|
|
|
prototype.addFlag(OV_AttributeId_Box_FlagIsUnstable);
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
_IsDerivedFromClass_Final_(IBoxAlgorithmDesc, OVP_ClassId_BoxAlgorithm_UDPStimcodeSenderDesc)
|
|
|
|
|
|
};
|
|
|
|
|
|
} // namespace Tactilebci
|
|
|
|
|
|
} // namespace Plugins
|
|
|
|
|
|
} // namespace OpenViBE
|