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

#include <testsourceinput.h>

+ Inheritance diagram for TestSourceInput:
+ Collaboration diagram for TestSourceInput:

Classes

class  MsgConfigureTestSource
 
class  MsgFileRecord
 
class  MsgStartStop
 

Public Member Functions

 TestSourceInput (DeviceAPI *deviceAPI)
 
virtual ~TestSourceInput ()
 
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 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 ()
 
virtual int webapiReportGet (SWGSDRangel::SWGDeviceReport &response, QString &errorMessage)
 
MessageQueuegetInputMessageQueue ()
 
MessageQueuegetMessageQueueToGUI ()
 
SampleSinkFifogetSampleFifo ()
 

Private Slots

void networkManagerFinished (QNetworkReply *reply)
 

Private Member Functions

bool applySettings (const TestSourceSettings &settings, bool force)
 
void webapiFormatDeviceSettings (SWGSDRangel::SWGDeviceSettings &response, const TestSourceSettings &settings)
 
void webapiReverseSendSettings (QList< QString > &deviceSettingsKeys, const TestSourceSettings &settings, bool force)
 
void webapiReverseSendStartStop (bool start)
 

Private Attributes

DeviceAPIm_deviceAPI
 
FileRecordm_fileSink
 File sink to record device I/Q output. More...
 
QMutex m_mutex
 
TestSourceSettings m_settings
 
TestSourceThreadm_testSourceThread
 
QString m_deviceDescription
 
bool m_running
 
const QTimer & m_masterTimer
 
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 35 of file testsourceinput.h.

Constructor & Destructor Documentation

◆ TestSourceInput()

TestSourceInput::TestSourceInput ( DeviceAPI deviceAPI)

Definition at line 41 of file testsourceinput.cpp.

References arg().

Referenced by TestSourceInput::MsgStartStop::MsgStartStop().

41  :
42  m_deviceAPI(deviceAPI),
43  m_settings(),
46  m_running(false),
47  m_masterTimer(deviceAPI->getMasterTimer())
48 {
49  m_fileSink = new FileRecord(QString("test_%1.sdriq").arg(m_deviceAPI->getDeviceUID()));
52 
53  if (!m_sampleFifo.setSize(96000 * 4)) {
54  qCritical("TestSourceInput::TestSourceInput: Could not allocate SampleFifo");
55  }
56 
57  m_networkManager = new QNetworkAccessManager();
58  connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
59 }
uint getDeviceUID() const
Return the current device engine unique ID.
Definition: deviceapi.cpp:303
void setNbSourceStreams(uint32_t nbSourceStreams)
Definition: deviceapi.h:168
const QTimer & m_masterTimer
const QTimer & getMasterTimer() const
This is the DSPEngine master timer.
Definition: deviceapi.h:173
void networkManagerFinished(QNetworkReply *reply)
SampleSinkFifo m_sampleFifo
bool setSize(int size)
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
QNetworkAccessManager * m_networkManager
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
TestSourceThread * m_testSourceThread
TestSourceSettings m_settings
FileRecord * m_fileSink
File sink to record device I/Q output.
DeviceAPI * m_deviceAPI
QString m_deviceDescription
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ~TestSourceInput()

TestSourceInput::~TestSourceInput ( )
virtual

Definition at line 61 of file testsourceinput.cpp.

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

Referenced by TestSourceInput::MsgStartStop::MsgStartStop().

62 {
63  disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
64  delete m_networkManager;
65 
66  if (m_running) {
67  stop();
68  }
69 
71  delete m_fileSink;
72 }
void networkManagerFinished(QNetworkReply *reply)
virtual void stop()
QNetworkAccessManager * m_networkManager
void removeAncillarySink(BasebandSampleSink *sink, unsigned int index=0)
Removes it.
Definition: deviceapi.cpp:100
FileRecord * m_fileSink
File sink to record device I/Q output.
DeviceAPI * m_deviceAPI
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ applySettings()

bool TestSourceInput::applySettings ( const TestSourceSettings settings,
bool  force 
)
private

Definition at line 240 of file testsourceinput.cpp.

References TestSourceSettings::AutoCorrDC, TestSourceSettings::AutoCorrDCAndIQ, TestSourceSettings::AutoCorrNone, DeviceSampleSource::calculateDeviceCenterFrequency(), DeviceSampleSource::calculateFrequencyShift(), DeviceAPI::configureCorrections(), DeviceSampleSource::FSHIFT_STD, DeviceAPI::getDeviceEngineInputMessageQueue(), FileRecord::handleMessage(), TestSourceSettings::m_amModulation, TestSourceSettings::m_amplitudeBits, TestSourceSettings::m_autoCorrOptions, TestSourceSettings::m_centerFrequency, TestSourceSettings::m_dcFactor, m_deviceAPI, TestSourceSettings::m_fcPos, m_fileSink, TestSourceSettings::m_fmDeviation, TestSourceSettings::m_frequencyShift, TestSourceSettings::m_iFactor, TestSourceSettings::m_log2Decim, TestSourceSettings::m_modulation, TestSourceSettings::m_modulationTone, TestSourceSettings::m_phaseImbalance, TestSourceSettings::m_qFactor, TestSourceSettings::m_reverseAPIAddress, TestSourceSettings::m_reverseAPIDeviceIndex, TestSourceSettings::m_reverseAPIPort, TestSourceSettings::m_sampleRate, TestSourceSettings::m_sampleSizeIndex, m_settings, m_testSourceThread, TestSourceSettings::m_useReverseAPI, TestSourceSettings::ModulationPattern0, TestSourceSettings::ModulationPattern1, TestSourceSettings::ModulationPattern2, MessageQueue::push(), TestSourceThread::setAMModulation(), TestSourceThread::setAmplitudeBits(), TestSourceThread::setBitSize(), TestSourceThread::setDCFactor(), TestSourceThread::setFcPos(), TestSourceThread::setFMDeviation(), TestSourceThread::setFrequencyShift(), TestSourceThread::setIFactor(), TestSourceThread::setLog2Decimation(), TestSourceThread::setModulation(), TestSourceThread::setPattern0(), TestSourceThread::setPattern1(), TestSourceThread::setPattern2(), TestSourceThread::setPhaseImbalance(), TestSourceThread::setQFactor(), TestSourceThread::setSamplerate(), TestSourceThread::setToneFrequency(), and webapiReverseSendSettings().

Referenced by handleMessage(), init(), and start().

