You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ovpCBoxAlgorithmTactiloController.h 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. ///-------------------------------------------------------------------------------------------------
  2. ///
  3. /// \file ovpCBoxAlgorithmTactiloController.h
  4. /// \brief Classes of the Box Tactilo Controller.
  5. /// \author Tobias Baumann (TH-Nürnberg).
  6. /// \version 1.0.
  7. /// \date Mon Feb 21 14:59:56 2022.
  8. /// \copyright <a href="https://choosealicense.com/licenses/agpl-3.0/">GNU Affero General Public License v3.0</a>.
  9. ///
  10. ///-------------------------------------------------------------------------------------------------
  11. //includes
  12. #pragma once
  13. #include "../ovp_defines.h"
  14. #include <openvibe/ov_all.h>
  15. #include <toolkit/ovtk_all.h>
  16. #include <boost/asio.hpp>
  17. #include <boost/bind.hpp>
  18. #include <string>
  19. namespace OpenViBE
  20. {
  21. namespace Plugins
  22. {
  23. namespace Tactilebci
  24. {
  25. /// <summary> The class CBoxAlgorithmTactiloController describes the box Tactilo Controller. </summary>
  26. class CBoxAlgorithmTactiloController final : virtual public Toolkit::TBoxAlgorithm<IBoxAlgorithm>
  27. {
  28. public:
  29. void release() override { delete this; }
  30. bool initialize() override;
  31. bool uninitialize() override;
  32. bool processInput(const size_t index) override;
  33. bool process() override;
  34. // write handler
  35. void handler(const boost::system::error_code& error, std::size_t bytes_transferred);
  36. // As we do with any class in openvibe, we use the macro below to associate this box to an unique identifier.
  37. // The inheritance information is also made available, as we provide the superclass Toolkit::TBoxAlgorithm < IBoxAlgorithm >
  38. _IsDerivedFromClass_Final_(Toolkit::TBoxAlgorithm<IBoxAlgorithm>, OVP_ClassId_BoxAlgorithm_TactiloController)
  39. protected:
  40. // Input decoder:
  41. Toolkit::TStimulationDecoder<CBoxAlgorithmTactiloController> m_StimDecoder;
  42. // Output decoder:
  43. Toolkit::TStimulationEncoder<CBoxAlgorithmTactiloController> m_StimEncoder;
  44. private:
  45. //variable to store the current TactiloNr
  46. uint64_t m_currTactiloID = 0;
  47. //Box Settings
  48. CString m_PortName = "";
  49. uint64_t m_RowBase = 0;
  50. uint64_t m_nTactilos = 0;
  51. //Serial Port
  52. boost::asio::io_service m_IOService;
  53. boost::asio::serial_port m_Port{m_IOService};
  54. };
  55. /// <summary> Descriptor of the box Tactilo Controller. </summary>
  56. class CBoxAlgorithmTactiloControllerDesc final : virtual public IBoxAlgorithmDesc
  57. {
  58. public:
  59. void release() override { }
  60. CString getName() const override { return CString("Tactilo Controller"); }
  61. CString getAuthorName() const override { return CString("Tobias Baumann"); }
  62. CString getAuthorCompanyName() const override { return CString("TH-Nürnberg"); }
  63. CString getShortDescription() const override { return CString("Controls the Tactilos on the Lattepandas GPIOs"); }
  64. CString getDetailedDescription() const override { return CString("Communicates with the Arduino Coprocessor of the Lattepanda over a Serial Inteface, to control the Tactilos connected to the Arduinos GPIOs"); }
  65. CString getCategory() const override { return CString("TactileBCI"); }
  66. CString getVersion() const override { return CString("1.0"); }
  67. CString getStockItemName() const override { return CString("gtk-network"); }
  68. CIdentifier getCreatedClass() const override { return OVP_ClassId_BoxAlgorithm_TactiloController; }
  69. IPluginObject* create() override { return new CBoxAlgorithmTactiloController; }
  70. bool getBoxPrototype(Kernel::IBoxProto& prototype) const override
  71. {
  72. prototype.addInput("StimInput",OV_TypeId_Stimulations);
  73. //prototype.addFlag(Kernel::BoxFlag_CanModifyInput);
  74. //prototype.addFlag(Kernel::BoxFlag_CanAddInput);
  75. prototype.addOutput("StimOutput",OV_TypeId_Stimulations);
  76. //prototype.addFlag(Kernel::BoxFlag_CanModifyOutput);
  77. //prototype.addFlag(Kernel::BoxFlag_CanAddOutput);
  78. //Box Settings
  79. prototype.addSetting("Serial Port Name",OV_TypeId_String,"/dev/ttyACM0");
  80. prototype.addSetting("Row Stimulation Base",OV_TypeId_Stimulation,"OVTK_StimulationId_Label_01");
  81. prototype.addSetting("Number of Tactilos",OV_TypeId_Integer,"6");
  82. //prototype.addFlag(Kernel::BoxFlag_CanModifySetting);
  83. //prototype.addFlag(Kernel::BoxFlag_CanAddSetting);
  84. prototype.addFlag(OV_AttributeId_Box_FlagIsUnstable);
  85. return true;
  86. }
  87. _IsDerivedFromClass_Final_(IBoxAlgorithmDesc, OVP_ClassId_BoxAlgorithm_TactiloControllerDesc)
  88. };
  89. } // namespace Tactilebci
  90. } // namespace Plugins
  91. } // namespace OpenViBE