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

#include <remoteinput.h>

+ Inheritance diagram for RemoteInput:
+ Collaboration diagram for RemoteInput:

Classes

class  MsgConfigureRemoteInput
 
class  MsgConfigureRemoteInputTiming
 
class  MsgFileRecord
 
class  MsgReportRemoteInputAcquisition
 
class  MsgReportRemoteInputStreamData
 
class  MsgReportRemoteInputStreamTiming
 
class  MsgStartStop
 

Public Member Functions

 RemoteInput (DeviceAPI *deviceAPI)
 
virtual ~RemoteInput ()
 
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)
 
std::time_t getStartingTimeStamp () const
 
bool isStreaming () 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 DeviceSampleSource
 DeviceSampleSource ()
 
virtual ~DeviceSampleSource ()
 
MessageQueuegetInputMessageQueue ()
 
MessageQueuegetMessageQueueToGUI ()
 
SampleSinkFifogetSampleFifo ()
 

Private Slots

void networkManagerFinished (QNetworkReply *reply)
 

Private Member Functions

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

Private Attributes

DeviceAPIm_deviceAPI
 
QMutex m_mutex
 
RemoteInputSettings m_settings
 
RemoteInputUDPHandlerm_remoteInputUDPHandler
 
QString m_remoteAddress
 
QString m_deviceDescription
 
std::time_t m_startingTimeStamp
 
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 40 of file remoteinput.h.

Constructor & Destructor Documentation

◆ RemoteInput()

RemoteInput::RemoteInput ( DeviceAPI deviceAPI)

Definition at line 47 of file remoteinput.cpp.

References arg().

Referenced by RemoteInput::MsgStartStop::MsgStartStop().

47  :
48  m_deviceAPI(deviceAPI),
49  m_settings(),
53 {
54  m_sampleFifo.setSize(96000 * 4);
56 
57  m_fileSink = new FileRecord(QString("test_%1.sdriq").arg(m_deviceAPI->getDeviceUID()));
60 
61  m_networkManager = new QNetworkAccessManager();
62  connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
63 }
FileRecord * m_fileSink
File sink to record device I/Q output.
Definition: remoteinput.h:324
uint getDeviceUID() const
Return the current device engine unique ID.
Definition: deviceapi.cpp:303
void setNbSourceStreams(uint32_t nbSourceStreams)
Definition: deviceapi.h:168
RemoteInputSettings m_settings
Definition: remoteinput.h:319
QNetworkAccessManager * m_networkManager
Definition: remoteinput.h:325
RemoteInputUDPHandler * m_remoteInputUDPHandler
Definition: remoteinput.h:320
SampleSinkFifo m_sampleFifo
bool setSize(int size)
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
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
std::time_t m_startingTimeStamp
Definition: remoteinput.h:323
DeviceAPI * m_deviceAPI
Definition: remoteinput.h:317
QString m_deviceDescription
Definition: remoteinput.h:322
void networkManagerFinished(QNetworkReply *reply)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ~RemoteInput()

RemoteInput::~RemoteInput ( )
virtual

Definition at line 65 of file remoteinput.cpp.

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

Referenced by RemoteInput::MsgStartStop::MsgStartStop().

66 {
67  disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
68  delete m_networkManager;
69  stop();
71  delete m_fileSink;
73 }
FileRecord * m_fileSink
File sink to record device I/Q output.
Definition: remoteinput.h:324
QNetworkAccessManager * m_networkManager
Definition: remoteinput.h:325
RemoteInputUDPHandler * m_remoteInputUDPHandler
Definition: remoteinput.h:320
void removeAncillarySink(BasebandSampleSink *sink, unsigned int index=0)
Removes it.
Definition: deviceapi.cpp:100
virtual void stop()
Definition: remoteinput.cpp:92
DeviceAPI * m_deviceAPI
Definition: remoteinput.h:317
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 RemoteInput::applySettings ( const RemoteInputSettings settings,
bool  force = false 
)
private

Definition at line 226 of file remoteinput.cpp.

References DeviceAPI::configureCorrections(), RemoteInputUDPHandler::configureUDPLink(), RemoteInputUDPHandler::getRemoteAddress(), RemoteInputSettings::m_apiAddress, RemoteInputSettings::m_apiPort, RemoteInputSettings::m_dataAddress, RemoteInputSettings::m_dataPort, RemoteInputSettings::m_dcBlock, m_deviceAPI, RemoteInputSettings::m_fileRecordName, RemoteInputSettings::m_iqCorrection, m_mutex, m_remoteAddress, m_remoteInputUDPHandler, RemoteInputSettings::m_reverseAPIAddress, RemoteInputSettings::m_reverseAPIDeviceIndex, RemoteInputSettings::m_reverseAPIPort, m_settings, RemoteInputSettings::m_useReverseAPI, and webapiReverseSendSettings().

