///------------------------------------------------------------------------------------------------- /// /// \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 GNU Affero General Public License v3.0. /// ///------------------------------------------------------------------------------------------------- //includes #pragma once //You may have to change this path to match your folder organisation #include "../ovp_defines.h" #include #include #include namespace OpenViBE { namespace Plugins { namespace Tactilebci { /// The class CBoxAlgorithmUDPStimcodeSender describes the box UDPStimcodeSender. class CBoxAlgorithmUDPStimcodeSender final : virtual public Toolkit::TBoxAlgorithm { 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, OVP_ClassId_BoxAlgorithm_UDPStimcodeSender) protected: // Input decoder: Toolkit::TStimulationDecoder m_StimDecoder; // Output decoder: Toolkit::TStimulationEncoder m_StimEncoder; private: // Box setting variables CString m_IP = ""; uint64_t m_Port = 0; uint64_t m_RowBase = 0; uint64_t m_nTactilos = 0; // Socket boost::asio::io_service m_IOService; boost::asio::ip::udp::socket m_Socket{m_IOService}; }; /// Descriptor of the box UDPStimcodeSender. 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; } 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"); 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