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
LocalInput Class Reference

#include <localinput.h>

+ Inheritance diagram for LocalInput:
+ Collaboration diagram for LocalInput:

Classes

class  MsgConfigureLocalInput
 
class  MsgFileRecord
 
class  MsgReportSampleRateAndFrequency
 
class  MsgStartStop
 

Public Member Functions

 LocalInput (DeviceAPI *deviceAPI)
 
virtual ~LocalInput ()
 
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 source. More...
 
virtual void setSampleRate (int sampleRate)
 For when the source sample rate is set externally. More...
 
virtual quint64 getCenterFrequency () const
 Center frequency exposed by the source. More...
 
virtual void setCenterFrequency (qint64 centerFrequency)
 
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 DeviceSampleSource
 DeviceSampleSource ()
 
virtual ~DeviceSampleSource ()
 
MessageQueuegetInputMessageQueue ()
 
MessageQueuegetMessageQueueToGUI ()
 
SampleSinkFifogetSampleFifo ()
 

Private Slots

void networkManagerFinished (QNetworkReply *reply)
 

Private Member Functions

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

Private Attributes

DeviceAPIm_deviceAPI
 
QMutex m_mutex
 
LocalInputSettings 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 DeviceSampleSource
enum  fcPos_t { FC_POS_INFRA = 0, FC_POS_SUPRA, FC_POS_CENTER }
 
enum  FrequencyShiftScheme { FSHIFT_STD = 0, FSHIFT_TXSYNC }
 
- Static Public Member Functions inherited from DeviceSampleSource
static qint64 calculateDeviceCenterFrequency (quint64 centerFrequency, qint64 transverterDeltaFrequency, int log2Decim, fcPos_t fcPos, quint32 devSampleRate, FrequencyShiftScheme frequencyShiftScheme, bool transverterMode=false)
 
static qint64 calculateCenterFrequency (quint64 deviceCenterFrequency, qint64 transverterDeltaFrequency, int log2Decim, fcPos_t fcPos, quint32 devSampleRate, FrequencyShiftScheme frequencyShiftScheme, bool transverterMode=false)
 
static qint32 calculateFrequencyShift (int log2Decim, fcPos_t fcPos, quint32 devSampleRate, FrequencyShiftScheme frequencyShiftScheme)
 
- Protected Slots inherited from DeviceSampleSource
void handleInputMessages ()
 
- Protected Attributes inherited from DeviceSampleSource
SampleSinkFifo m_sampleFifo
 
MessageQueue m_inputMessageQueue
 Input queue to the source. More...
 
MessageQueuem_guiMessageQueue
 Input message queue to the GUI. More...
 

Detailed Description

Definition at line 39 of file localinput.h.

Constructor & Destructor Documentation

◆ LocalInput()

LocalInput::LocalInput ( DeviceAPI deviceAPI)

Definition at line 43 of file localinput.cpp.

References arg().

Referenced by LocalInput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

43  :
44  m_deviceAPI(deviceAPI),
45  m_settings(),
47  m_deviceDescription("LocalInput")
48 {
49  m_sampleFifo.setSize(96000 * 4);
50 
51  m_fileSink = new FileRecord(QString("test_%1.sdriq").arg(m_deviceAPI->getDeviceUID()));
54 
55  m_networkManager = new QNetworkAccessManager();
56  connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
57 }
QNetworkAccessManager * m_networkManager
Definition: localinput.h:177
DeviceAPI * m_deviceAPI
Definition: localinput.h:169
uint getDeviceUID() const
Return the current device engine unique ID.
Definition: deviceapi.cpp:303
void setNbSourceStreams(uint32_t nbSourceStreams)
Definition: deviceapi.h:168
SampleSinkFifo m_sampleFifo
bool setSize(int size)
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
LocalInputSettings m_settings
Definition: localinput.h:171
QString m_deviceDescription
Definition: localinput.h:175
void addAncillarySink(BasebandSampleSink *sink, unsigned int index=0)
Adds a sink to receive full baseband and that is not a channel (e.g. spectrum)
Definition: deviceapi.cpp:89
FileRecord * m_fileSink
File sink to record device I/Q output.
Definition: localinput.h:176
void networkManagerFinished(QNetworkReply *reply)
Definition: localinput.cpp:465
qint64 m_centerFrequency
Definition: localinput.h:172
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ~LocalInput()

