libcyberradio  22.01.24
TXClient.h
1 /*
2  * TXClient - Refactored Implementation of TransmitPacketizer
3  * Author: Nathan Harter
4  * Author: Joseph Martin
5  * Date: 5/23/2017
6  */
7 
8 #ifndef INCLUDED_LIBCYBERRADIO_NDR651_TXCLIENT_H
9 #define INCLUDED_LIBCYBERRADIO_NDR651_TXCLIENT_H
10 
11 #include "LibCyberRadio/Common/Debuggable.h"
12 #include "LibCyberRadio/NDR651/FlowControlClient.h"
13 #include "LibCyberRadio/NDR651/PacketTypes.h"
14 #include "LibCyberRadio/NDR651/UdpStatusReceiver.h"
15 #include "LibCyberRadio/NDR651/StatusReceiver.h"
16 #include "LibCyberRadio/NDR651/RadioController.h"
17 #include "LibCyberRadio/NDR651/Packetizer.h"
18 
19 #include <boost/algorithm/string.hpp>
20 #include <boost/thread.hpp>
21 
22 #define UDP_STATUS_BASE 65500
23 #define INVALID_VALUE 100000
24 
25 namespace LibCyberRadio
26 {
27  namespace NDR651
28  {
29  class TXClient : public Debuggable
30  {
31 
32  private:
33  /* Instance variables */
34  // Constructor Args
35  std::string txInterfaceName;
36  unsigned int ducChannel;
37  unsigned int tenGbeIndex;
38  double ducAttenuation;
39  unsigned int ducRateIndex;
40  unsigned int rfChannel;
41  unsigned short txUdpPort;
42  double ducFreq;
43  double ducFullThreshPercent;
44  double ducEmptyThreshPercent;
45  unsigned int updatesPerSecond;
46  double txFreq;
47  double txAttenuation;
48  bool txInversion;
49  std::string radioHostName;
50  bool debugOn;
51 
52  // Other Inits
53  int txSock;
54  Packetizer *packetizer;
55  //UdpStatusReceiver *statusRX;
56  StatusReceiver *statusRX;
57  RadioController *rc;
58  bool isGrouped; // Is this Client part of a sync transmit?
59  bool isRunning; // Has the user called start()
60  bool DUCPaused; // Should the DUC currently paused?
61  bool DUCReady; // Is the DUC ready to be unpaused?
62  long prefillSampleCount;
63 
64  // To synchronize calls from other threads
65  boost::mutex objectAccessMutex;
66 
67  /* Instance methods */
68  std::string getSourceMac();
69  std::string getSourceIP();
70  bool validInputs(std::string &errors);
71 
72  public:
73  /* Constructors */
74  TXClient(std::string radioHostName, bool debug);
75  ~TXClient();
76 
77  /* Instance methods */
78  void start();
79  void stop(bool disableRF = false);
80  void setGrouped(bool isGrouped);
81  void sendFrame(short * samples, unsigned int samplesPerFrame);
82  unsigned int getDucChannel();
83  bool isDUCPaused();
84  bool isDUCReady();
85  bool setDUCPaused(bool paused);
86 
87  // Config Setters
88  bool setDUCChannel(unsigned int ducChannel); // Required (fulfillled by setDucParameters)
89  bool setTxChannel(unsigned int txChannel); // Required (fulfillled by setDucParameters)
90  bool setDUCRateIndex(unsigned int ducRateIndex); // Required (fulfillled by setDucParameters)
91  bool setDUCFreq(double ducFreq); // Optional
92  bool setDUCAtten(double ducAtten); // Optional
93  bool setTxFreq(double txFreq); // Optional
94  bool setTxAtten(double txAttenuation); // Optional
95  bool setDUCParameters(
96  unsigned int ducChannel,
97  unsigned int ducRateIndex,
98  unsigned int txChannel
99  );
100  bool setEthernetInterface(unsigned int tenGbeIndex, const std::string &txInterfaceName, unsigned short port); // Required
101  void disableRF();
102  bool setTxInversion(bool txInversion);
103  bool pauseDUC(bool paused = true);
104 
105  protected:
106  bool setDUCRateIndexUnlocked(unsigned int ducRateIndex);
107 
108  };
109  }
110 }
111 
112 #endif /* INCLUDED_LIBCYBERRADIO_NDR651_TXCLIENT_H */
Defines functionality for LibCyberRadio applications.
Definition: App.h:23