1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-04-04 10:38:45 -04:00

Frequency Tracker: refactoring of classes: even more fixes

This commit is contained in:
f4exb 2019-12-10 13:55:42 +01:00
parent 85304534ca
commit 8004559ab5
8 changed files with 40 additions and 67 deletions

View File

@ -125,6 +125,12 @@ bool FreqTracker::handleMessage(const Message& cmd)
qDebug() << "FreqTracker::handleMessage: DSPSignalNotification";
m_basebandSink->getInputMessageQueue()->push(rep);
if (getMessageQueueToGUI())
{
DSPSignalNotification *msg = new DSPSignalNotification(notif);
getMessageQueueToGUI()->push(msg);
}
return true;
}
else if (MsgConfigureFreqTracker::match(cmd))
@ -142,6 +148,12 @@ bool FreqTracker::handleMessage(const Message& cmd)
settings.m_inputFrequencyOffset = cfg.getFrequencyOffset();
applySettings(settings, false);
if (getMessageQueueToGUI())
{
FreqTrackerReport::MsgSinkFrequencyOffsetNotification *msg = new FreqTrackerReport::MsgSinkFrequencyOffsetNotification(cfg);
getMessageQueueToGUI()->push(msg);
}
return true;
}
else

View File

@ -120,10 +120,6 @@ public:
m_basebandSink->setMessageQueueToInput(messageQueueToInput);
}
void propagateMessageQueueToGUI(MessageQueue *messageQueueToGUI) {
m_basebandSink->setMessageQueueToGUI(messageQueueToGUI);
}
uint32_t getNumberOfDeviceStreams() const;
static const QString m_channelIdURI;

View File

@ -27,8 +27,7 @@
MESSAGE_CLASS_DEFINITION(FreqTrackerBaseband::MsgConfigureFreqTrackerBaseband, Message)
FreqTrackerBaseband::FreqTrackerBaseband() :
m_mutex(QMutex::Recursive),
m_messageQueueToGUI(nullptr)
m_mutex(QMutex::Recursive)
{
m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(48000));
m_channelizer = new DownSampleChannelizer(&m_sink);
@ -127,15 +126,6 @@ bool FreqTrackerBaseband::handleMessage(const Message& cmd)
m_channelizer->getChannelFrequencyOffset()
);
if (getMessageQueueToGUI())
{
FreqTrackerReport::MsgNotificationToGUI *msg = FreqTrackerReport::MsgNotificationToGUI::create(
m_basebandSampleRate / (1<<m_settings.m_log2Decim),
m_settings.m_inputFrequencyOffset
);
getMessageQueueToGUI()->push(msg);
}
return true;
}
else
@ -155,15 +145,6 @@ void FreqTrackerBaseband::applySettings(const FreqTrackerSettings& settings, boo
m_channelizer->getChannelSampleRate(),
m_channelizer->getChannelFrequencyOffset()
);
if (getMessageQueueToGUI())
{
FreqTrackerReport::MsgNotificationToGUI *msg = FreqTrackerReport::MsgNotificationToGUI::create(
m_basebandSampleRate / (1<<settings.m_log2Decim),
settings.m_inputFrequencyOffset
);
getMessageQueueToGUI()->push(msg);
}
}
m_sink.applySettings(settings, force);

View File

@ -64,7 +64,6 @@ public:
int getChannelSampleRate() const;
void setBasebandSampleRate(int sampleRate);
void setMessageQueueToInput(MessageQueue *messageQueue) { m_sink.setMessageQueueToInput(messageQueue); }
void setMessageQueueToGUI(MessageQueue *messageQueue) { m_messageQueueToGUI = messageQueue; }
double getMagSq() const { return m_sink.getMagSq(); }
bool getSquelchOpen() const { return m_sink.getSquelchOpen(); }
@ -83,9 +82,6 @@ private:
unsigned int m_basebandSampleRate;
QMutex m_mutex;
MessageQueue *m_messageQueueToGUI;
MessageQueue *getMessageQueueToGUI() { return m_messageQueueToGUI; }
bool handleMessage(const Message& cmd);
void applySettings(const FreqTrackerSettings& settings, bool force = false);

View File