241 {
242  QList<QString> reverseAPIKeys;
243 
244  if ((m_settings.m_autoCorrOptions != settings.m_autoCorrOptions) || force)
245  {
246  reverseAPIKeys.append("autoCorrOptions");
247 
248  switch(settings.m_autoCorrOptions)
249  {
251  m_deviceAPI->configureCorrections(true, false);
252  break;
254  m_deviceAPI->configureCorrections(true, true);
255  break;
257  default:
258  m_deviceAPI->configureCorrections(false, false);
259  break;
260  }
261  }
262 
263  if ((m_settings.m_sampleRate != settings.m_sampleRate) || force)
264  {
265  reverseAPIKeys.append("sampleRate");
266 
267  if (m_testSourceThread != 0)
268  {
270  qDebug("TestSourceInput::applySettings: sample rate set to %d", settings.m_sampleRate);
271  }
272  }
273 
274  if ((m_settings.m_log2Decim != settings.m_log2Decim) || force)
275  {
276  reverseAPIKeys.append("log2Decim");
277 
278  if (m_testSourceThread != 0)
279  {
281  qDebug() << "TestSourceInput::applySettings: set decimation to " << (1<<settings.m_log2Decim);
282  }
283  }
284 
286  || (m_settings.m_fcPos != settings.m_fcPos)
288  || (m_settings.m_sampleRate != settings.m_sampleRate)
289  || (m_settings.m_log2Decim != settings.m_log2Decim) || force)
290  {
291  reverseAPIKeys.append("centerFrequency");
292  reverseAPIKeys.append("fcPos");
293  reverseAPIKeys.append("frequencyShift");
294 
295  qint64 deviceCenterFrequency = DeviceSampleSource::calculateDeviceCenterFrequency(
296  settings.m_centerFrequency,
297  0, // no transverter mode
298  settings.m_log2Decim,
300  settings.m_sampleRate,
301  DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
302  false);
303 
304  int frequencyShift = settings.m_frequencyShift;
305  quint32 devSampleRate = settings.m_sampleRate;
306 
307  if (settings.m_log2Decim != 0)
308  {
310  settings.m_log2Decim,
312  settings.m_sampleRate,
314  }
315 
316  if (m_testSourceThread != 0)
317  {
318  m_testSourceThread->setFcPos((int) settings.m_fcPos);
319  m_testSourceThread->setFrequencyShift(frequencyShift);
320  qDebug() << "TestSourceInput::applySettings:"
321  << " center freq: " << settings.m_centerFrequency << " Hz"
322  << " device center freq: " << deviceCenterFrequency << " Hz"
323  << " device sample rate: " << devSampleRate << "Hz"
324  << " Actual sample rate: " << devSampleRate/(1<<m_settings.m_log2Decim) << "Hz"
325  << " f shift: " << settings.m_frequencyShift;
326  }
327  }
328 
329  if ((m_settings.m_amplitudeBits != settings.m_amplitudeBits) || force)
330  {
331  reverseAPIKeys.append("amplitudeBits");
332 
333  if (m_testSourceThread != 0) {
335  }
336  }
337 
338  if ((m_settings.m_dcFactor != settings.m_dcFactor) || force)
339  {
340  reverseAPIKeys.append("dcFactor");
341 
342  if (m_testSourceThread != 0) {
344  }
345  }
346 
347  if ((m_settings.m_iFactor != settings.m_iFactor) || force)
348  {
349  reverseAPIKeys.append("iFactor");
350 
351  if (m_testSourceThread != 0) {
353  }
354  }
355 
356  if ((m_settings.m_qFactor != settings.m_qFactor) || force)
357  {
358  reverseAPIKeys.append("qFactor");
359 
360  if (m_testSourceThread != 0) {
362  }
363  }
364 
365  if ((m_settings.m_phaseImbalance != settings.m_phaseImbalance) || force)
366  {
367  reverseAPIKeys.append("phaseImbalance");
368 
369  if (m_testSourceThread != 0) {
371  }
372  }
373 
374  if ((m_settings.m_sampleSizeIndex != settings.m_sampleSizeIndex) || force)
375  {
376  reverseAPIKeys.append("sampleSizeIndex");
377 
378  if (m_testSourceThread != 0) {
380  }
381  }
382 
383  if ((m_settings.m_sampleRate != settings.m_sampleRate)
385  || (m_settings.m_log2Decim != settings.m_log2Decim)
386  || (m_settings.m_fcPos != settings.m_fcPos) || force)
387  {
388  int sampleRate = settings.m_sampleRate/(1<<settings.m_log2Decim);
389  DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, settings.m_centerFrequency);
390  m_fileSink->handleMessage(*notif); // forward to file sink
392  }
393 
394  if ((m_settings.m_modulationTone != settings.m_modulationTone) || force)
395  {
396  reverseAPIKeys.append("modulationTone");
397 
398  if (m_testSourceThread != 0) {
400  }
401  }
402 
403  if ((m_settings.m_modulation != settings.m_modulation) || force)
404  {
405  reverseAPIKeys.append("modulation");
406 
407  if (m_testSourceThread != 0)
408  {
410 
413  } else if (settings.m_modulation == TestSourceSettings::ModulationPattern1) {
415  } else if (settings.m_modulation == TestSourceSettings::ModulationPattern2) {
417  }
418  }
419  }
420 
421  if ((m_settings.m_amModulation != settings.m_amModulation) || force)
422  {
423  reverseAPIKeys.append("amModulation");
424 
425  if (m_testSourceThread != 0) {
427  }
428  }
429 
430  if ((m_settings.m_fmDeviation != settings.m_fmDeviation) || force)
431  {
432  reverseAPIKeys.append("fmDeviation");
433 
434  if (m_testSourceThread != 0) {
435  m_testSourceThread->setFMDeviation(settings.m_fmDeviation * 100.0f);
436  }
437  }
438 
439  if (settings.m_useReverseAPI)
440  {
441  qDebug("TestSourceInput::applySettings: call webapiReverseSendSettings");
442  bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
446  webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
447  }
448 
449  m_settings = settings;
450  return true;
451 }
static qint32 calculateFrequencyShift(int log2Decim, fcPos_t fcPos, quint32 devSampleRate, FrequencyShiftScheme frequencyShiftScheme)
static qint64 calculateDeviceCenterFrequency(quint64 centerFrequency, qint64 transverterDeltaFrequency, int log2Decim, fcPos_t fcPos, quint32 devSampleRate, FrequencyShiftScheme frequencyShiftScheme, bool transverterMode=false)
void push(Message *message, bool emitSignal=true)
Push message onto queue.
void setPhaseImbalance(float phaseImbalance)
void setSamplerate(int samplerate)
void setIFactor(float iFactor)
void setLog2Decimation(unsigned int log2_decim)
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
Definition: deviceapi.cpp:316
void setAMModulation(float amModulation)
void setBitSize(uint32_t bitSizeIndex)
float m_qFactor
-1.0 < x < 1.0
float m_phaseImbalance
-1.0 < x < 1.0
AutoCorrOptions m_autoCorrOptions
void setModulation(TestSourceSettings::Modulation modulation)
virtual bool handleMessage(const Message &message)
Processing of a message. Returns true if message has actually been processed.
Definition: filerecord.cpp:128
void setToneFrequency(int toneFrequency)
void setFrequencyShift(int shift)
float m_iFactor
-1.0 < x < 1.0
uint16_t m_reverseAPIDeviceIndex
TestSourceThread * m_testSourceThread
TestSourceSettings m_settings
void setAmplitudeBits(int32_t amplitudeBits)
void setFMDeviation(float deviation)
FileRecord * m_fileSink
File sink to record device I/Q output.
void setDCFactor(float iFactor)
int m_modulationTone
10&#39;Hz
DeviceAPI * m_deviceAPI
void setQFactor(float qFactor)
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const TestSourceSettings &settings, bool force)
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection, int streamIndex=0)
Configure current device engine DSP corrections (Rx)
Definition: deviceapi.cpp:355
int m_fmDeviation
100&#39;Hz
void setFcPos(int fcPos)
int m_amModulation
percent
float m_dcFactor
-1.0 < x < 1.0
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deserialize()

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

