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 // (2^26)-2 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;
bool isConnected(void)
Gets whether or not the client is connected.
Flow control client class.
long unsigned int getUtc(void)
Gets the radio's UTC time.
std::string getRadioIp(unsigned int tenGbeIndex)
Gets the IP address of a 10GigE port on the radio.
bool setTxFrequency(double txFreq, bool applySetting=true)
Sets the transmitter frequency.
virtual ~FlowControlClient()
Destroys a FlowControlClient object.
bool isConnected(void)
Gets whether or not the socket is connected.
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 setDucRateIndex(unsigned int rateIndex, bool applySetting=true)
Sets the DUC rate index.
bool setDucStreamId(unsigned int streamId, bool applySetting=true)
Sets the Stream ID.
Class that supports debug output.
bool setTxAttenuation(unsigned int txAttenuation, bool applySetting=true)
Sets the transmitter attenuation.
std::string getRadioMac(unsigned int tenGbeIndex)
Gets the MAC address of a 10GigE port on the radio.
bool setDucTxChannel(unsigned int txChannel, bool applySetting=true)
Sets the DUC transmitter bitmap.
bool okToSend(long int pendingSamples, bool lockIfOk)
Determines if it is OK to send data.
bool disconnect(void)
Disconnects the flow control client.
virtual int debug(const char *format,...)
Outputs debug information.
bool setDucEnable(bool ducEnable, bool applySetting=true)
Sets whether or not the DUC is enabled.
BASIC_LIST_CONTAINER< std::string > BasicStringList
Type representing a list of strings.
bool setDucFrequency(long ducFreq, bool applySetting=true)
Sets the DUC frequency.
void testQueries(void)
Tests the flow control queries.
Defines functionality for LibCyberRadio applications.
virtual void run()
Executes the main processing loop for the thread.
bool connectToRadio(const std::string &hostname, unsigned int port)
Connects to the radio.
bool setDucAttenuation(float attenuation, bool applySetting=true)
Sets the DUC attenuation.
unsigned int getUpdateDelay()
Gets the update delay.
FlowControlClient(unsigned int ducChannel, bool config_tx, unsigned int updatesPerSecond, bool debug=false)
Constructs a FlowControlClient object.
Transmit status frame information.
long int getFreeSpace(void)
Gets the amount of free space available.
bool setDucTxinvMode(unsigned int txinvMode, bool applySetting=true)
Sets the DUC TX Inversion Mode.
bool sentNSamples(long int samplesSent)
Updates status based on the number of samples sent.
void setDucChannel(unsigned int ducChannel)
Sets the DUC channel number.
Base class for a thread object, based on Boost Threads.
void update(void)
Updates the flow controller.
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 disableDuc()
Disables the DUC.