LocalInput::~LocalInput ( )
virtual

Definition at line 59 of file localinput.cpp.

References m_deviceAPI, m_fileSink, m_networkManager, networkManagerFinished(), DeviceAPI::removeAncillarySink(), and stop().

Referenced by LocalInput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

60 {
61  disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
62  delete m_networkManager;
63  stop();
65  delete m_fileSink;
66 }
QNetworkAccessManager * m_networkManager
Definition: localinput.h:177
DeviceAPI * m_deviceAPI
Definition: localinput.h:169
FileRecord * m_fileSink
File sink to record device I/Q output.
Definition: localinput.h:176
void removeAncillarySink(BasebandSampleSink *sink, unsigned int index=0)
Removes it.
Definition: deviceapi.cpp:100
void networkManagerFinished(QNetworkReply *reply)
Definition: localinput.cpp:465
virtual void stop()
Definition: localinput.cpp:84
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ applySettings()

void LocalInput::applySettings ( const LocalInputSettings settings,
bool  force = false 
)
private

Definition at line 229 of file localinput.cpp.

References DeviceAPI::configureCorrections(), LocalInputSettings::m_dcBlock, m_deviceAPI, LocalInputSettings::m_fileRecordName, LocalInputSettings::m_iqCorrection, m_mutex, m_remoteAddress, LocalInputSettings::m_reverseAPIAddress, LocalInputSettings::m_reverseAPIDeviceIndex, LocalInputSettings::m_reverseAPIPort, m_settings, LocalInputSettings::m_useReverseAPI, and webapiReverseSendSettings().

Referenced by handleMessage(), and init().

230 {
231  QMutexLocker mutexLocker(&m_mutex);
232  std::ostringstream os;
233  QString remoteAddress;
234  QList<QString> reverseAPIKeys;
235 
236  if ((m_settings.m_dcBlock != settings.m_dcBlock) || force) {
237  reverseAPIKeys.append("dcBlock");
238  }
239  if ((m_settings.m_iqCorrection != settings.m_iqCorrection) || force) {
240  reverseAPIKeys.append("iqCorrection");
241  }
242  if ((m_settings.m_fileRecordName != settings.m_fileRecordName) || force) {
243  reverseAPIKeys.append("fileRecordName");
244  }
245 
246  if ((m_settings.m_dcBlock != settings.m_dcBlock) || (m_settings.m_iqCorrection != settings.m_iqCorrection) || force)
247  {
249  qDebug("LocalInput::applySettings: corrections: DC block: %s IQ imbalance: %s",
250  settings.m_dcBlock ? "true" : "false",
251  settings.m_iqCorrection ? "true" : "false");
252  }
253 
254  mutexLocker.unlock();
255 
256  if (settings.m_useReverseAPI)
257  {
258  bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
262  webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
263  }
264 
265  m_settings = settings;
266  m_remoteAddress = remoteAddress;
267 
268  qDebug() << "LocalInput::applySettings: "
269  << " m_dcBlock: " << m_settings.m_dcBlock
270  << " m_iqCorrection: " << m_settings.m_iqCorrection
271  << " m_fileRecordName: " << m_settings.m_fileRecordName
272  << " m_remoteAddress: " << m_remoteAddress;
273 }
QString m_remoteAddress
Definition: localinput.h:174
DeviceAPI * m_deviceAPI
Definition: localinput.h:169
LocalInputSettings m_settings
Definition: localinput.h:171
uint16_t m_reverseAPIDeviceIndex
QMutex m_mutex
Definition: localinput.h:170
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const LocalInputSettings &settings, bool force)
Definition: localinput.cpp:398
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection, int streamIndex=0)
Configure current device engine DSP corrections (Rx)
Definition: deviceapi.cpp:355
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deserialize()

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

Implements DeviceSampleSource.

Definition at line 94 of file localinput.cpp.

References LocalInput::MsgConfigureLocalInput::create(), LocalInputSettings::deserialize(), DeviceSampleSource::m_guiMessageQueue, DeviceSampleSource::m_inputMessageQueue, m_settings, MessageQueue::push(), and LocalInputSettings::resetToDefaults().

Referenced by LocalInput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

