11#ifndef INCLUDED_LIBCYBERRADIO_NDR651_FLOWCONTROLCLIENT_H
12#define INCLUDED_LIBCYBERRADIO_NDR651_FLOWCONTROLCLIENT_H
14#include "LibCyberRadio/Common/BasicList.h"
15#include "LibCyberRadio/Common/Debuggable.h"
16#include "LibCyberRadio/Common/Thread.h"
17#include "LibCyberRadio/NDR651/ClientSocket.h"
18#include "LibCyberRadio/NDR651/PacketTypes.h"
19#include <boost/thread/mutex.hpp>
20#include <boost/ptr_container/ptr_vector.hpp>
24#define TX_BUFFER_MAX_SIZE 67108862
25#define TX_BUFFER_MIN_SIZE 0
53 unsigned int updatesPerSecond,
73 bool connectToRadio(
const std::string& hostname,
unsigned int port);
109 long unsigned int getUtc(
void) {
return _utc;};
121 std::string
getRadioIp(
unsigned int tenGbeIndex);
141 bool enableDuc(
unsigned int rateIndex,
unsigned int txChannel,
142 unsigned int streamId,
unsigned int tenGbeIndex,
float attenuation,
143 double txFreq,
long ducFreq,
unsigned int txAtten,
bool ducEnable =
true);
159 bool setTxAttenuation(
unsigned int txAttenuation,
bool applySetting =
true);
166 bool setDucTxChannel(
unsigned int txChannel,
bool applySetting =
true);
173 bool setDucRateIndex(
unsigned int rateIndex,
bool applySetting =
true);
180 bool setDucStreamId(
unsigned int streamId,
bool applySetting =
true);
201 bool setDucTxinvMode(
unsigned int txinvMode,
bool applySetting =
true);
208 bool setDucEnable(
bool ducEnable,
bool applySetting =
true);
215 bool setDucTenGbePort(
unsigned int ducTenGbePort,
bool applySetting =
true);
222 bool okToSend(
long int pendingSamples,
bool lockIfOk);
238 bool setDucDipStatusEntry(
int dipIndex, std::string dip, std::string dmac,
unsigned int ducStatusPort);
239 bool setDuchsParameters(
unsigned int duchsFullThresh,
unsigned int duchsEmptyThresh,
unsigned int duchsPeriod);
245 std::string _radioHostname;
246 unsigned int _radioTcpPort;
250 socklen_t _statusDestLen;
251 struct sockaddr_in _statusDestAddr, _statusCopyAddr;
253 unsigned int _tbsChannel;
254 unsigned int _tbsSpace;
255 unsigned int _tbsUnderrunFlag;
256 unsigned int _tbsUnderrunCount;
257 unsigned int _tbsOverrunFlag;
258 unsigned int _tbsOverrunCount;
259 unsigned int _tbsEmptyFlag;
260 unsigned int _tbsFullFlag;
262 bool _validDucChannel, _multiChannel;
264 unsigned int _ducChannel;
265 unsigned int _ducRateIndex;
266 unsigned int _ducStreamId;
267 unsigned int _ducTxChannel;
268 unsigned int _ducTenGbePort;
269 unsigned int _ducDipIndex;
270 unsigned int _ducAttenuation;
271 unsigned int _txinvMode;
272 unsigned int _txAttenuation;
278 unsigned int _duchsFullThresh;
279 unsigned int _duchsEmptyThresh;
280 unsigned int _duchsPeriod;
281 unsigned int _duchsUdpPort;
285 boost::ptr_vector<boost::mutex> _fcMutexVector;
286 std::vector<long int> _freeSpaceVector;
288 boost::mutex _fcMutex, _fcSendMutex, _fcUpdateMutex;
290 unsigned int _fcUpdateRate, _fcUpdateDelay;
293 unsigned long int _utc;
294 long int _651freeSpace;
295 long int _651freeSpaceArray[8];
296 long int _651freeSpaceLast;
297 long int _samplesPerUpdate;
300 std::string _tbsQuery;
304 bool _sendCmdAndQry(
const std::string& cmd,
const std::string& qry);
319 bool _clearDucSettingsInRadio(
void);
321 void _initStatusFrame(
void);
322 void _initStatusSocket(
void);
323 void _initStatusAddress(
void);
324 void _sendStatusFrame(
void);
327 void _queryBufferState(
void);
328 void _queryUtc(
void);
329 void _queryStatus(
void);
330 long _getDucSampleRate(
void)
const;
virtual int debug(const char *format,...)
Outputs debug information.
Debuggable(bool debug=false, const std::string &debug_name="", FILE *debug_fp=DEBUG_FP, const std::string &debug_timefmt=DEBUG_TIME_FMT)
Constructs a Debuggable object.
bool disableDuc()
Disables the DUC.
virtual void run()
Executes the main processing loop for the thread.
std::string getRadioMac(unsigned int tenGbeIndex)
Gets the MAC address of a 10GigE port on the radio.
bool okToSend(long int pendingSamples, bool lockIfOk)
Determines if it is OK to send data.
bool enableDuc(unsigned int rateIndex, unsigned int txChannel, unsigned int streamId, unsigned int tenGbeIndex, float attenuation, double txFreq, long ducFreq, unsigned int txAtten, bool ducEnable=true)
Enables the DUC.
bool setDucFrequency(long ducFreq, bool applySetting=true)
Sets the DUC frequency.
void setDucChannel(unsigned int ducChannel)
Sets the DUC channel number.
bool isConnected(void)
Gets whether or not the client is connected.
unsigned int setUpdateRate(unsigned int updatesPerSecond)
Sets the update rate.
bool setDucTenGbePort(unsigned int ducTenGbePort, bool applySetting=true)
Sets the 10GigE port used by the DUC.
bool setDucRateIndex(unsigned int rateIndex, bool applySetting=true)
Sets the DUC rate index.
bool setDucStreamId(unsigned int streamId, bool applySetting=true)
Sets the Stream ID.
void update(void)
Updates the flow controller.
bool setDucTxinvMode(unsigned int txinvMode, bool applySetting=true)
Sets the DUC TX Inversion Mode.
unsigned int getUpdateDelay()
Gets the update delay.
bool setTxAttenuation(unsigned int txAttenuation, bool applySetting=true)
Sets the transmitter attenuation.
virtual ~FlowControlClient()
Destroys a FlowControlClient object.
bool setTxFrequency(double txFreq, bool applySetting=true)
Sets the transmitter frequency.
bool setDucTxChannel(unsigned int txChannel, bool applySetting=true)
Sets the DUC transmitter bitmap.
std::string getRadioIp(unsigned int tenGbeIndex)
Gets the IP address of a 10GigE port on the radio.
bool setDucAttenuation(float attenuation, bool applySetting=true)
Sets the DUC attenuation.
void testQueries(void)
Tests the flow control queries.
bool connectToRadio(const std::string &hostname, unsigned int port)
Connects to the radio.
FlowControlClient(unsigned int ducChannel, bool config_tx, unsigned int updatesPerSecond, bool debug=false)
Constructs a FlowControlClient object.
bool disconnect(void)
Disconnects the flow control client.
long unsigned int getUtc(void)
Gets the radio's UTC time.
bool setDucEnable(bool ducEnable, bool applySetting=true)
Sets whether or not the DUC is enabled.
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.
Thread(const std::string &name="", const std::string &cls="")
Creates a Thread object.
Provides programming elements for controlling the CyberRadio Solutions NDR651 radio.
Defines functionality for LibCyberRadio applications.
BASIC_LIST_CONTAINER< std::string > BasicStringList
Type representing a list of strings.
Transmit status frame information.