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.
Public Types | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Attributes | List of all members
DeviceSampleSink Class Referenceabstract

#include <devicesamplesink.h>

+ Inheritance diagram for DeviceSampleSink:
+ Collaboration diagram for DeviceSampleSink:

Public Types

enum  fcPos_t { FC_POS_INFRA = 0, FC_POS_SUPRA, FC_POS_CENTER }
 

Public Member Functions

 DeviceSampleSink ()
 
virtual ~DeviceSampleSink ()
 
virtual void destroy ()=0
 
virtual void init ()=0
 initializations to be done when all collaborating objects are created and possibly connected More...
 
virtual bool start ()=0
 
virtual void stop ()=0
 
virtual QByteArray serialize () const =0
 
virtual bool deserialize (const QByteArray &data)=0
 
virtual const QString & getDeviceDescription () const =0
 
virtual int getSampleRate () const =0
 Sample rate exposed by the sink. More...
 
virtual void setSampleRate (int sampleRate)=0
 For when the sink sample rate is set externally. More...
 
virtual quint64 getCenterFrequency () const =0
 Center frequency exposed by the sink. More...
 
virtual void setCenterFrequency (qint64 centerFrequency)=0
 
virtual bool handleMessage (const Message &message)=0
 
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)
 
virtual int webapiReportGet (SWGSDRangel::SWGDeviceReport &response, QString &errorMessage)
 
MessageQueuegetInputMessageQueue ()
 
virtual void setMessageQueueToGUI (MessageQueue *queue)=0
 
MessageQueuegetMessageQueueToGUI ()
 
SampleSourceFifogetSampleFifo ()
 

Static Public Member Functions

static qint64 calculateDeviceCenterFrequency (quint64 centerFrequency, qint64 transverterDeltaFrequency, int log2Interp, fcPos_t fcPos, quint32 devSampleRate, bool transverterMode=false)
 
static qint64 calculateCenterFrequency (quint64 deviceCenterFrequency, qint64 transverterDeltaFrequency, int log2Interp, fcPos_t fcPos, quint32 devSampleRate, bool transverterMode=false)
 
static qint32 calculateFrequencyShift (int log2Interp, fcPos_t fcPos, quint32 devSampleRate)
 

Protected Slots

void handleInputMessages ()
 

Protected Attributes

SampleSourceFifo m_sampleSourceFifo
 
MessageQueue m_inputMessageQueue
 Input queue to the sink. More...
 
MessageQueuem_guiMessageQueue
 Input message queue to the GUI. More...
 

Detailed Description

Definition at line 36 of file devicesamplesink.h.

Member Enumeration Documentation

◆ fcPos_t

Enumerator
FC_POS_INFRA 
FC_POS_SUPRA 
FC_POS_CENTER 

Definition at line 39 of file devicesamplesink.h.

Constructor & Destructor Documentation

◆ DeviceSampleSink()

DeviceSampleSink::DeviceSampleSink ( )

Definition at line 23 of file devicesamplesink.cpp.

References handleInputMessages(), and m_inputMessageQueue.

23  :
24  m_sampleSourceFifo(1<<19),
26 {
27  connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
28 }
MessageQueue m_inputMessageQueue
Input queue to the sink.
SampleSourceFifo m_sampleSourceFifo
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
+ Here is the call graph for this function:

◆ ~DeviceSampleSink()

DeviceSampleSink::~DeviceSampleSink ( )
virtual

Definition at line 30 of file devicesamplesink.cpp.

31 {
32 }

Member Function Documentation

◆ calculateCenterFrequency()

qint64 DeviceSampleSink::calculateCenterFrequency ( quint64  deviceCenterFrequency,
qint64  transverterDeltaFrequency,
int  log2Interp,
fcPos_t  fcPos,
quint32  devSampleRate,
bool  transverterMode = false 
)
static

Definition at line 74 of file devicesamplesink.cpp.

References calculateFrequencyShift().

Referenced by HackRFOutput::handleMessage().

81 {
82  qint64 centerFrequency = deviceCenterFrequency;
83  centerFrequency += calculateFrequencyShift(log2Interp, fcPos, devSampleRate);
84  centerFrequency += transverterMode ? transverterDeltaFrequency : 0;
85  centerFrequency = centerFrequency < 0 ? 0 : centerFrequency;
86 
87  qDebug() << "DeviceSampleSink::calculateCenterFrequency:"
88  << " desired center freq: " << centerFrequency << " Hz"
89  << " device center freq: " << deviceCenterFrequency << " Hz"
90  << " device sample rate: " << devSampleRate << "S/s"
91  << " Actual sample rate: " << devSampleRate/(1<<log2Interp) << "S/s"
92  << " center freq position code: " << fcPos;
93 
94  return centerFrequency;
95 }
static qint32 calculateFrequencyShift(int log2Interp, fcPos_t fcPos, quint32 devSampleRate)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateDeviceCenterFrequency()

