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

#include <perseusinput.h>

+ Inheritance diagram for PerseusInput:
+ Collaboration diagram for PerseusInput:

Classes

class  MsgConfigurePerseus
 
class  MsgFileRecord
 
class  MsgStartStop
 

Public Member Functions

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

Private Slots

void networkManagerFinished (QNetworkReply *reply)
 

Private Member Functions

bool openDevice ()
 
void closeDevice ()
 
void setDeviceCenterFrequency (quint64 freq, const PerseusSettings &settings)
 
bool applySettings (const PerseusSettings &settings, bool force=false)
 
void webapiFormatDeviceSettings (SWGSDRangel::SWGDeviceSettings &response, const PerseusSettings &settings)
 
void webapiFormatDeviceReport (SWGSDRangel::SWGDeviceReport &response)
 
void webapiReverseSendSettings (QList< QString > &deviceSettingsKeys, const PerseusSettings &settings, bool force)
 
void webapiReverseSendStartStop (bool start)
 

Private Attributes

DeviceAPIm_deviceAPI
 
FileRecordm_fileSink
 
QString m_deviceDescription
 
PerseusSettings m_settings
 
bool m_running
 
PerseusThreadm_perseusThread
 
perseus_descr * m_perseusDescriptor
 
std::vector< uint32_tm_sampleRates
 
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 36 of file perseusinput.h.

Constructor & Destructor Documentation

◆ PerseusInput()

PerseusInput::PerseusInput ( DeviceAPI deviceAPI)

Definition at line 40 of file perseusinput.cpp.

References arg().

Referenced by PerseusInput::MsgStartStop::MsgStartStop().

40  :
41  m_deviceAPI(deviceAPI),
42  m_fileSink(0),
43  m_deviceDescription("PerseusInput"),
44  m_running(false),
45  m_perseusThread(0),
47 {
48  openDevice();
49  m_fileSink = new FileRecord(QString("test_%1.sdriq").arg(m_deviceAPI->getDeviceUID()));
52 
53  m_networkManager = new QNetworkAccessManager();
54  connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
55 }
QNetworkAccessManager * m_networkManager
Definition: perseusinput.h:154
uint getDeviceUID() const
Return the current device engine unique ID.
Definition: deviceapi.cpp:303
void setNbSourceStreams(uint32_t nbSourceStreams)
Definition: deviceapi.h:168
DeviceAPI * m_deviceAPI
Definition: perseusinput.h:146
void networkManagerFinished(QNetworkReply *reply)
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
FileRecord * m_fileSink
Definition: perseusinput.h:147
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
perseus_descr * m_perseusDescriptor
Definition: perseusinput.h:152
PerseusThread * m_perseusThread
Definition: perseusinput.h:151
QString m_deviceDescription
Definition: perseusinput.h:148
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ~PerseusInput()

PerseusInput::~PerseusInput ( )

Definition at line 57 of file perseusinput.cpp.

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

Referenced by PerseusInput::MsgStartStop::MsgStartStop().

58 {
59  disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
60  delete m_networkManager;
62  delete m_fileSink;
63  closeDevice();
64 }
QNetworkAccessManager * m_networkManager
Definition: perseusinput.h:154
DeviceAPI * m_deviceAPI
Definition: perseusinput.h:146
void networkManagerFinished(QNetworkReply *reply)
void closeDevice()
FileRecord * m_fileSink
Definition: perseusinput.h:147
void removeAncillarySink(BasebandSampleSink *sink, unsigned int index=0)
Removes it.
Definition: deviceapi.cpp:100
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ applySettings()

bool PerseusInput::applySettings ( const PerseusSettings settings,
bool  force = false 
)
private

Definition at line 299 of file perseusinput.cpp.

References DeviceAPI::getDeviceEngineInputMessageQueue(), FileRecord::handleMessage(), i, PerseusSettings::m_adcDither, PerseusSettings::m_adcPreamp, PerseusSettings::m_attenuator, PerseusSettings::m_centerFrequency, m_deviceAPI, PerseusSettings::m_devSampleRateIndex, m_fileSink, PerseusSettings::m_log2Decim, PerseusSettings::m_LOppmTenths, m_perseusDescriptor, m_perseusThread, PerseusSettings::m_reverseAPIAddress, PerseusSettings::m_reverseAPIDeviceIndex, PerseusSettings::m_reverseAPIPort, m_sampleRates, m_settings, PerseusSettings::m_transverterDeltaFrequency, PerseusSettings::m_transverterMode, PerseusSettings::m_useReverseAPI, PerseusSettings::m_wideBand, MessageQueue::push(), setDeviceCenterFrequency(), PerseusThread::setLog2Decimation(), and webapiReverseSendSettings().

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

