1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

Device plugins: make setMessageQueueToGUI pure virtual so that child classes must have to deal with this

This commit is contained in:
f4exb 2017-12-24 19:58:26 +01:00
parent b127182062
commit 1987bbac77
25 changed files with 54 additions and 72 deletions

View File

@ -97,6 +97,7 @@ public:
virtual bool start(); virtual bool start();
virtual void stop(); virtual void stop();
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
virtual const QString& getDeviceDescription() const; virtual const QString& getDeviceDescription() const;
virtual int getSampleRate() const; virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const; virtual quint64 getCenterFrequency() const;

View File

@ -177,6 +177,7 @@ public:
virtual bool start(); virtual bool start();
virtual void stop(); virtual void stop();
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
virtual const QString& getDeviceDescription() const; virtual const QString& getDeviceDescription() const;
virtual int getSampleRate() const; virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const; virtual quint64 getCenterFrequency() const;

View File

@ -97,6 +97,7 @@ public:
virtual bool start(); virtual bool start();
virtual void stop(); virtual void stop();
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
virtual const QString& getDeviceDescription() const; virtual const QString& getDeviceDescription() const;
virtual int getSampleRate() const; virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const; virtual quint64 getCenterFrequency() const;

View File

@ -191,6 +191,7 @@ public:
virtual bool start(); virtual bool start();
virtual void stop(); virtual void stop();
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
virtual const QString& getDeviceDescription() const; virtual const QString& getDeviceDescription() const;
virtual int getSampleRate() const; virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const; virtual quint64 getCenterFrequency() const;

View File

@ -79,6 +79,7 @@ public:
virtual bool start(); virtual bool start();
virtual void stop(); virtual void stop();
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
virtual const QString& getDeviceDescription() const; virtual const QString& getDeviceDescription() const;
virtual int getSampleRate() const; virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const; virtual quint64 getCenterFrequency() const;

View File

@ -158,6 +158,7 @@ public:
virtual bool start(); virtual bool start();
virtual void stop(); virtual void stop();
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
virtual const QString& getDeviceDescription() const; virtual const QString& getDeviceDescription() const;
virtual int getSampleRate() const; virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const; virtual quint64 getCenterFrequency() const;

View File

@ -97,6 +97,7 @@ public:
virtual bool start(); virtual bool start();
virtual void stop(); virtual void stop();
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
virtual const QString& getDeviceDescription() const; virtual const QString& getDeviceDescription() const;
virtual int getSampleRate() const; virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const; virtual quint64 getCenterFrequency() const;

View File

@ -100,6 +100,7 @@ public:
virtual bool start(); virtual bool start();
virtual void stop(); virtual void stop();
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
virtual const QString& getDeviceDescription() const; virtual const QString& getDeviceDescription() const;
virtual int getSampleRate() const; virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const; virtual quint64 getCenterFrequency() const;

View File

@ -104,6 +104,7 @@ public:
virtual bool start(); virtual bool start();
virtual void stop(); virtual void stop();
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
virtual const QString& getDeviceDescription() const; virtual const QString& getDeviceDescription() const;
virtual int getSampleRate() const; virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const; virtual quint64 getCenterFrequency() const;

View File

@ -103,6 +103,7 @@ public:
virtual bool start(); virtual bool start();
virtual void stop(); virtual void stop();
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
virtual const QString& getDeviceDescription() const; virtual const QString& getDeviceDescription() const;
virtual int getSampleRate() const; virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const; virtual quint64 getCenterFrequency() const;

View File

@ -229,6 +229,7 @@ public:
virtual bool start(); virtual bool start();
virtual void stop(); virtual void stop();
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
virtual const QString& getDeviceDescription() const; virtual const QString& getDeviceDescription() const;
virtual int getSampleRate() const; virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const; virtual quint64 getCenterFrequency() const;

View File

@ -117,6 +117,7 @@ public:
virtual bool start(); virtual bool start();
virtual void stop(); virtual void stop();
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
virtual const QString& getDeviceDescription() const; virtual const QString& getDeviceDescription() const;
virtual int getSampleRate() const; virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const; virtual quint64 getCenterFrequency() const;

View File

@ -211,6 +211,7 @@ public:
virtual bool start(); virtual bool start();
virtual void stop(); virtual void stop();
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
virtual const QString& getDeviceDescription() const; virtual const QString& getDeviceDescription() const;
virtual int getSampleRate() const; virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const; virtual quint64 getCenterFrequency() const;