Implements DeviceSampleSource.

Definition at line 121 of file testsourceinput.cpp.

References TestSourceInput::MsgConfigureTestSource::create(), TestSourceSettings::deserialize(), DeviceSampleSource::m_guiMessageQueue, DeviceSampleSource::m_inputMessageQueue, m_settings, MessageQueue::push(), and TestSourceSettings::resetToDefaults().

Referenced by TestSourceInput::MsgStartStop::MsgStartStop().

122 {
123  bool success = true;
124 
125  if (!m_settings.deserialize(data))
126  {
128  success = false;
129  }
130 
131  MsgConfigureTestSource* message = MsgConfigureTestSource::create(m_settings, true);
132  m_inputMessageQueue.push(message);
133 
134  if (m_guiMessageQueue)
135  {
136  MsgConfigureTestSource* messageToGUI = MsgConfigureTestSource::create(m_settings, true);
137  m_guiMessageQueue->push(messageToGUI);
138  }
139 
140  return success;
141 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
bool deserialize(const QByteArray &data)
MessageQueue m_inputMessageQueue
Input queue to the source.
static MsgConfigureTestSource * create(const TestSourceSettings &settings, bool force)
TestSourceSettings m_settings
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 TestSourceInput::destroy ( )
virtual

Implements DeviceSampleSource.

Definition at line 74 of file testsourceinput.cpp.

Referenced by TestSourceInput::MsgStartStop::MsgStartStop().

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

◆ getCenterFrequency()

quint64 TestSourceInput::getCenterFrequency ( ) const
virtual

Center frequency exposed by the source.

Implements DeviceSampleSource.

Definition at line 153 of file testsourceinput.cpp.

References TestSourceSettings::m_centerFrequency, and m_settings.

Referenced by setSampleRate().

154 {
156 }
TestSourceSettings m_settings
+ Here is the caller graph for this function:

◆ getDeviceDescription()

const QString & TestSourceInput::getDeviceDescription ( ) const
virtual

Implements DeviceSampleSource.

Definition at line 143 of file testsourceinput.cpp.

References m_deviceDescription.

Referenced by setMessageQueueToGUI().

144 {
145  return m_deviceDescription;
146 }
QString m_deviceDescription
+ Here is the caller graph for this function:

◆ getSampleRate()

int TestSourceInput::getSampleRate ( ) const
virtual

Sample rate exposed by the source.

Implements DeviceSampleSource.

Definition at line 148 of file testsourceinput.cpp.

References TestSourceSettings::m_log2Decim, TestSourceSettings::m_sampleRate, and m_settings.

Referenced by setMessageQueueToGUI().

149 {
151 }
TestSourceSettings m_settings
+ Here is the caller graph for this function:

◆ handleMessage()

bool TestSourceInput::handleMessage ( const Message message)
virtual

Implements DeviceSampleSource.

Definition at line 173 of file testsourceinput.cpp.

References applySettings(), FileRecord::genUniqueFileName(), DeviceAPI::getDeviceUID(), TestSourceInput::MsgConfigureTestSource::getForce(), TestSourceInput::MsgConfigureTestSource::getSettings(), TestSourceInput::MsgFileRecord::getStartStop(), TestSourceInput::MsgStartStop::getStartStop(), DeviceAPI::initDeviceEngine(), m_deviceAPI, TestSourceSettings::m_fileRecordName, m_fileSink, m_settings, TestSourceSettings::m_useReverseAPI, Message::match(), FileRecord::setFileName(), DeviceAPI::startDeviceEngine(), FileRecord::startRecording(), DeviceAPI::stopDeviceEngine(), FileRecord::stopRecording(), and webapiReverseSendStartStop().

Referenced by setSampleRate().

174 {
175  if (MsgConfigureTestSource::match(message))
176  {
177  MsgConfigureTestSource& conf = (MsgConfigureTestSource&) message;
178  qDebug() << "TestSourceInput::handleMessage: MsgConfigureTestSource";
179 
180  bool success = applySettings(conf.getSettings(), conf.getForce());
181 
182  if (!success)
183  {
184  qDebug("TestSourceInput::handleMessage: config error");
185  }
186 
187  return true;
188  }
189  else if (MsgFileRecord::match(message))
190  {
191  MsgFileRecord& conf = (MsgFileRecord&) message;
192  qDebug() << "TestSourceInput::handleMessage: MsgFileRecord: " << conf.getStartStop();
193 
194  if (conf.getStartStop())
195  {
196  if (m_settings.m_fileRecordName.size() != 0) {
198  } else {
200  }
201 
203  }
204  else
205  {
207  }
208 
209  return true;
210  }
211  else if (MsgStartStop::match(message))
212  {
213  MsgStartStop& cmd = (MsgStartStop&) message;
214  qDebug() << "TestSourceInput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
215 
216  if (cmd.getStartStop())
217  {
219  {
221  }
222  }
223  else
224  {
226  }
227 
229  webapiReverseSendStartStop(cmd.getStartStop());
230  }
231 
232  return true;
233  }
234  else
235  {
236  return false;
237  }
238 }
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
bool initDeviceEngine()
Init the device engine corresponding to the stream type.
Definition: deviceapi.cpp:240
void genUniqueFileName(uint deviceUID, int istream=-1)
Definition: filerecord.cpp:67
void webapiReverseSendStartStop(bool start)
TestSourceSettings m_settings
void stopRecording()
Definition: filerecord.cpp:117
static bool match(const Message *message)
Definition: message.cpp:45
FileRecord * m_fileSink
File sink to record device I/Q output.
DeviceAPI * m_deviceAPI
bool applySettings(const TestSourceSettings &settings, bool force)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

