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.

ovasCDriverGTecGUSBampLinux.h 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. #if defined TARGET_HAS_ThirdPartyGUSBampCAPI_Linux
  3. #include "ovasIDriver.h"
  4. #include "../ovasCHeader.h"
  5. #include <openvibe/ov_all.h>
  6. #include "../ovasCSettingsHelper.h"
  7. #include "../ovasCSettingsHelperOperators.h"
  8. #include <gAPI.h>
  9. #include "Queue.h"
  10. namespace OpenViBE {
  11. namespace AcquisitionServer {
  12. void OnDataReady(void* param);
  13. /**
  14. * \class CDriverGTecGUSBampLinux
  15. * \author Tom Stewart (University of Tsukuba)
  16. * \date Mon Feb 9 18:59:22 2015
  17. * \brief The CDriverGTecGUSBampLinux allows the acquisition server to acquire data from a g.tec g.USBamp from Linux.
  18. *
  19. * \sa CConfigurationGTecGUSBampLinux
  20. */
  21. class CDriverGTecGUSBampLinux final : public IDriver
  22. {
  23. static const int ReceiveBufferSize = 8192;
  24. public:
  25. friend void OnDataReady(void* param);
  26. explicit CDriverGTecGUSBampLinux(IDriverContext& ctx);
  27. ~CDriverGTecGUSBampLinux() override {}
  28. const char* getName() override { return "g.tec g.USBamp Linux BCI-Lab"; }
  29. bool initialize(const uint32_t nSamplePerSentBlock, IDriverCallback& callback) override;
  30. bool uninitialize() override;
  31. bool start() override;
  32. bool stop() override;
  33. bool loop() override;
  34. bool isConfigurable() override;
  35. bool configure() override;
  36. const IHeader* getHeader() override { return &m_header; }
  37. bool isFlagSet(const EDriverFlag flag) const override { return flag == EDriverFlag::IsUnstable; }
  38. protected:
  39. SettingsHelper m_settings;
  40. IDriverCallback* m_callback = nullptr;
  41. // Replace this generic Header with any specific header you might have written
  42. CHeader m_header;
  43. uint32_t m_nSamplePerSentBlock;
  44. float *m_sampleSend, *m_sampleReceive, *m_sampleBuffer;
  45. Queue<float> m_sampleQueue;
  46. private:
  47. /*
  48. * Insert here all specific attributes, such as USB port number or device ID.
  49. */
  50. std::string m_deviceName;
  51. gt_usbamp_config m_config;
  52. gt_usbamp_analog_out_config m_analogOutConfig;
  53. // Keeps track of where we are with filling up the buffer
  54. uint32_t m_currentSample, m_currentChannel;
  55. };
  56. } // namespace AcquisitionServer
  57. } // namespace OpenViBE
  58. #endif // TARGET_HAS_ThirdPartyGUSBampCAPI_Linux