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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 <string>
  18. namespace OpenViBE
  19. {
  20. namespace Plugins
  21. {
  22. namespace Tactilebci
  23. {
  24. /// <summary> The class CBoxAlgorithmTactiloController describes the box Tactilo Controller. </summary>
  25. class CBoxAlgorithmTactiloController final : virtual public Toolkit::TBoxAlgorithm<IBoxAlgorithm>
  26. {
  27. public:
  28. void release() override { delete this; }
  29. bool initialize() override;
  30. bool uninitialize() override;
  31. bool processInput(const size_t index) override;
  32. bool process() override;
  33. // As we do with any class in openvibe, we use the macro below to associate this box to an unique identifier.
  34. // The inheritance information is also made available, as we provide the superclass Toolkit::TBoxAlgorithm < IBoxAlgorithm >
  35. _IsDerivedFromClass_Final_(Toolkit::TBoxAlgorithm<IBoxAlgorithm>, OVP_ClassId_BoxAlgorithm_TactiloController)
  36. protected:
  37. // Input decoder:
  38. Toolkit::TStimulationDecoder<CBoxAlgorithmTactiloController> m_StimDecoder;
  39. // Output decoder:
  40. Toolkit::TStimulationEncoder<CBoxAlgorithmTactiloController> m_StimEncoder;
  41. private:
  42. //variable to store the current TactiloNr
  43. uint64_t m_currTactiloNr = 0;
  44. //Box Settings
  45. CString m_PortName = "";
  46. uint64_t m_RowBase = 0;
  47. uint64_t m_nTactilos = 0;
  48. //Serial Port
  49. boost::asio::io_service m_IOService;
  50. boost::asio::serial_port m_Port{m_IOService};
  51. };
  52. /// <summary> Descriptor of the box Tactilo Controller. </summary>
  53. class CBoxAlgorithmTactiloControllerDesc final : virtual public IBoxAlgorithmDesc
  54. {
  55. public:
  56. void release() override { }
  57. CString getName() const override { return CString("Tactilo Controller"); }
  58. CString getAuthorName() const override { return CString("Tobias Baumann"); }
  59. CString getAuthorCompanyName() const override { return CString("TH-Nürnberg"); }
  60. CString getShortDescription() const override { return CString("Controls the Tactilos on the Lattepandas GPIOs"); }
  61. 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"); }
  62. CString getCategory() const override { return CString("TactileBCI"); }
  63. CString getVersion() const override { return CString("1.0"); }
  64. CString getStockItemName() const override { return CString("gtk-network"); }
  65. CIdentifier getCreatedClass() const override { return OVP_ClassId_BoxAlgorithm_TactiloController; }
  66. IPluginObject* create() override { return new CBoxAlgorithmTactiloController; }
  67. bool getBoxPrototype(Kernel::IBoxProto& prototype) const override
  68. {
  69. prototype.addInput("StimInput",OV_TypeId_Stimulations);
  70. //prototype.addFlag(Kernel::BoxFlag_CanModifyInput);
  71. //prototype.addFlag(Kernel::BoxFlag_CanAddInput);
  72. prototype.addOutput("StimOutput",OV_TypeId_Stimulations);
  73. //prototype.addFlag(Kernel::BoxFlag_CanModifyOutput);
  74. //prototype.addFlag(Kernel::BoxFlag_CanAddOutput);
  75. //Box Settings
  76. prototype.addSetting("Serial Port Name",OV_TypeId_String,"/dev/ttyACM0");
  77. prototype.addSetting("Row Stimulation Base",OV_TypeId_Stimulation,"OVTK_StimulationId_Label_01");
  78. prototype.addSetting("Number of Tactilos",OV_TypeId_Integer,"6");
  79. //prototype.addFlag(Kernel::BoxFlag_CanModifySetting);
  80. //prototype.addFlag(Kernel::BoxFlag_CanAddSetting);
  81. prototype.addFlag(OV_AttributeId_Box_FlagIsUnstable);
  82. return true;
  83. }
  84. _IsDerivedFromClass_Final_(IBoxAlgorithmDesc, OVP_ClassId_BoxAlgorithm_TactiloControllerDesc)
  85. };
  86. } // namespace Tactilebci
  87. } // namespace Plugins
  88. } // namespace OpenViBE