void TestSourceInput::init ( )
virtual

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

Implements DeviceSampleSource.

Definition at line 79 of file testsourceinput.cpp.

References applySettings(), and m_settings.

Referenced by TestSourceInput::MsgStartStop::MsgStartStop().

80 {
82 }
TestSourceSettings m_settings
bool applySettings(const TestSourceSettings &settings, bool force)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ networkManagerFinished

void TestSourceInput::networkManagerFinished ( QNetworkReply *  reply)
privateslot

Definition at line 734 of file testsourceinput.cpp.

Referenced by ~TestSourceInput().

735 {
736  QNetworkReply::NetworkError replyError = reply->error();
737 
738  if (replyError)
739  {
740  qWarning() << "TestSourceInput::networkManagerFinished:"
741  << " error(" << (int) replyError
742  << "): " << replyError
743  << ": " << reply->errorString();
744  return;
745  }
746 
747  QString answer = reply->readAll();
748  answer.chop(1); // remove last \n
749  qDebug("TestSourceInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
750 }
+ Here is the caller graph for this function:

◆ serialize()

QByteArray TestSourceInput::serialize ( ) const
virtual

Implements DeviceSampleSource.

Definition at line 116 of file testsourceinput.cpp.

References m_settings, and TestSourceSettings::serialize().

Referenced by TestSourceInput::MsgStartStop::MsgStartStop().

117 {
118  return m_settings.serialize();
119 }
QByteArray serialize() const
TestSourceSettings m_settings
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCenterFrequency()

void TestSourceInput::setCenterFrequency ( qint64  centerFrequency)
virtual

Implements DeviceSampleSource.

Definition at line 158 of file testsourceinput.cpp.

References TestSourceInput::MsgConfigureTestSource::create(), TestSourceSettings::m_centerFrequency, DeviceSampleSource::m_guiMessageQueue, DeviceSampleSource::m_inputMessageQueue, m_settings, and MessageQueue::push().

Referenced by setSampleRate().

159 {
160  TestSourceSettings settings = m_settings;
161  settings.m_centerFrequency = centerFrequency;
162 
163  MsgConfigureTestSource* message = MsgConfigureTestSource::create(settings, false);
164  m_inputMessageQueue.push(message);
165 
166  if (m_guiMessageQueue)
167  {
168  MsgConfigureTestSource* messageToGUI = MsgConfigureTestSource::create(settings, false);
169  m_guiMessageQueue->push(messageToGUI);
170  }
171 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
static MsgConfigureTestSource * create(const TestSourceSettings &settings, bool force)
TestSourceSettings m_settings
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:

◆ setMessageQueueToGUI()

virtual void TestSourceInput::setMessageQueueToGUI ( MessageQueue queue)
inlinevirtual

Implements DeviceSampleSource.

Definition at line 110 of file testsourceinput.h.

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

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

◆ setSampleRate()

virtual void TestSourceInput::setSampleRate ( int  sampleRate)
inlinevirtual

For when the source sample rate is set externally.

Implements DeviceSampleSource.

Definition at line 113 of file testsourceinput.h.

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

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

◆ start()

bool TestSourceInput::start ( )
virtual

Implements DeviceSampleSource.

Definition at line 84 of file testsourceinput.cpp.

References applySettings(), m_mutex, m_running, DeviceSampleSource::m_sampleFifo, TestSourceSettings::m_sampleRate, m_settings, m_testSourceThread, TestSourceThread::setSamplerate(), TestSourceThread::startStop(), and stop().

Referenced by TestSourceInput::MsgStartStop::MsgStartStop().

85 {
86  QMutexLocker mutexLocker(&m_mutex);
87 
88  if (m_running) stop();
89 
93 
94  mutexLocker.unlock();
95 
97  m_running = true;
98 
99  return true;
100 }
void setSamplerate(int samplerate)
void startStop(bool start)
virtual void stop()
SampleSinkFifo m_sampleFifo
TestSourceThread * m_testSourceThread
TestSourceSettings m_settings
bool applySettings(const TestSourceSettings &settings, bool force)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop()

void TestSourceInput::stop ( )
virtual

Implements DeviceSampleSource.

Definition at line 102 of file testsourceinput.cpp.

References m_mutex, m_running, m_testSourceThread, and TestSourceThread::startStop().

Referenced by TestSourceInput::MsgStartStop::MsgStartStop(), start(), and ~TestSourceInput().

103 {
104  QMutexLocker mutexLocker(&m_mutex);
105 
106  if (m_testSourceThread != 0)
107  {
109  m_testSourceThread->deleteLater();
110  m_testSourceThread = 0;
111  }
112 
113  m_running = false;
114 }
void startStop(bool start)
TestSourceThread * m_testSourceThread
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatDeviceSettings()

void TestSourceInput::webapiFormatDeviceSettings ( SWGSDRangel::SWGDeviceSettings response,
const TestSourceSettings settings 
)
private

Definition at line 586 of file testsourceinput.cpp.

References SWGSDRangel::SWGTestSourceSettings::getFileRecordName(), SWGSDRangel::SWGTestSourceSettings::getReverseApiAddress(), SWGSDRangel::SWGDeviceSettings::getTestSourceSettings(), TestSourceSettings::m_amModulation, TestSourceSettings::m_amplitudeBits, TestSourceSettings::m_autoCorrOptions, TestSourceSettings::m_centerFrequency, TestSourceSettings::m_dcFactor, TestSourceSettings::m_fcPos, TestSourceSettings::m_fileRecordName, TestSourceSettings::m_fmDeviation, TestSourceSettings::m_frequencyShift, TestSourceSettings::m_iFactor, TestSourceSettings::m_log2Decim, TestSourceSettings::m_modulation, TestSourceSettings::m_modulationTone, TestSourceSettings::m_phaseImbalance, TestSourceSettings::m_qFactor, TestSourceSettings::m_reverseAPIAddress, TestSourceSettings::m_reverseAPIDeviceIndex, TestSourceSettings::m_reverseAPIPort, TestSourceSettings::m_sampleRate, TestSourceSettings::m_sampleSizeIndex, TestSourceSettings::m_useReverseAPI, SWGSDRangel::SWGTestSourceSettings::setAmModulation(), SWGSDRangel::SWGTestSourceSettings::setAmplitudeBits(), SWGSDRangel::SWGTestSourceSettings::setAutoCorrOptions(), SWGSDRangel::SWGTestSourceSettings::setCenterFrequency(), SWGSDRangel::SWGTestSourceSettings::setDcFactor(), SWGSDRangel::SWGTestSourceSettings::setFcPos(), SWGSDRangel::SWGTestSourceSettings::setFileRecordName(), SWGSDRangel::SWGTestSourceSettings::setFmDeviation(), SWGSDRangel::SWGTestSourceSettings::setFrequencyShift(), SWGSDRangel::SWGTestSourceSettings::setIFactor(), SWGSDRangel::SWGTestSourceSettings::setLog2Decim(), SWGSDRangel::SWGTestSourceSettings::setModulation(), SWGSDRangel::SWGTestSourceSettings::setModulationTone(), SWGSDRangel::SWGTestSourceSettings::setPhaseImbalance(), SWGSDRangel::SWGTestSourceSettings::setQFactor(), SWGSDRangel::SWGTestSourceSettings::setReverseApiAddress(), SWGSDRangel::SWGTestSourceSettings::setReverseApiDeviceIndex(), SWGSDRangel::SWGTestSourceSettings::setReverseApiPort(), SWGSDRangel::SWGTestSourceSettings::setSampleRate(), SWGSDRangel::SWGTestSourceSettings::setSampleSizeIndex(), and SWGSDRangel::SWGTestSourceSettings::setUseReverseApi().

Referenced by webapiSettingsGet(), and webapiSettingsPutPatch().

587 {
590  response.getTestSourceSettings()->setSampleRate(settings.m_sampleRate);
591  response.getTestSourceSettings()->setLog2Decim(settings.m_log2Decim);
592  response.getTestSourceSettings()->setFcPos((int) settings.m_fcPos);
593  response.getTestSourceSettings()->setSampleSizeIndex((int) settings.m_sampleSizeIndex);
595  response.getTestSourceSettings()->setAutoCorrOptions((int) settings.m_autoCorrOptions);
596  response.getTestSourceSettings()->setModulation((int) settings.m_modulation);
599  response.getTestSourceSettings()->setFmDeviation(settings.m_fmDeviation);
600  response.getTestSourceSettings()->setDcFactor(settings.m_dcFactor);
601  response.getTestSourceSettings()->setIFactor(settings.m_iFactor);
602  response.getTestSourceSettings()->setQFactor(settings.m_qFactor);
604 
605  if (response.getTestSourceSettings()->getFileRecordName()) {
606  *response.getTestSourceSettings()->getFileRecordName() = settings.m_fileRecordName;
607  } else {
608  response.getTestSourceSettings()->setFileRecordName(new QString(settings.m_fileRecordName));
609  }
610 
611  response.getTestSourceSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
612 
613  if (response.getTestSourceSettings()->getReverseApiAddress()) {
615  } else {
616  response.getTestSourceSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
617  }
618 
621 }
SWGTestSourceSettings * getTestSourceSettings()
void setFileRecordName(QString *file_record_name)
void setReverseApiPort(qint32 reverse_api_port)
float m_qFactor
-1.0 < x < 1.0
void setUseReverseApi(qint32 use_reverse_api)
float m_phaseImbalance
-1.0 < x < 1.0
AutoCorrOptions m_autoCorrOptions
void setSampleSizeIndex(qint32 sample_size_index)
float m_iFactor
-1.0 < x < 1.0
void setReverseApiAddress(QString *reverse_api_address)
void setAutoCorrOptions(qint32 auto_corr_options)
uint16_t m_reverseAPIDeviceIndex
void setAmplitudeBits(qint32 amplitude_bits)
void setModulationTone(qint32 modulation_tone)
void setPhaseImbalance(float phase_imbalance)
void setCenterFrequency(qint32 center_frequency)
void setAmModulation(qint32 am_modulation)
int m_modulationTone
10&#39;Hz
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setFrequencyShift(qint32 frequency_shift)
int m_fmDeviation
100&#39;Hz
int m_amModulation
percent
float m_dcFactor
-1.0 < x < 1.0
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendSettings()

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

Definition at line 623 of file testsourceinput.cpp.

References SWGSDRangel::SWGDeviceSettings::asJson(), DeviceAPI::getDeviceSetIndex(), SWGSDRangel::SWGDeviceSettings::getTestSourceSettings(), TestSourceSettings::m_amModulation, TestSourceSettings::m_amplitudeBits, TestSourceSettings::m_centerFrequency, TestSourceSettings::m_dcFactor, m_deviceAPI, TestSourceSettings::m_fcPos, TestSourceSettings::m_fileRecordName, TestSourceSettings::m_fmDeviation, TestSourceSettings::m_frequencyShift, TestSourceSettings::m_iFactor, TestSourceSettings::m_log2Decim, TestSourceSettings::m_modulation, TestSourceSettings::m_modulationTone, m_networkManager, m_networkRequest, TestSourceSettings::m_phaseImbalance, TestSourceSettings::m_qFactor, TestSourceSettings::m_reverseAPIAddress, TestSourceSettings::m_reverseAPIDeviceIndex, TestSourceSettings::m_reverseAPIPort, TestSourceSettings::m_sampleRate, TestSourceSettings::m_sampleSizeIndex, SWGSDRangel::SWGTestSourceSettings::setAmModulation(), SWGSDRangel::SWGTestSourceSettings::setAmplitudeBits(), SWGSDRangel::SWGTestSourceSettings::setAutoCorrOptions(), SWGSDRangel::SWGTestSourceSettings::setCenterFrequency(), SWGSDRangel::SWGTestSourceSettings::setDcFactor(), SWGSDRangel::SWGDeviceSettings::setDeviceHwType(), SWGSDRangel::SWGDeviceSettings::setDirection(), SWGSDRangel::SWGTestSourceSettings::setFcPos(), SWGSDRangel::SWGTestSourceSettings::setFileRecordName(), SWGSDRangel::SWGTestSourceSettings::setFmDeviation(), SWGSDRangel::SWGTestSourceSettings::setFrequencyShift(), SWGSDRangel::SWGTestSourceSettings::setIFactor(), SWGSDRangel::SWGTestSourceSettings::setLog2Decim(), SWGSDRangel::SWGTestSourceSettings::setModulation(), SWGSDRangel::SWGTestSourceSettings::setModulationTone(), SWGSDRangel::SWGDeviceSettings::setOriginatorIndex(), SWGSDRangel::SWGTestSourceSettings::setPhaseImbalance(), SWGSDRangel::SWGTestSourceSettings::setQFactor(), SWGSDRangel::SWGTestSourceSettings::setSampleRate(), SWGSDRangel::SWGTestSourceSettings::setSampleSizeIndex(), and SWGSDRangel::SWGDeviceSettings::setTestSourceSettings().

Referenced by applySettings().

624 {
626  swgDeviceSettings->setDirection(0); // single Rx
627  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
628  swgDeviceSettings->setDeviceHwType(new QString("TestSource"));
630  SWGSDRangel::SWGTestSourceSettings *swgTestSourceSettings = swgDeviceSettings->getTestSourceSettings();
631 
632  // transfer data that has been modified. When force is on transfer all data except reverse API data
633 
634  if (deviceSettingsKeys.contains("centerFrequency") || force) {
635  swgTestSourceSettings->setCenterFrequency(settings.m_centerFrequency);
636  }
637  if (deviceSettingsKeys.contains("frequencyShift") || force) {
638  swgTestSourceSettings->setFrequencyShift(settings.m_frequencyShift);
639  }
640  if (deviceSettingsKeys.contains("sampleRate") || force) {
641  swgTestSourceSettings->setSampleRate(settings.m_sampleRate);
642  }
643  if (deviceSettingsKeys.contains("log2Decim") || force) {
644  swgTestSourceSettings->setLog2Decim(settings.m_log2Decim);
645  }
646  if (deviceSettingsKeys.contains("fcPos") || force) {
647  swgTestSourceSettings->setFcPos((int) settings.m_fcPos);
648  }
649  if (deviceSettingsKeys.contains("sampleSizeIndex") || force) {
650  swgTestSourceSettings->setSampleSizeIndex(settings.m_sampleSizeIndex);
651  }
652  if (deviceSettingsKeys.contains("amplitudeBits") || force) {
653  swgTestSourceSettings->setAmplitudeBits(settings.m_amplitudeBits);
654  }
655  if (deviceSettingsKeys.contains("autoCorrOptions") || force) {
656  swgTestSourceSettings->setAutoCorrOptions((int) settings.m_sampleSizeIndex);
657  }
658  if (deviceSettingsKeys.contains("modulation") || force) {
659  swgTestSourceSettings->setModulation((int) settings.m_modulation);
660  }
661  if (deviceSettingsKeys.contains("modulationTone")) {
662  swgTestSourceSettings->setModulationTone(settings.m_modulationTone);
663  }
664  if (deviceSettingsKeys.contains("amModulation") || force) {
665  swgTestSourceSettings->setAmModulation(settings.m_amModulation);
666  };
667  if (deviceSettingsKeys.contains("fmDeviation") || force) {
668  swgTestSourceSettings->setFmDeviation(settings.m_fmDeviation);
669  };
670  if (deviceSettingsKeys.contains("dcFactor") || force) {
671  swgTestSourceSettings->setDcFactor(settings.m_dcFactor);
672  };
673  if (deviceSettingsKeys.contains("iFactor") || force) {
674  swgTestSourceSettings->setIFactor(settings.m_iFactor);
675  };
676  if (deviceSettingsKeys.contains("qFactor") || force) {
677  swgTestSourceSettings->setQFactor(settings.m_qFactor);
678  };
679  if (deviceSettingsKeys.contains("phaseImbalance") || force) {
680  swgTestSourceSettings->setPhaseImbalance(settings.m_phaseImbalance);
681  };
682  if (deviceSettingsKeys.contains("fileRecordName") || force) {
683  swgTestSourceSettings->setFileRecordName(new QString(settings.m_fileRecordName));
684  }
685 
686  QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/settings")
687  .arg(settings.m_reverseAPIAddress)
688  .arg(settings.m_reverseAPIPort)
689  .arg(settings.m_reverseAPIDeviceIndex);
690  m_networkRequest.setUrl(QUrl(channelSettingsURL));
691  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
692 
693  QBuffer *buffer=new QBuffer();
694  buffer->open((QBuffer::ReadWrite));
695  buffer->write(swgDeviceSettings->asJson().toUtf8());
696  buffer->seek(0);
697 // qDebug("TestSourceInput::webapiReverseSendSettings: %s", channelSettingsURL.toStdString().c_str());
698 // qDebug("TestSourceInput::webapiReverseSendSettings: query:\n%s", swgDeviceSettings->asJson().toStdString().c_str());
699 
700  // Always use PATCH to avoid passing reverse API settings
701  m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
702 
703  delete swgDeviceSettings;
704 }
SWGTestSourceSettings * getTestSourceSettings()
void setFileRecordName(QString *file_record_name)
virtual QString asJson() override
float m_qFactor
-1.0 < x < 1.0
float m_phaseImbalance
-1.0 < x < 1.0
void setOriginatorIndex(qint32 originator_index)
QNetworkAccessManager * m_networkManager
void setSampleSizeIndex(qint32 sample_size_index)
int getDeviceSetIndex() const
Definition: deviceapi.h:131
float m_iFactor
-1.0 < x < 1.0
void setAutoCorrOptions(qint32 auto_corr_options)
uint16_t m_reverseAPIDeviceIndex
QNetworkRequest m_networkRequest
void setAmplitudeBits(qint32 amplitude_bits)
void setModulationTone(qint32 modulation_tone)
void setTestSourceSettings(SWGTestSourceSettings *test_source_settings)
void setPhaseImbalance(float phase_imbalance)
void setCenterFrequency(qint32 center_frequency)
void setAmModulation(qint32 am_modulation)
int m_modulationTone
10&#39;Hz
DeviceAPI * m_deviceAPI
void setFrequencyShift(qint32 frequency_shift)
int m_fmDeviation
100&#39;Hz
void setDirection(qint32 direction)
void setDeviceHwType(QString *device_hw_type)
int m_amModulation
percent
float m_dcFactor
-1.0 < x < 1.0
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendStartStop()

void TestSourceInput::webapiReverseSendStartStop ( bool  start)
private

Definition at line 706 of file testsourceinput.cpp.

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

Referenced by handleMessage().

707 {
709  swgDeviceSettings->setDirection(0); // single Rx
710  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
711  swgDeviceSettings->setDeviceHwType(new QString("TestSource"));
712 
713  QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
717  m_networkRequest.setUrl(QUrl(channelSettingsURL));
718  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
719 
720  QBuffer *buffer=new QBuffer();
721  buffer->open((QBuffer::ReadWrite));
722  buffer->write(swgDeviceSettings->asJson().toUtf8());
723  buffer->seek(0);
724 
725  if (start) {
726  m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
727  } else {
728  m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
729  }
730 
731  delete swgDeviceSettings;
732 }
virtual QString asJson() override
void setOriginatorIndex(qint32 originator_index)
QNetworkAccessManager * m_networkManager
int getDeviceSetIndex() const
Definition: deviceapi.h:131
uint16_t m_reverseAPIDeviceIndex
QNetworkRequest m_networkRequest
TestSourceSettings m_settings
DeviceAPI * m_deviceAPI
virtual bool start()
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 TestSourceInput::webapiRun ( bool  run,
SWGSDRangel::SWGDeviceState response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSource.

Definition at line 462 of file testsourceinput.cpp.

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

Referenced by setSampleRate().

466 {
467  (void) errorMessage;
469  MsgStartStop *message = MsgStartStop::create(run);
470  m_inputMessageQueue.push(message);
471 
472  if (m_guiMessageQueue) // forward to GUI if any
473  {
474  MsgStartStop *msgToGUI = MsgStartStop::create(run);
475  m_guiMessageQueue->push(msgToGUI);
476  }
477 
478  return 200;
479 }
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.
void getDeviceEngineStateStr(QString &state)
Definition: deviceapi.cpp:389
static MsgStartStop * create(bool startStop)
DeviceAPI * m_deviceAPI
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiRunGet()

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

Reimplemented from DeviceSampleSource.

Definition at line 453 of file testsourceinput.cpp.

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

Referenced by setSampleRate().

456 {
457  (void) errorMessage;
459  return 200;
460 }
void getDeviceEngineStateStr(QString &state)
Definition: deviceapi.cpp:389
DeviceAPI * m_deviceAPI
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsGet()

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

Reimplemented from DeviceSampleSource.

Definition at line 481 of file testsourceinput.cpp.

References SWGSDRangel::SWGDeviceSettings::getTestSourceSettings(), SWGSDRangel::SWGTestSourceSettings::init(), m_settings, SWGSDRangel::SWGDeviceSettings::setTestSourceSettings(), and webapiFormatDeviceSettings().

Referenced by setSampleRate().

484 {
485  (void) errorMessage;
487  response.getTestSourceSettings()->init();
489  return 200;
490 }
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const TestSourceSettings &settings)
SWGTestSourceSettings * getTestSourceSettings()
TestSourceSettings m_settings
void setTestSourceSettings(SWGTestSourceSettings *test_source_settings)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsPutPatch()

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

Reimplemented from DeviceSampleSource.

Definition at line 492 of file testsourceinput.cpp.

References TestSourceSettings::AutoCorrLast, TestSourceInput::MsgConfigureTestSource::create(), SWGSDRangel::SWGTestSourceSettings::getAmModulation(), SWGSDRangel::SWGTestSourceSettings::getAmplitudeBits(), SWGSDRangel::SWGTestSourceSettings::getAutoCorrOptions(), SWGSDRangel::SWGTestSourceSettings::getCenterFrequency(), SWGSDRangel::SWGTestSourceSettings::getDcFactor(), SWGSDRangel::SWGTestSourceSettings::getFcPos(), SWGSDRangel::SWGTestSourceSettings::getFileRecordName(), SWGSDRangel::SWGTestSourceSettings::getFmDeviation(), SWGSDRangel::SWGTestSourceSettings::getFrequencyShift(), SWGSDRangel::SWGTestSourceSettings::getIFactor(), SWGSDRangel::SWGTestSourceSettings::getLog2Decim(), SWGSDRangel::SWGTestSourceSettings::getModulation(), SWGSDRangel::SWGTestSourceSettings::getModulationTone(), SWGSDRangel::SWGTestSourceSettings::getPhaseImbalance(), SWGSDRangel::SWGTestSourceSettings::getQFactor(), SWGSDRangel::SWGTestSourceSettings::getReverseApiAddress(), SWGSDRangel::SWGTestSourceSettings::getReverseApiDeviceIndex(), SWGSDRangel::SWGTestSourceSettings::getReverseApiPort(), SWGSDRangel::SWGTestSourceSettings::getSampleRate(), SWGSDRangel::SWGTestSourceSettings::getSampleSizeIndex(), SWGSDRangel::SWGDeviceSettings::getTestSourceSettings(), SWGSDRangel::SWGTestSourceSettings::getUseReverseApi(), TestSourceSettings::m_amModulation, TestSourceSettings::m_amplitudeBits, TestSourceSettings::m_centerFrequency, TestSourceSettings::m_dcFactor, TestSourceSettings::m_fcPos, TestSourceSettings::m_fileRecordName, TestSourceSettings::m_fmDeviation, TestSourceSettings::m_frequencyShift, DeviceSampleSource::m_guiMessageQueue, TestSourceSettings::m_iFactor, DeviceSampleSource::m_inputMessageQueue, TestSourceSettings::m_log2Decim, TestSourceSettings::m_modulation, TestSourceSettings::m_modulationTone, TestSourceSettings::m_phaseImbalance, TestSourceSettings::m_qFactor, TestSourceSettings::m_reverseAPIAddress, TestSourceSettings::m_reverseAPIDeviceIndex, TestSourceSettings::m_reverseAPIPort, TestSourceSettings::m_sampleRate, TestSourceSettings::m_sampleSizeIndex, m_settings, TestSourceSettings::m_useReverseAPI, TestSourceSettings::ModulationLast, MessageQueue::push(), and webapiFormatDeviceSettings().

Referenced by setSampleRate().

497 {
498  (void) errorMessage;
499  TestSourceSettings settings = m_settings;
500 
501  if (deviceSettingsKeys.contains("centerFrequency")) {
503  }
504  if (deviceSettingsKeys.contains("frequencyShift")) {
506  }
507  if (deviceSettingsKeys.contains("sampleRate")) {
508  settings.m_sampleRate = response.getTestSourceSettings()->getSampleRate();
509  }
510  if (deviceSettingsKeys.contains("log2Decim")) {
511  settings.m_log2Decim = response.getTestSourceSettings()->getLog2Decim();
512  }
513  if (deviceSettingsKeys.contains("fcPos")) {
514  int fcPos = response.getTestSourceSettings()->getFcPos();
515  fcPos = fcPos < 0 ? 0 : fcPos > 2 ? 2 : fcPos;
516  settings.m_fcPos = (TestSourceSettings::fcPos_t) fcPos;
517  }
518  if (deviceSettingsKeys.contains("sampleSizeIndex")) {
519  int sampleSizeIndex = response.getTestSourceSettings()->getSampleSizeIndex();
520  sampleSizeIndex = sampleSizeIndex < 0 ? 0 : sampleSizeIndex > 1 ? 2 : sampleSizeIndex;
521  settings.m_sampleSizeIndex = sampleSizeIndex;
522  }
523  if (deviceSettingsKeys.contains("amplitudeBits")) {
524  settings.m_amplitudeBits = response.getTestSourceSettings()->getAmplitudeBits();
525  }
526  if (deviceSettingsKeys.contains("autoCorrOptions")) {
527  int autoCorrOptions = response.getTestSourceSettings()->getAutoCorrOptions();
528  autoCorrOptions = autoCorrOptions < 0 ? 0 : autoCorrOptions >= TestSourceSettings::AutoCorrLast ? TestSourceSettings::AutoCorrLast-1 : autoCorrOptions;
529  settings.m_sampleSizeIndex = (TestSourceSettings::AutoCorrOptions) autoCorrOptions;
530  }
531  if (deviceSettingsKeys.contains("modulation")) {
532  int modulation = response.getTestSourceSettings()->getModulation();
533  modulation = modulation < 0 ? 0 : modulation >= TestSourceSettings::ModulationLast ? TestSourceSettings::ModulationLast-1 : modulation;
534  settings.m_modulation = (TestSourceSettings::Modulation) modulation;
535  }
536  if (deviceSettingsKeys.contains("modulationTone")) {
538  }
539  if (deviceSettingsKeys.contains("amModulation")) {
540  settings.m_amModulation = response.getTestSourceSettings()->getAmModulation();
541  };
542  if (deviceSettingsKeys.contains("fmDeviation")) {
543  settings.m_fmDeviation = response.getTestSourceSettings()->getFmDeviation();
544  };
545  if (deviceSettingsKeys.contains("dcFactor")) {
546  settings.m_dcFactor = response.getTestSourceSettings()->getDcFactor();
547  };
548  if (deviceSettingsKeys.contains("iFactor")) {
549  settings.m_iFactor = response.getTestSourceSettings()->getIFactor();
550  };
551  if (deviceSettingsKeys.contains("qFactor")) {
552  settings.m_qFactor = response.getTestSourceSettings()->getQFactor();
553  };
554  if (deviceSettingsKeys.contains("phaseImbalance")) {
556  };
557  if (deviceSettingsKeys.contains("fileRecordName")) {
558  settings.m_fileRecordName = *response.getTestSourceSettings()->getFileRecordName();
559  }
560  if (deviceSettingsKeys.contains("useReverseAPI")) {
561  settings.m_useReverseAPI = response.getTestSourceSettings()->getUseReverseApi() != 0;
562  }
563  if (deviceSettingsKeys.contains("reverseAPIAddress")) {
565  }
566  if (deviceSettingsKeys.contains("reverseAPIPort")) {
568  }
569  if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
571  }
572 
573  MsgConfigureTestSource *msg = MsgConfigureTestSource::create(settings, force);
575 
576  if (m_guiMessageQueue) // forward to GUI if any
577  {
578  MsgConfigureTestSource *msgToGUI = MsgConfigureTestSource::create(settings, force);
579  m_guiMessageQueue->push(msgToGUI);
580  }
581 
582  webapiFormatDeviceSettings(response, settings);
583  return 200;
584 }
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const TestSourceSettings &settings)
void push(Message *message, bool emitSignal=true)
Push message onto queue.
SWGTestSourceSettings * getTestSourceSettings()
MessageQueue m_inputMessageQueue
Input queue to the source.
float m_qFactor
-1.0 < x < 1.0
float m_phaseImbalance
-1.0 < x < 1.0
float m_iFactor
-1.0 < x < 1.0
static MsgConfigureTestSource * create(const TestSourceSettings &settings, bool force)
uint16_t m_reverseAPIDeviceIndex
TestSourceSettings m_settings
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
int m_modulationTone
10&#39;Hz
int m_fmDeviation
100&#39;Hz
int m_amModulation
percent
float m_dcFactor
-1.0 < x < 1.0
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_deviceAPI