qint64 DeviceSampleSink::calculateDeviceCenterFrequency ( quint64  centerFrequency,
qint64  transverterDeltaFrequency,
int  log2Interp,
fcPos_t  fcPos,
quint32  devSampleRate,
bool  transverterMode = false 
)
static

Definition at line 47 of file devicesamplesink.cpp.

References calculateFrequencyShift().

Referenced by HackRFOutput::applySettings().

54 {
55  qint64 deviceCenterFrequency = centerFrequency;
56  deviceCenterFrequency -= transverterMode ? transverterDeltaFrequency : 0;
57  deviceCenterFrequency = deviceCenterFrequency < 0 ? 0 : deviceCenterFrequency;
58  qint64 f_img = deviceCenterFrequency;
59 
60  deviceCenterFrequency -= calculateFrequencyShift(log2Interp, fcPos, devSampleRate);
61  f_img -= 2*calculateFrequencyShift(log2Interp, fcPos, devSampleRate);
62 
63  qDebug() << "DeviceSampleSink::calculateDeviceCenterFrequency:"
64  << " desired center freq: " << centerFrequency << " Hz"
65  << " device center freq: " << deviceCenterFrequency << " Hz"
66  << " device sample rate: " << devSampleRate << "S/s"
67  << " Actual sample rate: " << devSampleRate/(1<<log2Interp) << "S/s"
68  << " center freq position code: " << fcPos
69  << " image frequency: " << f_img << "Hz";
70 
71  return deviceCenterFrequency;
72 }
static qint32 calculateFrequencyShift(int log2Interp, fcPos_t fcPos, quint32 devSampleRate)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateFrequencyShift()

qint32 DeviceSampleSink::calculateFrequencyShift ( int  log2Interp,
fcPos_t  fcPos,
quint32  devSampleRate 
)
static

log2Interp = 0: no shift

log2Interp = 1: middle of side band (inf or sup: 1/2) ^ | ^ | inf | inf | sup | sup |

log2Interp = 2: middle of far side half side band (inf, inf or sup, sup: 1/2 + 1/4) ^ | ^ | inf | inf | sup | sup |

log2Interp = 3: inf, inf, sup or sup, sup, inf: 1/2 + 1/4 - 1/8 = 5/8 log2Interp = 4: inf, inf, sup, inf or sup, sup, inf, sup: 1/2 + 1/4 - 1/8 + 1/16 = 11/16 log2Interp = 5: inf, inf, sup, inf, sup or sup, sup, inf, sup, inf: 1/2 + 1/4 - 1/8 + 1/16 - 1/32 = 21/32 log2Interp = 6: inf, sup, inf, sup, inf, sup or sup, inf, sup, inf, sup, inf: 1/2 - 1/4 + 1/8 -1/16 + 1/32 - 1/64 = 21/64

Definition at line 114 of file devicesamplesink.cpp.

References FC_POS_CENTER, and FC_POS_INFRA.

Referenced by calculateCenterFrequency(), calculateDeviceCenterFrequency(), and HackRFOutputGui::displayFcTooltip().

118 {
119  if (fcPos == FC_POS_CENTER) {
120  return 0;
121  }
122 
123  int sign = fcPos == FC_POS_INFRA ? -1 : 1;
124  int halfSampleRate = devSampleRate / 2; // fractions are relative to sideband thus based on half the sample rate
125 
126  if (log2Interp == 0) {
127  return 0;
128  } else if (log2Interp == 1) {
129  return sign * (halfSampleRate / 2);
130  } else if (log2Interp == 2) {
131  return sign * ((halfSampleRate * 3) / 4);
132  } else if (log2Interp == 3) {
133  return sign * ((halfSampleRate * 5) / 8);
134  } else if (log2Interp == 4) {
135  return sign * ((halfSampleRate * 11) / 16);
136  } else if (log2Interp == 5) {
137  return sign * ((halfSampleRate * 21) / 32);
138  } else if (log2Interp == 6) {
139  return sign * ((halfSampleRate * 21) / 64);
140  } else {
141  return 0;
142  }
143 }
+ Here is the caller graph for this function:

◆ deserialize()

virtual bool DeviceSampleSink::deserialize ( const QByteArray &  data)
pure virtual

◆ destroy()