View File

@ -99,6 +99,7 @@ public:
virtual bool start(); virtual bool start();
virtual void stop(); virtual void stop();
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
virtual const QString& getDeviceDescription() const; virtual const QString& getDeviceDescription() const;
virtual int getSampleRate() const; virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const; virtual quint64 getCenterFrequency() const;

View File

@ -55,6 +55,9 @@ RTLSDRGui::RTLSDRGui(DeviceUISet *deviceUISet, QWidget* parent) :
displaySettings(); displaySettings();
m_gains = m_sampleSource->getGains();
displayGains();
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection); connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection);
} }
@ -133,13 +136,7 @@ bool RTLSDRGui::deserialize(const QByteArray& data)
bool RTLSDRGui::handleMessage(const Message& message) bool RTLSDRGui::handleMessage(const Message& message)
{ {
if (RTLSDRInput::MsgReportRTLSDR::match(message)) if (RTLSDRInput::MsgConfigureRTLSDR::match(message))
{
m_gains = ((RTLSDRInput::MsgReportRTLSDR&) message).getGains();
displayGains();
return true;
}
else if (RTLSDRInput::MsgConfigureRTLSDR::match(message))
{ {
const RTLSDRInput::MsgConfigureRTLSDR& cfg = (RTLSDRInput::MsgConfigureRTLSDR&) message; const RTLSDRInput::MsgConfigureRTLSDR& cfg = (RTLSDRInput::MsgConfigureRTLSDR&) message;
m_settings = cfg.getSettings(); m_settings = cfg.getSettings();

View File

@ -61,7 +61,7 @@ private:
QTimer m_updateTimer; QTimer m_updateTimer;
QTimer m_statusTimer; QTimer m_statusTimer;
std::vector<int> m_gains; std::vector<int> m_gains;
DeviceSampleSource* m_sampleSource; RTLSDRInput* m_sampleSource;
int m_sampleRate; int m_sampleRate;
quint64 m_deviceCenterFrequency; //!< Center frequency in device quint64 m_deviceCenterFrequency; //!< Center frequency in device
int m_lastEngineState; int m_lastEngineState;

View File

@ -32,7 +32,6 @@
#include "dsp/filerecord.h" #include "dsp/filerecord.h"
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgConfigureRTLSDR, Message) MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgConfigureRTLSDR, Message)
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgReportRTLSDR, Message)
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgFileRecord, Message) MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgFileRecord, Message)
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgStartStop, Message) MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgStartStop, Message)
@ -481,17 +480,6 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force)
return true; return true;
} }
void RTLSDRInput::setMessageQueueToGUI(MessageQueue *queue)
{
qDebug("RTLSDRInput::setMessageQueueToGUI: %p", queue);
DeviceSampleSource::setMessageQueueToGUI(queue);
if (queue) {
MsgReportRTLSDR *message = MsgReportRTLSDR::create(m_gains);
queue->push(message);
}
}
void RTLSDRInput::set_ds_mode(int on) void RTLSDRInput::set_ds_mode(int on)
{ {
rtlsdr_set_direct_sampling(m_dev, on); rtlsdr_set_direct_sampling(m_dev, on);

View File

@ -53,26 +53,6 @@ public:
{ } { }
}; };
class MsgReportRTLSDR : public Message {
MESSAGE_CLASS_DECLARATION
public:
const std::vector<int>& getGains() const { return m_gains; }
static MsgReportRTLSDR* create(const std::vector<int>& gains)
{
return new MsgReportRTLSDR(gains);
}
protected:
std::vector<int> m_gains;
MsgReportRTLSDR(const std::vector<int>& gains) :
Message(),
m_gains(gains)
{ }
};
class MsgFileRecord : public Message { class MsgFileRecord : public Message {
MESSAGE_CLASS_DECLARATION MESSAGE_CLASS_DECLARATION
@ -118,12 +98,12 @@ public:
virtual bool start(); virtual bool start();
virtual void stop(); virtual void stop();
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
virtual const QString& getDeviceDescription() const; virtual const QString& getDeviceDescription() const;
virtual int getSampleRate() const; virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const; virtual quint64 getCenterFrequency() const;
virtual bool handleMessage(const Message& message); virtual bool handleMessage(const Message& message);
virtual void setMessageQueueToGUI(MessageQueue *queue);
virtual int webapiSettingsGet( virtual int webapiSettingsGet(
SWGSDRangel::SWGDeviceSettings& response, SWGSDRangel::SWGDeviceSettings& response,

View File

@ -54,7 +54,8 @@ SDRdaemonSourceInput::SDRdaemonSourceInput(DeviceSourceAPI *deviceAPI) :
m_autoCorrBuffer(false) m_autoCorrBuffer(false)
{ {
m_sampleFifo.setSize(96000 * 4); m_sampleFifo.setSize(96000 * 4);
m_SDRdaemonUDPHandler = new SDRdaemonSourceUDPHandler(&m_sampleFifo, &m_inputMessageQueue, m_deviceAPI); //m_SDRdaemonUDPHandler = new SDRdaemonSourceUDPHandler(&m_sampleFifo, &m_inputMessageQueue, m_deviceAPI);
m_SDRdaemonUDPHandler = new SDRdaemonSourceUDPHandler(&m_sampleFifo, m_deviceAPI);
m_SDRdaemonUDPHandler->connectTimer(&m_masterTimer); m_SDRdaemonUDPHandler->connectTimer(&m_masterTimer);
char recFileNameCStr[30]; char recFileNameCStr[30];
@ -91,6 +92,12 @@ void SDRdaemonSourceInput::stop()
getInputMessageQueue()->push(command); getInputMessageQueue()->push(command);
} }
void SDRdaemonSourceInput::setMessageQueueToGUI(MessageQueue *queue)
{
m_guiMessageQueue = queue;
m_SDRdaemonUDPHandler->setMessageQueueToGUI(queue);
}
const QString& SDRdaemonSourceInput::getDeviceDescription() const const QString& SDRdaemonSourceInput::getDeviceDescription() const
{ {
return m_deviceDescription; return m_deviceDescription;
@ -224,13 +231,6 @@ bool SDRdaemonSourceInput::handleMessage(const Message& message)
} }
} }
void SDRdaemonSourceInput::setMessageQueueToGUI(MessageQueue *queue)
{
qDebug("SDRdaemonSourceInput::setMessageQueueToGUI: %p", queue);
DeviceSampleSource::setMessageQueueToGUI(queue);
m_SDRdaemonUDPHandler->setMessageQueueToGUI(queue);
}
int SDRdaemonSourceInput::webapiRunGet( int SDRdaemonSourceInput::webapiRunGet(
SWGSDRangel::SWGDeviceState& response, SWGSDRangel::SWGDeviceState& response,
QString& errorMessage __attribute__((unused))) QString& errorMessage __attribute__((unused)))

View File

@ -329,6 +329,7 @@ public:
virtual bool start(); virtual bool start();
virtual void stop(); virtual void stop();
virtual void setMessageQueueToGUI(MessageQueue *queue);
virtual const QString& getDeviceDescription() const; virtual const QString& getDeviceDescription() const;
virtual int getSampleRate() const; virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const; virtual quint64 getCenterFrequency() const;
@ -337,8 +338,6 @@ public:
virtual bool handleMessage(const Message& message); virtual bool handleMessage(const Message& message);
virtual void setMessageQueueToGUI(MessageQueue *queue);
virtual int webapiRunGet( virtual int webapiRunGet(
SWGSDRangel::SWGDeviceState& response, SWGSDRangel::SWGDeviceState& response,
QString& errorMessage); QString& errorMessage);

View File

@ -26,7 +26,7 @@
#include "sdrdaemonsourceinput.h" #include "sdrdaemonsourceinput.h"
#include "sdrdaemonsourceudphandler.h" #include "sdrdaemonsourceudphandler.h"
SDRdaemonSourceUDPHandler::SDRdaemonSourceUDPHandler(SampleSinkFifo *sampleFifo, MessageQueue *outputMessageQueueToGUI, DeviceSourceAPI *devieAPI) : SDRdaemonSourceUDPHandler::SDRdaemonSourceUDPHandler(SampleSinkFifo *sampleFifo, DeviceSourceAPI *devieAPI) :
m_deviceAPI(devieAPI), m_deviceAPI(devieAPI),
m_sdrDaemonBuffer(m_rateDivider), m_sdrDaemonBuffer(m_rateDivider),
m_dataSocket(0), m_dataSocket(0),
@ -41,7 +41,7 @@ SDRdaemonSourceUDPHandler::SDRdaemonSourceUDPHandler(SampleSinkFifo *sampleFifo,
m_centerFrequency(0), m_centerFrequency(0),
m_tv_sec(0), m_tv_sec(0),
m_tv_usec(0), m_tv_usec(0),
m_outputMessageQueueToGUI(outputMessageQueueToGUI), m_outputMessageQueueToGUI(0),
m_tickCount(0), m_tickCount(0),
m_samplesCount(0), m_samplesCount(0),
m_timer(0), m_timer(0),
@ -244,22 +244,25 @@ void SDRdaemonSourceUDPHandler::tick()
framesDecodingStatus = 2; framesDecodingStatus = 2;
} }
SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming *report = SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming::create( if (m_outputMessageQueueToGUI)
m_tv_sec, {
m_tv_usec, SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming *report = SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming::create(
m_sdrDaemonBuffer.getBufferLengthInSecs(), m_tv_sec,
m_sdrDaemonBuffer.getBufferGauge(), m_tv_usec,
framesDecodingStatus, m_sdrDaemonBuffer.getBufferLengthInSecs(),
minNbBlocks == nbOriginalBlocks + nbFECblocks, m_sdrDaemonBuffer.getBufferGauge(),
minNbBlocks, framesDecodingStatus,
minNbOriginalBlocks, minNbBlocks == nbOriginalBlocks + nbFECblocks,
m_sdrDaemonBuffer.getMaxNbRecovery(), minNbBlocks,
m_sdrDaemonBuffer.getAvgNbBlocks(), minNbOriginalBlocks,
m_sdrDaemonBuffer.getAvgOriginalBlocks(), m_sdrDaemonBuffer.getMaxNbRecovery(),
m_sdrDaemonBuffer.getAvgNbRecovery(), m_sdrDaemonBuffer.getAvgNbBlocks(),
nbOriginalBlocks, m_sdrDaemonBuffer.getAvgOriginalBlocks(),
nbFECblocks); m_sdrDaemonBuffer.getAvgNbRecovery(),
nbOriginalBlocks,
nbFECblocks);
m_outputMessageQueueToGUI->push(report); m_outputMessageQueueToGUI->push(report);
}
} }
} }