Referenced by handleMessage(), and init().

227 {
228  QMutexLocker mutexLocker(&m_mutex);
229  std::ostringstream os;
230  QString remoteAddress;
232  QList<QString> reverseAPIKeys;
233 
234  if ((m_settings.m_dcBlock != settings.m_dcBlock) || force) {
235  reverseAPIKeys.append("dcBlock");
236  }
237  if ((m_settings.m_iqCorrection != settings.m_iqCorrection) || force) {
238  reverseAPIKeys.append("iqCorrection");
239  }
240  if ((m_settings.m_dataAddress != settings.m_dataAddress) || force) {
241  reverseAPIKeys.append("dataAddress");
242  }
243  if ((m_settings.m_dataPort != settings.m_dataPort) || force) {
244  reverseAPIKeys.append("dataPort");
245  }
246  if ((m_settings.m_apiAddress != settings.m_apiAddress) || force) {
247  reverseAPIKeys.append("apiAddress");
248  }
249  if ((m_settings.m_apiPort != settings.m_apiPort) || force) {
250  reverseAPIKeys.append("apiPort");
251  }
252  if ((m_settings.m_fileRecordName != settings.m_fileRecordName) || force) {
253  reverseAPIKeys.append("fileRecordName");
254  }
255 
256  if ((m_settings.m_dcBlock != settings.m_dcBlock) || (m_settings.m_iqCorrection != settings.m_iqCorrection) || force)
257  {
259  qDebug("RemoteInput::applySettings: corrections: DC block: %s IQ imbalance: %s",
260  settings.m_dcBlock ? "true" : "false",
261  settings.m_iqCorrection ? "true" : "false");
262  }
263 
266 
267  mutexLocker.unlock();
268 
269  if (settings.m_useReverseAPI)
270  {
271  bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
275  webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
276  }
277 
278  m_settings = settings;
279  m_remoteAddress = remoteAddress;
280 
281  qDebug() << "RemoteInput::applySettings: "
282  << " m_dataAddress: " << m_settings.m_dataAddress
283  << " m_dataPort: " << m_settings.m_dataPort
284  << " m_apiAddress: " << m_settings.m_apiAddress
285  << " m_apiPort: " << m_settings.m_apiPort
286  << " m_remoteAddress: " << m_remoteAddress;
287 }
QMutex m_mutex
Definition: remoteinput.h:318
void getRemoteAddress(QString &s) const
RemoteInputSettings m_settings
Definition: remoteinput.h:319
RemoteInputUDPHandler * m_remoteInputUDPHandler
Definition: remoteinput.h:320
QString m_remoteAddress
Definition: remoteinput.h:321
void configureUDPLink(const QString &address, quint16 port)
DeviceAPI * m_deviceAPI
Definition: remoteinput.h:317
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection, int streamIndex=0)
Configure current device engine DSP corrections (Rx)
Definition: deviceapi.cpp:355
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const RemoteInputSettings &settings, bool force)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deserialize()

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

Implements DeviceSampleSource.

Definition at line 103 of file remoteinput.cpp.

References RemoteInput::MsgConfigureRemoteInput::create(), RemoteInputSettings::deserialize(), DeviceSampleSource::m_guiMessageQueue, DeviceSampleSource::m_inputMessageQueue, m_settings, MessageQueue::push(), and RemoteInputSettings::resetToDefaults().

Referenced by RemoteInput::MsgStartStop::MsgStartStop().

