SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Classes | Public Member Functions | Private Slots | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
RemoteOutput Class Reference

#include <remoteoutput.h>

+ Inheritance diagram for RemoteOutput:
+ Collaboration diagram for RemoteOutput:

Classes

class  MsgConfigureRemoteOutput
 
class  MsgConfigureRemoteOutputChunkCorrection
 
class  MsgConfigureRemoteOutputWork
 
class  MsgStartStop
 

Public Member Functions

 RemoteOutput (DeviceAPI *deviceAPI)
 
virtual ~RemoteOutput ()
 
virtual void destroy ()
 
virtual void init ()
 initializations to be done when all collaborating objects are created and possibly connected More...
 
virtual bool start ()
 
virtual void stop ()
 
virtual QByteArray serialize () const
 
virtual bool deserialize (const QByteArray &data)
 
virtual void setMessageQueueToGUI (MessageQueue *queue)
 
virtual const QString & getDeviceDescription () const
 
virtual int getSampleRate () const
 Sample rate exposed by the sink. More...
 
virtual void setSampleRate (int sampleRate)
 For when the sink sample rate is set externally. More...
 
virtual quint64 getCenterFrequency () const
 Center frequency exposed by the sink. More...
 
virtual void setCenterFrequency (qint64 centerFrequency)
 
std::time_t getStartingTimeStamp () const
 
virtual bool handleMessage (const Message &message)
 