virtual void DeviceSampleSink::destroy ( )
pure virtual

◆ getCenterFrequency()

virtual quint64 DeviceSampleSink::getCenterFrequency ( ) const
pure virtual

◆ getDeviceDescription()

virtual const QString& DeviceSampleSink::getDeviceDescription ( ) const
pure virtual

◆ getInputMessageQueue()

MessageQueue* DeviceSampleSink::getInputMessageQueue ( )
inline

◆ getMessageQueueToGUI()

MessageQueue* DeviceSampleSink::getMessageQueueToGUI ( )
inline

◆ getSampleFifo()

SampleSourceFifo* DeviceSampleSink::getSampleFifo ( )
inline

◆ getSampleRate()

virtual int DeviceSampleSink::getSampleRate ( ) const
pure virtual

◆ handleInputMessages

void DeviceSampleSink::handleInputMessages ( )
protectedslot

Definition at line 34 of file devicesamplesink.cpp.

References handleMessage(), m_inputMessageQueue, and MessageQueue::pop().

Referenced by DeviceSampleSink().

35 {
36  Message* message;
37 
38  while ((message = m_inputMessageQueue.pop()) != 0)
39  {
40  if (handleMessage(*message))
41  {
42  delete message;
43  }
44  }
45 }
Message * pop()
Pop message from queue.
MessageQueue m_inputMessageQueue
Input queue to the sink.
virtual bool handleMessage(const Message &message)=0
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleMessage()

virtual bool DeviceSampleSink::handleMessage ( const Message message)
pure virtual

Implemented in LimeSDROutput, XTRXOutput, FileSinkOutput, RemoteOutput, SoapySDROutput, BladeRF2Output, LocalOutput, HackRFOutput, Bladerf1Output, and PlutoSDROutput.

Referenced by handleInputMessages().

+ Here is the caller graph for this function:

◆ init()

virtual void DeviceSampleSink::init ( )
pure virtual

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

Implemented in LimeSDROutput, FileSinkOutput, XTRXOutput, RemoteOutput, SoapySDROutput, BladeRF2Output, LocalOutput, HackRFOutput, Bladerf1Output, and PlutoSDROutput.

◆ serialize()

virtual QByteArray DeviceSampleSink::serialize ( ) const
pure virtual

◆ setCenterFrequency()

virtual void DeviceSampleSink::setCenterFrequency ( qint64  centerFrequency)
pure virtual

◆ setMessageQueueToGUI()

virtual void DeviceSampleSink::setMessageQueueToGUI ( MessageQueue queue)
pure virtual

◆ setSampleRate()

virtual void DeviceSampleSink::setSampleRate ( int  sampleRate)
pure virtual

For when the sink sample rate is set externally.

Implemented in LimeSDROutput, XTRXOutput, FileSinkOutput, RemoteOutput, SoapySDROutput, BladeRF2Output, LocalOutput, HackRFOutput, Bladerf1Output, and PlutoSDROutput.

Referenced by LocalSource::propagateSampleRateAndFrequency().

+ Here is the caller graph for this function:

◆ start()

virtual bool DeviceSampleSink::start ( )
pure virtual

◆ stop()

virtual void DeviceSampleSink::stop ( )
pure virtual

◆ webapiReportGet()

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

Reimplemented in LimeSDROutput, XTRXOutput, SoapySDROutput, RemoteOutput, BladeRF2Output, LocalOutput, and PlutoSDROutput.

Definition at line 105 of file devicesamplesink.h.

Referenced by WebAPIAdapterGUI::devicesetDeviceReportGet(), and WebAPIAdapterSrv::devicesetDeviceReportGet().

108  {
109  (void) response;
110  errorMessage = "Not implemented";
111  return 501;
112  }
+ Here is the caller graph for this function:

◆ webapiRun()

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

Reimplemented in LimeSDROutput, XTRXOutput, FileSinkOutput, SoapySDROutput, RemoteOutput, BladeRF2Output, LocalOutput, HackRFOutput, Bladerf1Output, and PlutoSDROutput.

Definition at line 95 of file devicesamplesink.h.

Referenced by WebAPIAdapterGUI::devicesetDeviceRunDelete(), WebAPIAdapterSrv::devicesetDeviceRunDelete(), WebAPIAdapterGUI::devicesetDeviceRunPost(), and WebAPIAdapterSrv::devicesetDeviceRunPost().

98  {
99  (void) run;
100  (void) response;
101  errorMessage = "Not implemented";
102  return 501;
103  }
+ Here is the caller graph for this function:

◆ webapiRunGet()

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