104 {
105  bool success = true;
106 
107  if (!m_settings.deserialize(data))
108  {
110  success = false;
111  }
112 
113  MsgConfigureRemoteInput* message = MsgConfigureRemoteInput::create(m_settings, true);
114  m_inputMessageQueue.push(message);
115 
116  if (m_guiMessageQueue)
117  {
118  MsgConfigureRemoteInput* messageToGUI = MsgConfigureRemoteInput::create(m_settings, true);
119  m_guiMessageQueue->push(messageToGUI);
120  }
121 
122  return success;
123 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
RemoteInputSettings m_settings
Definition: remoteinput.h:319
static MsgConfigureRemoteInput * create(const RemoteInputSettings &settings, bool force=false)
Definition: remoteinput.h:50
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
bool deserialize(const QByteArray &data)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ destroy()

void RemoteInput::destroy ( )
virtual

Implements DeviceSampleSource.

Definition at line 75 of file remoteinput.cpp.

Referenced by RemoteInput::MsgStartStop::MsgStartStop().

76 {
77  delete this;
78 }
+ Here is the caller graph for this function:

◆ getCenterFrequency()

quint64 RemoteInput::getCenterFrequency ( ) const
virtual

Center frequency exposed by the source.

Implements DeviceSampleSource.

Definition at line 141 of file remoteinput.cpp.

References RemoteInputUDPHandler::getCenterFrequency(), and m_remoteInputUDPHandler.

Referenced by setSampleRate().

142 {
144 }
RemoteInputUDPHandler * m_remoteInputUDPHandler
Definition: remoteinput.h:320
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDeviceDescription()

const QString & RemoteInput::getDeviceDescription ( ) const
virtual

Implements DeviceSampleSource.

Definition at line 131 of file remoteinput.cpp.

References m_deviceDescription.

Referenced by RemoteInput::MsgStartStop::MsgStartStop().

132 {
133  return m_deviceDescription;
134 }
QString m_deviceDescription
Definition: remoteinput.h:322
+ Here is the caller graph for this function:

◆ getSampleRate()

int RemoteInput::getSampleRate ( ) const
virtual

Sample rate exposed by the source.

Implements DeviceSampleSource.

Definition at line 136 of file remoteinput.cpp.

References RemoteInputUDPHandler::getSampleRate(), and m_remoteInputUDPHandler.

Referenced by RemoteInput::MsgStartStop::MsgStartStop().

137 {
139 }
RemoteInputUDPHandler * m_remoteInputUDPHandler
Definition: remoteinput.h:320
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStartingTimeStamp()

std::time_t RemoteInput::getStartingTimeStamp ( ) const

Definition at line 151 of file remoteinput.cpp.

References m_startingTimeStamp.

Referenced by setSampleRate().

152 {
153  return m_startingTimeStamp;
154 }
std::time_t m_startingTimeStamp
Definition: remoteinput.h:323
+ Here is the caller graph for this function:

◆ handleMessage()

bool RemoteInput::handleMessage ( const Message message)
virtual

Implements DeviceSampleSource.

Definition at line 161 of file remoteinput.cpp.

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

Referenced by setSampleRate().

162 {
163  if (DSPSignalNotification::match(message))
164  {
165  DSPSignalNotification& notif = (DSPSignalNotification&) message;
166  return m_fileSink->handleMessage(notif); // forward to file sink
167  }
168  else if (MsgFileRecord::match(message))
169  {
170  MsgFileRecord& conf = (MsgFileRecord&) message;
171  qDebug() << "RemoteInput::handleMessage: MsgFileRecord: " << conf.getStartStop();
172 
173  if (conf.getStartStop())
174  {
175  if (m_settings.m_fileRecordName.size() != 0) {
177  } else {
179  }
180 
182  }
183  else
184  {
186  }
187 
188  return true;
189  }
190  else if (MsgStartStop::match(message))
191  {
192  MsgStartStop& cmd = (MsgStartStop&) message;
193  qDebug() << "RemoteInput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
194 
195  if (cmd.getStartStop())
196  {
198  {
200  }
201  }
202  else
203  {
205  }
206 
208  webapiReverseSendStartStop(cmd.getStartStop());
209  }
210 
211  return true;
212  }
213  else if (MsgConfigureRemoteInput::match(message))
214  {
215  qDebug() << "RemoteInput::handleMessage:" << message.getIdentifier();
216  MsgConfigureRemoteInput& conf = (MsgConfigureRemoteInput&) message;
217  applySettings(conf.getSettings(), conf.getForce());
218  return true;
219  }
220  else
221  {
222  return false;
223  }
224 }
FileRecord * m_fileSink
File sink to record device I/Q output.
Definition: remoteinput.h:324
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 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
void applySettings(const RemoteInputSettings &settings, bool force=false)
RemoteInputSettings m_settings
Definition: remoteinput.h:319
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 genUniqueFileName(uint deviceUID, int istream=-1)
Definition: filerecord.cpp:67
void stopRecording()
Definition: filerecord.cpp:117
static bool match(const Message *message)
Definition: message.cpp:45
DeviceAPI * m_deviceAPI
Definition: remoteinput.h:317
virtual const char * getIdentifier() const
Definition: message.cpp:35
void webapiReverseSendStartStop(bool start)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

void RemoteInput::init ( )
virtual

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

Implements DeviceSampleSource.

Definition at line 80 of file remoteinput.cpp.

References applySettings(), and m_settings.

Referenced by RemoteInput::MsgStartStop::MsgStartStop().

81 {
83 }
void applySettings(const RemoteInputSettings &settings, bool force=false)
RemoteInputSettings m_settings
Definition: remoteinput.h:319
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isStreaming()