@ -24,7 +24,7 @@
#include "device/deviceuiset.h"
#include "dsp/downchannelizer.h"
#include "dsp/dspengine.h"
#include "dsp/threadedbasebandsamplesink.h"
#include "dsp/dspcommands.h"
#include "ui_freqtrackergui.h"
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
@ -106,23 +106,28 @@ bool FreqTrackerGUI::handleMessage(const Message& message)
blockApplySettings(false);
return true;
}
else if (FreqTrackerReport::MsgNotificationToGUI::match(message))
else if (DSPSignalNotification::match(message))
{
DSPSignalNotification& cfg = (DSPSignalNotification&) message;
m_basebandSampleRate = cfg.getSampleRate();
int sinkSampleRate = m_basebandSampleRate / (1<<m_settings.m_log2Decim);
ui->channelSampleRateText->setText(tr("%1k").arg(QString::number(sinkSampleRate / 1000.0f, 'g', 5)));
if (sinkSampleRate > 1000) {
ui->rfBW->setMaximum(sinkSampleRate/100);
}
return true;
}
else if (FreqTrackerReport::MsgSinkFrequencyOffsetNotification::match(message))
{
if (!m_settings.m_tracking) {
qDebug("FreqTrackerGUI::handleMessage: FreqTrackerReport::MsgNotificationToGUI");
qDebug("FreqTrackerGUI::handleMessage: FreqTrackerReport::MsgSinkFrequencyOffsetNotification");
}
const FreqTrackerReport::MsgNotificationToGUI& cfg = (FreqTrackerReport::MsgNotificationToGUI&) message;
m_channelSampleRate = cfg.getSinkSampleRate();
m_settings.m_inputFrequencyOffset = cfg.getSinkFrequencyOffset();
ui->channelSampleRateText->setText(tr("%1k").arg(QString::number(m_channelSampleRate / 1000.0f, 'g', 5)));
blockApplySettings(true);
const FreqTrackerReport::MsgSinkFrequencyOffsetNotification& cfg = (FreqTrackerReport::MsgSinkFrequencyOffsetNotification&) message;
m_settings.m_inputFrequencyOffset = cfg.getFrequencyOffset();
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
ui->deltaFrequency->setValue(m_settings.m_inputFrequencyOffset);
blockApplySettings(false);
if (m_channelSampleRate > 1000) {
ui->rfBW->setMaximum(m_channelSampleRate/100);
}
return true;
}
@ -165,6 +170,13 @@ void FreqTrackerGUI::on_deltaFrequency_changed(qint64 value)
void FreqTrackerGUI::on_log2Decim_currentIndexChanged(int index)
{
m_settings.m_log2Decim = index < 0 ? 0 : index > 6 ? 6 : index;
int sinkSampleRate = m_basebandSampleRate / (1<<m_settings.m_log2Decim);
ui->channelSampleRateText->setText(tr("%1k").arg(QString::number(sinkSampleRate / 1000.0f, 'g', 5)));
if (sinkSampleRate > 1000) {
ui->rfBW->setMaximum(sinkSampleRate/100);
}
applySettings();
}
@ -297,7 +309,7 @@ FreqTrackerGUI::FreqTrackerGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, B
m_pluginAPI(pluginAPI),
m_deviceUISet(deviceUISet),
m_channelMarker(this),
m_channelSampleRate(0),
m_basebandSampleRate(0),
m_doApplySettings(true),
m_squelchOpen(false),
m_tickCount(0)
@ -309,7 +321,6 @@ FreqTrackerGUI::FreqTrackerGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, B
m_freqTracker = reinterpret_cast<FreqTracker*>(rxChannel); //new FreqTracker(m_deviceUISet->m_deviceSourceAPI);
m_freqTracker->setMessageQueueToGUI(getInputMessageQueue());
m_freqTracker->propagateMessageQueueToGUI(getInputMessageQueue());
connect(&MainWindow::getInstance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); // 50 ms

View File

@ -65,7 +65,7 @@ private:
DeviceUISet* m_deviceUISet;
ChannelMarker m_channelMarker;
FreqTrackerSettings m_settings;
int m_channelSampleRate;
int m_basebandSampleRate;
bool m_doApplySettings;
FreqTracker* m_freqTracker;

View File

@ -17,7 +17,6 @@
#include "freqtrackerreport.h"
MESSAGE_CLASS_DEFINITION(FreqTrackerReport::MsgNotificationToGUI, Message)
MESSAGE_CLASS_DEFINITION(FreqTrackerReport::MsgConfigureChannelizer, Message)
MESSAGE_CLASS_DEFINITION(FreqTrackerReport::MsgSinkFrequencyOffsetNotification, Message)

View File

@ -23,28 +23,6 @@
class FreqTrackerReport
{
public:
class MsgNotificationToGUI : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgNotificationToGUI* create(int sinkSampleRate, int sinkFrequencyOffset) {
return new MsgNotificationToGUI(sinkSampleRate, sinkFrequencyOffset);
}
int getSinkSampleRate() const { return m_sinkSampleRate; }
int getSinkFrequencyOffset() const { return m_sinkFrequencyOffset; }
private:
MsgNotificationToGUI(int sinkSampleRate, int sinkFrequencyOffset) :
Message(),
m_sinkSampleRate(sinkSampleRate),
m_sinkFrequencyOffset(sinkFrequencyOffset)
{ }
int m_sinkSampleRate;
int m_sinkFrequencyOffset;
};
class MsgConfigureChannelizer : public Message {
MESSAGE_CLASS_DECLARATION