300 {
301  bool forwardChange = false;
302  int sampleRateIndex = settings.m_devSampleRateIndex;
303  QList<QString> reverseAPIKeys;
304 
305  if ((m_settings.m_devSampleRateIndex != settings.m_devSampleRateIndex) || force)
306  {
307  reverseAPIKeys.append("devSampleRateIndex");
308  forwardChange = true;
309 
310  if (settings.m_devSampleRateIndex >= m_sampleRates.size()) {
311  sampleRateIndex = m_sampleRates.size() - 1;
312  }
313 
314  if (m_perseusDescriptor != 0)
315  {
316  int rate = m_sampleRates[settings.m_devSampleRateIndex < m_sampleRates.size() ? settings.m_devSampleRateIndex: 0];
317  int rc;
318 
319  for (int i = 0; i < 2; i++) // it turns out that it has to be done twice
320  {
321  rc = perseus_set_sampling_rate(m_perseusDescriptor, rate);
322 
323  if (rc < 0) {
324  qCritical("PerseusInput::applySettings: could not set sample rate index %u (%d S/s): %s",
325  settings.m_devSampleRateIndex, rate, perseus_errorstr());
326  break;
327  }
328  else
329  {
330  qDebug("PerseusInput::applySettings: sample rate set to index #%d: %u (%d S/s)",
331  i, settings.m_devSampleRateIndex, rate);
332  }
333  }
334  }
335  }
336 
337  if ((m_settings.m_log2Decim != settings.m_log2Decim) || force)
338  {
339  reverseAPIKeys.append("log2Decim");
340  forwardChange = true;
341 
342  if (m_perseusThread != 0)
343  {
345  qDebug("PerseusInput: set decimation to %d", (1<<settings.m_log2Decim));
346  }
347  }
348 
349  if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency)) {
350  reverseAPIKeys.append("centerFrequency");
351  }
352  if (force || (m_settings.m_LOppmTenths != settings.m_LOppmTenths)) {
353  reverseAPIKeys.append("LOppmTenths");
354  }
355  if (force || (m_settings.m_wideBand != settings.m_wideBand)) {
356  reverseAPIKeys.append("wideBand");
357  }
358  if (force || (m_settings.m_transverterMode != settings.m_transverterMode)) {
359  reverseAPIKeys.append("transverterMode");
360  }
362  reverseAPIKeys.append("transverterDeltaFrequency");
363  }
364 
365  if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency)
366  || (m_settings.m_LOppmTenths != settings.m_LOppmTenths)
367  || (m_settings.m_wideBand != settings.m_wideBand)
371  {
372  qint64 deviceCenterFrequency = settings.m_centerFrequency;
373  deviceCenterFrequency -= settings.m_transverterMode ? settings.m_transverterDeltaFrequency : 0;
374  deviceCenterFrequency = deviceCenterFrequency < 0 ? 0 : deviceCenterFrequency;
375 
376  if (m_perseusDescriptor != 0)
377  {
378  setDeviceCenterFrequency(deviceCenterFrequency, settings);
379  qDebug("PerseusInput::applySettings: center freq: %llu Hz", settings.m_centerFrequency);
380  }
381 
382  forwardChange = true;
383  }
384 
385  if ((m_settings.m_attenuator != settings.m_attenuator) || force)
386  {
387  reverseAPIKeys.append("attenuator");
388  int rc = perseus_set_attenuator_n(m_perseusDescriptor, (int) settings.m_attenuator);
389 
390  if (rc < 0) {
391  qWarning("PerseusInput::applySettings: cannot set attenuator to %d dB: %s", (int) settings.m_attenuator*10, perseus_errorstr());
392  } else {
393  qDebug("PerseusInput::applySettings: attenuator set to %d dB", (int) settings.m_attenuator*10);
394  }
395  }
396 
397  if (force || (m_settings.m_adcDither != settings.m_adcDither)) {
398  reverseAPIKeys.append("adcDither");
399  }
400  if (force || (m_settings.m_adcPreamp != settings.m_adcPreamp)) {
401  reverseAPIKeys.append("adcPreamp");
402  }
403 
404  if ((m_settings.m_adcDither != settings.m_adcDither)
405  || (m_settings.m_adcPreamp != settings.m_adcPreamp) || force)
406  {
407  int rc = perseus_set_adc(m_perseusDescriptor, settings.m_adcDither ? 1 : 0, settings.m_adcPreamp ? 1 : 0);
408 
409  if (rc < 0) {
410  qWarning("PerseusInput::applySettings: cannot set ADC to dither %s and preamp %s: %s",
411  settings.m_adcDither ? "on" : "off", settings.m_adcPreamp ? "on" : "off", perseus_errorstr());
412  } else {
413  qDebug("PerseusInput::applySettings: ADC set to dither %s and preamp %s",
414  settings.m_adcDither ? "on" : "off", settings.m_adcPreamp ? "on" : "off");
415  }
416  }
417 
418  if (forwardChange)
419  {
420  int sampleRate = m_sampleRates[sampleRateIndex]/(1<<settings.m_log2Decim);
421  DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, settings.m_centerFrequency);
422  m_fileSink->handleMessage(*notif); // forward to file sink
424  }
425 
426  if (settings.m_useReverseAPI)
427  {
428  bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
432  webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
433  }
434 
435  m_settings = settings;
436  m_settings.m_devSampleRateIndex = sampleRateIndex;
437 
438  qDebug() << "PerseusInput::applySettings: "
439  << " m_LOppmTenths: " << m_settings.m_LOppmTenths
440  << " m_devSampleRateIndex: " << m_settings.m_devSampleRateIndex
441  << " m_log2Decim: " << m_settings.m_log2Decim
442  << " m_transverterMode: " << m_settings.m_transverterMode
443  << " m_transverterDeltaFrequency: " << m_settings.m_transverterDeltaFrequency
444  << " m_adcDither: " << m_settings.m_adcDither
445  << " m_adcPreamp: " << m_settings.m_adcPreamp
446  << " m_wideBand: " << m_settings.m_wideBand
447  << " m_attenuator: " << m_settings.m_attenuator;
448 
449  return true;
450 }
qint64 m_transverterDeltaFrequency
Attenuator m_attenuator
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const PerseusSettings &settings, bool force)
void push(Message *message, bool emitSignal=true)
Push message onto queue.
quint32 m_devSampleRateIndex
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
Definition: deviceapi.cpp:316
uint16_t m_reverseAPIDeviceIndex
DeviceAPI * m_deviceAPI
Definition: perseusinput.h:146
void setLog2Decimation(unsigned int log2_decim)
virtual bool handleMessage(const Message &message)
Processing of a message. Returns true if message has actually been processed.
Definition: filerecord.cpp:128
quint64 m_centerFrequency
FileRecord * m_fileSink
Definition: perseusinput.h:147
void setDeviceCenterFrequency(quint64 freq, const PerseusSettings &settings)
QString m_reverseAPIAddress
int32_t i
Definition: decimators.h:244
perseus_descr * m_perseusDescriptor
Definition: perseusinput.h:152
std::vector< uint32_t > m_sampleRates
Definition: perseusinput.h:153
PerseusThread * m_perseusThread
Definition: perseusinput.h:151
PerseusSettings m_settings
Definition: perseusinput.h:149
uint16_t m_reverseAPIPort
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ closeDevice()

void PerseusInput::closeDevice ( )
private

Definition at line 275 of file perseusinput.cpp.

References m_perseusDescriptor, m_running, and stop().

Referenced by openDevice(), and ~PerseusInput().

276 {
278  {
279  if (m_running) { stop(); }
280  perseus_close(m_perseusDescriptor);
281  }
282 }
virtual void stop()
perseus_descr * m_perseusDescriptor
Definition: perseusinput.h:152
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deserialize()

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