bool RemoteInput::isStreaming ( ) const

Definition at line 156 of file remoteinput.cpp.

References RemoteInputUDPHandler::isStreaming(), and m_remoteInputUDPHandler.

Referenced by setSampleRate(), and RemoteInputGui::updateStatus().

157 {
159 }
RemoteInputUDPHandler * m_remoteInputUDPHandler
Definition: remoteinput.h:320
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ networkManagerFinished

void RemoteInput::networkManagerFinished ( QNetworkReply *  reply)
privateslot

Definition at line 514 of file remoteinput.cpp.

Referenced by ~RemoteInput().

515 {
516  QNetworkReply::NetworkError replyError = reply->error();
517 
518  if (replyError)
519  {
520  qWarning() << "RemoteInput::networkManagerFinished:"
521  << " error(" << (int) replyError
522  << "): " << replyError
523  << ": " << reply->errorString();
524  return;
525  }
526 
527  QString answer = reply->readAll();
528  answer.chop(1); // remove last \n
529  qDebug("RemoteInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
530 }
+ Here is the caller graph for this function:

◆ serialize()

QByteArray RemoteInput::serialize ( ) const
virtual

Implements DeviceSampleSource.

Definition at line 98 of file remoteinput.cpp.

References m_settings, and RemoteInputSettings::serialize().

Referenced by RemoteInput::MsgStartStop::MsgStartStop().

99 {
100  return m_settings.serialize();
101 }
RemoteInputSettings m_settings
Definition: remoteinput.h:319
QByteArray serialize() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCenterFrequency()

void RemoteInput::setCenterFrequency ( qint64  centerFrequency)
virtual

Implements DeviceSampleSource.

Definition at line 146 of file remoteinput.cpp.

Referenced by setSampleRate().

147 {
148  (void) centerFrequency;
149 }
+ Here is the caller graph for this function:

◆ setMessageQueueToGUI()

void RemoteInput::setMessageQueueToGUI ( MessageQueue queue)
virtual

Implements DeviceSampleSource.

Definition at line 125 of file remoteinput.cpp.

References DeviceSampleSource::m_guiMessageQueue, m_remoteInputUDPHandler, and RemoteInputUDPHandler::setMessageQueueToGUI().

Referenced by RemoteInput::MsgStartStop::MsgStartStop(), and RemoteInputGui::RemoteInputGui().

126 {
127  m_guiMessageQueue = queue;
129 }
void setMessageQueueToGUI(MessageQueue *queue)
RemoteInputUDPHandler * m_remoteInputUDPHandler
Definition: remoteinput.h:320
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:

◆ setSampleRate()

virtual void RemoteInput::setSampleRate ( int  sampleRate)
inlinevirtual

For when the source sample rate is set externally.

Implements DeviceSampleSource.

Definition at line 285 of file remoteinput.h.

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

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

◆ start()

bool RemoteInput::start ( )
virtual

Implements DeviceSampleSource.

Definition at line 85 of file remoteinput.cpp.

References m_remoteInputUDPHandler, and RemoteInputUDPHandler::start().

Referenced by RemoteInput::MsgStartStop::MsgStartStop().

86 {
87  qDebug() << "RemoteInput::start";
89  return true;
90 }
RemoteInputUDPHandler * m_remoteInputUDPHandler
Definition: remoteinput.h:320
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop()

void RemoteInput::stop ( )
virtual

Implements DeviceSampleSource.

Definition at line 92 of file remoteinput.cpp.

References m_remoteInputUDPHandler, and RemoteInputUDPHandler::stop().

Referenced by RemoteInput::MsgStartStop::MsgStartStop(), and ~RemoteInput().

93 {
94  qDebug() << "RemoteInput::stop";
96 }
RemoteInputUDPHandler * m_remoteInputUDPHandler
Definition: remoteinput.h:320
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatDeviceReport()

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

Definition at line 422 of file remoteinput.cpp.

References RemoteInputUDPHandler::getBufferGauge(), RemoteInputUDPHandler::getCenterFrequency(), RemoteInputUDPHandler::getMaxNbRecovery(), RemoteInputUDPHandler::getMinNbBlocks(), SWGSDRangel::SWGDeviceReport::getRemoteInputReport(), RemoteInputUDPHandler::getSampleRate(), RemoteInputUDPHandler::getTVmSec(), m_remoteInputUDPHandler, SWGSDRangel::SWGRemoteInputReport::setBufferRwBalance(), SWGSDRangel::SWGRemoteInputReport::setCenterFrequency(), SWGSDRangel::SWGRemoteInputReport::setMaxNbRecovery(), SWGSDRangel::SWGRemoteInputReport::setMinNbBlocks(), SWGSDRangel::SWGRemoteInputReport::setRemoteTimestamp(), and SWGSDRangel::SWGRemoteInputReport::setSampleRate().

Referenced by webapiReportGet().

423 {
427 
428  QDateTime dt = QDateTime::fromMSecsSinceEpoch(m_remoteInputUDPHandler->getTVmSec());
429  response.getRemoteInputReport()->setRemoteTimestamp(new QString(dt.toString("yyyy-MM-dd HH:mm:ss.zzz")));
430 
433 }
void setMinNbBlocks(qint32 min_nb_blocks)
void setRemoteTimestamp(QString *remote_timestamp)
SWGRemoteInputReport * getRemoteInputReport()
RemoteInputUDPHandler * m_remoteInputUDPHandler
Definition: remoteinput.h:320
void setCenterFrequency(qint32 center_frequency)
void setMaxNbRecovery(qint32 max_nb_recovery)
void setBufferRwBalance(qint32 buffer_rw_balance)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatDeviceSettings()

void RemoteInput::webapiFormatDeviceSettings ( SWGSDRangel::SWGDeviceSettings response,
const RemoteInputSettings settings 
)
private

Definition at line 384 of file remoteinput.cpp.

References SWGSDRangel::SWGRemoteInputSettings::getFileRecordName(), SWGSDRangel::SWGDeviceSettings::getRemoteInputSettings(), SWGSDRangel::SWGRemoteInputSettings::getReverseApiAddress(), RemoteInputSettings::m_apiAddress, RemoteInputSettings::m_apiPort, RemoteInputSettings::m_dataAddress, RemoteInputSettings::m_dataPort, RemoteInputSettings::m_dcBlock, RemoteInputSettings::m_fileRecordName, RemoteInputSettings::m_iqCorrection, RemoteInputSettings::m_reverseAPIAddress, RemoteInputSettings::m_reverseAPIDeviceIndex, RemoteInputSettings::m_reverseAPIPort, RemoteInputSettings::m_useReverseAPI, SWGSDRangel::SWGRemoteInputSettings::setApiAddress(), SWGSDRangel::SWGRemoteInputSettings::setApiPort(), SWGSDRangel::SWGRemoteInputSettings::setDataAddress(), SWGSDRangel::SWGRemoteInputSettings::setDataPort(), SWGSDRangel::SWGRemoteInputSettings::setDcBlock(), SWGSDRangel::SWGRemoteInputSettings::setFileRecordName(), SWGSDRangel::SWGRemoteInputSettings::setIqCorrection(), SWGSDRangel::SWGRemoteInputSettings::setReverseApiAddress(), SWGSDRangel::SWGRemoteInputSettings::setReverseApiDeviceIndex(), SWGSDRangel::SWGRemoteInputSettings::setReverseApiPort(), and SWGSDRangel::SWGRemoteInputSettings::setUseReverseApi().

Referenced by webapiSettingsGet(), and webapiSettingsPutPatch().

385 {
386  response.getRemoteInputSettings()->setApiAddress(new QString(settings.m_apiAddress));
387  response.getRemoteInputSettings()->setApiPort(settings.m_apiPort);
388  response.getRemoteInputSettings()->setDataAddress(new QString(settings.m_dataAddress));
389  response.getRemoteInputSettings()->setDataPort(settings.m_dataPort);
390  response.getRemoteInputSettings()->setDcBlock(settings.m_dcBlock ? 1 : 0);
392 
393  if (response.getRemoteInputSettings()->getFileRecordName()) {
395  } else {
396  response.getRemoteInputSettings()->setFileRecordName(new QString(settings.m_fileRecordName));
397  }
398 
399  response.getRemoteInputSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
400 
401  if (response.getRemoteInputSettings()->getReverseApiAddress()) {
403  } else {
404  response.getRemoteInputSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
405  }
406 
409 }
void setDataAddress(QString *data_address)
void setReverseApiPort(qint32 reverse_api_port)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setUseReverseApi(qint32 use_reverse_api)
void setFileRecordName(QString *file_record_name)
SWGRemoteInputSettings * getRemoteInputSettings()
void setReverseApiAddress(QString *reverse_api_address)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReportGet()

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

Reimplemented from DeviceSampleSource.

Definition at line 411 of file remoteinput.cpp.

References SWGSDRangel::SWGDeviceReport::getRemoteInputReport(), SWGSDRangel::SWGRemoteInputReport::init(), SWGSDRangel::SWGDeviceReport::setRemoteInputReport(), and webapiFormatDeviceReport().

Referenced by setSampleRate().

414 {
415  (void) errorMessage;
417  response.getRemoteInputReport()->init();
418  webapiFormatDeviceReport(response);
419  return 200;
420 }
void setRemoteInputReport(SWGRemoteInputReport *remote_input_report)
SWGRemoteInputReport * getRemoteInputReport()
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport &response)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendSettings()

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