View File

@ -36,7 +36,7 @@ class SDRdaemonSourceUDPHandler : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
SDRdaemonSourceUDPHandler(SampleSinkFifo* sampleFifo, MessageQueue *outputMessageQueueToGUI, DeviceSourceAPI *deviceAPI); SDRdaemonSourceUDPHandler(SampleSinkFifo* sampleFifo, DeviceSourceAPI *deviceAPI);
~SDRdaemonSourceUDPHandler(); ~SDRdaemonSourceUDPHandler();
void setMessageQueueToGUI(MessageQueue *queue) { m_outputMessageQueueToGUI = queue; } void setMessageQueueToGUI(MessageQueue *queue) { m_outputMessageQueueToGUI = queue; }
void connectTimer(const QTimer* timer); void connectTimer(const QTimer* timer);

View File

@ -135,6 +135,7 @@ public:
virtual bool start(); virtual bool start();
virtual void stop(); virtual void stop();
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
virtual const QString& getDeviceDescription() const; virtual const QString& getDeviceDescription() const;
virtual int getSampleRate() const; virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const; virtual quint64 getCenterFrequency() const;

View File

@ -69,7 +69,7 @@ public:
{ errorMessage = "Not implemented"; return 501; } { errorMessage = "Not implemented"; return 501; }
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; } virtual void setMessageQueueToGUI(MessageQueue *queue) = 0; // pure virtual so that child classes must have to deal with this
MessageQueue *getMessageQueueToGUI() { return m_guiMessageQueue; } MessageQueue *getMessageQueueToGUI() { return m_guiMessageQueue; }
SampleSourceFifo* getSampleFifo() { return &m_sampleSourceFifo; } SampleSourceFifo* getSampleFifo() { return &m_sampleSourceFifo; }

View File

@ -69,7 +69,7 @@ public:
{ errorMessage = "Not implemented"; return 501; } { errorMessage = "Not implemented"; return 501; }
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; } virtual void setMessageQueueToGUI(MessageQueue *queue) = 0; // pure virtual so that child classes must have to deal with this
MessageQueue *getMessageQueueToGUI() { return m_guiMessageQueue; } MessageQueue *getMessageQueueToGUI() { return m_guiMessageQueue; }
SampleSinkFifo* getSampleFifo() { return &m_sampleFifo; } SampleSinkFifo* getSampleFifo() { return &m_sampleFifo; }