123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- ///-------------------------------------------------------------------------------------------------
- ///
- /// \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 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};
- };
-
-
- /// <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; }
-
- 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
|