Definition at line 435 of file remoteinput.cpp.

References SWGSDRangel::SWGDeviceSettings::asJson(), DeviceAPI::getDeviceSetIndex(), SWGSDRangel::SWGDeviceSettings::getRemoteInputSettings(), RemoteInputSettings::m_apiAddress, RemoteInputSettings::m_apiPort, RemoteInputSettings::m_dataAddress, RemoteInputSettings::m_dataPort, RemoteInputSettings::m_dcBlock, m_deviceAPI, RemoteInputSettings::m_fileRecordName, RemoteInputSettings::m_iqCorrection, m_networkManager, m_networkRequest, RemoteInputSettings::m_reverseAPIAddress, RemoteInputSettings::m_reverseAPIDeviceIndex, RemoteInputSettings::m_reverseAPIPort, SWGSDRangel::SWGRemoteInputSettings::setApiAddress(), SWGSDRangel::SWGRemoteInputSettings::setApiPort(), SWGSDRangel::SWGRemoteInputSettings::setDataAddress(), SWGSDRangel::SWGRemoteInputSettings::setDataPort(), SWGSDRangel::SWGRemoteInputSettings::setDcBlock(), SWGSDRangel::SWGDeviceSettings::setDeviceHwType(), SWGSDRangel::SWGDeviceSettings::setDirection(), SWGSDRangel::SWGRemoteInputSettings::setFileRecordName(), SWGSDRangel::SWGRemoteInputSettings::setIqCorrection(), SWGSDRangel::SWGDeviceSettings::setOriginatorIndex(), and SWGSDRangel::SWGDeviceSettings::setRemoteInputSettings().