Reimplemented in LimeSDROutput, XTRXOutput, FileSinkOutput, SoapySDROutput, RemoteOutput, BladeRF2Output, LocalOutput, HackRFOutput, Bladerf1Output, and PlutoSDROutput.

Definition at line 86 of file devicesamplesink.h.

Referenced by WebAPIAdapterGUI::devicesetDeviceRunGet(), and WebAPIAdapterSrv::devicesetDeviceRunGet().

89  {
90  (void) response;
91  errorMessage = "Not implemented";
92  return 501;
93  }
+ Here is the caller graph for this function:

◆ webapiSettingsGet()

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

Reimplemented in LimeSDROutput, XTRXOutput, SoapySDROutput, RemoteOutput, BladeRF2Output, LocalOutput, HackRFOutput, Bladerf1Output, and PlutoSDROutput.

Definition at line 64 of file devicesamplesink.h.

Referenced by WebAPIAdapterGUI::devicesetDeviceSettingsGet(), and WebAPIAdapterSrv::devicesetDeviceSettingsGet().

67  {
68  (void) response;
69  errorMessage = "Not implemented";
70  return 501;
71  }
+ Here is the caller graph for this function:

◆ webapiSettingsPutPatch()

virtual int DeviceSampleSink::webapiSettingsPutPatch ( bool  force,
const QStringList &  deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings response,
QString &  errorMessage 
)
inlinevirtual
Parameters
forcetrue to force settings = put

Reimplemented in LimeSDROutput, XTRXOutput, SoapySDROutput, RemoteOutput, BladeRF2Output, LocalOutput, HackRFOutput, Bladerf1Output, and PlutoSDROutput.

Definition at line 73 of file devicesamplesink.h.

Referenced by WebAPIAdapterGUI::devicesetDeviceSettingsPutPatch(), and WebAPIAdapterSrv::devicesetDeviceSettingsPutPatch().

78  {
79  (void) force;
80  (void) deviceSettingsKeys;
81  (void) response;
82  errorMessage = "Not implemented";
83  return 501;
84  }
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_guiMessageQueue

MessageQueue* DeviceSampleSink::m_guiMessageQueue
protected

Input message queue to the GUI.

Definition at line 146 of file devicesamplesink.h.

Referenced by PlutoSDROutput::deserialize(), Bladerf1Output::deserialize(), HackRFOutput::deserialize(), LocalOutput::deserialize(), BladeRF2Output::deserialize(), SoapySDROutput::deserialize(), RemoteOutput::deserialize(), FileSinkOutput::deserialize(), XTRXOutput::deserialize(), LimeSDROutput::deserialize(), HackRFOutput::handleMessage(), PlutoSDROutput::setCenterFrequency(), Bladerf1Output::setCenterFrequency(), HackRFOutput::setCenterFrequency(), BladeRF2Output::setCenterFrequency(), SoapySDROutput::setCenterFrequency(), FileSinkOutput::setCenterFrequency(), XTRXOutput::setCenterFrequency(), LimeSDROutput::setCenterFrequency(), PlutoSDROutput::setMessageQueueToGUI(), Bladerf1Output::setMessageQueueToGUI(), HackRFOutput::setMessageQueueToGUI(), LocalOutput::setMessageQueueToGUI(), BladeRF2Output::setMessageQueueToGUI(), RemoteOutput::setMessageQueueToGUI(), FileSinkOutput::setMessageQueueToGUI(), XTRXOutput::setMessageQueueToGUI(), LimeSDROutput::setMessageQueueToGUI(), PlutoSDROutput::webapiRun(), Bladerf1Output::webapiRun(), HackRFOutput::webapiRun(), LocalOutput::webapiRun(), BladeRF2Output::webapiRun(), RemoteOutput::webapiRun(), SoapySDROutput::webapiRun(), FileSinkOutput::webapiRun(), XTRXOutput::webapiRun(), LimeSDROutput::webapiRun(), PlutoSDROutput::webapiSettingsPutPatch(), Bladerf1Output::webapiSettingsPutPatch(), HackRFOutput::webapiSettingsPutPatch(), LocalOutput::webapiSettingsPutPatch(), BladeRF2Output::webapiSettingsPutPatch(), RemoteOutput::webapiSettingsPutPatch(), SoapySDROutput::webapiSettingsPutPatch(), XTRXOutput::webapiSettingsPutPatch(), and LimeSDROutput::webapiSettingsPutPatch().

◆ m_inputMessageQueue

MessageQueue DeviceSampleSink::m_inputMessageQueue
protected

◆ m_sampleSourceFifo

SampleSourceFifo DeviceSampleSink::m_sampleSourceFifo
protected

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