Implements DeviceSampleSource.

Definition at line 112 of file perseusinput.cpp.

References PerseusInput::MsgConfigurePerseus::create(), PerseusSettings::deserialize(), DeviceSampleSource::m_guiMessageQueue, DeviceSampleSource::m_inputMessageQueue, m_settings, MessageQueue::push(), and PerseusSettings::resetToDefaults().

Referenced by PerseusInput::MsgStartStop::MsgStartStop().

113 {
114  bool success = true;
115 
116  if (!m_settings.deserialize(data))
117  {
119  success = false;
120  }
121 
122  MsgConfigurePerseus* message = MsgConfigurePerseus::create(m_settings, true);
123  m_inputMessageQueue.push(message);
124 
125  if (m_guiMessageQueue)
126  {
127  MsgConfigurePerseus* messageToGUI = MsgConfigurePerseus::create(m_settings, true);
128  m_guiMessageQueue->push(messageToGUI);
129  }
130 
131  return success;
132 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
static MsgConfigurePerseus * create(const PerseusSettings &settings, bool force)
Definition: perseusinput.h:46
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
bool deserialize(const QByteArray &data)
PerseusSettings m_settings
Definition: perseusinput.h:149
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ destroy()

void PerseusInput::destroy ( )
virtual

Implements DeviceSampleSource.

Definition at line 66 of file perseusinput.cpp.

Referenced by PerseusInput::MsgStartStop::MsgStartStop().

67 {
68  delete this;
69 }
+ Here is the caller graph for this function:

◆ getCenterFrequency()

quint64 PerseusInput::getCenterFrequency ( ) const
virtual

Center frequency exposed by the source.

Implements DeviceSampleSource.

Definition at line 147 of file perseusinput.cpp.

References PerseusSettings::m_centerFrequency, and m_settings.

Referenced by setSampleRate().

148 {
150 }
quint64 m_centerFrequency
PerseusSettings m_settings
Definition: perseusinput.h:149
+ Here is the caller graph for this function:

◆ getDeviceDescription()

const QString & PerseusInput::getDeviceDescription ( ) const
virtual

Implements DeviceSampleSource.

Definition at line 134 of file perseusinput.cpp.

References m_deviceDescription.

Referenced by setMessageQueueToGUI().

135 {
136  return m_deviceDescription;
137 }
QString m_deviceDescription
Definition: perseusinput.h:148
+ Here is the caller graph for this function:

◆ getSampleRate()

int PerseusInput::getSampleRate ( ) const
virtual

Sample rate exposed by the source.

Implements DeviceSampleSource.

Definition at line 138 of file perseusinput.cpp.

References PerseusSettings::m_devSampleRateIndex, PerseusSettings::m_log2Decim, m_sampleRates, and m_settings.

Referenced by setMessageQueueToGUI().

139 {
142  } else {
143  return (m_sampleRates[0] / (1<<m_settings.m_log2Decim));
144  }
145 }
quint32 m_devSampleRateIndex
std::vector< uint32_t > m_sampleRates
Definition: perseusinput.h:153
PerseusSettings m_settings
Definition: perseusinput.h:149
+ Here is the caller graph for this function:

◆ getSampleRates()

const std::vector<uint32_t>& PerseusInput::getSampleRates ( ) const
inline

Definition at line 143 of file perseusinput.h.

References m_sampleRates.

Referenced by PerseusGui::PerseusGui(), and webapiFormatDeviceReport().

143 { return m_sampleRates; }
std::vector< uint32_t > m_sampleRates
Definition: perseusinput.h:153
+ Here is the caller graph for this function:

◆ handleMessage()

bool PerseusInput::handleMessage ( const Message message)
virtual

Implements DeviceSampleSource.

Definition at line 167 of file perseusinput.cpp.

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

Referenced by setSampleRate().