Referenced by applySettings().

436 {
438  swgDeviceSettings->setDirection(0); // single Rx
439  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
440  swgDeviceSettings->setDeviceHwType(new QString("RemoteInput"));
442  SWGSDRangel::SWGRemoteInputSettings *swgRemoteInputSettings = swgDeviceSettings->getRemoteInputSettings();
443 
444  // transfer data that has been modified. When force is on transfer all data except reverse API data
445 
446  if (deviceSettingsKeys.contains("apiAddress") || force) {
447  swgRemoteInputSettings->setApiAddress(new QString(settings.m_apiAddress));
448  }
449  if (deviceSettingsKeys.contains("apiPort") || force) {
450  swgRemoteInputSettings->setApiPort(settings.m_apiPort);
451  }
452  if (deviceSettingsKeys.contains("dataAddress") || force) {
453  swgRemoteInputSettings->setDataAddress(new QString(settings.m_dataAddress));
454  }
455  if (deviceSettingsKeys.contains("dataPort") || force) {
456  swgRemoteInputSettings->setDataPort(settings.m_dataPort);
457  }
458  if (deviceSettingsKeys.contains("dcBlock") || force) {
459  swgRemoteInputSettings->setDcBlock(settings.m_dcBlock ? 1 : 0);
460  }
461  if (deviceSettingsKeys.contains("iqCorrection") || force) {
462  swgRemoteInputSettings->setIqCorrection(settings.m_iqCorrection ? 1 : 0);
463  }
464  if (deviceSettingsKeys.contains("fileRecordName") || force) {
465  swgRemoteInputSettings->setFileRecordName(new QString(settings.m_fileRecordName));
466  }
467 
468  QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/settings")
469  .arg(settings.m_reverseAPIAddress)
470  .arg(settings.m_reverseAPIPort)
471  .arg(settings.m_reverseAPIDeviceIndex);
472  m_networkRequest.setUrl(QUrl(deviceSettingsURL));
473  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
474 
475  QBuffer *buffer=new QBuffer();
476  buffer->open((QBuffer::ReadWrite));
477  buffer->write(swgDeviceSettings->asJson().toUtf8());
478  buffer->seek(0);
479 
480  // Always use PATCH to avoid passing reverse API settings
481  m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
482 
483  delete swgDeviceSettings;
484 }
void setDataAddress(QString *data_address)
virtual QString asJson() override
QNetworkRequest m_networkRequest
Definition: remoteinput.h:326
QNetworkAccessManager * m_networkManager
Definition: remoteinput.h:325
void setOriginatorIndex(qint32 originator_index)
int getDeviceSetIndex() const
Definition: deviceapi.h:131
void setRemoteInputSettings(SWGRemoteInputSettings *remote_input_settings)
DeviceAPI * m_deviceAPI
Definition: remoteinput.h:317
void setFileRecordName(QString *file_record_name)
SWGRemoteInputSettings * getRemoteInputSettings()
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 RemoteInput::webapiReverseSendStartStop ( bool  start)
private