DeviceAPI* TestSourceInput::m_deviceAPI
private

◆ m_deviceDescription

QString TestSourceInput::m_deviceDescription
private

Definition at line 144 of file testsourceinput.h.

Referenced by getDeviceDescription().

◆ m_fileSink

FileRecord* TestSourceInput::m_fileSink
private

File sink to record device I/Q output.

Definition at line 140 of file testsourceinput.h.

Referenced by applySettings(), handleMessage(), and ~TestSourceInput().

◆ m_masterTimer

const QTimer& TestSourceInput::m_masterTimer
private

Definition at line 146 of file testsourceinput.h.

◆ m_mutex

QMutex TestSourceInput::m_mutex
private

Definition at line 141 of file testsourceinput.h.

Referenced by start(), and stop().

◆ m_networkManager

QNetworkAccessManager* TestSourceInput::m_networkManager
private

◆ m_networkRequest

QNetworkRequest TestSourceInput::m_networkRequest
private

Definition at line 148 of file testsourceinput.h.

Referenced by webapiReverseSendSettings(), and webapiReverseSendStartStop().

◆ m_running

bool TestSourceInput::m_running
private

Definition at line 145 of file testsourceinput.h.

Referenced by start(), stop(), and ~TestSourceInput().

◆ m_settings

TestSourceSettings TestSourceInput::m_settings
private

◆ m_testSourceThread

TestSourceThread* TestSourceInput::m_testSourceThread
private

Definition at line 143 of file testsourceinput.h.

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


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