1 #include <LibCyberRadio/NDR651/SyncTXClient.h> 7 SyncTXClient::SyncTXClient(
8 std::vector<TXClient *> txClients,
12 Debuggable(debug,
"SyncTXClient"),
20 for (
int i = 0; i < this->txClients.size(); i++)
22 this->txClients[i]->setGrouped(
true);
25 this->rc =
new RadioController(this->hostname, 8617,
debug);
28 SyncTXClient::~SyncTXClient()
36 for (
int i = 0; i < this->txClients.size(); i++)
38 delete this->txClients[i];
40 this->txClients.clear();
44 void SyncTXClient::start()
51 this->isRunning =
true;
55 this->debug(
"[start] Setting up DUC Group %d\n", ducGroup);
57 this->rc->clearDUCG(ducGroup);
59 for (
int i = 0; i < this->txClients.size(); i++)
64 this->rc->setDUCG(ducGroup, this->txClients[i]->getDucChannel(),
true);
69 this->debug(
"[start] Disabling DUC Group %d\n", ducGroup);
70 this->rc->setDUCGE(ducGroup,
false);
73 for (
int i = 0; i < this->txClients.size(); i++)
75 this->debug(
"[start] Starting TX Client for DUC %d\n",
76 this->txClients[i]->getDucChannel(),
79 this->txClients[i]->start();
81 this->waitingToEnableDUCGE =
true;
85 void SyncTXClient::stop()
89 this->rc->setDUCGE(ducGroup,
false);
90 for (
int i = 0; i < this->txClients.size(); i++)
92 this->txClients[i]->stop();
94 this->isRunning =
false;
98 bool SyncTXClient::areAllDucsPaused(
void) {
99 bool allDucsInPause =
true;
100 for (
int i = 0; i < this->txClients.size(); i++)
102 allDucsInPause &= this->txClients[i]->isDUCPaused();
104 return allDucsInPause;
107 bool SyncTXClient::checkClientStatus(
void) {
108 bool ducsStarted =
false;
109 bool anyDucsInPause =
false;
110 bool anyDucsReady =
false;
111 bool allDucsReady =
true;
112 for (
int i = 0; i < this->txClients.size(); i++)
114 anyDucsInPause |= this->txClients[i]->isDUCPaused();
115 anyDucsReady |= !(this->txClients[i]->isDUCReady());
116 allDucsReady &= !(this->txClients[i]->isDUCReady());
119 if ( anyDucsInPause && allDucsReady )
121 this->debug(
"[sendFrames] DUCs are ready, enabling DUC Group %d", ducGroup);
122 this->rc->setDUCGE(ducGroup,
true);
123 for (
int i = 0; i < this->txClients.size(); i++)
125 this->txClients[i]->setDUCPaused(
false);
132 bool SyncTXClient::sendFrameToClient(
short *frame,
unsigned int samplesPerFrame,
int client) {
134 if (client < this->txClients.size()) {
135 this->txClients[client]->sendFrame(frame, samplesPerFrame);
141 void SyncTXClient::sendFrames(
short **frames,
unsigned int samplesPerFrame)
149 bool anyDucsInPause =
false;
150 for (
int i = 0; i < this->txClients.size(); i++)
152 anyDucsInPause |= this->txClients[i]->isDUCPaused();
157 for (
int i = 0; i < this->txClients.size(); i++)
159 this->txClients[i]->sendFrame(frames[i], samplesPerFrame);
163 if (anyDucsInPause) {
165 bool anyDucsReady =
false;
166 for (
int i = 0; i < this->txClients.size(); i++)
168 anyDucsReady |= this->txClients[i]->isDUCReady();
172 this->rc->setDUCGE(ducGroup,
true);
173 for (
int i = 0; i < this->txClients.size(); i++)
175 this->txClients[i]->setDUCPaused(
false);
196 void SyncTXClient::setDucGroup(
int ducGroup)
198 if (ducGroup >= 1 && ducGroup <= 4) {
199 this->ducGroup = ducGroup;
203 int SyncTXClient::getDucGroup()
205 return(this->ducGroup);
virtual int debug(const char *format,...)
Outputs debug information.
Defines functionality for LibCyberRadio applications.