Definition at line 486 of file remoteinput.cpp.

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

Referenced by handleMessage().

487 {
489  swgDeviceSettings->setDirection(0); // single Rx
490  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
491  swgDeviceSettings->setDeviceHwType(new QString("RemoteInput"));
492 
493  QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
497  m_networkRequest.setUrl(QUrl(deviceSettingsURL));
498  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
499 
500  QBuffer *buffer=new QBuffer();
501  buffer->open((QBuffer::ReadWrite));
502  buffer->write(swgDeviceSettings->asJson().toUtf8());
503  buffer->seek(0);
504 
505  if (start) {
506  m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
507  } else {
508  m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
509  }
510 
511  delete swgDeviceSettings;
512 }
RemoteInputSettings m_settings
Definition: remoteinput.h:319
virtual QString asJson() override
QNetworkRequest m_networkRequest
Definition: remoteinput.h:326
QNetworkAccessManager * m_networkManager
Definition: remoteinput.h:325
void setOriginatorIndex(qint32 originator_index)
int getDeviceSetIndex() const
Definition: deviceapi.h:131
virtual bool start()
Definition: remoteinput.cpp:85
DeviceAPI * m_deviceAPI
Definition: remoteinput.h:317
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 RemoteInput::webapiRun ( bool  run,
SWGSDRangel::SWGDeviceState response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSource.

Definition at line 298 of file remoteinput.cpp.

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

Referenced by setSampleRate().

302 {
303  (void) errorMessage;
305  MsgStartStop *message = MsgStartStop::create(run);
306  m_inputMessageQueue.push(message);
307 
308  if (m_guiMessageQueue) // forward to GUI if any
309  {
310  MsgStartStop *msgToGUI = MsgStartStop::create(run);
311  m_guiMessageQueue->push(msgToGUI);
312  }
313 
314  return 200;
315 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
static MsgStartStop * create(bool startStop)
Definition: remoteinput.h:258
void getDeviceEngineStateStr(QString &state)
Definition: deviceapi.cpp:389
DeviceAPI * m_deviceAPI
Definition: remoteinput.h:317
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiRunGet()

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

Reimplemented from DeviceSampleSource.

Definition at line 289 of file remoteinput.cpp.

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

Referenced by setSampleRate().

292 {
293  (void) errorMessage;
295  return 200;
296 }
void getDeviceEngineStateStr(QString &state)
Definition: deviceapi.cpp:389
DeviceAPI * m_deviceAPI
Definition: remoteinput.h:317
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsGet()

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

Reimplemented from DeviceSampleSource.

Definition at line 317 of file remoteinput.cpp.

References SWGSDRangel::SWGDeviceSettings::getRemoteInputSettings(), SWGSDRangel::SWGRemoteInputSettings::init(), m_settings, SWGSDRangel::SWGDeviceSettings::setRemoteInputSettings(), and webapiFormatDeviceSettings().

Referenced by setSampleRate().

320 {
321  (void) errorMessage;
323  response.getRemoteInputSettings()->init();
325  return 200;
326 }
RemoteInputSettings m_settings
Definition: remoteinput.h:319
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const RemoteInputSettings &settings)
void setRemoteInputSettings(SWGRemoteInputSettings *remote_input_settings)
SWGRemoteInputSettings * getRemoteInputSettings()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsPutPatch()

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

Reimplemented from DeviceSampleSource.

Definition at line 328 of file remoteinput.cpp.

References RemoteInput::MsgConfigureRemoteInput::create(), SWGSDRangel::SWGRemoteInputSettings::getApiAddress(), SWGSDRangel::SWGRemoteInputSettings::getApiPort(), SWGSDRangel::SWGRemoteInputSettings::getDataAddress(), SWGSDRangel::SWGRemoteInputSettings::getDataPort(), SWGSDRangel::SWGRemoteInputSettings::getDcBlock(), SWGSDRangel::SWGRemoteInputSettings::getFileRecordName(), SWGSDRangel::SWGRemoteInputSettings::getIqCorrection(), SWGSDRangel::SWGDeviceSettings::getRemoteInputSettings(), SWGSDRangel::SWGRemoteInputSettings::getReverseApiAddress(), SWGSDRangel::SWGRemoteInputSettings::getReverseApiDeviceIndex(), SWGSDRangel::SWGRemoteInputSettings::getReverseApiPort(), SWGSDRangel::SWGRemoteInputSettings::getUseReverseApi(), RemoteInputSettings::m_apiAddress, RemoteInputSettings::m_apiPort, RemoteInputSettings::m_dataAddress, RemoteInputSettings::m_dataPort, RemoteInputSettings::m_dcBlock, RemoteInputSettings::m_fileRecordName, DeviceSampleSource::m_guiMessageQueue, DeviceSampleSource::m_inputMessageQueue, RemoteInputSettings::m_iqCorrection, RemoteInputSettings::m_reverseAPIAddress, RemoteInputSettings::m_reverseAPIDeviceIndex, RemoteInputSettings::m_reverseAPIPort, m_settings, RemoteInputSettings::m_useReverseAPI, MessageQueue::push(), and webapiFormatDeviceSettings().

Referenced by setSampleRate().

333 {
334  (void) errorMessage;
335  RemoteInputSettings settings = m_settings;
336 
337  if (deviceSettingsKeys.contains("apiAddress")) {
338  settings.m_apiAddress = *response.getRemoteInputSettings()->getApiAddress();
339  }
340  if (deviceSettingsKeys.contains("apiPort")) {
341  settings.m_apiPort = response.getRemoteInputSettings()->getApiPort();
342  }
343  if (deviceSettingsKeys.contains("dataAddress")) {
344  settings.m_dataAddress = *response.getRemoteInputSettings()->getDataAddress();
345  }
346  if (deviceSettingsKeys.contains("dataPort")) {
347  settings.m_dataPort = response.getRemoteInputSettings()->getDataPort();
348  }
349  if (deviceSettingsKeys.contains("dcBlock")) {
350  settings.m_dcBlock = response.getRemoteInputSettings()->getDcBlock() != 0;
351  }
352  if (deviceSettingsKeys.contains("iqCorrection")) {
353  settings.m_iqCorrection = response.getRemoteInputSettings()->getIqCorrection() != 0;
354  }
355  if (deviceSettingsKeys.contains("fileRecordName")) {
357  }
358  if (deviceSettingsKeys.contains("useReverseAPI")) {
359  settings.m_useReverseAPI = response.getRemoteInputSettings()->getUseReverseApi() != 0;
360  }
361  if (deviceSettingsKeys.contains("reverseAPIAddress")) {
363  }
364  if (deviceSettingsKeys.contains("reverseAPIPort")) {
366  }
367  if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
369  }
370 
371  MsgConfigureRemoteInput *msg = MsgConfigureRemoteInput::create(settings, force);
373 
374  if (m_guiMessageQueue) // forward to GUI if any
375  {
376  MsgConfigureRemoteInput *msgToGUI = MsgConfigureRemoteInput::create(settings, force);
377  m_guiMessageQueue->push(msgToGUI);
378  }
379 
380  webapiFormatDeviceSettings(response, settings);
381  return 200;
382 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
RemoteInputSettings m_settings
Definition: remoteinput.h:319
static MsgConfigureRemoteInput * create(const RemoteInputSettings &settings, bool force=false)
Definition: remoteinput.h:50
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const RemoteInputSettings &settings)
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
SWGRemoteInputSettings * getRemoteInputSettings()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_deviceAPI

