// // Created by epagris on 2021. 11. 22.. // #ifndef WFR_MULTISTREAMRECEIVER_H #define WFR_MULTISTREAMRECEIVER_H #include #include #include #include #include #include "SampleWriter.h" #include "AcquisitionFormat.h" #include "MultiStreamProcessor.h" class MultiStreamReceiver { public: static constexpr unsigned short DEFAULT_PORT = 20220; // default port static constexpr double TS_VALIDITY_RANGE = 0.1; // maximal variation of packet length considered valid private: std::vector mClientNodes; // client node addresses int mSoc; // UDP-socket for receiving samples std::shared_ptr mRecvThread; // thread for reception static void fnRecv(MultiStreamReceiver *pMSR); // routine function running in separate thread bool mRunning; std::shared_ptr mpMSP; // multistream processor INSTANCE (pointer to...) private: AcquisitionFormat mAcqFmt; // acquisition format private: void startNetworking(); // start networking public: const unsigned short port; // port public: MultiStreamReceiver(const std::vector &nodes, size_t samplingRate, size_t sampleSize, size_t channelCount, size_t mchSampPerPckt, unsigned short port = DEFAULT_PORT); MultiStreamReceiver(const std::vector &nodes, const AcquisitionFormat &acqFormat, unsigned short port = DEFAULT_PORT); MultiStreamReceiver(const std::vector &nodes, const std::string &acqFormat_str, unsigned short port = DEFAULT_PORT); MultiStreamReceiver(const std::vector &nodes_str, const AcquisitionFormat &acqFormat, unsigned short port = DEFAULT_PORT); MultiStreamReceiver(const std::vector &nodes_str, const std::string &acqFormat_str, unsigned short port = DEFAULT_PORT); void start(const std::shared_ptr &pMSP); // start reception void stop(); // stop reception size_t getChannelCount() const; // get number of data channels virtual ~MultiStreamReceiver(); }; #endif //WFR_MULTISTREAMRECEIVER_H