SampleReceiver/libwfr/src/MultiStreamReceiver.h
Wiesner András a6be70fb7b - MultiStreamOscilloscope first implementation done
- SlopeTrigger -> EdgeTrigger
- working Python example included
- libwfr.h introduced for easy including all libwfr headers
- ChannelBuffer is now template
- Semaphore moved
2022-05-05 22:19:52 +02:00

51 lines
2.1 KiB
C++

//
// Created by epagris on 2021. 11. 22..
//
#ifndef WFR_MULTISTREAMRECEIVER_H
#define WFR_MULTISTREAMRECEIVER_H
#include <netinet/in.h>
#include <vector>
#include <memory>
#include <thread>
#include <mutex>
#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<in_addr_t> mClientNodes; // client node addresses
int mSoc; // UDP-socket for receiving samples
std::shared_ptr<std::thread> mRecvThread; // thread for reception
static void fnRecv(MultiStreamReceiver *pMSR); // routine function running in separate thread
bool mRunning;
std::shared_ptr<MultiStreamProcessor> 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<in_addr_t> &nodes, size_t samplingRate, size_t sampleSize, size_t channelCount, size_t mchSampPerPckt, unsigned short port = DEFAULT_PORT);
MultiStreamReceiver(const std::vector<in_addr_t> &nodes, const AcquisitionFormat &acqFormat, unsigned short port = DEFAULT_PORT);
MultiStreamReceiver(const std::vector<in_addr_t> &nodes, const std::string &acqFormat_str, unsigned short port = DEFAULT_PORT);
MultiStreamReceiver(const std::vector<std::string> &nodes_str, const AcquisitionFormat &acqFormat, unsigned short port = DEFAULT_PORT);
MultiStreamReceiver(const std::vector<std::string> &nodes_str, const std::string &acqFormat_str, unsigned short port = DEFAULT_PORT);
void start(const std::shared_ptr<MultiStreamProcessor> &pMSP); // start reception
void stop(); // stop reception
size_t getChannelCount() const; // get number of data channels
virtual ~MultiStreamReceiver();
};
#endif //WFR_MULTISTREAMRECEIVER_H