DeviceAPI* RemoteInput::m_deviceAPI
private

◆ m_deviceDescription

QString RemoteInput::m_deviceDescription
private

Definition at line 322 of file remoteinput.h.

Referenced by getDeviceDescription().

◆ m_fileSink

FileRecord* RemoteInput::m_fileSink
private

File sink to record device I/Q output.

Definition at line 324 of file remoteinput.h.

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

◆ m_mutex

QMutex RemoteInput::m_mutex
private

Definition at line 318 of file remoteinput.h.

Referenced by applySettings().

◆ m_networkManager

QNetworkAccessManager* RemoteInput::m_networkManager
private

◆ m_networkRequest

QNetworkRequest RemoteInput::m_networkRequest
private

Definition at line 326 of file remoteinput.h.

Referenced by webapiReverseSendSettings(), and webapiReverseSendStartStop().

◆ m_remoteAddress

QString RemoteInput::m_remoteAddress
private

Definition at line 321 of file remoteinput.h.

Referenced by applySettings().

◆ m_remoteInputUDPHandler

RemoteInputUDPHandler* RemoteInput::m_remoteInputUDPHandler
private

◆ m_settings

RemoteInputSettings RemoteInput::m_settings
private

◆ m_startingTimeStamp

std::time_t RemoteInput::m_startingTimeStamp
private

Definition at line 323 of file remoteinput.h.

Referenced by getStartingTimeStamp().


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