libcyberradio 22.01.24
UdpStatusReceiver.h
1/***************************************************************************
2 * \file UdpStatusReceiver.h
3 *
4 * \brief NDR651 UDP status receiver.
5 *
6 * \author NH
7 * \copyright Copyright (c) 2015-2021 CyberRadio Solutions, Inc.
8 *
9 */
10
11#ifndef INCLUDED_LIBCYBERRADIO_NDR651_UDPSTATUSRECEIVER_H_
12#define INCLUDED_LIBCYBERRADIO_NDR651_UDPSTATUSRECEIVER_H_
13
14#include <boost/thread/mutex.hpp>
15#include "LibCyberRadio/Common/Debuggable.h"
16#include "LibCyberRadio/Common/Thread.h"
17
18#define MAX_RX_SIZE 8192
19#define MAX_RADIO_BUFFSIZE 67108862 // (2^26)-2 samples
20#define RADIO_BUFFER_RESERVE 1048576
21
25namespace LibCyberRadio
26{
31 namespace NDR651
32 {
33
38 {
39 public:
47 UdpStatusReceiver(std::string ifname, unsigned int port, bool debug, bool updatePE);
51 virtual ~UdpStatusReceiver();
55 virtual void run();
61 bool setStatusInterface(std::string ifname);
68 bool setStatusInterface(std::string ifname, bool makeSocketFlag);
74 bool setStatusPort(unsigned int port);
81 bool setStatusPort(unsigned int port, bool makeSocketFlag);
88 bool okToSend(long int pendingSamples, bool lockIfOk);
93 long int getFreeSpace(void);
99 bool sentNSamples(long int samplesSent);
100
101 bool setUpdatePE(bool updatePE);
102 bool getUpdatePE(void) { return _updatePE; };
103 int setMaxFreeSpace(float fs, float maxLatency);
104 int getMaxFreeSpace(void) { return _freeSpaceMax; };
105 //~ bool setUdpPort(unsigned int port);
106 int getUdpPort(void) { return _port; };
107
108 private:
109 int _sockfd;
110 char _rxbuff[MAX_RX_SIZE];
111 fd_set set;
112 boost::mutex _fcMutex, _selMutex;
113 bool _sendLock;
114 bool _shutdown;
115 bool _updatePE;
116
117 std::string _ifname;
118 unsigned int _port;
119 uint64_t timeoutCount;
120
121 int _651freeSpace;
122 int _freeSpaceMax;
123
124 bool _makeSocket(void);
125 bool _setFreeSpace(int, bool, bool, bool);
126 };
127
128 } /* namespace NDR651 */
129
130} /* namespace LibCyberRadio */
131
132#endif /* INCLUDED_LIBCYBERRADIO_NDR651_UDPSTATUSRECEIVER_H_ */
Class that supports debug output.
Definition Debuggable.h:39
virtual int debug(const char *format,...)
Outputs debug information.
virtual void run()
Executes the main processing loop for the thread.
bool okToSend(long int pendingSamples, bool lockIfOk)
Determines if it is OK to send data.
UdpStatusReceiver(std::string ifname, unsigned int port, bool debug, bool updatePE)
Constructs a UdpStatusReceiver object.
bool setStatusInterface(std::string ifname)
Sets the interface name.
bool setStatusPort(unsigned int port)
Sets the UDP port.
virtual ~UdpStatusReceiver()
Destroys a UdpStatusReceiver object.
long int getFreeSpace(void)
Gets the amount of free space available.
bool sentNSamples(long int samplesSent)
Updates status based on the number of samples sent.
Base class for a thread object, based on Boost Threads.
Definition Thread.h:49
Provides programming elements for controlling the CyberRadio Solutions NDR651 radio.
Defines functionality for LibCyberRadio applications.
Definition App.h:24