95 {
96  bool success = true;
97 
98  if (!m_settings.deserialize(data))
99  {
101  success = false;
102  }
103 
104  MsgConfigureLocalInput* message = MsgConfigureLocalInput::create(m_settings, true);
105  m_inputMessageQueue.push(message);
106 
107  if (m_guiMessageQueue)
108  {
109  MsgConfigureLocalInput* messageToGUI = MsgConfigureLocalInput::create(m_settings, true);
110  m_guiMessageQueue->push(messageToGUI);
111  }
112 
113  return success;
114 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
LocalInputSettings m_settings
Definition: localinput.h:171
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
bool deserialize(const QByteArray &data)
static MsgConfigureLocalInput * create(const LocalInputSettings &settings, bool force=false)
Definition: localinput.h:49
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ destroy()

void LocalInput::destroy ( )
virtual

Implements DeviceSampleSource.

Definition at line 68 of file localinput.cpp.

Referenced by LocalInput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

69 {
70  delete this;
71 }
+ Here is the caller graph for this function:

◆ getCenterFrequency()

quint64 LocalInput::getCenterFrequency ( ) const
virtual

Center frequency exposed by the source.

Implements DeviceSampleSource.

Definition at line 145 of file localinput.cpp.

References m_centerFrequency.

Referenced by LocalInput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

146 {
147  return m_centerFrequency;
148 }
qint64 m_centerFrequency
Definition: localinput.h:172
+ Here is the caller graph for this function:

◆ getDeviceDescription()

const QString & LocalInput::getDeviceDescription ( ) const
virtual

Implements DeviceSampleSource.

Definition at line 121 of file localinput.cpp.

References m_deviceDescription.

Referenced by LocalInput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

122 {
123  return m_deviceDescription;
124 }
QString m_deviceDescription
Definition: localinput.h:175
+ Here is the caller graph for this function:

◆ getSampleRate()

int LocalInput::getSampleRate ( ) const
virtual

Sample rate exposed by the source.

Implements DeviceSampleSource.

Definition at line 126 of file localinput.cpp.

References m_sampleRate.

Referenced by LocalInput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

127 {
128  return m_sampleRate;
129 }
int m_sampleRate
Definition: localinput.h:173
+ Here is the caller graph for this function:

◆ handleMessage()

bool LocalInput::handleMessage ( const Message message)
virtual

Implements DeviceSampleSource.

Definition at line 164 of file localinput.cpp.

References applySettings(), FileRecord::genUniqueFileName(), DeviceAPI::getDeviceUID(), LocalInput::MsgConfigureLocalInput::getForce(), Message::getIdentifier(), LocalInput::MsgConfigureLocalInput::getSettings(), LocalInput::MsgFileRecord::getStartStop(), LocalInput::MsgStartStop::getStartStop(), FileRecord::handleMessage(), DeviceAPI::initDeviceEngine(), m_deviceAPI, LocalInputSettings::m_fileRecordName, m_fileSink, m_settings, LocalInputSettings::m_useReverseAPI, Message::match(), FileRecord::setFileName(), DeviceAPI::startDeviceEngine(), FileRecord::startRecording(), DeviceAPI::stopDeviceEngine(), FileRecord::stopRecording(), and webapiReverseSendStartStop().

Referenced by LocalInput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

165 {
166  if (DSPSignalNotification::match(message))
167  {
168  DSPSignalNotification& notif = (DSPSignalNotification&) message;
169  return m_fileSink->handleMessage(notif); // forward to file sink
170  }
171  else if (MsgFileRecord::match(message))
172  {
173  MsgFileRecord& conf = (MsgFileRecord&) message;
174  qDebug() << "LocalInput::handleMessage: MsgFileRecord: " << conf.getStartStop();
175 
176  if (conf.getStartStop())
177  {
178  if (m_settings.m_fileRecordName.size() != 0) {
180  } else {
182  }
183 
185  }
186  else
187  {
189  }
190 
191  return true;
192  }
193  else if (MsgStartStop::match(message))
194  {
195  MsgStartStop& cmd = (MsgStartStop&) message;
196  qDebug() << "LocalInput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
197 
198  if (cmd.getStartStop())
199  {
201  {
203  }
204  }
205  else
206  {
208  }
209 
211  webapiReverseSendStartStop(cmd.getStartStop());
212  }
213 
214  return true;
215  }
216  else if (MsgConfigureLocalInput::match(message))
217  {
218  qDebug() << "LocalInput::handleMessage:" << message.getIdentifier();
219  MsgConfigureLocalInput& conf = (MsgConfigureLocalInput&) message;
220  applySettings(conf.getSettings(), conf.getForce());
221  return true;
222  }
223  else
224  {
225  return false;
226  }
227 }
bool startDeviceEngine()
Start the device engine corresponding to the stream type.
Definition: deviceapi.cpp:253
DeviceAPI * m_deviceAPI
Definition: localinput.h:169
void stopDeviceEngine()
Stop the device engine corresponding to the stream type.
Definition: deviceapi.cpp:266
void setFileName(const QString &filename)
Definition: filerecord.cpp:59
uint getDeviceUID() const
Return the current device engine unique ID.
Definition: deviceapi.cpp:303
void startRecording()
Definition: filerecord.cpp:105
bool initDeviceEngine()
Init the device engine corresponding to the stream type.
Definition: deviceapi.cpp:240
virtual bool handleMessage(const Message &message)
Processing of a message. Returns true if message has actually been processed.
Definition: filerecord.cpp:128
void applySettings(const LocalInputSettings &settings, bool force=false)
Definition: localinput.cpp:229
LocalInputSettings m_settings
Definition: localinput.h:171
void genUniqueFileName(uint deviceUID, int istream=-1)
Definition: filerecord.cpp:67
FileRecord * m_fileSink
File sink to record device I/Q output.
Definition: localinput.h:176
void stopRecording()
Definition: filerecord.cpp:117
void webapiReverseSendStartStop(bool start)
Definition: localinput.cpp:437
static bool match(const Message *message)
Definition: message.cpp:45
virtual const char * getIdentifier() const
Definition: message.cpp:35
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