168 {
169  if (MsgConfigurePerseus::match(message))
170  {
171  MsgConfigurePerseus& conf = (MsgConfigurePerseus&) message;
172  qDebug() << "PerseusInput::handleMessage: MsgConfigurePerseus";
173 
174  bool success = applySettings(conf.getSettings(), conf.getForce());
175 
176  if (!success) {
177  qDebug("MsgConfigurePerseus::handleMessage: Perseus config error");
178  }
179 
180  return true;
181  }
182  else if (MsgStartStop::match(message))
183  {
184  MsgStartStop& cmd = (MsgStartStop&) message;
185  qDebug() << "PerseusInput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
186 
187  if (cmd.getStartStop())
188  {
190  {
192  }
193  }
194  else
195  {
197  }
198 
200  webapiReverseSendStartStop(cmd.getStartStop());
201  }
202 
203  return true;
204  }
205  else if (MsgFileRecord::match(message))
206  {
207  MsgFileRecord& conf = (MsgFileRecord&) message;
208  qDebug() << "PerseusInput::handleMessage: MsgFileRecord: " << conf.getStartStop();
209 
210  if (conf.getStartStop())
211  {
212  if (m_settings.m_fileRecordName.size() != 0) {
214  } else {
216  }
217 
219  }
220  else
221  {
223  }
224 
225  return true;
226  }
227  else
228  {
229  return false;
230  }
231 }
bool startDeviceEngine()
Start the device engine corresponding to the stream type.
Definition: deviceapi.cpp:253
void webapiReverseSendStartStop(bool start)
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
QString m_fileRecordName
void startRecording()
Definition: filerecord.cpp:105
DeviceAPI * m_deviceAPI
Definition: perseusinput.h:146
bool initDeviceEngine()
Init the device engine corresponding to the stream type.
Definition: deviceapi.cpp:240
FileRecord * m_fileSink
Definition: perseusinput.h:147
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
PerseusSettings m_settings
Definition: perseusinput.h:149
bool applySettings(const PerseusSettings &settings, bool force=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

void PerseusInput::init ( )
virtual

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

Implements DeviceSampleSource.

Definition at line 71 of file perseusinput.cpp.

References applySettings(), and m_settings.

Referenced by PerseusInput::MsgStartStop::MsgStartStop().

72 {
74 }
PerseusSettings m_settings
Definition: perseusinput.h:149
bool applySettings(const PerseusSettings &settings, bool force=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ networkManagerFinished

void PerseusInput::networkManagerFinished ( QNetworkReply *  reply)
privateslot

Definition at line 705 of file perseusinput.cpp.

Referenced by ~PerseusInput().

706 {
707  QNetworkReply::NetworkError replyError = reply->error();
708 
709  if (replyError)
710  {
711  qWarning() << "PerseusInput::networkManagerFinished:"
712  << " error(" << (int) replyError
713  << "): " << replyError
714  << ": " << reply->errorString();
715  return;
716  }
717 
718  QString answer = reply->readAll();
719  answer.chop(1); // remove last \n
720  qDebug("PerseusInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
721 }
+ Here is the caller graph for this function:

◆ openDevice()

bool PerseusInput::openDevice ( )
private

Definition at line 233 of file perseusinput.cpp.

References closeDevice(), DeviceAPI::getSamplingDeviceSerial(), DevicePerseus::getSequenceFromSerial(), i, DevicePerseus::instance(), m_deviceAPI, m_perseusDescriptor, DeviceSampleSource::m_sampleFifo, m_sampleRates, PERSEUS_NBSAMPLES, and SampleSinkFifo::setSize().

234 {
235  if (m_perseusDescriptor != 0) {
236  closeDevice();
237  }
238 
240  {
241  qCritical("PerseusInput::start: could not allocate SampleFifo");
242  return false;
243  }
244 
246  int deviceSequence = DevicePerseus::instance().getSequenceFromSerial(m_deviceAPI->getSamplingDeviceSerial().toStdString());
247 
248  if ((m_perseusDescriptor = perseus_open(deviceSequence)) == 0)
249  {
250  qCritical("PerseusInput::openDevice: cannot open device: %s", perseus_errorstr());
251  return false;
252  }
253 
254  int buf[32];
255  m_sampleRates.clear();
256 
257  if (perseus_get_sampling_rates(m_perseusDescriptor, buf, sizeof(buf)/sizeof(buf[0])) < 0)
258  {
259  qCritical("PerseusInput::openDevice: cannot get sampling rates: %s", perseus_errorstr());
260  perseus_close(m_perseusDescriptor);
261  return false;
262  }
263  else
264  {
265  for (int i = 0; (i < 32) && (buf[i] != 0); i++)
266  {
267  qDebug("PerseusInput::openDevice: sample rate: %d", buf[i]);
268  m_sampleRates.push_back(buf[i]);
269  }
270  }
271 
272  return true;
273 }
static DevicePerseus & instance()
int getSequenceFromSerial(const std::string &serial) const
Definition: deviceperseus.h:31
DeviceAPI * m_deviceAPI
Definition: perseusinput.h:146
void closeDevice()
SampleSinkFifo m_sampleFifo
bool setSize(int size)
int32_t i
Definition: decimators.h:244
perseus_descr * m_perseusDescriptor
Definition: perseusinput.h:152
std::vector< uint32_t > m_sampleRates
Definition: perseusinput.h:153
const QString & getSamplingDeviceSerial() const
Definition: deviceapi.h:121
#define PERSEUS_NBSAMPLES
Definition: perseusthread.h:29
+ Here is the call graph for this function:

◆ serialize()

QByteArray PerseusInput::serialize ( ) const
virtual

Implements DeviceSampleSource.

Definition at line 107 of file perseusinput.cpp.

References m_settings, and PerseusSettings::serialize().

Referenced by PerseusInput::MsgStartStop::MsgStartStop().

108 {
109  return m_settings.serialize();
110 }
QByteArray serialize() const
PerseusSettings m_settings
Definition: perseusinput.h:149
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCenterFrequency()

void PerseusInput::setCenterFrequency ( qint64  centerFrequency)
virtual

Implements DeviceSampleSource.

Definition at line 152 of file perseusinput.cpp.

References PerseusInput::MsgConfigurePerseus::create(), PerseusSettings::m_centerFrequency, DeviceSampleSource::m_guiMessageQueue, DeviceSampleSource::m_inputMessageQueue, m_settings, and MessageQueue::push().

Referenced by setSampleRate().

153 {
154  PerseusSettings settings = m_settings;
155  settings.m_centerFrequency = centerFrequency;
156 
157  MsgConfigurePerseus* message = MsgConfigurePerseus::create(settings, false);
158  m_inputMessageQueue.push(message);
159 
160  if (m_guiMessageQueue)
161  {
162  MsgConfigurePerseus* messageToGUI = MsgConfigurePerseus::create(settings, false);
163  m_guiMessageQueue->push(messageToGUI);
164  }
165 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
quint64 m_centerFrequency
static MsgConfigurePerseus * create(const PerseusSettings &settings, bool force)
Definition: perseusinput.h:46
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
PerseusSettings m_settings
Definition: perseusinput.h:149
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDeviceCenterFrequency()

void PerseusInput::setDeviceCenterFrequency ( quint64  freq,
const PerseusSettings settings 
)
private

Definition at line 284 of file perseusinput.cpp.

References PerseusSettings::m_LOppmTenths, m_perseusDescriptor, and PerseusSettings::m_wideBand.

Referenced by applySettings().

285 {
286  qint64 df = ((qint64)freq_hz * settings.m_LOppmTenths) / 10000000LL;
287  freq_hz += df;
288 
289  // wideband flag is inverted since parameter is set to enable preselection filters
290  int rc = perseus_set_ddc_center_freq(m_perseusDescriptor, freq_hz, settings.m_wideBand ? 0 : 1);
291 
292  if (rc < 0) {
293  qWarning("PerseusInput::setDeviceCenterFrequency: could not set frequency to %llu Hz: %s", freq_hz, perseus_errorstr());
294  } else {
295  qDebug("PerseusInput::setDeviceCenterFrequency: frequency set to %llu Hz", freq_hz);
296  }
297 }
perseus_descr * m_perseusDescriptor
Definition: perseusinput.h:152
+ Here is the caller graph for this function:

◆ setMessageQueueToGUI()

virtual void PerseusInput::setMessageQueueToGUI ( MessageQueue queue)
inlinevirtual

Implements DeviceSampleSource.

Definition at line 111 of file perseusinput.h.

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

Referenced by PerseusGui::PerseusGui().

111 { m_guiMessageQueue = queue; }
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 PerseusInput::setSampleRate ( int  sampleRate)
inlinevirtual

For when the source sample rate is set externally.

Implements DeviceSampleSource.

Definition at line 114 of file perseusinput.h.

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

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

◆ start()

bool PerseusInput::start ( )
virtual

Implements DeviceSampleSource.

Definition at line 76 of file perseusinput.cpp.

References applySettings(), PerseusSettings::m_log2Decim, m_perseusDescriptor, m_perseusThread, m_running, DeviceSampleSource::m_sampleFifo, m_settings, PerseusThread::setLog2Decimation(), PerseusThread::startWork(), and stop().

Referenced by PerseusInput::MsgStartStop::MsgStartStop().

77 {
78  if (m_running) stop();
79 
80  // start / stop streaming is done in the thread.
81 
83  qDebug("PerseusInput::start: thread created");
84 
86 
89 
90  m_running = true;
91 
92  return true;
93 }
void setLog2Decimation(unsigned int log2_decim)
SampleSinkFifo m_sampleFifo
virtual void stop()
perseus_descr * m_perseusDescriptor
Definition: perseusinput.h:152
PerseusThread * m_perseusThread
Definition: perseusinput.h:151
PerseusSettings m_settings
Definition: perseusinput.h:149
bool applySettings(const PerseusSettings &settings, bool force=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop()

void PerseusInput::stop ( )
virtual

Implements DeviceSampleSource.

Definition at line 95 of file perseusinput.cpp.

References m_perseusThread, m_running, and PerseusThread::stopWork().

Referenced by closeDevice(), PerseusInput::MsgStartStop::MsgStartStop(), and start().

96 {
97  if (m_perseusThread != 0)
98  {
100  delete m_perseusThread;
101  m_perseusThread = 0;
102  }
103 
104  m_running = false;
105 }
PerseusThread * m_perseusThread
Definition: perseusinput.h:151
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatDeviceReport()

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

Definition at line 603 of file perseusinput.cpp.

References SWGSDRangel::SWGDeviceReport::getPerseusReport(), SWGSDRangel::SWGPerseusReport::getSampleRates(), getSampleRates(), and SWGSDRangel::SWGPerseusReport::setSampleRates().

Referenced by webapiReportGet().

604 {
605  response.getPerseusReport()->setSampleRates(new QList<SWGSDRangel::SWGSampleRate*>);
606 
607  for (std::vector<uint32_t>::const_iterator it = getSampleRates().begin(); it != getSampleRates().end(); ++it)
608  {
610  response.getPerseusReport()->getSampleRates()->back()->setRate(*it);
611  }
612 }
SWGPerseusReport * getPerseusReport()
const std::vector< uint32_t > & getSampleRates() const
Definition: perseusinput.h:143
void setSampleRates(QList< SWGSampleRate *> *sample_rates)
QList< SWGSampleRate * > * getSampleRates()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatDeviceSettings()

void PerseusInput::webapiFormatDeviceSettings ( SWGSDRangel::SWGDeviceSettings response,
const PerseusSettings settings 
)
private

Definition at line 572 of file perseusinput.cpp.

References SWGSDRangel::SWGPerseusSettings::getFileRecordName(), SWGSDRangel::SWGDeviceSettings::getPerseusSettings(), SWGSDRangel::SWGPerseusSettings::getReverseApiAddress(), PerseusSettings::m_adcDither, PerseusSettings::m_adcPreamp, PerseusSettings::m_attenuator, PerseusSettings::m_centerFrequency, PerseusSettings::m_devSampleRateIndex, PerseusSettings::m_fileRecordName, PerseusSettings::m_log2Decim, PerseusSettings::m_LOppmTenths, PerseusSettings::m_reverseAPIAddress, PerseusSettings::m_reverseAPIDeviceIndex, PerseusSettings::m_reverseAPIPort, PerseusSettings::m_transverterDeltaFrequency, PerseusSettings::m_transverterMode, PerseusSettings::m_useReverseAPI, PerseusSettings::m_wideBand, SWGSDRangel::SWGPerseusSettings::setAdcDither(), SWGSDRangel::SWGPerseusSettings::setAdcPreamp(), SWGSDRangel::SWGPerseusSettings::setAttenuator(), SWGSDRangel::SWGPerseusSettings::setCenterFrequency(), SWGSDRangel::SWGPerseusSettings::setDevSampleRateIndex(), SWGSDRangel::SWGPerseusSettings::setFileRecordName(), SWGSDRangel::SWGPerseusSettings::setLog2Decim(), SWGSDRangel::SWGPerseusSettings::setLOppmTenths(), SWGSDRangel::SWGPerseusSettings::setReverseApiAddress(), SWGSDRangel::SWGPerseusSettings::setReverseApiDeviceIndex(), SWGSDRangel::SWGPerseusSettings::setReverseApiPort(), SWGSDRangel::SWGPerseusSettings::setTransverterDeltaFrequency(), SWGSDRangel::SWGPerseusSettings::setTransverterMode(), SWGSDRangel::SWGPerseusSettings::setUseReverseApi(), and SWGSDRangel::SWGPerseusSettings::setWideBand().

Referenced by webapiSettingsGet(), and webapiSettingsPutPatch().

573 {
575  response.getPerseusSettings()->setLOppmTenths(settings.m_LOppmTenths);
577  response.getPerseusSettings()->setLog2Decim(settings.m_log2Decim);
578  response.getPerseusSettings()->setAdcDither(settings.m_adcDither ? 1 : 0);
579  response.getPerseusSettings()->setAdcPreamp(settings.m_adcPreamp ? 1 : 0);
580  response.getPerseusSettings()->setWideBand(settings.m_wideBand ? 1 : 0);
581  response.getPerseusSettings()->setAttenuator((int) settings.m_attenuator);
583  response.getPerseusSettings()->setTransverterMode(settings.m_transverterMode ? 1 : 0);
584 
585  if (response.getPerseusSettings()->getFileRecordName()) {
586  *response.getPerseusSettings()->getFileRecordName() = settings.m_fileRecordName;
587  } else {
588  response.getPerseusSettings()->setFileRecordName(new QString(settings.m_fileRecordName));
589  }
590 
591  response.getPerseusSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
592 
593  if (response.getPerseusSettings()->getReverseApiAddress()) {
595  } else {
596  response.getPerseusSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
597  }
598 
601 }
qint64 m_transverterDeltaFrequency
Attenuator m_attenuator
void setLOppmTenths(qint32 l_oppm_tenths)
quint32 m_devSampleRateIndex
void setTransverterMode(qint32 transverter_mode)
void setUseReverseApi(qint32 use_reverse_api)
void setReverseApiPort(qint32 reverse_api_port)
QString m_fileRecordName
void setAdcPreamp(qint32 adc_preamp)
uint16_t m_reverseAPIDeviceIndex
SWGPerseusSettings * getPerseusSettings()
void setDevSampleRateIndex(qint32 dev_sample_rate_index)
void setReverseApiAddress(QString *reverse_api_address)
quint64 m_centerFrequency
void setAdcDither(qint32 adc_dither)
void setTransverterDeltaFrequency(qint64 transverter_delta_frequency)
QString m_reverseAPIAddress
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setCenterFrequency(qint64 center_frequency)
uint16_t m_reverseAPIPort
void setFileRecordName(QString *file_record_name)
void setLog2Decim(qint32 log2_decim)
void setAttenuator(qint32 attenuator)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReportGet()

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

Reimplemented from DeviceSampleSource.

Definition at line 561 of file perseusinput.cpp.

References SWGSDRangel::SWGDeviceReport::getPerseusReport(), SWGSDRangel::SWGPerseusReport::init(), SWGSDRangel::SWGDeviceReport::setPerseusReport(), and webapiFormatDeviceReport().

Referenced by setSampleRate().

564 {
565  (void) errorMessage;
567  response.getPerseusReport()->init();
568  webapiFormatDeviceReport(response);
569  return 200;
570 }
void setPerseusReport(SWGPerseusReport *perseus_report)
SWGPerseusReport * getPerseusReport()
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport &response)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendSettings()

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

Definition at line 614 of file perseusinput.cpp.

References SWGSDRangel::SWGDeviceSettings::asJson(), DeviceAPI::getDeviceSetIndex(), SWGSDRangel::SWGDeviceSettings::getPerseusSettings(), PerseusSettings::m_adcDither, PerseusSettings::m_adcPreamp, PerseusSettings::m_attenuator, PerseusSettings::m_centerFrequency, m_deviceAPI, PerseusSettings::m_devSampleRateIndex, PerseusSettings::m_fileRecordName, PerseusSettings::m_log2Decim, PerseusSettings::m_LOppmTenths, m_networkManager, m_networkRequest, PerseusSettings::m_reverseAPIAddress, PerseusSettings::m_reverseAPIDeviceIndex, PerseusSettings::m_reverseAPIPort, PerseusSettings::m_transverterDeltaFrequency, PerseusSettings::m_transverterMode, PerseusSettings::m_wideBand, SWGSDRangel::SWGPerseusSettings::setAdcDither(), SWGSDRangel::SWGPerseusSettings::setAdcPreamp(), SWGSDRangel::SWGPerseusSettings::setAttenuator(), SWGSDRangel::SWGPerseusSettings::setCenterFrequency(), SWGSDRangel::SWGDeviceSettings::setDeviceHwType(), SWGSDRangel::SWGPerseusSettings::setDevSampleRateIndex(), SWGSDRangel::SWGDeviceSettings::setDirection(), SWGSDRangel::SWGPerseusSettings::setFileRecordName(), SWGSDRangel::SWGPerseusSettings::setLog2Decim(), SWGSDRangel::SWGPerseusSettings::setLOppmTenths(), SWGSDRangel::SWGDeviceSettings::setOriginatorIndex(), SWGSDRangel::SWGDeviceSettings::setPerseusSettings(), SWGSDRangel::SWGPerseusSettings::setTransverterDeltaFrequency(), SWGSDRangel::SWGPerseusSettings::setTransverterMode(), and SWGSDRangel::SWGPerseusSettings::setWideBand().

Referenced by applySettings().

615 {
617  swgDeviceSettings->setDirection(0); // single Rx
618  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
619  swgDeviceSettings->setDeviceHwType(new QString("Perseus"));
620  swgDeviceSettings->setPerseusSettings(new SWGSDRangel::SWGPerseusSettings());
621  SWGSDRangel::SWGPerseusSettings *swgPerseusSettings = swgDeviceSettings->getPerseusSettings();
622 
623  // transfer data that has been modified. When force is on transfer all data except reverse API data
624 
625  if (deviceSettingsKeys.contains("centerFrequency") || force) {
626  swgPerseusSettings->setCenterFrequency(settings.m_centerFrequency);
627  }
628  if (deviceSettingsKeys.contains("LOppmTenths") || force) {
629  swgPerseusSettings->setLOppmTenths(settings.m_LOppmTenths);
630  }
631  if (deviceSettingsKeys.contains("devSampleRateIndex") || force) {
632  swgPerseusSettings->setDevSampleRateIndex(settings.m_devSampleRateIndex);
633  }
634  if (deviceSettingsKeys.contains("log2Decim") || force) {
635  swgPerseusSettings->setLog2Decim(settings.m_log2Decim);
636  }
637  if (deviceSettingsKeys.contains("adcDither") || force) {
638  swgPerseusSettings->setAdcDither(settings.m_adcDither ? 1 : 0);
639  }
640  if (deviceSettingsKeys.contains("adcPreamp") || force) {
641  swgPerseusSettings->setAdcPreamp(settings.m_adcPreamp ? 1 : 0);
642  }
643  if (deviceSettingsKeys.contains("wideBand") || force) {
644  swgPerseusSettings->setWideBand(settings.m_wideBand ? 1 : 0);
645  }
646  if (deviceSettingsKeys.contains("attenuator") || force) {
647  swgPerseusSettings->setAttenuator((int) settings.m_attenuator);
648  }
649  if (deviceSettingsKeys.contains("transverterDeltaFrequency") || force) {
650  swgPerseusSettings->setTransverterDeltaFrequency(settings.m_transverterDeltaFrequency);
651  }
652  if (deviceSettingsKeys.contains("transverterMode") || force) {
653  swgPerseusSettings->setTransverterMode(settings.m_transverterMode ? 1 : 0);
654  }
655  if (deviceSettingsKeys.contains("fileRecordName") || force) {
656  swgPerseusSettings->setFileRecordName(new QString(settings.m_fileRecordName));
657  }
658 
659  QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/settings")
660  .arg(settings.m_reverseAPIAddress)
661  .arg(settings.m_reverseAPIPort)
662  .arg(settings.m_reverseAPIDeviceIndex);
663  m_networkRequest.setUrl(QUrl(deviceSettingsURL));
664  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
665 
666  QBuffer *buffer=new QBuffer();
667  buffer->open((QBuffer::ReadWrite));
668  buffer->write(swgDeviceSettings->asJson().toUtf8());
669  buffer->seek(0);
670 
671  // Always use PATCH to avoid passing reverse API settings
672  m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
673 
674  delete swgDeviceSettings;
675 }
qint64 m_transverterDeltaFrequency
Attenuator m_attenuator
void setLOppmTenths(qint32 l_oppm_tenths)
QNetworkAccessManager * m_networkManager
Definition: perseusinput.h:154
quint32 m_devSampleRateIndex
void setTransverterMode(qint32 transverter_mode)
QString m_fileRecordName
void setAdcPreamp(qint32 adc_preamp)
virtual QString asJson() override
uint16_t m_reverseAPIDeviceIndex
DeviceAPI * m_deviceAPI
Definition: perseusinput.h:146
SWGPerseusSettings * getPerseusSettings()
void setPerseusSettings(SWGPerseusSettings *perseus_settings)
void setDevSampleRateIndex(qint32 dev_sample_rate_index)
void setOriginatorIndex(qint32 originator_index)
quint64 m_centerFrequency
void setAdcDither(qint32 adc_dither)
int getDeviceSetIndex() const
Definition: deviceapi.h:131
void setTransverterDeltaFrequency(qint64 transverter_delta_frequency)
QString m_reverseAPIAddress
QNetworkRequest m_networkRequest
Definition: perseusinput.h:155
void setCenterFrequency(qint64 center_frequency)
uint16_t m_reverseAPIPort
void setFileRecordName(QString *file_record_name)
void setLog2Decim(qint32 log2_decim)
void setAttenuator(qint32 attenuator)
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 PerseusInput::webapiReverseSendStartStop ( bool  start)
private

Definition at line 677 of file perseusinput.cpp.

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

Referenced by handleMessage().

678 {
680  swgDeviceSettings->setDirection(0); // single Rx
681  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
682  swgDeviceSettings->setDeviceHwType(new QString("Perseus"));
683 
684  QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
688  m_networkRequest.setUrl(QUrl(deviceSettingsURL));
689  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
690 
691  QBuffer *buffer=new QBuffer();
692  buffer->open((QBuffer::ReadWrite));
693  buffer->write(swgDeviceSettings->asJson().toUtf8());
694  buffer->seek(0);
695 
696  if (start) {
697  m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
698  } else {
699  m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
700  }
701 
702  delete swgDeviceSettings;
703 }
QNetworkAccessManager * m_networkManager
Definition: perseusinput.h:154
virtual QString asJson() override
uint16_t m_reverseAPIDeviceIndex
DeviceAPI * m_deviceAPI
Definition: perseusinput.h:146
void setOriginatorIndex(qint32 originator_index)
int getDeviceSetIndex() const
Definition: deviceapi.h:131
QString m_reverseAPIAddress
virtual bool start()
QNetworkRequest m_networkRequest
Definition: perseusinput.h:155
PerseusSettings m_settings
Definition: perseusinput.h:149
uint16_t m_reverseAPIPort
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 PerseusInput::webapiRun ( bool  run,
SWGSDRangel::SWGDeviceState response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSource.

Definition at line 461 of file perseusinput.cpp.

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

Referenced by setSampleRate().

465 {
466  (void) errorMessage;
468  MsgStartStop *message = MsgStartStop::create(run);
469  m_inputMessageQueue.push(message);
470 
471  if (m_guiMessageQueue) // forward to GUI if any
472  {
473  MsgStartStop *msgToGUI = MsgStartStop::create(run);
474  m_guiMessageQueue->push(msgToGUI);
475  }
476 
477  return 200;
478 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
DeviceAPI * m_deviceAPI
Definition: perseusinput.h:146
static MsgStartStop * create(bool startStop)
Definition: perseusinput.h:87
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
void getDeviceEngineStateStr(QString &state)
Definition: deviceapi.cpp:389
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiRunGet()

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

Reimplemented from DeviceSampleSource.

Definition at line 452 of file perseusinput.cpp.

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

Referenced by setSampleRate().

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

◆ webapiSettingsGet()

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

Reimplemented from DeviceSampleSource.

Definition at line 480 of file perseusinput.cpp.

References SWGSDRangel::SWGDeviceSettings::getPerseusSettings(), SWGSDRangel::SWGPerseusSettings::init(), m_settings, SWGSDRangel::SWGDeviceSettings::setPerseusSettings(), and webapiFormatDeviceSettings().

Referenced by setSampleRate().

483 {
484  (void) errorMessage;
486  response.getPerseusSettings()->init();
488  return 200;
489 }
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const PerseusSettings &settings)
SWGPerseusSettings * getPerseusSettings()
void setPerseusSettings(SWGPerseusSettings *perseus_settings)
PerseusSettings m_settings
Definition: perseusinput.h:149
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsPutPatch()

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

Reimplemented from DeviceSampleSource.

Definition at line 491 of file perseusinput.cpp.

References PerseusInput::MsgConfigurePerseus::create(), SWGSDRangel::SWGPerseusSettings::getAdcDither(), SWGSDRangel::SWGPerseusSettings::getAdcPreamp(), SWGSDRangel::SWGPerseusSettings::getAttenuator(), SWGSDRangel::SWGPerseusSettings::getCenterFrequency(), SWGSDRangel::SWGPerseusSettings::getDevSampleRateIndex(), SWGSDRangel::SWGPerseusSettings::getFileRecordName(), SWGSDRangel::SWGPerseusSettings::getLog2Decim(), SWGSDRangel::SWGPerseusSettings::getLOppmTenths(), SWGSDRangel::SWGDeviceSettings::getPerseusSettings(), SWGSDRangel::SWGPerseusSettings::getReverseApiAddress(), SWGSDRangel::SWGPerseusSettings::getReverseApiDeviceIndex(), SWGSDRangel::SWGPerseusSettings::getReverseApiPort(), SWGSDRangel::SWGPerseusSettings::getTransverterDeltaFrequency(), SWGSDRangel::SWGPerseusSettings::getTransverterMode(), SWGSDRangel::SWGPerseusSettings::getUseReverseApi(), SWGSDRangel::SWGPerseusSettings::getWideBand(), PerseusSettings::m_adcDither, PerseusSettings::m_adcPreamp, PerseusSettings::m_attenuator, PerseusSettings::m_centerFrequency, PerseusSettings::m_devSampleRateIndex, PerseusSettings::m_fileRecordName, DeviceSampleSource::m_guiMessageQueue, DeviceSampleSource::m_inputMessageQueue, PerseusSettings::m_log2Decim, PerseusSettings::m_LOppmTenths, PerseusSettings::m_reverseAPIAddress, PerseusSettings::m_reverseAPIDeviceIndex, PerseusSettings::m_reverseAPIPort, m_settings, PerseusSettings::m_transverterDeltaFrequency, PerseusSettings::m_transverterMode, PerseusSettings::m_useReverseAPI, PerseusSettings::m_wideBand, MessageQueue::push(), and webapiFormatDeviceSettings().

Referenced by setSampleRate().

496 {
497  (void) errorMessage;
498  PerseusSettings settings = m_settings;
499 
500  if (deviceSettingsKeys.contains("centerFrequency")) {
502  }
503  if (deviceSettingsKeys.contains("LOppmTenths")) {
504  settings.m_LOppmTenths = response.getPerseusSettings()->getLOppmTenths();
505  }
506  if (deviceSettingsKeys.contains("devSampleRateIndex")) {
508  }
509  if (deviceSettingsKeys.contains("log2Decim")) {
510  settings.m_log2Decim = response.getPerseusSettings()->getLog2Decim();
511  }
512  if (deviceSettingsKeys.contains("adcDither")) {
513  settings.m_adcDither = response.getPerseusSettings()->getAdcDither() != 0;
514  }
515  if (deviceSettingsKeys.contains("adcPreamp")) {
516  settings.m_adcPreamp = response.getPerseusSettings()->getAdcPreamp() != 0;
517  }
518  if (deviceSettingsKeys.contains("wideBand")) {
519  settings.m_wideBand = response.getPerseusSettings()->getWideBand() != 0;
520  }
521  if (deviceSettingsKeys.contains("attenuator")) {
522  int attenuator = response.getPerseusSettings()->getAttenuator();
523  attenuator = attenuator < 0 ? 0 : attenuator > 3 ? 3 : attenuator;
524  settings.m_attenuator = (PerseusSettings::Attenuator) attenuator;
525  }
526  if (deviceSettingsKeys.contains("transverterDeltaFrequency")) {
528  }
529  if (deviceSettingsKeys.contains("transverterMode")) {
530  settings.m_transverterMode = response.getPerseusSettings()->getTransverterMode() != 0;
531  }
532  if (deviceSettingsKeys.contains("fileRecordName")) {
533  settings.m_fileRecordName = *response.getPerseusSettings()->getFileRecordName();
534  }
535  if (deviceSettingsKeys.contains("useReverseAPI")) {
536  settings.m_useReverseAPI = response.getPerseusSettings()->getUseReverseApi() != 0;
537  }
538  if (deviceSettingsKeys.contains("reverseAPIAddress")) {
540  }
541  if (deviceSettingsKeys.contains("reverseAPIPort")) {
542  settings.m_reverseAPIPort = response.getPerseusSettings()->getReverseApiPort();
543  }
544  if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
546  }
547 
548  MsgConfigurePerseus *msg = MsgConfigurePerseus::create(settings, force);
550 
551  if (m_guiMessageQueue) // forward to GUI if any
552  {
553  MsgConfigurePerseus *msgToGUI = MsgConfigurePerseus::create(settings, force);
554  m_guiMessageQueue->push(msgToGUI);
555  }
556 
557  webapiFormatDeviceSettings(response, settings);
558  return 200;
559 }
qint64 m_transverterDeltaFrequency
Attenuator m_attenuator
void push(Message *message, bool emitSignal=true)
Push message onto queue.
quint32 m_devSampleRateIndex
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const PerseusSettings &settings)
QString m_fileRecordName
MessageQueue m_inputMessageQueue
Input queue to the source.
uint16_t m_reverseAPIDeviceIndex
SWGPerseusSettings * getPerseusSettings()
quint64 m_centerFrequency
QString m_reverseAPIAddress
static MsgConfigurePerseus * create(const PerseusSettings &settings, bool force)
Definition: perseusinput.h:46
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
PerseusSettings m_settings
Definition: perseusinput.h:149
uint16_t m_reverseAPIPort
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_deviceAPI

DeviceAPI* PerseusInput::m_deviceAPI
private

◆ m_deviceDescription

QString PerseusInput::m_deviceDescription
private

Definition at line 148 of file perseusinput.h.

Referenced by getDeviceDescription().

◆ m_fileSink

FileRecord* PerseusInput::m_fileSink
private

Definition at line 147 of file perseusinput.h.

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

◆ m_networkManager

QNetworkAccessManager* PerseusInput::m_networkManager
private

◆ m_networkRequest

QNetworkRequest PerseusInput::m_networkRequest
private

Definition at line 155 of file perseusinput.h.

Referenced by webapiReverseSendSettings(), and webapiReverseSendStartStop().

◆ m_perseusDescriptor

perseus_descr* PerseusInput::m_perseusDescriptor
private

◆ m_perseusThread

PerseusThread* PerseusInput::m_perseusThread
private

Definition at line 151 of file perseusinput.h.

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

◆ m_running

bool PerseusInput::m_running
private

Definition at line 150 of file perseusinput.h.

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

◆ m_sampleRates

std::vector<uint32_t> PerseusInput::m_sampleRates
private

Definition at line 153 of file perseusinput.h.

Referenced by applySettings(), getSampleRate(), getSampleRates(), and openDevice().

◆ m_settings

PerseusSettings PerseusInput::m_settings
private

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