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.

ovasCPluginTCPTagging.h 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. /**
  3. * \brief Acquisition Server plugin adding the capability to receive stimulations from external sources
  4. * via TCP/IP.
  5. *
  6. * The stimulation format is the same as with Shared Memory Tagging. It comprises three blocks of 8 bytes:
  7. *
  8. * ----------------------------------------------------------------------
  9. * | padding (8 bytes) | event id (8 bytes) | timestamp (8 bytes) |
  10. * ----------------------------------------------------------------------
  11. *
  12. * The padding is only for consistency with Shared Memory Tagging and has no utility.
  13. * The event id informs about the type of event happening.
  14. * The timestamp is the posix time (ms since Epoch) at the moment of the event.
  15. * It the latter is set to 0, the acquisition server issues its own timestamp upon reception of the stimulation.
  16. *
  17. * Have a look at contrib/plugins/server-extensions/tcp-tagging/client-example to learn about the protocol
  18. * to send stimulations from the client.
  19. */
  20. #include "ovasIAcquisitionServerPlugin.h"
  21. #include "ovasCTagStream.h"
  22. namespace OpenViBE {
  23. namespace AcquisitionServer {
  24. namespace Plugins {
  25. class CPluginTCPTagging final : public IAcquisitionServerPlugin
  26. {
  27. public:
  28. explicit CPluginTCPTagging(const Kernel::IKernelContext& ctx);
  29. ~CPluginTCPTagging() override { }
  30. // Overrides virtual method startHook inherited from class IAcquisitionServerPlugin.
  31. bool startHook(const std::vector<CString>& vSelectedChannelNames, const size_t sampling, const size_t nChannel, const size_t nSamplePerSentBlock) override;
  32. // Overrides virtual method stopHook inherited from class IAcquisitionServerPlugin
  33. void stopHook() override;
  34. // Overrides virtual method loopHook inherited from class IAcquisitionServerPlugin.
  35. void loopHook(std::deque<std::vector<float>>& vPendingBuffer, CStimulationSet& stimulationSet, const uint64_t start, const uint64_t end,
  36. const uint64_t sampleTime) override;
  37. private:
  38. uint64_t m_previousClockTime = 0;
  39. uint64_t m_previousSampleTime = 0;
  40. uint64_t m_lastTagTime = 0;
  41. uint64_t m_lastTagTimeAdjusted = 0;
  42. std::unique_ptr<CTagStream> m_scopedTagStream;
  43. size_t m_port = 0;
  44. bool m_warningPrinted = false;
  45. };
  46. } // namespace Plugins
  47. } // namespace AcquisitionServer
  48. } // namespace OpenViBE