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 | List of all members
LocalOutput Class Reference

#include <localoutput.h>

+ Inheritance diagram for LocalOutput:
+ Collaboration diagram for LocalOutput:

Classes

class  MsgConfigureLocalOutput
 
class  MsgReportSampleRateAndFrequency
 
class  MsgStartStop
 

Public Member Functions

 LocalOutput (DeviceAPI *deviceAPI)
 
virtual ~LocalOutput ()
 
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 networkManagerFinished (QNetworkReply *reply)
 

Private Member Functions

void applySettings (const LocalOutputSettings &settings, bool force=false)
 
void webapiFormatDeviceSettings (SWGSDRangel::SWGDeviceSettings &response, const LocalOutputSettings &settings)
 
void webapiFormatDeviceReport (SWGSDRangel::SWGDeviceReport &response)
 
void webapiReverseSendSettings (QList< QString > &deviceSettingsKeys, const LocalOutputSettings &settings, bool force)
 
void webapiReverseSendStartStop (bool start)
 

Private Attributes

DeviceAPIm_deviceAPI
 
QMutex m_mutex
 
LocalOutputSettings m_settings
 
qint64 m_centerFrequency
 
int m_sampleRate
 
QString m_remoteAddress
 
QString m_deviceDescription
 
FileRecordm_fileSink
 File sink to record device I/Q output. More...
 
QNetworkAccessManager * m_networkManager
 
QNetworkRequest m_networkRequest
 

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 39 of file localoutput.h.

Constructor & Destructor Documentation

◆ LocalOutput()

LocalOutput::LocalOutput ( DeviceAPI deviceAPI)

Definition at line 41 of file localoutput.cpp.

Referenced by LocalOutput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

41  :
42  m_deviceAPI(deviceAPI),
43  m_settings(),
45  m_sampleRate(48000),
46  m_fileSink(nullptr),
47  m_deviceDescription("LocalOutput")
48 {
49  m_sampleSourceFifo.resize(96000 * 4);
51  m_networkManager = new QNetworkAccessManager();
52  connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
53 }
FileRecord * m_fileSink
File sink to record device I/Q output.
Definition: localoutput.h:158
void setNbSinkStreams(uint32_t nbSinkStreams)
Definition: deviceapi.h:169
QString m_deviceDescription
Definition: localoutput.h:157
LocalOutputSettings m_settings
Definition: localoutput.h:153
qint64 m_centerFrequency
Definition: localoutput.h:154
void resize(uint32_t size)
QNetworkAccessManager * m_networkManager
Definition: localoutput.h:159
SampleSourceFifo m_sampleSourceFifo
void networkManagerFinished(QNetworkReply *reply)
DeviceAPI * m_deviceAPI
Definition: localoutput.h:151
int m_sampleRate
Definition: localoutput.h:155
+ Here is the caller graph for this function:

◆ ~LocalOutput()

LocalOutput::~LocalOutput ( )
virtual

Definition at line 55 of file localoutput.cpp.

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

Referenced by LocalOutput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

56 {
57  disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
58  delete m_networkManager;
59  stop();
60 }
QNetworkAccessManager * m_networkManager
Definition: localoutput.h:159
virtual void stop()
Definition: localoutput.cpp:78
void networkManagerFinished(QNetworkReply *reply)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ applySettings()

void LocalOutput::applySettings ( const LocalOutputSettings settings,
bool  force = false 
)
private

Definition at line 200 of file localoutput.cpp.

References m_mutex, m_remoteAddress, LocalOutputSettings::m_reverseAPIAddress, LocalOutputSettings::m_reverseAPIDeviceIndex, LocalOutputSettings::m_reverseAPIPort, m_settings, LocalOutputSettings::m_useReverseAPI, and webapiReverseSendSettings().

Referenced by handleMessage(), and init().

201 {
202  QMutexLocker mutexLocker(&m_mutex);
203  std::ostringstream os;
204  QString remoteAddress;
205  QList<QString> reverseAPIKeys;
206 
207  if (settings.m_useReverseAPI)
208  {
209  bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
213  webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
214  }
215 
216  m_settings = settings;
217  m_remoteAddress = remoteAddress;
218 
219  qDebug() << "LocalOutput::applySettings: "
220  << " m_remoteAddress: " << m_remoteAddress;
221 }
QString m_remoteAddress
Definition: localoutput.h:156
LocalOutputSettings m_settings
Definition: localoutput.h:153
QMutex m_mutex
Definition: localoutput.h:152
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const LocalOutputSettings &settings, bool force)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deserialize()

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

Implements DeviceSampleSink.

Definition at line 88 of file localoutput.cpp.

References LocalOutput::MsgConfigureLocalOutput::create(), LocalOutputSettings::deserialize(), DeviceSampleSink::m_guiMessageQueue, DeviceSampleSink::m_inputMessageQueue, m_settings, MessageQueue::push(), and LocalOutputSettings::resetToDefaults().

Referenced by LocalOutput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

89 {
90  bool success = true;
91 
92  if (!m_settings.deserialize(data))
93  {
95  success = false;
96  }
97 
98  MsgConfigureLocalOutput* message = MsgConfigureLocalOutput::create(m_settings, true);
99  m_inputMessageQueue.push(message);
100 
101  if (m_guiMessageQueue)
102  {
103  MsgConfigureLocalOutput* messageToGUI = MsgConfigureLocalOutput::create(m_settings, true);
104  m_guiMessageQueue->push(messageToGUI);
105  }
106 
107  return success;
108 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the sink.
LocalOutputSettings m_settings
Definition: localoutput.h:153
bool deserialize(const QByteArray &data)
static MsgConfigureLocalOutput * create(const LocalOutputSettings &settings, bool force=false)
Definition: localoutput.h:49
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 LocalOutput::destroy ( )
virtual

Implements DeviceSampleSink.

Definition at line 62 of file localoutput.cpp.

Referenced by LocalOutput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

63 {
64  delete this;
65 }
+ Here is the caller graph for this function:

◆ getCenterFrequency()

quint64 LocalOutput::getCenterFrequency ( ) const
virtual

Center frequency exposed by the sink.

Implements DeviceSampleSink.

Definition at line 139 of file localoutput.cpp.

References m_centerFrequency.

Referenced by LocalOutput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

140 {
141  return m_centerFrequency;
142 }
qint64 m_centerFrequency
Definition: localoutput.h:154
+ Here is the caller graph for this function:

◆ getDeviceDescription()

const QString & LocalOutput::getDeviceDescription ( ) const
virtual

Implements DeviceSampleSink.

Definition at line 115 of file localoutput.cpp.

References m_deviceDescription.

Referenced by LocalOutput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

116 {
117  return m_deviceDescription;
118 }
QString m_deviceDescription
Definition: localoutput.h:157
+ Here is the caller graph for this function:

◆ getSampleRate()

int LocalOutput::getSampleRate ( ) const
virtual

Sample rate exposed by the sink.

Implements DeviceSampleSink.

Definition at line 120 of file localoutput.cpp.

References m_sampleRate.

Referenced by LocalOutput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

121 {
122  return m_sampleRate;
123 }
int m_sampleRate
Definition: localoutput.h:155
+ Here is the caller graph for this function:

◆ getStartingTimeStamp()

std::time_t LocalOutput::getStartingTimeStamp ( ) const

Referenced by LocalOutput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

+ Here is the caller graph for this function:

◆ handleMessage()

bool LocalOutput::handleMessage ( const Message message)
virtual

Implements DeviceSampleSink.

Definition at line 158 of file localoutput.cpp.

References applySettings(), LocalOutput::MsgConfigureLocalOutput::getForce(), Message::getIdentifier(), LocalOutput::MsgConfigureLocalOutput::getSettings(), LocalOutput::MsgStartStop::getStartStop(), DeviceAPI::initDeviceEngine(), m_deviceAPI, m_settings, LocalOutputSettings::m_useReverseAPI, Message::match(), DeviceAPI::startDeviceEngine(), DeviceAPI::stopDeviceEngine(), and webapiReverseSendStartStop().

Referenced by LocalOutput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

159 {
160  if (DSPSignalNotification::match(message))
161  {
162  return false;
163  }
164  else if (MsgStartStop::match(message))
165  {
166  MsgStartStop& cmd = (MsgStartStop&) message;
167  qDebug() << "LocalOutput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
168 
169  if (cmd.getStartStop())
170  {
172  {
174  }
175  }
176  else
177  {
179  }
180 
182  webapiReverseSendStartStop(cmd.getStartStop());
183  }
184 
185  return true;
186  }
187  else if (MsgConfigureLocalOutput::match(message))
188  {
189  qDebug() << "LocalOutput::handleMessage:" << message.getIdentifier();
190  MsgConfigureLocalOutput& conf = (MsgConfigureLocalOutput&) message;
191  applySettings(conf.getSettings(), conf.getForce());
192  return true;
193  }
194  else
195  {
196  return false;
197  }
198 }
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
void applySettings(const LocalOutputSettings &settings, bool force=false)
bool initDeviceEngine()
Init the device engine corresponding to the stream type.
Definition: deviceapi.cpp:240
void webapiReverseSendStartStop(bool start)
LocalOutputSettings m_settings
Definition: localoutput.h:153
static bool match(const Message *message)
Definition: message.cpp:45
virtual const char * getIdentifier() const
Definition: message.cpp:35
DeviceAPI * m_deviceAPI
Definition: localoutput.h:151
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

void LocalOutput::init ( )
virtual

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

Implements DeviceSampleSink.

Definition at line 67 of file localoutput.cpp.

References applySettings(), and m_settings.

Referenced by LocalOutput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

68 {
70 }
void applySettings(const LocalOutputSettings &settings, bool force=false)
LocalOutputSettings m_settings
Definition: localoutput.h:153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ networkManagerFinished

void LocalOutput::networkManagerFinished ( QNetworkReply *  reply)
privateslot

Definition at line 386 of file localoutput.cpp.

Referenced by ~LocalOutput().

387 {
388  QNetworkReply::NetworkError replyError = reply->error();
389 
390  if (replyError)
391  {
392  qWarning() << "LocalOutput::networkManagerFinished:"
393  << " error(" << (int) replyError
394  << "): " << replyError
395  << ": " << reply->errorString();
396  return;
397  }
398 
399  QString answer = reply->readAll();
400  answer.chop(1); // remove last \n
401  qDebug("LocalOutput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
402 }
+ Here is the caller graph for this function:

◆ serialize()

QByteArray LocalOutput::serialize ( ) const
virtual

Implements DeviceSampleSink.

Definition at line 83 of file localoutput.cpp.

References m_settings, and LocalOutputSettings::serialize().

Referenced by LocalOutput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

84 {
85  return m_settings.serialize();
86 }
QByteArray serialize() const
LocalOutputSettings m_settings
Definition: localoutput.h:153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCenterFrequency()

void LocalOutput::setCenterFrequency ( qint64  centerFrequency)
virtual

Implements DeviceSampleSink.

Definition at line 144 of file localoutput.cpp.

References LocalOutput::MsgReportSampleRateAndFrequency::create(), DeviceAPI::getDeviceEngineInputMessageQueue(), DeviceSampleSink::getMessageQueueToGUI(), m_centerFrequency, m_deviceAPI, m_sampleRate, and MessageQueue::push().

Referenced by LocalOutput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

145 {
146  m_centerFrequency = centerFrequency;
147 
148  DSPSignalNotification *notif = new DSPSignalNotification(m_sampleRate, m_centerFrequency); // Frequency in Hz for the DSP engine
150 
151  if (getMessageQueueToGUI())
152  {
153  MsgReportSampleRateAndFrequency *msg = MsgReportSampleRateAndFrequency::create(m_sampleRate, m_centerFrequency);
154  getMessageQueueToGUI()->push(msg);
155  }
156 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
Definition: deviceapi.cpp:316
static MsgReportSampleRateAndFrequency * create(int sampleRate, qint64 centerFrequency)
Definition: localoutput.h:91
qint64 m_centerFrequency
Definition: localoutput.h:154
DeviceAPI * m_deviceAPI
Definition: localoutput.h:151
int m_sampleRate
Definition: localoutput.h:155
MessageQueue * getMessageQueueToGUI()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMessageQueueToGUI()

void LocalOutput::setMessageQueueToGUI ( MessageQueue queue)
virtual

Implements DeviceSampleSink.

Definition at line 110 of file localoutput.cpp.

References DeviceSampleSink::m_guiMessageQueue.

Referenced by LocalOutputGui::LocalOutputGui(), and LocalOutput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

111 {
112  m_guiMessageQueue = queue;
113 }
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
+ Here is the caller graph for this function:

◆ setSampleRate()

void LocalOutput::setSampleRate ( int  sampleRate)
virtual

For when the sink sample rate is set externally.

Implements DeviceSampleSink.

Definition at line 125 of file localoutput.cpp.

References LocalOutput::MsgReportSampleRateAndFrequency::create(), DeviceAPI::getDeviceEngineInputMessageQueue(), DeviceSampleSink::getMessageQueueToGUI(), m_centerFrequency, m_deviceAPI, m_sampleRate, and MessageQueue::push().

Referenced by LocalOutput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

126 {
127  m_sampleRate = sampleRate;
128 
129  DSPSignalNotification *notif = new DSPSignalNotification(m_sampleRate, m_centerFrequency); // Frequency in Hz for the DSP engine
131 
132  if (getMessageQueueToGUI())
133  {
134  MsgReportSampleRateAndFrequency *msg = MsgReportSampleRateAndFrequency::create(m_sampleRate, m_centerFrequency);
135  getMessageQueueToGUI()->push(msg);
136  }
137 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
Definition: deviceapi.cpp:316
static MsgReportSampleRateAndFrequency * create(int sampleRate, qint64 centerFrequency)
Definition: localoutput.h:91
qint64 m_centerFrequency
Definition: localoutput.h:154
DeviceAPI * m_deviceAPI
Definition: localoutput.h:151
int m_sampleRate
Definition: localoutput.h:155
MessageQueue * getMessageQueueToGUI()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ start()

bool LocalOutput::start ( )
virtual

Implements DeviceSampleSink.

Definition at line 72 of file localoutput.cpp.

Referenced by LocalOutput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

73 {
74  qDebug() << "LocalOutput::start";
75  return true;
76 }
+ Here is the caller graph for this function:

◆ stop()

void LocalOutput::stop ( )
virtual

Implements DeviceSampleSink.

Definition at line 78 of file localoutput.cpp.

Referenced by LocalOutput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency(), and ~LocalOutput().

79 {
80  qDebug() << "LocalOutput::stop";
81 }
+ Here is the caller graph for this function:

◆ webapiFormatDeviceReport()

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

Definition at line 322 of file localoutput.cpp.

References SWGSDRangel::SWGDeviceReport::getLocalOutputReport(), m_centerFrequency, m_sampleRate, SWGSDRangel::SWGLocalOutputReport::setCenterFrequency(), and SWGSDRangel::SWGLocalOutputReport::setSampleRate().

Referenced by webapiReportGet().

323 {
326 }
void setCenterFrequency(qint32 center_frequency)
qint64 m_centerFrequency
Definition: localoutput.h:154
int m_sampleRate
Definition: localoutput.h:155
SWGLocalOutputReport * getLocalOutputReport()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatDeviceSettings()

void LocalOutput::webapiFormatDeviceSettings ( SWGSDRangel::SWGDeviceSettings response,
const LocalOutputSettings settings 
)
private

Definition at line 297 of file localoutput.cpp.

References SWGSDRangel::SWGDeviceSettings::getLocalOutputSettings(), SWGSDRangel::SWGLocalOutputSettings::getReverseApiAddress(), LocalOutputSettings::m_reverseAPIAddress, LocalOutputSettings::m_reverseAPIDeviceIndex, LocalOutputSettings::m_reverseAPIPort, LocalOutputSettings::m_useReverseAPI, SWGSDRangel::SWGLocalOutputSettings::setReverseApiAddress(), SWGSDRangel::SWGLocalOutputSettings::setReverseApiDeviceIndex(), SWGSDRangel::SWGLocalOutputSettings::setReverseApiPort(), and SWGSDRangel::SWGLocalOutputSettings::setUseReverseApi().

Referenced by webapiSettingsGet(), and webapiSettingsPutPatch().

298 {
299  response.getLocalOutputSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
300 
301  if (response.getLocalOutputSettings()->getReverseApiAddress()) {
303  } else {
304  response.getLocalOutputSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
305  }
306 
309 }
void setReverseApiPort(qint32 reverse_api_port)
void setReverseApiAddress(QString *reverse_api_address)
SWGLocalOutputSettings * getLocalOutputSettings()
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setUseReverseApi(qint32 use_reverse_api)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReportGet()

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

Reimplemented from DeviceSampleSink.

Definition at line 311 of file localoutput.cpp.

References SWGSDRangel::SWGDeviceReport::getLocalOutputReport(), SWGSDRangel::SWGLocalOutputReport::init(), SWGSDRangel::SWGDeviceReport::setLocalOutputReport(), and webapiFormatDeviceReport().

Referenced by LocalOutput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

314 {
315  (void) errorMessage;
317  response.getLocalOutputReport()->init();
318  webapiFormatDeviceReport(response);
319  return 200;
320 }
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport &response)
void setLocalOutputReport(SWGLocalOutputReport *local_output_report)
SWGLocalOutputReport * getLocalOutputReport()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendSettings()

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

Definition at line 328 of file localoutput.cpp.

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

Referenced by applySettings().

329 {
330  (void) deviceSettingsKeys;
331  (void) force;
333  swgDeviceSettings->setDirection(1); // single Tx
334  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
335  swgDeviceSettings->setDeviceHwType(new QString("LocalOutput"));
337 
338  // transfer data that has been modified. When force is on transfer all data except reverse API data
339 
340  QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/settings")
341  .arg(settings.m_reverseAPIAddress)
342  .arg(settings.m_reverseAPIPort)
343  .arg(settings.m_reverseAPIDeviceIndex);
344  m_networkRequest.setUrl(QUrl(deviceSettingsURL));
345  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
346 
347  QBuffer *buffer=new QBuffer();
348  buffer->open((QBuffer::ReadWrite));
349  buffer->write(swgDeviceSettings->asJson().toUtf8());
350  buffer->seek(0);
351 
352  // Always use PATCH to avoid passing reverse API settings
353  m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
354 
355  delete swgDeviceSettings;
356 }
virtual QString asJson() override
QNetworkRequest m_networkRequest
Definition: localoutput.h:160
void setOriginatorIndex(qint32 originator_index)
int getDeviceSetIndex() const
Definition: deviceapi.h:131
void setLocalOutputSettings(SWGLocalOutputSettings *local_output_settings)
QNetworkAccessManager * m_networkManager
Definition: localoutput.h:159
DeviceAPI * m_deviceAPI
Definition: localoutput.h:151
void setDirection(qint32 direction)
void setDeviceHwType(QString *device_hw_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendStartStop()

void LocalOutput::webapiReverseSendStartStop ( bool  start)
private

Definition at line 358 of file localoutput.cpp.

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

Referenced by handleMessage().

359 {
361  swgDeviceSettings->setDirection(0); // single Rx
362  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
363  swgDeviceSettings->setDeviceHwType(new QString("LocalInput"));
364 
365  QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
369  m_networkRequest.setUrl(QUrl(deviceSettingsURL));
370  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
371 
372  QBuffer *buffer=new QBuffer();
373  buffer->open((QBuffer::ReadWrite));
374  buffer->write(swgDeviceSettings->asJson().toUtf8());
375  buffer->seek(0);
376 
377  if (start) {
378  m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
379  } else {
380  m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
381  }
382 
383  delete swgDeviceSettings;
384 }
virtual QString asJson() override
QNetworkRequest m_networkRequest
Definition: localoutput.h:160
void setOriginatorIndex(qint32 originator_index)
int getDeviceSetIndex() const
Definition: deviceapi.h:131
LocalOutputSettings m_settings
Definition: localoutput.h:153
QNetworkAccessManager * m_networkManager
Definition: localoutput.h:159
DeviceAPI * m_deviceAPI
Definition: localoutput.h:151
virtual bool start()
Definition: localoutput.cpp:72
void setDirection(qint32 direction)
void setDeviceHwType(QString *device_hw_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiRun()

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

Reimplemented from DeviceSampleSink.

Definition at line 232 of file localoutput.cpp.

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

Referenced by LocalOutput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

236 {
237  (void) errorMessage;
239  MsgStartStop *message = MsgStartStop::create(run);
240  m_inputMessageQueue.push(message);
241 
242  if (m_guiMessageQueue) // forward to GUI if any
243  {
244  MsgStartStop *msgToGUI = MsgStartStop::create(run);
245  m_guiMessageQueue->push(msgToGUI);
246  }
247 
248  return 200;
249 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
static MsgStartStop * create(bool startStop)
Definition: localoutput.h:71
MessageQueue m_inputMessageQueue
Input queue to the sink.
void getDeviceEngineStateStr(QString &state)
Definition: deviceapi.cpp:389
DeviceAPI * m_deviceAPI
Definition: localoutput.h:151
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:

◆ webapiRunGet()

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

Reimplemented from DeviceSampleSink.

Definition at line 223 of file localoutput.cpp.

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

Referenced by LocalOutput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

226 {
227  (void) errorMessage;
229  return 200;
230 }
void getDeviceEngineStateStr(QString &state)
Definition: deviceapi.cpp:389
DeviceAPI * m_deviceAPI
Definition: localoutput.h:151
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsGet()

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

Reimplemented from DeviceSampleSink.

Definition at line 251 of file localoutput.cpp.

References SWGSDRangel::SWGDeviceSettings::getLocalOutputSettings(), SWGSDRangel::SWGLocalOutputSettings::init(), m_settings, SWGSDRangel::SWGDeviceSettings::setLocalOutputSettings(), and webapiFormatDeviceSettings().

Referenced by LocalOutput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

254 {
255  (void) errorMessage;
257  response.getLocalOutputSettings()->init();
259  return 200;
260 }
SWGLocalOutputSettings * getLocalOutputSettings()
void setLocalOutputSettings(SWGLocalOutputSettings *local_output_settings)
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const LocalOutputSettings &settings)
LocalOutputSettings m_settings
Definition: localoutput.h:153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsPutPatch()

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

Reimplemented from DeviceSampleSink.

Definition at line 262 of file localoutput.cpp.

References LocalOutput::MsgConfigureLocalOutput::create(), SWGSDRangel::SWGDeviceSettings::getLocalOutputSettings(), SWGSDRangel::SWGLocalOutputSettings::getReverseApiAddress(), SWGSDRangel::SWGLocalOutputSettings::getReverseApiDeviceIndex(), SWGSDRangel::SWGLocalOutputSettings::getReverseApiPort(), SWGSDRangel::SWGLocalOutputSettings::getUseReverseApi(), DeviceSampleSink::m_guiMessageQueue, DeviceSampleSink::m_inputMessageQueue, LocalOutputSettings::m_reverseAPIAddress, LocalOutputSettings::m_reverseAPIDeviceIndex, LocalOutputSettings::m_reverseAPIPort, m_settings, LocalOutputSettings::m_useReverseAPI, MessageQueue::push(), and webapiFormatDeviceSettings().

Referenced by LocalOutput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

267 {
268  (void) errorMessage;
269  LocalOutputSettings settings = m_settings;
270 
271  if (deviceSettingsKeys.contains("useReverseAPI")) {
272  settings.m_useReverseAPI = response.getLocalOutputSettings()->getUseReverseApi() != 0;
273  }
274  if (deviceSettingsKeys.contains("reverseAPIAddress")) {
276  }
277  if (deviceSettingsKeys.contains("reverseAPIPort")) {
279  }
280  if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
282  }
283 
284  MsgConfigureLocalOutput *msg = MsgConfigureLocalOutput::create(settings, force);
286 
287  if (m_guiMessageQueue) // forward to GUI if any
288  {
289  MsgConfigureLocalOutput *msgToGUI = MsgConfigureLocalOutput::create(settings, force);
290  m_guiMessageQueue->push(msgToGUI);
291  }
292 
293  webapiFormatDeviceSettings(response, settings);
294  return 200;
295 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the sink.
SWGLocalOutputSettings * getLocalOutputSettings()
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const LocalOutputSettings &settings)
LocalOutputSettings m_settings
Definition: localoutput.h:153
static MsgConfigureLocalOutput * create(const LocalOutputSettings &settings, bool force=false)
Definition: localoutput.h:49
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

qint64 LocalOutput::m_centerFrequency
private

◆ m_deviceAPI

DeviceAPI* LocalOutput::m_deviceAPI
private

◆ m_deviceDescription

QString LocalOutput::m_deviceDescription
private

Definition at line 157 of file localoutput.h.

Referenced by getDeviceDescription().

◆ m_fileSink

FileRecord* LocalOutput::m_fileSink
private

File sink to record device I/Q output.

Definition at line 158 of file localoutput.h.

◆ m_mutex

QMutex LocalOutput::m_mutex
private

Definition at line 152 of file localoutput.h.

Referenced by applySettings().

◆ m_networkManager

QNetworkAccessManager* LocalOutput::m_networkManager
private

◆ m_networkRequest

QNetworkRequest LocalOutput::m_networkRequest
private

Definition at line 160 of file localoutput.h.

Referenced by webapiReverseSendSettings(), and webapiReverseSendStartStop().

◆ m_remoteAddress

QString LocalOutput::m_remoteAddress
private

Definition at line 156 of file localoutput.h.

Referenced by applySettings().

◆ m_sampleRate

int LocalOutput::m_sampleRate
private

◆ m_settings

LocalOutputSettings LocalOutput::m_settings
private

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