void LocalInput::init ( )
virtual

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

Implements DeviceSampleSource.

Definition at line 73 of file localinput.cpp.

References applySettings(), and m_settings.

Referenced by LocalInput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

74 {
76 }
void applySettings(const LocalInputSettings &settings, bool force=false)
Definition: localinput.cpp:229
LocalInputSettings m_settings
Definition: localinput.h:171
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ networkManagerFinished

void LocalInput::networkManagerFinished ( QNetworkReply *  reply)
privateslot

Definition at line 465 of file localinput.cpp.

Referenced by ~LocalInput().

466 {
467  QNetworkReply::NetworkError replyError = reply->error();
468 
469  if (replyError)
470  {
471  qWarning() << "LocalInput::networkManagerFinished:"
472  << " error(" << (int) replyError
473  << "): " << replyError
474  << ": " << reply->errorString();
475  return;
476  }
477 
478  QString answer = reply->readAll();
479  answer.chop(1); // remove last \n
480  qDebug("LocalInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
481 }
+ Here is the caller graph for this function:

◆ serialize()

QByteArray LocalInput::serialize ( ) const
virtual

Implements DeviceSampleSource.

Definition at line 89 of file localinput.cpp.

References m_settings, and LocalInputSettings::serialize().

Referenced by LocalInput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

90 {
91  return m_settings.serialize();
92 }
LocalInputSettings m_settings
Definition: localinput.h:171
QByteArray serialize() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCenterFrequency()

void LocalInput::setCenterFrequency ( qint64  centerFrequency)
virtual

Implements DeviceSampleSource.

Definition at line 150 of file localinput.cpp.

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

Referenced by LocalInput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

151 {
152  m_centerFrequency = centerFrequency;
153 
154  DSPSignalNotification *notif = new DSPSignalNotification(m_sampleRate, m_centerFrequency); // Frequency in Hz for the DSP engine
156 
157  if (getMessageQueueToGUI())
158  {
159  MsgReportSampleRateAndFrequency *msg = MsgReportSampleRateAndFrequency::create(m_sampleRate, m_centerFrequency);
160  getMessageQueueToGUI()->push(msg);
161  }
162 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
DeviceAPI * m_deviceAPI
Definition: localinput.h:169
int m_sampleRate
Definition: localinput.h:173
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
Definition: deviceapi.cpp:316
MessageQueue * getMessageQueueToGUI()
static MsgReportSampleRateAndFrequency * create(int sampleRate, qint64 centerFrequency)
Definition: localinput.h:110
qint64 m_centerFrequency
Definition: localinput.h:172
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMessageQueueToGUI()

void LocalInput::setMessageQueueToGUI ( MessageQueue queue)
virtual

Implements DeviceSampleSource.

Definition at line 116 of file localinput.cpp.

References DeviceSampleSource::m_guiMessageQueue.

Referenced by LocalInputGui::LocalInputGui(), and LocalInput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

117 {
118  m_guiMessageQueue = queue;
119 }
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
+ Here is the caller graph for this function:

◆ setSampleRate()

void LocalInput::setSampleRate ( int  sampleRate)
virtual

For when the source sample rate is set externally.

Implements DeviceSampleSource.

Definition at line 131 of file localinput.cpp.

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

Referenced by LocalInput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

132 {
133  m_sampleRate = sampleRate;
134 
135  DSPSignalNotification *notif = new DSPSignalNotification(m_sampleRate, m_centerFrequency); // Frequency in Hz for the DSP engine
137 
138  if (getMessageQueueToGUI())
139  {
140  MsgReportSampleRateAndFrequency *msg = MsgReportSampleRateAndFrequency::create(m_sampleRate, m_centerFrequency);
141  getMessageQueueToGUI()->push(msg);
142  }
143 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
DeviceAPI * m_deviceAPI
Definition: localinput.h:169
int m_sampleRate
Definition: localinput.h:173
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
Definition: deviceapi.cpp:316
MessageQueue * getMessageQueueToGUI()
static MsgReportSampleRateAndFrequency * create(int sampleRate, qint64 centerFrequency)
Definition: localinput.h:110
qint64 m_centerFrequency
Definition: localinput.h:172
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ start()

bool LocalInput::start ( )
virtual

Implements DeviceSampleSource.

Definition at line 78 of file localinput.cpp.

Referenced by LocalInput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

79 {
80  qDebug() << "LocalInput::start";
81  return true;
82 }
+ Here is the caller graph for this function:

◆ stop()

void LocalInput::stop ( )
virtual

Implements DeviceSampleSource.

Definition at line 84 of file localinput.cpp.

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

85 {
86  qDebug() << "LocalInput::stop";
87 }
+ Here is the caller graph for this function:

◆ webapiFormatDeviceReport()

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

Definition at line 392 of file localinput.cpp.

References SWGSDRangel::SWGDeviceReport::getLocalInputReport(), m_centerFrequency, m_sampleRate, SWGSDRangel::SWGLocalInputReport::setCenterFrequency(), and SWGSDRangel::SWGLocalInputReport::setSampleRate().

Referenced by webapiReportGet().

393 {
396 }
int m_sampleRate
Definition: localinput.h:173
SWGLocalInputReport * getLocalInputReport()
void setSampleRate(qint32 sample_rate)
void setCenterFrequency(qint32 center_frequency)
qint64 m_centerFrequency
Definition: localinput.h:172
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatDeviceSettings()

void LocalInput::webapiFormatDeviceSettings ( SWGSDRangel::SWGDeviceSettings response,
const LocalInputSettings settings 
)
private

Definition at line 358 of file localinput.cpp.

References SWGSDRangel::SWGLocalInputSettings::getFileRecordName(), SWGSDRangel::SWGDeviceSettings::getLocalInputSettings(), SWGSDRangel::SWGLocalInputSettings::getReverseApiAddress(), LocalInputSettings::m_dcBlock, LocalInputSettings::m_fileRecordName, LocalInputSettings::m_iqCorrection, LocalInputSettings::m_reverseAPIAddress, LocalInputSettings::m_reverseAPIDeviceIndex, LocalInputSettings::m_reverseAPIPort, LocalInputSettings::m_useReverseAPI, SWGSDRangel::SWGLocalInputSettings::setDcBlock(), SWGSDRangel::SWGLocalInputSettings::setFileRecordName(), SWGSDRangel::SWGLocalInputSettings::setIqCorrection(), SWGSDRangel::SWGLocalInputSettings::setReverseApiAddress(), SWGSDRangel::SWGLocalInputSettings::setReverseApiDeviceIndex(), SWGSDRangel::SWGLocalInputSettings::setReverseApiPort(), and SWGSDRangel::SWGLocalInputSettings::setUseReverseApi().

Referenced by webapiSettingsGet(), and webapiSettingsPutPatch().

359 {
360  response.getLocalInputSettings()->setDcBlock(settings.m_dcBlock ? 1 : 0);
362 
363  if (response.getLocalInputSettings()->getFileRecordName()) {
364  *response.getLocalInputSettings()->getFileRecordName() = settings.m_fileRecordName;
365  } else {
366  response.getLocalInputSettings()->setFileRecordName(new QString(settings.m_fileRecordName));
367  }
368 
369  response.getLocalInputSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
370 
371  if (response.getLocalInputSettings()->getReverseApiAddress()) {
373  } else {
374  response.getLocalInputSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
375  }
376 
379 }
SWGLocalInputSettings * getLocalInputSettings()
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setReverseApiAddress(QString *reverse_api_address)
void setIqCorrection(qint32 iq_correction)
void setUseReverseApi(qint32 use_reverse_api)
void setReverseApiPort(qint32 reverse_api_port)
uint16_t m_reverseAPIDeviceIndex
void setFileRecordName(QString *file_record_name)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReportGet()

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

Reimplemented from DeviceSampleSource.

Definition at line 381 of file localinput.cpp.

References SWGSDRangel::SWGDeviceReport::getLocalInputReport(), SWGSDRangel::SWGLocalInputReport::init(), SWGSDRangel::SWGDeviceReport::setLocalInputReport(), and webapiFormatDeviceReport().

Referenced by LocalInput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

384 {
385  (void) errorMessage;
387  response.getLocalInputReport()->init();
388  webapiFormatDeviceReport(response);
389  return 200;
390 }
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport &response)
Definition: localinput.cpp:392
SWGLocalInputReport * getLocalInputReport()
void setLocalInputReport(SWGLocalInputReport *local_input_report)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendSettings()

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

Definition at line 398 of file localinput.cpp.

References SWGSDRangel::SWGDeviceSettings::asJson(), DeviceAPI::getDeviceSetIndex(), SWGSDRangel::SWGDeviceSettings::getLocalInputSettings(), LocalInputSettings::m_dcBlock, m_deviceAPI, LocalInputSettings::m_fileRecordName, LocalInputSettings::m_iqCorrection, m_networkManager, m_networkRequest, LocalInputSettings::m_reverseAPIAddress, LocalInputSettings::m_reverseAPIDeviceIndex, LocalInputSettings::m_reverseAPIPort, SWGSDRangel::SWGLocalInputSettings::setDcBlock(), SWGSDRangel::SWGDeviceSettings::setDeviceHwType(), SWGSDRangel::SWGDeviceSettings::setDirection(), SWGSDRangel::SWGLocalInputSettings::setFileRecordName(), SWGSDRangel::SWGLocalInputSettings::setIqCorrection(), SWGSDRangel::SWGDeviceSettings::setLocalInputSettings(), and SWGSDRangel::SWGDeviceSettings::setOriginatorIndex().

Referenced by applySettings().

399 {
401  swgDeviceSettings->setDirection(0); // single Rx
402  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
403  swgDeviceSettings->setDeviceHwType(new QString("LocalInput"));
405  SWGSDRangel::SWGLocalInputSettings *swgLocalInputSettings = swgDeviceSettings->getLocalInputSettings();
406 
407  // transfer data that has been modified. When force is on transfer all data except reverse API data
408 
409  if (deviceSettingsKeys.contains("dcBlock") || force) {
410  swgLocalInputSettings->setDcBlock(settings.m_dcBlock ? 1 : 0);
411  }
412  if (deviceSettingsKeys.contains("iqCorrection") || force) {
413  swgLocalInputSettings->setIqCorrection(settings.m_iqCorrection ? 1 : 0);
414  }
415  if (deviceSettingsKeys.contains("fileRecordName") || force) {
416  swgLocalInputSettings->setFileRecordName(new QString(settings.m_fileRecordName));
417  }
418 
419  QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/settings")
420  .arg(settings.m_reverseAPIAddress)
421  .arg(settings.m_reverseAPIPort)
422  .arg(settings.m_reverseAPIDeviceIndex);
423  m_networkRequest.setUrl(QUrl(deviceSettingsURL));
424  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
425 
426  QBuffer *buffer=new QBuffer();
427  buffer->open((QBuffer::ReadWrite));
428  buffer->write(swgDeviceSettings->asJson().toUtf8());
429  buffer->seek(0);
430 
431  // Always use PATCH to avoid passing reverse API settings
432  m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
433 
434  delete swgDeviceSettings;
435 }
QNetworkAccessManager * m_networkManager
Definition: localinput.h:177
void setLocalInputSettings(SWGLocalInputSettings *local_input_settings)
SWGLocalInputSettings * getLocalInputSettings()
DeviceAPI * m_deviceAPI
Definition: localinput.h:169
virtual QString asJson() override
QNetworkRequest m_networkRequest
Definition: localinput.h:178
void setOriginatorIndex(qint32 originator_index)
int getDeviceSetIndex() const
Definition: deviceapi.h:131
void setIqCorrection(qint32 iq_correction)
uint16_t m_reverseAPIDeviceIndex
void setFileRecordName(QString *file_record_name)
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 LocalInput::webapiReverseSendStartStop ( bool  start)
private

Definition at line 437 of file localinput.cpp.

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

Referenced by handleMessage().

438 {
440  swgDeviceSettings->setDirection(0); // single Rx
441  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
442  swgDeviceSettings->setDeviceHwType(new QString("LocalInput"));
443 
444  QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
448  m_networkRequest.setUrl(QUrl(deviceSettingsURL));
449  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
450 
451  QBuffer *buffer=new QBuffer();
452  buffer->open((QBuffer::ReadWrite));
453  buffer->write(swgDeviceSettings->asJson().toUtf8());
454  buffer->seek(0);
455 
456  if (start) {
457  m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
458  } else {
459  m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
460  }
461 
462  delete swgDeviceSettings;
463 }
QNetworkAccessManager * m_networkManager
Definition: localinput.h:177
DeviceAPI * m_deviceAPI
Definition: localinput.h:169
virtual QString asJson() override
QNetworkRequest m_networkRequest
Definition: localinput.h:178
void setOriginatorIndex(qint32 originator_index)
LocalInputSettings m_settings
Definition: localinput.h:171
int getDeviceSetIndex() const
Definition: deviceapi.h:131
virtual bool start()
Definition: localinput.cpp:78
uint16_t m_reverseAPIDeviceIndex
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 LocalInput::webapiRun ( bool  run,
SWGSDRangel::SWGDeviceState response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSource.

Definition at line 284 of file localinput.cpp.

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

Referenced by LocalInput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

288 {
289  (void) errorMessage;
291  MsgStartStop *message = MsgStartStop::create(run);
292  m_inputMessageQueue.push(message);
293 
294  if (m_guiMessageQueue) // forward to GUI if any
295  {
296  MsgStartStop *msgToGUI = MsgStartStop::create(run);
297  m_guiMessageQueue->push(msgToGUI);
298  }
299 
300  return 200;
301 }
static MsgStartStop * create(bool startStop)
Definition: localinput.h:90
void push(Message *message, bool emitSignal=true)
Push message onto queue.
DeviceAPI * m_deviceAPI
Definition: localinput.h:169
MessageQueue m_inputMessageQueue
Input queue to the source.
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
void getDeviceEngineStateStr(QString &state)
Definition: deviceapi.cpp:389
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiRunGet()

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

Reimplemented from DeviceSampleSource.

Definition at line 275 of file localinput.cpp.

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

Referenced by LocalInput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

278 {
279  (void) errorMessage;
281  return 200;
282 }
DeviceAPI * m_deviceAPI
Definition: localinput.h:169
void getDeviceEngineStateStr(QString &state)
Definition: deviceapi.cpp:389
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsGet()

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

Reimplemented from DeviceSampleSource.

Definition at line 303 of file localinput.cpp.

References SWGSDRangel::SWGDeviceSettings::getLocalInputSettings(), SWGSDRangel::SWGLocalInputSettings::init(), m_settings, SWGSDRangel::SWGDeviceSettings::setLocalInputSettings(), and webapiFormatDeviceSettings().

Referenced by LocalInput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

306 {
307  (void) errorMessage;
309  response.getLocalInputSettings()->init();
311  return 200;
312 }
void setLocalInputSettings(SWGLocalInputSettings *local_input_settings)
SWGLocalInputSettings * getLocalInputSettings()
LocalInputSettings m_settings
Definition: localinput.h:171
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const LocalInputSettings &settings)
Definition: localinput.cpp:358
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsPutPatch()

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

Reimplemented from DeviceSampleSource.

Definition at line 314 of file localinput.cpp.

References LocalInput::MsgConfigureLocalInput::create(), SWGSDRangel::SWGLocalInputSettings::getDcBlock(), SWGSDRangel::SWGLocalInputSettings::getFileRecordName(), SWGSDRangel::SWGLocalInputSettings::getIqCorrection(), SWGSDRangel::SWGDeviceSettings::getLocalInputSettings(), SWGSDRangel::SWGLocalInputSettings::getReverseApiAddress(), SWGSDRangel::SWGLocalInputSettings::getReverseApiDeviceIndex(), SWGSDRangel::SWGLocalInputSettings::getReverseApiPort(), SWGSDRangel::SWGLocalInputSettings::getUseReverseApi(), LocalInputSettings::m_dcBlock, LocalInputSettings::m_fileRecordName, DeviceSampleSource::m_guiMessageQueue, DeviceSampleSource::m_inputMessageQueue, LocalInputSettings::m_iqCorrection, LocalInputSettings::m_reverseAPIAddress, LocalInputSettings::m_reverseAPIDeviceIndex, LocalInputSettings::m_reverseAPIPort, m_settings, LocalInputSettings::m_useReverseAPI, MessageQueue::push(), and webapiFormatDeviceSettings().

Referenced by LocalInput::MsgReportSampleRateAndFrequency::MsgReportSampleRateAndFrequency().

319 {
320  (void) errorMessage;
321  LocalInputSettings settings = m_settings;
322 
323  if (deviceSettingsKeys.contains("dcBlock")) {
324  settings.m_dcBlock = response.getLocalInputSettings()->getDcBlock() != 0;
325  }
326  if (deviceSettingsKeys.contains("iqCorrection")) {
327  settings.m_iqCorrection = response.getLocalInputSettings()->getIqCorrection() != 0;
328  }
329  if (deviceSettingsKeys.contains("fileRecordName")) {
330  settings.m_fileRecordName = *response.getLocalInputSettings()->getFileRecordName();
331  }
332  if (deviceSettingsKeys.contains("useReverseAPI")) {
333  settings.m_useReverseAPI = response.getLocalInputSettings()->getUseReverseApi() != 0;
334  }
335  if (deviceSettingsKeys.contains("reverseAPIAddress")) {
337  }
338  if (deviceSettingsKeys.contains("reverseAPIPort")) {
340  }
341  if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
343  }
344 
345  MsgConfigureLocalInput *msg = MsgConfigureLocalInput::create(settings, force);
347 
348  if (m_guiMessageQueue) // forward to GUI if any
349  {
350  MsgConfigureLocalInput *msgToGUI = MsgConfigureLocalInput::create(settings, force);
351  m_guiMessageQueue->push(msgToGUI);
352  }
353 
354  webapiFormatDeviceSettings(response, settings);
355  return 200;
356 }
SWGLocalInputSettings * getLocalInputSettings()
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
LocalInputSettings m_settings
Definition: localinput.h:171
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
uint16_t m_reverseAPIDeviceIndex
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const LocalInputSettings &settings)
Definition: localinput.cpp:358
static MsgConfigureLocalInput * create(const LocalInputSettings &settings, bool force=false)
Definition: localinput.h:49
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_centerFrequency

qint64 LocalInput::m_centerFrequency
private

◆ m_deviceAPI

DeviceAPI* LocalInput::m_deviceAPI
private

◆ m_deviceDescription

QString LocalInput::m_deviceDescription
private

Definition at line 175 of file localinput.h.

Referenced by getDeviceDescription().

◆ m_fileSink

FileRecord* LocalInput::m_fileSink
private

File sink to record device I/Q output.

Definition at line 176 of file localinput.h.

Referenced by handleMessage(), and ~LocalInput().

◆ m_mutex

QMutex LocalInput::m_mutex
private

Definition at line 170 of file localinput.h.

Referenced by applySettings().

◆ m_networkManager

QNetworkAccessManager* LocalInput::m_networkManager
private

◆ m_networkRequest

QNetworkRequest LocalInput::m_networkRequest
private

Definition at line 178 of file localinput.h.

Referenced by webapiReverseSendSettings(), and webapiReverseSendStartStop().

◆ m_remoteAddress

QString LocalInput::m_remoteAddress
private

Definition at line 174 of file localinput.h.

Referenced by applySettings().

◆ m_sampleRate

int LocalInput::m_sampleRate
private

◆ m_settings

LocalInputSettings LocalInput::m_settings
private

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