virtual int webapiSettingsGet (SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
 
virtual int webapiSettingsPutPatch (bool force, const QStringList &deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
 
virtual int webapiReportGet (SWGSDRangel::SWGDeviceReport &response, QString &errorMessage)
 
virtual int webapiRunGet (SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
 
virtual int webapiRun (bool run, SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
 
- Public Member Functions inherited from DeviceSampleSink
 DeviceSampleSink ()
 
virtual ~DeviceSampleSink ()
 
MessageQueuegetInputMessageQueue ()
 
MessageQueuegetMessageQueueToGUI ()
 
SampleSourceFifogetSampleFifo ()
 

Private Slots

void tick ()
 
void networkManagerFinished (QNetworkReply *reply)
 

Private Member Functions

void applySettings (const RemoteOutputSettings &settings, bool force=false)
 
void webapiFormatDeviceSettings (SWGSDRangel::SWGDeviceSettings &response, const RemoteOutputSettings &settings)
 
void webapiFormatDeviceReport (SWGSDRangel::SWGDeviceReport &response)
 
void analyzeApiReply (const QJsonObject &jsonObject, const QString &answer)
 
void sampleRateCorrection (double remoteTimeDeltaUs, double timeDeltaUs, uint32_t remoteSampleCount, uint32_t sampleCount)
 
void webapiReverseSendSettings (QList< QString > &deviceSettingsKeys, const RemoteOutputSettings &settings, bool force)
 
void webapiReverseSendStartStop (bool start)
 

Private Attributes

DeviceAPIm_deviceAPI
 
QMutex m_mutex
 
RemoteOutputSettings m_settings
 
uint64_t m_centerFrequency
 
RemoteOutputThreadm_remoteOutputThread
 
QString m_deviceDescription
 
std::time_t m_startingTimeStamp
 
const QTimer & m_masterTimer
 
uint32_t m_tickCount
 
uint32_t m_tickMultiplier
 
QNetworkAccessManager * m_networkManager
 
QNetworkRequest m_networkRequest
 
uint32_t m_lastRemoteSampleCount
 
uint32_t m_lastSampleCount
 
uint64_t m_lastRemoteTimestampRateCorrection
 
uint64_t m_lastTimestampRateCorrection
 
int m_lastQueueLength
 
uint32_t m_nbRemoteSamplesSinceRateCorrection
 
uint32_t m_nbSamplesSinceRateCorrection
 
int m_chunkSizeCorrection
 

Static Private Attributes

static const uint32_t NbSamplesForRateCorrection = 5000000
 

Additional Inherited Members

- Public Types inherited from DeviceSampleSink
enum  fcPos_t { FC_POS_INFRA = 0, FC_POS_SUPRA, FC_POS_CENTER }
 
- Static Public Member Functions inherited from DeviceSampleSink
static qint64 calculateDeviceCenterFrequency (quint64 centerFrequency, qint64 transverterDeltaFrequency, int log2Interp, fcPos_t fcPos, quint32 devSampleRate, bool transverterMode=false)
 
static qint64 calculateCenterFrequency (quint64 deviceCenterFrequency, qint64 transverterDeltaFrequency, int log2Interp, fcPos_t fcPos, quint32 devSampleRate, bool transverterMode=false)
 
static qint32 calculateFrequencyShift (int log2Interp, fcPos_t fcPos, quint32 devSampleRate)
 
- Protected Slots inherited from DeviceSampleSink
void handleInputMessages ()
 
- Protected Attributes inherited from DeviceSampleSink
SampleSourceFifo m_sampleSourceFifo
 
MessageQueue m_inputMessageQueue
 Input queue to the sink. More...
 
MessageQueuem_guiMessageQueue
 Input message queue to the GUI. More...
 

Detailed Description

Definition at line 40 of file remoteoutput.h.

Constructor & Destructor Documentation

◆ RemoteOutput()

RemoteOutput::RemoteOutput ( DeviceAPI deviceAPI)

Definition at line 48 of file remoteoutput.cpp.

References m_deviceAPI, m_masterTimer, m_networkManager, networkManagerFinished(), DeviceAPI::setNbSinkStreams(), and tick().

Referenced by RemoteOutput::MsgConfigureRemoteOutputChunkCorrection::MsgConfigureRemoteOutputChunkCorrection().

48  :
49  m_deviceAPI(deviceAPI),
50  m_settings(),
53  m_deviceDescription("RemoteOutput"),
55  m_masterTimer(deviceAPI->getMasterTimer()),
56  m_tickCount(0),
57  m_tickMultiplier(20),
66 {
68  m_networkManager = new QNetworkAccessManager();
69  connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
70  connect(&m_masterTimer, SIGNAL(timeout()), this, SLOT(tick()));
71 }
RemoteOutputThread * m_remoteOutputThread
Definition: remoteoutput.h:174
std::time_t m_startingTimeStamp
Definition: remoteoutput.h:176
uint32_t m_nbRemoteSamplesSinceRateCorrection
Definition: remoteoutput.h:189
uint32_t m_tickCount
Definition: remoteoutput.h:178
const QTimer & m_masterTimer
Definition: remoteoutput.h:177
void setNbSinkStreams(uint32_t nbSinkStreams)
Definition: deviceapi.h:169
uint64_t m_centerFrequency
Definition: remoteoutput.h:173
const QTimer & getMasterTimer() const
This is the DSPEngine master timer.
Definition: deviceapi.h:173
int m_lastQueueLength
Definition: remoteoutput.h:188
RemoteOutputSettings m_settings
Definition: remoteoutput.h:172
uint32_t m_lastSampleCount
Definition: remoteoutput.h:185
QString m_deviceDescription
Definition: remoteoutput.h:175
uint64_t m_lastTimestampRateCorrection
Definition: remoteoutput.h:187
uint32_t m_nbSamplesSinceRateCorrection
Definition: remoteoutput.h:190
uint32_t m_lastRemoteSampleCount
Definition: remoteoutput.h:184
uint64_t m_lastRemoteTimestampRateCorrection
Definition: remoteoutput.h:186
uint32_t m_tickMultiplier
Definition: remoteoutput.h:179
void networkManagerFinished(QNetworkReply *reply)
int m_chunkSizeCorrection
Definition: remoteoutput.h:191
QNetworkAccessManager * m_networkManager
Definition: remoteoutput.h:181
DeviceAPI * m_deviceAPI
Definition: remoteoutput.h:170
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ~RemoteOutput()

RemoteOutput::~RemoteOutput ( )
virtual

Definition at line 73 of file remoteoutput.cpp.

References m_networkManager, networkManagerFinished(), and stop().

Referenced by RemoteOutput::MsgConfigureRemoteOutputChunkCorrection::MsgConfigureRemoteOutputChunkCorrection().

74 {
75  disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
76  stop();
77  delete m_networkManager;
78 }
virtual void stop()
void networkManagerFinished(QNetworkReply *reply)
QNetworkAccessManager * m_networkManager
Definition: remoteoutput.h:181
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ analyzeApiReply()

void RemoteOutput::analyzeApiReply ( const QJsonObject &  jsonObject,
const QString &  answer 
)
private

Definition at line 536 of file remoteoutput.cpp.

References RemoteOutputThread::getSamplesCount(), m_centerFrequency, m_lastQueueLength, m_lastRemoteSampleCount, m_lastRemoteTimestampRateCorrection, m_lastSampleCount, m_lastTimestampRateCorrection, m_nbRemoteSamplesSinceRateCorrection, m_nbSamplesSinceRateCorrection, m_remoteOutputThread, NbSamplesForRateCorrection, and sampleRateCorrection().

Referenced by networkManagerFinished().

537 {
538  if (jsonObject.contains("RemoteSourceReport"))
539  {
540  QJsonObject report = jsonObject["RemoteSourceReport"].toObject();
541  m_centerFrequency = report["deviceCenterFreq"].toInt() * 1000;
542 
543  if (!m_remoteOutputThread) {
544  return;
545  }
546 
547  int queueSize = report["queueSize"].toInt();
548  queueSize = queueSize == 0 ? 10 : queueSize;
549  int queueLength = report["queueLength"].toInt();
550  int queueLengthPercent = (queueLength*100)/queueSize;
551  uint64_t remoteTimestampUs = report["tvSec"].toInt()*1000000ULL + report["tvUSec"].toInt();
552 
553  uint32_t remoteSampleCountDelta, remoteSampleCount;
554  remoteSampleCount = report["samplesCount"].toInt();
555 
556  if (remoteSampleCount < m_lastRemoteSampleCount) {
557  remoteSampleCountDelta = (0xFFFFFFFFU - m_lastRemoteSampleCount) + remoteSampleCount + 1;
558  } else {
559  remoteSampleCountDelta = remoteSampleCount - m_lastRemoteSampleCount;
560  }
561 
562  uint32_t sampleCountDelta, sampleCount;
563  uint64_t timestampUs;
564  sampleCount = m_remoteOutputThread->getSamplesCount(timestampUs);
565 
566  if (sampleCount < m_lastSampleCount) {
567  sampleCountDelta = (0xFFFFFFFFU - m_lastSampleCount) + sampleCount + 1;
568  } else {
569  sampleCountDelta = sampleCount - m_lastSampleCount;
570  }
571 
572  // on initial state wait for queue stabilization
573  if ((m_lastRemoteTimestampRateCorrection == 0) && (queueLength >= m_lastQueueLength-1) && (queueLength <= m_lastQueueLength+1))
574  {
575  m_lastRemoteTimestampRateCorrection = remoteTimestampUs;
576  m_lastTimestampRateCorrection = timestampUs;
579  }
580  else
581  {
582  m_nbRemoteSamplesSinceRateCorrection += remoteSampleCountDelta;
583  m_nbSamplesSinceRateCorrection += sampleCountDelta;
584 
585  qDebug("RemoteOutput::analyzeApiReply: queueLengthPercent: %d m_nbSamplesSinceRateCorrection: %u",
586  queueLengthPercent,
588 
590  {
592  timestampUs - m_lastTimestampRateCorrection,
595  m_lastRemoteTimestampRateCorrection = remoteTimestampUs;
596  m_lastTimestampRateCorrection = timestampUs;
599  }
600  }
601 
602  m_lastRemoteSampleCount = remoteSampleCount;
603  m_lastSampleCount = sampleCount;
604  m_lastQueueLength = queueLength;
605  }
606  else if (jsonObject.contains("remoteOutputSettings"))
607  {
608  qDebug("RemoteOutput::analyzeApiReply: reply:\n%s", answer.toStdString().c_str());
609  }
610 }
RemoteOutputThread * m_remoteOutputThread
Definition: remoteoutput.h:174
uint32_t m_nbRemoteSamplesSinceRateCorrection
Definition: remoteoutput.h:189
uint32_t getSamplesCount(uint64_t &ts_usecs) const
uint64_t m_centerFrequency
Definition: remoteoutput.h:173
int m_lastQueueLength
Definition: remoteoutput.h:188
static const uint32_t NbSamplesForRateCorrection
Definition: remoteoutput.h:192
unsigned int uint32_t
Definition: rtptypes_win.h:46
uint32_t m_lastSampleCount
Definition: remoteoutput.h:185
uint64_t m_lastTimestampRateCorrection
Definition: remoteoutput.h:187
uint32_t m_nbSamplesSinceRateCorrection
Definition: remoteoutput.h:190
uint32_t m_lastRemoteSampleCount
Definition: remoteoutput.h:184
uint64_t m_lastRemoteTimestampRateCorrection
Definition: remoteoutput.h:186
void sampleRateCorrection(double remoteTimeDeltaUs, double timeDeltaUs, uint32_t remoteSampleCount, uint32_t sampleCount)
unsigned __int64 uint64_t
Definition: rtptypes_win.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applySettings()

void RemoteOutput::applySettings ( const RemoteOutputSettings settings,
bool  force = false 
)
private

Definition at line 246 of file remoteoutput.cpp.

References DeviceAPI::getDeviceEngineInputMessageQueue(), RemoteOutputSettings::m_apiAddress, RemoteOutputSettings::m_apiPort, m_centerFrequency, RemoteOutputSettings::m_dataAddress, RemoteOutputSettings::m_dataPort, m_deviceAPI, m_mutex, RemoteOutputSettings::m_nbFECBlocks, m_remoteOutputThread, RemoteOutputSettings::m_reverseAPIAddress, RemoteOutputSettings::m_reverseAPIDeviceIndex, RemoteOutputSettings::m_reverseAPIPort, RemoteOutputSettings::m_sampleRate, m_settings, m_tickMultiplier, RemoteOutputSettings::m_txDelay, RemoteOutputSettings::m_useReverseAPI, NbSamplesForRateCorrection, MessageQueue::push(), RemoteOutputThread::setDataAddress(), RemoteOutputThread::setNbBlocksFEC(), RemoteOutputThread::setSamplerate(), RemoteOutputThread::setTxDelay(), and webapiReverseSendSettings().

Referenced by handleMessage(), and init().

247 {
248  QMutexLocker mutexLocker(&m_mutex);
249  bool forwardChange = false;
250  bool changeTxDelay = false;
251  QList<QString> reverseAPIKeys;
252 
253  if ((m_settings.m_dataAddress != settings.m_dataAddress) || force) {
254  reverseAPIKeys.append("dataAddress");
255  }
256  if ((m_settings.m_dataPort != settings.m_dataPort) || force) {
257  reverseAPIKeys.append("dataPort");
258  }
259  if ((m_settings.m_apiAddress != settings.m_apiAddress) || force) {
260  reverseAPIKeys.append("apiAddress");
261  }
262  if ((m_settings.m_apiPort != settings.m_apiPort) || force) {
263  reverseAPIKeys.append("apiPort");
264  }
265 
266  if (force || (m_settings.m_dataAddress != settings.m_dataAddress) || (m_settings.m_dataPort != settings.m_dataPort))
267  {
268  if (m_remoteOutputThread != 0) {
270  }
271  }
272 
273  if (force || (m_settings.m_sampleRate != settings.m_sampleRate))
274  {
275  reverseAPIKeys.append("sampleRate");
276 
277  if (m_remoteOutputThread != 0) {
279  }
280 
281  m_tickMultiplier = (21*NbSamplesForRateCorrection) / (2*settings.m_sampleRate); // two times per sample filling period plus small extension
282  m_tickMultiplier = m_tickMultiplier < 20 ? 20 : m_tickMultiplier; // not below half a second
283 
284  forwardChange = true;
285  changeTxDelay = true;
286  }
287 
288  if (force || (m_settings.m_nbFECBlocks != settings.m_nbFECBlocks))
289  {
290  reverseAPIKeys.append("nbFECBlocks");
291 
292  if (m_remoteOutputThread != 0) {
294  }
295 
296  changeTxDelay = true;
297  }
298 
299  if (force || (m_settings.m_txDelay != settings.m_txDelay))
300  {
301  reverseAPIKeys.append("txDelay");
302  changeTxDelay = true;
303  }
304 
305  if (changeTxDelay)
306  {
307  if (m_remoteOutputThread != 0) {
309  }
310  }
311 
312  mutexLocker.unlock();
313 
314  qDebug() << "RemoteOutput::applySettings:"
315  << " m_sampleRate: " << settings.m_sampleRate
316  << " m_txDelay: " << settings.m_txDelay
317  << " m_nbFECBlocks: " << settings.m_nbFECBlocks
318  << " m_apiAddress: " << settings.m_apiAddress
319  << " m_apiPort: " << settings.m_apiPort
320  << " m_dataAddress: " << settings.m_dataAddress
321  << " m_dataPort: " << settings.m_dataPort;
322 
323  if (forwardChange)
324  {
327  }
328 
329  if (settings.m_useReverseAPI)
330  {
331  bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
335  webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
336  }
337 
338  m_settings = settings;
339 }
QMutex m_mutex
Definition: remoteoutput.h:171
RemoteOutputThread * m_remoteOutputThread
Definition: remoteoutput.h:174
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
Definition: deviceapi.cpp:316
void setSamplerate(int samplerate)
uint64_t m_centerFrequency
Definition: remoteoutput.h:173
static const uint32_t NbSamplesForRateCorrection
Definition: remoteoutput.h:192
void setTxDelay(float txDelay)
RemoteOutputSettings m_settings
Definition: remoteoutput.h:172
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const RemoteOutputSettings &settings, bool force)
void setNbBlocksFEC(uint32_t nbBlocksFEC)
uint32_t m_tickMultiplier
Definition: remoteoutput.h:179
void setDataAddress(const QString &address, uint16_t port)
DeviceAPI * m_deviceAPI
Definition: remoteoutput.h:170
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deserialize()

bool RemoteOutput::deserialize ( const QByteArray &  data)
virtual

Implements DeviceSampleSink.

Definition at line 135 of file remoteoutput.cpp.

References RemoteOutput::MsgConfigureRemoteOutput::create(), RemoteOutputSettings::deserialize(), DeviceSampleSink::m_guiMessageQueue, DeviceSampleSink::m_inputMessageQueue, m_settings, MessageQueue::push(), and RemoteOutputSettings::resetToDefaults().

Referenced by RemoteOutput::MsgConfigureRemoteOutputChunkCorrection::MsgConfigureRemoteOutputChunkCorrection().

136 {
137  bool success = true;
138 
139  if (!m_settings.deserialize(data))
140  {
142  success = false;
143  }
144 
145  MsgConfigureRemoteOutput* message = MsgConfigureRemoteOutput::create(m_settings, true);
146  m_inputMessageQueue.push(message);
147 
148  if (m_guiMessageQueue)
149  {
150  MsgConfigureRemoteOutput* messageToGUI = MsgConfigureRemoteOutput::create(m_settings, true);
151  m_guiMessageQueue->push(messageToGUI);
152  }
153 
154  return success;
155 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
static MsgConfigureRemoteOutput * create(const RemoteOutputSettings &settings, bool force=false)
Definition: remoteoutput.h:50
RemoteOutputSettings m_settings
Definition: remoteoutput.h:172
MessageQueue m_inputMessageQueue
Input queue to the sink.
bool deserialize(const QByteArray &data)
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ destroy()

void RemoteOutput::destroy ( )
virtual

Implements DeviceSampleSink.

Definition at line 80 of file remoteoutput.cpp.

Referenced by RemoteOutput::MsgConfigureRemoteOutputChunkCorrection::MsgConfigureRemoteOutputChunkCorrection().

81 {
82  delete this;
83 }
+ Here is the caller graph for this function:

◆ getCenterFrequency()

quint64 RemoteOutput::getCenterFrequency ( ) const
virtual

Center frequency exposed by the sink.

Implements DeviceSampleSink.

Definition at line 167 of file remoteoutput.cpp.

References m_centerFrequency.

Referenced by setSampleRate().

168 {
169  return m_centerFrequency;
170 }
uint64_t m_centerFrequency
Definition: remoteoutput.h:173
+ Here is the caller graph for this function:

◆ getDeviceDescription()

const QString & RemoteOutput::getDeviceDescription ( ) const
virtual

Implements DeviceSampleSink.

Definition at line 157 of file remoteoutput.cpp.

References m_deviceDescription.

Referenced by setMessageQueueToGUI().

158 {
159  return m_deviceDescription;
160 }
QString m_deviceDescription
Definition: remoteoutput.h:175
+ Here is the caller graph for this function:

◆ getSampleRate()

int RemoteOutput::getSampleRate ( ) const
virtual

Sample rate exposed by the sink.

Implements DeviceSampleSink.

Definition at line 162 of file remoteoutput.cpp.

References RemoteOutputSettings::m_sampleRate, and m_settings.

Referenced by setMessageQueueToGUI().

163 {
164  return m_settings.m_sampleRate;
165 }
RemoteOutputSettings m_settings
Definition: remoteoutput.h:172
+ Here is the caller graph for this function:

◆ getStartingTimeStamp()

std::time_t RemoteOutput::getStartingTimeStamp ( ) const

Definition at line 172 of file remoteoutput.cpp.

References m_startingTimeStamp.

Referenced by setCenterFrequency().

173 {
174  return m_startingTimeStamp;
175 }
std::time_t m_startingTimeStamp
Definition: remoteoutput.h:176
+ Here is the caller graph for this function:

◆ handleMessage()

bool RemoteOutput::handleMessage ( const Message message)
virtual

Implements DeviceSampleSink.

Definition at line 177 of file remoteoutput.cpp.

References applySettings(), RemoteOutput::MsgConfigureRemoteOutputChunkCorrection::getChunkCorrection(), RemoteOutput::MsgConfigureRemoteOutput::getForce(), Message::getIdentifier(), RemoteOutput::MsgConfigureRemoteOutput::getSettings(), RemoteOutput::MsgStartStop::getStartStop(), DeviceAPI::initDeviceEngine(), RemoteOutput::MsgConfigureRemoteOutputWork::isWorking(), m_deviceAPI, m_remoteOutputThread, m_settings, RemoteOutputSettings::m_useReverseAPI, Message::match(), RemoteOutputThread::setChunkCorrection(), DeviceAPI::startDeviceEngine(), RemoteOutputThread::startWork(), DeviceAPI::stopDeviceEngine(), RemoteOutputThread::stopWork(), and webapiReverseSendStartStop().

Referenced by setCenterFrequency().

178 {
179 
180  if (MsgConfigureRemoteOutput::match(message))
181  {
182  qDebug() << "RemoteOutput::handleMessage:" << message.getIdentifier();
183  MsgConfigureRemoteOutput& conf = (MsgConfigureRemoteOutput&) message;
184  applySettings(conf.getSettings(), conf.getForce());
185  return true;
186  }
187  else if (MsgConfigureRemoteOutputWork::match(message))
188  {
189  MsgConfigureRemoteOutputWork& conf = (MsgConfigureRemoteOutputWork&) message;
190  bool working = conf.isWorking();
191 
192  if (m_remoteOutputThread != 0)
193  {
194  if (working)
195  {
197  }
198  else
199  {
201  }
202  }
203 
204  return true;
205  }
206  else if (MsgStartStop::match(message))
207  {
208  MsgStartStop& cmd = (MsgStartStop&) message;
209  qDebug() << "RemoteOutput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
210 
211  if (cmd.getStartStop())
212  {
214  {
216  }
217  }
218  else
219  {
221  }
222 
224  webapiReverseSendStartStop(cmd.getStartStop());
225  }
226 
227  return true;
228  }
230  {
231  MsgConfigureRemoteOutputChunkCorrection& conf = (MsgConfigureRemoteOutputChunkCorrection&) message;
232 
233  if (m_remoteOutputThread != 0)
234  {
235  m_remoteOutputThread->setChunkCorrection(conf.getChunkCorrection());
236  }
237 
238  return true;
239  }
240  else
241  {
242  return false;
243  }
244 }
RemoteOutputThread * m_remoteOutputThread
Definition: remoteoutput.h:174
bool startDeviceEngine()
Start the device engine corresponding to the stream type.
Definition: deviceapi.cpp:253
void stopDeviceEngine()
Stop the device engine corresponding to the stream type.
Definition: deviceapi.cpp:266
bool initDeviceEngine()
Init the device engine corresponding to the stream type.
Definition: deviceapi.cpp:240
void setChunkCorrection(int chunkCorrection)
RemoteOutputSettings m_settings
Definition: remoteoutput.h:172
void applySettings(const RemoteOutputSettings &settings, bool force=false)
static bool match(const Message *message)
Definition: message.cpp:45
void webapiReverseSendStartStop(bool start)
virtual const char * getIdentifier() const
Definition: message.cpp:35
DeviceAPI * m_deviceAPI
Definition: remoteoutput.h:170
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

void RemoteOutput::init ( )
virtual

initializations to be done when all collaborating objects are created and possibly connected

Implements DeviceSampleSink.

Definition at line 112 of file remoteoutput.cpp.

References applySettings(), and m_settings.

Referenced by RemoteOutput::MsgConfigureRemoteOutputChunkCorrection::MsgConfigureRemoteOutputChunkCorrection().

113 {
114  applySettings(m_settings, true);
115 }
RemoteOutputSettings m_settings
Definition: remoteoutput.h:172
void applySettings(const RemoteOutputSettings &settings, bool force=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ networkManagerFinished

void RemoteOutput::networkManagerFinished ( QNetworkReply *  reply)
privateslot

Definition at line 503 of file remoteoutput.cpp.

References analyzeApiReply().

Referenced by RemoteOutput(), and ~RemoteOutput().

504 {
505  if (reply->error())
506  {
507  qInfo("RemoteOutput::networkManagerFinished: error: %s", qPrintable(reply->errorString()));
508  return;
509  }
510 
511  QString answer = reply->readAll();
512 
513  try
514  {
515  QByteArray jsonBytes(answer.toStdString().c_str());
516  QJsonParseError error;
517  QJsonDocument doc = QJsonDocument::fromJson(jsonBytes, &error);
518 
519  if (error.error == QJsonParseError::NoError)
520  {
521  analyzeApiReply(doc.object(), answer);
522  }
523  else
524  {
525  QString errorMsg = QString("Reply JSON error: ") + error.errorString() + QString(" at offset ") + QString::number(error.offset);
526  qInfo().noquote() << "RemoteOutput::networkManagerFinished" << errorMsg;
527  }
528  }
529  catch (const std::exception& ex)
530  {
531  QString errorMsg = QString("Error parsing request: ") + ex.what();
532  qInfo().noquote() << "RemoteOutput::networkManagerFinished" << errorMsg;
533  }
534 }
void analyzeApiReply(const QJsonObject &jsonObject, const QString &answer)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sampleRateCorrection()

void RemoteOutput::sampleRateCorrection ( double  remoteTimeDeltaUs,
double  timeDeltaUs,
uint32_t  remoteSampleCount,
uint32_t  sampleCount 
)
private

Definition at line 612 of file remoteoutput.cpp.

References RemoteOutput::MsgConfigureRemoteOutputChunkCorrection::create(), DeviceSampleSink::getInputMessageQueue(), m_chunkSizeCorrection, and MessageQueue::push().

Referenced by analyzeApiReply().

613 {
614  double deltaSR = (remoteSampleCount/remoteTimeDeltaUs) - (sampleCount/timeDeltaUs);
615  double chunkCorr = 50000 * deltaSR; // for 50ms chunk intervals (50000us)
616  m_chunkSizeCorrection += roundf(chunkCorr);
617 
618  qDebug("RemoteOutput::sampleRateCorrection: %d (%f) samples", m_chunkSizeCorrection, chunkCorr);
619 
620  MsgConfigureRemoteOutputChunkCorrection* message = MsgConfigureRemoteOutputChunkCorrection::create(m_chunkSizeCorrection);
621  getInputMessageQueue()->push(message);
622 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue * getInputMessageQueue()
static MsgConfigureRemoteOutputChunkCorrection * create(int chunkCorrection)
Definition: remoteoutput.h:111
int m_chunkSizeCorrection
Definition: remoteoutput.h:191
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

QByteArray RemoteOutput::serialize ( ) const
virtual

Implements DeviceSampleSink.

Definition at line 130 of file remoteoutput.cpp.

References m_settings, and RemoteOutputSettings::serialize().

Referenced by RemoteOutput::MsgConfigureRemoteOutputChunkCorrection::MsgConfigureRemoteOutputChunkCorrection().

131 {
132  return m_settings.serialize();
133 }
RemoteOutputSettings m_settings
Definition: remoteoutput.h:172
QByteArray serialize() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCenterFrequency()

virtual void RemoteOutput::setCenterFrequency ( qint64  centerFrequency)
inlinevirtual

Implements DeviceSampleSink.

Definition at line 141 of file remoteoutput.h.

References getStartingTimeStamp(), handleMessage(), webapiReportGet(), webapiRun(), webapiRunGet(), webapiSettingsGet(), and webapiSettingsPutPatch().

141 { (void) centerFrequency; }
+ Here is the call graph for this function:

◆ setMessageQueueToGUI()

virtual void RemoteOutput::setMessageQueueToGUI ( MessageQueue queue)
inlinevirtual

Implements DeviceSampleSink.

Definition at line 136 of file remoteoutput.h.

References getDeviceDescription(), getSampleRate(), and DeviceSampleSink::m_guiMessageQueue.

136 { m_guiMessageQueue = queue; }
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
+ Here is the call graph for this function:

◆ setSampleRate()

virtual void RemoteOutput::setSampleRate ( int  sampleRate)
inlinevirtual

For when the sink sample rate is set externally.

Implements DeviceSampleSink.

Definition at line 139 of file remoteoutput.h.

References getCenterFrequency().

139 { (void) sampleRate; }
+ Here is the call graph for this function:

◆ start()

bool RemoteOutput::start ( )
virtual

Implements DeviceSampleSink.

Definition at line 85 of file remoteoutput.cpp.

References RemoteOutputThread::connectTimer(), m_chunkSizeCorrection, RemoteOutputSettings::m_dataAddress, RemoteOutputSettings::m_dataPort, m_lastQueueLength, m_lastRemoteTimestampRateCorrection, m_lastTimestampRateCorrection, m_masterTimer, m_mutex, RemoteOutputSettings::m_nbFECBlocks, m_remoteOutputThread, RemoteOutputSettings::m_sampleRate, DeviceSampleSink::m_sampleSourceFifo, m_settings, RemoteOutputSettings::m_txDelay, RemoteOutputThread::setDataAddress(), RemoteOutputThread::setNbBlocksFEC(), RemoteOutputThread::setSamplerate(), RemoteOutputThread::setTxDelay(), and RemoteOutputThread::startWork().

Referenced by RemoteOutput::MsgConfigureRemoteOutputChunkCorrection::MsgConfigureRemoteOutputChunkCorrection().

86 {
87  QMutexLocker mutexLocker(&m_mutex);
88  qDebug() << "RemoteOutput::start";
89 
96 
97  // restart auto rate correction
100  m_lastQueueLength = -2; // set first value out of bounds
102 
104 
105  mutexLocker.unlock();
106  //applySettings(m_generalSettings, m_settings, true);
107  qDebug("RemoteOutput::start: started");
108 
109  return true;
110 }
QMutex m_mutex
Definition: remoteoutput.h:171
RemoteOutputThread * m_remoteOutputThread
Definition: remoteoutput.h:174
const QTimer & m_masterTimer
Definition: remoteoutput.h:177
void setSamplerate(int samplerate)
int m_lastQueueLength
Definition: remoteoutput.h:188
void setTxDelay(float txDelay)
RemoteOutputSettings m_settings
Definition: remoteoutput.h:172
uint64_t m_lastTimestampRateCorrection
Definition: remoteoutput.h:187
void setNbBlocksFEC(uint32_t nbBlocksFEC)
uint64_t m_lastRemoteTimestampRateCorrection
Definition: remoteoutput.h:186
SampleSourceFifo m_sampleSourceFifo
int m_chunkSizeCorrection
Definition: remoteoutput.h:191
void setDataAddress(const QString &address, uint16_t port)
void connectTimer(const QTimer &timer)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop()

void RemoteOutput::stop ( )
virtual

Implements DeviceSampleSink.

Definition at line 117 of file remoteoutput.cpp.

References m_mutex, m_remoteOutputThread, and RemoteOutputThread::stopWork().

Referenced by RemoteOutput::MsgConfigureRemoteOutputChunkCorrection::MsgConfigureRemoteOutputChunkCorrection(), and ~RemoteOutput().

118 {
119  qDebug() << "RemoteOutput::stop";
120  QMutexLocker mutexLocker(&m_mutex);
121 
122  if(m_remoteOutputThread != 0)
123  {
125  delete m_remoteOutputThread;
127  }
128 }
QMutex m_mutex
Definition: remoteoutput.h:171
RemoteOutputThread * m_remoteOutputThread
Definition: remoteoutput.h:174
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tick

void RemoteOutput::tick ( )
privateslot

Definition at line 484 of file remoteoutput.cpp.

References RemoteOutputSettings::m_apiAddress, RemoteOutputSettings::m_apiPort, RemoteOutputSettings::m_channelIndex, RemoteOutputSettings::m_deviceIndex, m_networkManager, m_networkRequest, m_settings, m_tickCount, and m_tickMultiplier.

Referenced by RemoteOutput().

485 {
486  if (++m_tickCount == m_tickMultiplier)
487  {
488  QString reportURL;
489 
490  reportURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/report")
492  .arg(m_settings.m_apiPort)
495 
496  m_networkRequest.setUrl(QUrl(reportURL));
498 
499  m_tickCount = 0;
500  }
501 }
QNetworkRequest m_networkRequest
Definition: remoteoutput.h:182
uint32_t m_tickCount
Definition: remoteoutput.h:178
RemoteOutputSettings m_settings
Definition: remoteoutput.h:172
uint32_t m_tickMultiplier
Definition: remoteoutput.h:179
QNetworkAccessManager * m_networkManager
Definition: remoteoutput.h:181
+ Here is the caller graph for this function:

◆ webapiFormatDeviceReport()

void RemoteOutput::webapiFormatDeviceReport ( SWGSDRangel::SWGDeviceReport response)
private

Definition at line 477 of file remoteoutput.cpp.

References SWGSDRangel::SWGDeviceReport::getRemoteOutputReport(), SampleSourceFifo::getRWBalance(), RemoteOutputThread::getSamplesCount(), m_remoteOutputThread, DeviceSampleSink::m_sampleSourceFifo, SWGSDRangel::SWGRemoteOutputReport::setBufferRwBalance(), and SWGSDRangel::SWGRemoteOutputReport::setSampleCount().

Referenced by webapiReportGet().

478 {
479  uint64_t ts_usecs;
482 }
RemoteOutputThread * m_remoteOutputThread
Definition: remoteoutput.h:174
void setBufferRwBalance(float buffer_rw_balance)
uint32_t getSamplesCount(uint64_t &ts_usecs) const
float getRWBalance() const
SampleSourceFifo m_sampleSourceFifo
SWGRemoteOutputReport * getRemoteOutputReport()
unsigned __int64 uint64_t
Definition: rtptypes_win.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatDeviceSettings()

void RemoteOutput::webapiFormatDeviceSettings ( SWGSDRangel::SWGDeviceSettings response,
const RemoteOutputSettings settings 
)
private

Definition at line 453 of file remoteoutput.cpp.

References SWGSDRangel::SWGDeviceSettings::getRemoteOutputSettings(), SWGSDRangel::SWGRemoteOutputSettings::getReverseApiAddress(), RemoteOutputSettings::m_apiAddress, RemoteOutputSettings::m_apiPort, m_centerFrequency, RemoteOutputSettings::m_channelIndex, RemoteOutputSettings::m_dataAddress, RemoteOutputSettings::m_dataPort, RemoteOutputSettings::m_deviceIndex, RemoteOutputSettings::m_nbFECBlocks, RemoteOutputSettings::m_reverseAPIAddress, RemoteOutputSettings::m_reverseAPIDeviceIndex, RemoteOutputSettings::m_reverseAPIPort, RemoteOutputSettings::m_sampleRate, RemoteOutputSettings::m_txDelay, RemoteOutputSettings::m_useReverseAPI, SWGSDRangel::SWGRemoteOutputSettings::setApiAddress(), SWGSDRangel::SWGRemoteOutputSettings::setApiPort(), SWGSDRangel::SWGRemoteOutputSettings::setCenterFrequency(), SWGSDRangel::SWGRemoteOutputSettings::setChannelIndex(), SWGSDRangel::SWGRemoteOutputSettings::setDataAddress(), SWGSDRangel::SWGRemoteOutputSettings::setDataPort(), SWGSDRangel::SWGRemoteOutputSettings::setDeviceIndex(), SWGSDRangel::SWGRemoteOutputSettings::setNbFecBlocks(), SWGSDRangel::SWGRemoteOutputSettings::setReverseApiAddress(), SWGSDRangel::SWGRemoteOutputSettings::setReverseApiDeviceIndex(), SWGSDRangel::SWGRemoteOutputSettings::setReverseApiPort(), SWGSDRangel::SWGRemoteOutputSettings::setSampleRate(), SWGSDRangel::SWGRemoteOutputSettings::setTxDelay(), and SWGSDRangel::SWGRemoteOutputSettings::setUseReverseApi().

Referenced by webapiSettingsGet(), and webapiSettingsPutPatch().

454 {
456  response.getRemoteOutputSettings()->setSampleRate(settings.m_sampleRate);
457  response.getRemoteOutputSettings()->setTxDelay(settings.m_txDelay);
459  response.getRemoteOutputSettings()->setApiAddress(new QString(settings.m_apiAddress));
460  response.getRemoteOutputSettings()->setApiPort(settings.m_apiPort);
461  response.getRemoteOutputSettings()->setDataAddress(new QString(settings.m_dataAddress));
462  response.getRemoteOutputSettings()->setDataPort(settings.m_dataPort);
465  response.getRemoteOutputSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
466 
467  if (response.getRemoteOutputSettings()->getReverseApiAddress()) {
469  } else {
470  response.getRemoteOutputSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
471  }
472 
475 }
void setReverseApiPort(qint32 reverse_api_port)
uint64_t m_centerFrequency
Definition: remoteoutput.h:173
void setCenterFrequency(qint32 center_frequency)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setReverseApiAddress(QString *reverse_api_address)
SWGRemoteOutputSettings * getRemoteOutputSettings()
void setUseReverseApi(qint32 use_reverse_api)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReportGet()

int RemoteOutput::webapiReportGet ( SWGSDRangel::SWGDeviceReport response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSink.

Definition at line 442 of file remoteoutput.cpp.

References SWGSDRangel::SWGDeviceReport::getRemoteOutputReport(), SWGSDRangel::SWGRemoteOutputReport::init(), SWGSDRangel::SWGDeviceReport::setRemoteOutputReport(), and webapiFormatDeviceReport().

Referenced by setCenterFrequency().

445 {
446  (void) errorMessage;
448  response.getRemoteOutputReport()->init();
449  webapiFormatDeviceReport(response);
450  return 200;
451 }
void setRemoteOutputReport(SWGRemoteOutputReport *remote_output_report)
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport &response)
SWGRemoteOutputReport * getRemoteOutputReport()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendSettings()

void RemoteOutput::webapiReverseSendSettings ( QList< QString > &  deviceSettingsKeys,
const RemoteOutputSettings settings,
bool  force 
)
private

Definition at line 624 of file remoteoutput.cpp.

References SWGSDRangel::SWGDeviceSettings::asJson(), DeviceAPI::getDeviceSetIndex(), SWGSDRangel::SWGDeviceSettings::getRemoteOutputSettings(), RemoteOutputSettings::m_apiAddress, RemoteOutputSettings::m_apiPort, RemoteOutputSettings::m_channelIndex, RemoteOutputSettings::m_dataAddress, RemoteOutputSettings::m_dataPort, m_deviceAPI, RemoteOutputSettings::m_deviceIndex, RemoteOutputSettings::m_nbFECBlocks, m_networkManager, m_networkRequest, RemoteOutputSettings::m_reverseAPIAddress, RemoteOutputSettings::m_reverseAPIDeviceIndex, RemoteOutputSettings::m_reverseAPIPort, RemoteOutputSettings::m_sampleRate, RemoteOutputSettings::m_txDelay, SWGSDRangel::SWGRemoteOutputSettings::setApiAddress(), SWGSDRangel::SWGRemoteOutputSettings::setApiPort(), SWGSDRangel::SWGRemoteOutputSettings::setChannelIndex(), SWGSDRangel::SWGRemoteOutputSettings::setDataAddress(), SWGSDRangel::SWGRemoteOutputSettings::setDataPort(), SWGSDRangel::SWGDeviceSettings::setDeviceHwType(), SWGSDRangel::SWGRemoteOutputSettings::setDeviceIndex(), SWGSDRangel::SWGDeviceSettings::setDirection(), SWGSDRangel::SWGRemoteOutputSettings::setNbFecBlocks(), SWGSDRangel::SWGDeviceSettings::setOriginatorIndex(), SWGSDRangel::SWGDeviceSettings::setRemoteOutputSettings(), SWGSDRangel::SWGRemoteOutputSettings::setSampleRate(), and SWGSDRangel::SWGRemoteOutputSettings::setTxDelay().

Referenced by applySettings().

625 {
627  swgDeviceSettings->setDirection(1); // single Tx
628  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
629  swgDeviceSettings->setDeviceHwType(new QString("RemoteOutput"));
631  SWGSDRangel::SWGRemoteOutputSettings *swgRemoteOutputSettings = swgDeviceSettings->getRemoteOutputSettings();
632 
633  // transfer data that has been modified. When force is on transfer all data except reverse API data
634 
635  if (deviceSettingsKeys.contains("sampleRate") || force) {
636  swgRemoteOutputSettings->setSampleRate(settings.m_sampleRate);
637  }
638  if (deviceSettingsKeys.contains("txDelay") || force) {
639  swgRemoteOutputSettings->setTxDelay(settings.m_txDelay);
640  }
641  if (deviceSettingsKeys.contains("nbFECBlocks") || force) {
642  swgRemoteOutputSettings->setNbFecBlocks(settings.m_nbFECBlocks);
643  }
644  if (deviceSettingsKeys.contains("apiAddress") || force) {
645  swgRemoteOutputSettings->setApiAddress(new QString(settings.m_apiAddress));
646  }
647  if (deviceSettingsKeys.contains("apiPort") || force) {
648  swgRemoteOutputSettings->setApiPort(settings.m_apiPort);
649  }
650  if (deviceSettingsKeys.contains("dataAddress") || force) {
651  swgRemoteOutputSettings->setDataAddress(new QString(settings.m_dataAddress));
652  }
653  if (deviceSettingsKeys.contains("dataPort") || force) {
654  swgRemoteOutputSettings->setDataPort(settings.m_dataPort);
655  }
656  if (deviceSettingsKeys.contains("deviceIndex") || force) {
657  swgRemoteOutputSettings->setDeviceIndex(settings.m_deviceIndex);
658  }
659  if (deviceSettingsKeys.contains("channelIndex") || force) {
660  swgRemoteOutputSettings->setChannelIndex(settings.m_channelIndex);
661  }
662 
663  QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/settings")
664  .arg(settings.m_reverseAPIAddress)
665  .arg(settings.m_reverseAPIPort)
666  .arg(settings.m_reverseAPIDeviceIndex);
667  m_networkRequest.setUrl(QUrl(deviceSettingsURL));
668  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
669 
670  QBuffer *buffer=new QBuffer();
671  buffer->open((QBuffer::ReadWrite));
672  buffer->write(swgDeviceSettings->asJson().toUtf8());
673  buffer->seek(0);
674 
675  // Always use PATCH to avoid passing reverse API settings
676  m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
677 
678  delete swgDeviceSettings;
679 }
QNetworkRequest m_networkRequest
Definition: remoteoutput.h:182
virtual QString asJson() override
void setOriginatorIndex(qint32 originator_index)
int getDeviceSetIndex() const
Definition: deviceapi.h:131
void setRemoteOutputSettings(SWGRemoteOutputSettings *remote_output_settings)
SWGRemoteOutputSettings * getRemoteOutputSettings()
void setDirection(qint32 direction)
QNetworkAccessManager * m_networkManager
Definition: remoteoutput.h:181
DeviceAPI * m_deviceAPI
Definition: remoteoutput.h:170
void setDeviceHwType(QString *device_hw_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendStartStop()

void RemoteOutput::webapiReverseSendStartStop ( bool  start)
private

Definition at line 681 of file remoteoutput.cpp.

References SWGSDRangel::SWGDeviceSettings::asJson(), DeviceAPI::getDeviceSetIndex(), m_deviceAPI, m_networkManager, m_networkRequest, RemoteOutputSettings::m_reverseAPIAddress, RemoteOutputSettings::m_reverseAPIDeviceIndex, RemoteOutputSettings::m_reverseAPIPort, m_settings, SWGSDRangel::SWGDeviceSettings::setDeviceHwType(), SWGSDRangel::SWGDeviceSettings::setDirection(), and SWGSDRangel::SWGDeviceSettings::setOriginatorIndex().

Referenced by handleMessage().

682 {
684  swgDeviceSettings->setDirection(1); // single Tx
685  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
686  swgDeviceSettings->setDeviceHwType(new QString("RemoteOutput"));
687 
688  QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
692  m_networkRequest.setUrl(QUrl(deviceSettingsURL));
693  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
694 
695  QBuffer *buffer=new QBuffer();
696  buffer->open((QBuffer::ReadWrite));
697  buffer->write(swgDeviceSettings->asJson().toUtf8());
698  buffer->seek(0);
699 
700  if (start) {
701  m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
702  } else {
703  m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
704  }
705 
706  delete swgDeviceSettings;
707 }
QNetworkRequest m_networkRequest
Definition: remoteoutput.h:182
virtual QString asJson() override
RemoteOutputSettings m_settings
Definition: remoteoutput.h:172
void setOriginatorIndex(qint32 originator_index)
int getDeviceSetIndex() const
Definition: deviceapi.h:131
virtual bool start()
void setDirection(qint32 direction)
QNetworkAccessManager * m_networkManager
Definition: remoteoutput.h:181
DeviceAPI * m_deviceAPI
Definition: remoteoutput.h:170
void setDeviceHwType(QString *device_hw_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiRun()

int RemoteOutput::webapiRun ( bool  run,
SWGSDRangel::SWGDeviceState response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSink.

Definition at line 350 of file remoteoutput.cpp.

References RemoteOutput::MsgStartStop::create(), DeviceAPI::getDeviceEngineStateStr(), SWGSDRangel::SWGDeviceState::getState(), m_deviceAPI, DeviceSampleSink::m_guiMessageQueue, DeviceSampleSink::m_inputMessageQueue, and MessageQueue::push().

Referenced by setCenterFrequency().

354 {
355  (void) errorMessage;
357  MsgStartStop *message = MsgStartStop::create(run);
358  m_inputMessageQueue.push(message);
359 
360  if (m_guiMessageQueue)
361  {
362  MsgStartStop *messagetoGui = MsgStartStop::create(run);
363  m_guiMessageQueue->push(messagetoGui);
364  }
365 
366  return 200;
367 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the sink.
static MsgStartStop * create(bool startStop)
Definition: remoteoutput.h:92
void getDeviceEngineStateStr(QString &state)
Definition: deviceapi.cpp:389
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
DeviceAPI * m_deviceAPI
Definition: remoteoutput.h:170
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiRunGet()

int RemoteOutput::webapiRunGet ( SWGSDRangel::SWGDeviceState response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSink.

Definition at line 341 of file remoteoutput.cpp.

References DeviceAPI::getDeviceEngineStateStr(), SWGSDRangel::SWGDeviceState::getState(), and m_deviceAPI.

Referenced by setCenterFrequency().

344 {
345  (void) errorMessage;
347  return 200;
348 }
void getDeviceEngineStateStr(QString &state)
Definition: deviceapi.cpp:389
DeviceAPI * m_deviceAPI
Definition: remoteoutput.h:170
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsGet()

int RemoteOutput::webapiSettingsGet ( SWGSDRangel::SWGDeviceSettings response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSink.

Definition at line 369 of file remoteoutput.cpp.

References SWGSDRangel::SWGDeviceSettings::getRemoteOutputSettings(), SWGSDRangel::SWGRemoteOutputSettings::init(), m_settings, SWGSDRangel::SWGDeviceSettings::setRemoteOutputSettings(), and webapiFormatDeviceSettings().

Referenced by setCenterFrequency().

372 {
373  (void) errorMessage;
375  response.getRemoteOutputSettings()->init();
377  return 200;
378 }
RemoteOutputSettings m_settings
Definition: remoteoutput.h:172
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const RemoteOutputSettings &settings)
void setRemoteOutputSettings(SWGRemoteOutputSettings *remote_output_settings)
SWGRemoteOutputSettings * getRemoteOutputSettings()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsPutPatch()

int RemoteOutput::webapiSettingsPutPatch ( bool  force,
const QStringList &  deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSink.

Definition at line 380 of file remoteoutput.cpp.

References RemoteOutput::MsgConfigureRemoteOutput::create(), SWGSDRangel::SWGRemoteOutputSettings::getApiAddress(), SWGSDRangel::SWGRemoteOutputSettings::getApiPort(), SWGSDRangel::SWGRemoteOutputSettings::getChannelIndex(), SWGSDRangel::SWGRemoteOutputSettings::getDataAddress(), SWGSDRangel::SWGRemoteOutputSettings::getDataPort(), SWGSDRangel::SWGRemoteOutputSettings::getDeviceIndex(), SWGSDRangel::SWGRemoteOutputSettings::getNbFecBlocks(), SWGSDRangel::SWGDeviceSettings::getRemoteOutputSettings(), SWGSDRangel::SWGRemoteOutputSettings::getReverseApiAddress(), SWGSDRangel::SWGRemoteOutputSettings::getReverseApiDeviceIndex(), SWGSDRangel::SWGRemoteOutputSettings::getReverseApiPort(), SWGSDRangel::SWGRemoteOutputSettings::getSampleRate(), SWGSDRangel::SWGRemoteOutputSettings::getTxDelay(), SWGSDRangel::SWGRemoteOutputSettings::getUseReverseApi(), RemoteOutputSettings::m_apiAddress, RemoteOutputSettings::m_apiPort, RemoteOutputSettings::m_channelIndex, RemoteOutputSettings::m_dataAddress, RemoteOutputSettings::m_dataPort, RemoteOutputSettings::m_deviceIndex, DeviceSampleSink::m_guiMessageQueue, DeviceSampleSink::m_inputMessageQueue, RemoteOutputSettings::m_nbFECBlocks, RemoteOutputSettings::m_reverseAPIAddress, RemoteOutputSettings::m_reverseAPIDeviceIndex, RemoteOutputSettings::m_reverseAPIPort, RemoteOutputSettings::m_sampleRate, m_settings, RemoteOutputSettings::m_txDelay, RemoteOutputSettings::m_useReverseAPI, MessageQueue::push(), and webapiFormatDeviceSettings().

Referenced by setCenterFrequency().

385 {
386  (void) errorMessage;
387  RemoteOutputSettings settings = m_settings;
388 
389  if (deviceSettingsKeys.contains("sampleRate")) {
390  settings.m_sampleRate = response.getRemoteOutputSettings()->getSampleRate();
391  }
392  if (deviceSettingsKeys.contains("txDelay")) {
393  settings.m_txDelay = response.getRemoteOutputSettings()->getTxDelay();
394  }
395  if (deviceSettingsKeys.contains("nbFECBlocks")) {
396  settings.m_nbFECBlocks = response.getRemoteOutputSettings()->getNbFecBlocks();
397  }
398  if (deviceSettingsKeys.contains("apiAddress")) {
399  settings.m_apiAddress = *response.getRemoteOutputSettings()->getApiAddress();
400  }
401  if (deviceSettingsKeys.contains("apiPort")) {
402  settings.m_apiPort = response.getRemoteOutputSettings()->getApiPort();
403  }
404  if (deviceSettingsKeys.contains("dataAddress")) {
405  settings.m_dataAddress = *response.getRemoteOutputSettings()->getDataAddress();
406  }
407  if (deviceSettingsKeys.contains("dataPort")) {
408  settings.m_dataPort = response.getRemoteOutputSettings()->getDataPort();
409  }
410  if (deviceSettingsKeys.contains("deviceIndex")) {
411  settings.m_deviceIndex = response.getRemoteOutputSettings()->getDeviceIndex();
412  }
413  if (deviceSettingsKeys.contains("channelIndex")) {
414  settings.m_channelIndex = response.getRemoteOutputSettings()->getChannelIndex();
415  }
416  if (deviceSettingsKeys.contains("useReverseAPI")) {
417  settings.m_useReverseAPI = response.getRemoteOutputSettings()->getUseReverseApi() != 0;
418  }
419  if (deviceSettingsKeys.contains("reverseAPIAddress")) {
421  }
422  if (deviceSettingsKeys.contains("reverseAPIPort")) {
424  }
425  if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
427  }
428 
429  MsgConfigureRemoteOutput *msg = MsgConfigureRemoteOutput::create(settings, force);
431 
432  if (m_guiMessageQueue) // forward to GUI if any
433  {
434  MsgConfigureRemoteOutput *msgToGUI = MsgConfigureRemoteOutput::create(settings, force);
435  m_guiMessageQueue->push(msgToGUI);
436  }
437 
438  webapiFormatDeviceSettings(response, settings);
439  return 200;
440 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
static MsgConfigureRemoteOutput * create(const RemoteOutputSettings &settings, bool force=false)
Definition: remoteoutput.h:50
RemoteOutputSettings m_settings
Definition: remoteoutput.h:172
MessageQueue m_inputMessageQueue
Input queue to the sink.
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const RemoteOutputSettings &settings)
SWGRemoteOutputSettings * getRemoteOutputSettings()
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_centerFrequency

uint64_t RemoteOutput::m_centerFrequency
private

◆ m_chunkSizeCorrection

int RemoteOutput::m_chunkSizeCorrection
private

Definition at line 191 of file remoteoutput.h.

Referenced by sampleRateCorrection(), and start().

◆ m_deviceAPI

DeviceAPI* RemoteOutput::m_deviceAPI
private

◆ m_deviceDescription

QString RemoteOutput::m_deviceDescription
private

Definition at line 175 of file remoteoutput.h.

Referenced by getDeviceDescription().

◆ m_lastQueueLength

int RemoteOutput::m_lastQueueLength
private

Definition at line 188 of file remoteoutput.h.

Referenced by analyzeApiReply(), and start().

◆ m_lastRemoteSampleCount

uint32_t RemoteOutput::m_lastRemoteSampleCount
private

Definition at line 184 of file remoteoutput.h.

Referenced by analyzeApiReply().

◆ m_lastRemoteTimestampRateCorrection

uint64_t RemoteOutput::m_lastRemoteTimestampRateCorrection
private

Definition at line 186 of file remoteoutput.h.

Referenced by analyzeApiReply(), and start().

◆ m_lastSampleCount

uint32_t RemoteOutput::m_lastSampleCount
private

Definition at line 185 of file remoteoutput.h.

Referenced by analyzeApiReply().

◆ m_lastTimestampRateCorrection

uint64_t RemoteOutput::m_lastTimestampRateCorrection
private

Definition at line 187 of file remoteoutput.h.

Referenced by analyzeApiReply(), and start().

◆ m_masterTimer

const QTimer& RemoteOutput::m_masterTimer
private

Definition at line 177 of file remoteoutput.h.

Referenced by RemoteOutput(), and start().

◆ m_mutex

QMutex RemoteOutput::m_mutex
private

Definition at line 171 of file remoteoutput.h.

Referenced by applySettings(), start(), and stop().

◆ m_nbRemoteSamplesSinceRateCorrection

uint32_t RemoteOutput::m_nbRemoteSamplesSinceRateCorrection
private

Definition at line 189 of file remoteoutput.h.

Referenced by analyzeApiReply().

◆ m_nbSamplesSinceRateCorrection

uint32_t RemoteOutput::m_nbSamplesSinceRateCorrection
private

Definition at line 190 of file remoteoutput.h.

Referenced by analyzeApiReply().

◆ m_networkManager

QNetworkAccessManager* RemoteOutput::m_networkManager
private

◆ m_networkRequest

QNetworkRequest RemoteOutput::m_networkRequest
private

Definition at line 182 of file remoteoutput.h.

Referenced by tick(), webapiReverseSendSettings(), and webapiReverseSendStartStop().

◆ m_remoteOutputThread

RemoteOutputThread* RemoteOutput::m_remoteOutputThread
private

◆ m_settings

RemoteOutputSettings RemoteOutput::m_settings
private

◆ m_startingTimeStamp

std::time_t RemoteOutput::m_startingTimeStamp
private

Definition at line 176 of file remoteoutput.h.

Referenced by getStartingTimeStamp().

◆ m_tickCount

uint32_t RemoteOutput::m_tickCount
private

Definition at line 178 of file remoteoutput.h.

Referenced by tick().

◆ m_tickMultiplier

uint32_t RemoteOutput::m_tickMultiplier
private

Definition at line 179 of file remoteoutput.h.

Referenced by applySettings(), and tick().

◆ NbSamplesForRateCorrection

const uint32_t RemoteOutput::NbSamplesForRateCorrection = 5000000
staticprivate

Definition at line 192 of file remoteoutput.h.

Referenced by analyzeApiReply(), and applySettings().


The documentation for this class was generated from the following files: