diff --git a/plugins/channeltx/daemonsrc/daemonsrc.cpp b/plugins/channeltx/daemonsrc/daemonsrc.cpp
index 8f2f23b26..694a258dc 100644
--- a/plugins/channeltx/daemonsrc/daemonsrc.cpp
+++ b/plugins/channeltx/daemonsrc/daemonsrc.cpp
@@ -14,12 +14,16 @@
// along with this program. If not, see . //
///////////////////////////////////////////////////////////////////////////////////
+#include
+
#include "device/devicesinkapi.h"
#include "dsp/upchannelizer.h"
#include "dsp/threadedbasebandsamplesource.h"
#include "daemonsrc.h"
+MESSAGE_CLASS_DEFINITION(DaemonSrc::MsgSampleRateNotification, Message)
+
const QString DaemonSrc::m_channelIdURI = "sdrangel.channeltx.daemonsrc";
const QString DaemonSrc::m_channelId ="DaemonSrc";
@@ -61,8 +65,24 @@ void DaemonSrc::stop()
{
}
-bool DaemonSrc::handleMessage(const Message& cmd __attribute__((unused)))
+bool DaemonSrc::handleMessage(const Message& cmd)
{
+ if (UpChannelizer::MsgChannelizerNotification::match(cmd))
+ {
+ UpChannelizer::MsgChannelizerNotification& notif = (UpChannelizer::MsgChannelizerNotification&) cmd;
+ qDebug() << "DaemonSrc::handleMessage: MsgChannelizerNotification:"
+ << " basebandSampleRate: " << notif.getBasebandSampleRate()
+ << " outputSampleRate: " << notif.getSampleRate()
+ << " inputFrequencyOffset: " << notif.getFrequencyOffset();
+
+ if (m_guiMessageQueue)
+ {
+ MsgSampleRateNotification *msg = MsgSampleRateNotification::create(notif.getBasebandSampleRate());
+ m_guiMessageQueue->push(msg);
+ }
+
+ return true;
+ }
return false;
}
diff --git a/plugins/channeltx/daemonsrc/daemonsrc.h b/plugins/channeltx/daemonsrc/daemonsrc.h
index bf4e24813..743313b92 100644
--- a/plugins/channeltx/daemonsrc/daemonsrc.h
+++ b/plugins/channeltx/daemonsrc/daemonsrc.h
@@ -16,6 +16,7 @@
#include "dsp/basebandsamplesource.h"
#include "channel/channelsourceapi.h"
+#include "util/message.h"
#include "daemonsrcsettings.h"
@@ -27,6 +28,26 @@ class DaemonSrc : public BasebandSampleSource, public ChannelSourceAPI {
Q_OBJECT
public:
+ class MsgSampleRateNotification : public Message {
+ MESSAGE_CLASS_DECLARATION
+
+ public:
+ static MsgSampleRateNotification* create(int sampleRate) {
+ return new MsgSampleRateNotification(sampleRate);
+ }
+
+ int getSampleRate() const { return m_sampleRate; }
+
+ private:
+
+ MsgSampleRateNotification(int sampleRate) :
+ Message(),
+ m_sampleRate(sampleRate)
+ { }
+
+ int m_sampleRate;
+ };
+
DaemonSrc(DeviceSinkAPI *deviceAPI);
~DaemonSrc();
diff --git a/plugins/channeltx/daemonsrc/daemonsrcgui.cpp b/plugins/channeltx/daemonsrc/daemonsrcgui.cpp
index d67542d45..7e5074d55 100644
--- a/plugins/channeltx/daemonsrc/daemonsrcgui.cpp
+++ b/plugins/channeltx/daemonsrc/daemonsrcgui.cpp
@@ -16,7 +16,10 @@
#include "device/devicesinkapi.h"
#include "device/deviceuiset.h"
+#include "gui/basicchannelsettingsdialog.h"
+#include "mainwindow.h"
+#include "daemonsrc.h"
#include "ui_daemonsrcgui.h"
#include "daemonsrcgui.h"
@@ -73,8 +76,14 @@ bool DaemonSrcGUI::deserialize(const QByteArray& data)
}
}
-bool DaemonSrcGUI::handleMessage(const Message& message __attribute__((unused)))
+bool DaemonSrcGUI::handleMessage(const Message& message)
{
+ if (DaemonSrc::MsgSampleRateNotification::match(message))
+ {
+ DaemonSrc::MsgSampleRateNotification& notif = (DaemonSrc::MsgSampleRateNotification&) message;
+ m_channelMarker.setBandwidth(notif.getSampleRate());
+ }
+
return false;
}
@@ -87,6 +96,27 @@ DaemonSrcGUI::DaemonSrcGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
+
+ m_daemonSrc = (DaemonSrc*) channelTx;
+ m_daemonSrc->setMessageQueueToGUI(getInputMessageQueue());
+
+ m_channelMarker.blockSignals(true);
+ m_channelMarker.setColor(m_settings.m_rgbColor);
+ m_channelMarker.setCenterFrequency(0);
+ m_channelMarker.setTitle("Daemon source");
+ m_channelMarker.blockSignals(false);
+ m_channelMarker.setVisible(true); // activate signal on the last setting only
+
+ m_settings.setChannelMarker(&m_channelMarker);
+
+ m_deviceUISet->registerTxChannelInstance(DaemonSrc::m_channelIdURI, this);
+ m_deviceUISet->addChannelMarker(&m_channelMarker);
+ m_deviceUISet->addRollupWidget(this);
+
+ connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
+
+ displaySettings();
+ applySettings(true);
}
DaemonSrcGUI::~DaemonSrcGUI()
@@ -106,4 +136,60 @@ void DaemonSrcGUI::applySettings(bool force __attribute((unused)))
void DaemonSrcGUI::displaySettings()
{
+ m_channelMarker.blockSignals(true);
+ m_channelMarker.setCenterFrequency(0);
+ m_channelMarker.setTitle(m_settings.m_title);
+ m_channelMarker.setBandwidth(5000); // TODO
+ m_channelMarker.blockSignals(false);
+ m_channelMarker.setColor(m_settings.m_rgbColor); // activate signal on the last setting only
+
+ setTitleColor(m_settings.m_rgbColor);
+ setWindowTitle(m_channelMarker.getTitle());
+
+ blockApplySettings(true);
+ ui->dataAddress->setText(m_settings.m_dataAddress);
+ ui->dataPort->setText(tr("%1").arg(m_settings.m_dataPort));
+ blockApplySettings(false);
+}
+
+void DaemonSrcGUI::leaveEvent(QEvent*)
+{
+ m_channelMarker.setHighlighted(false);
+}
+
+void DaemonSrcGUI::enterEvent(QEvent*)
+{
+ m_channelMarker.setHighlighted(true);
+}
+
+void DaemonSrcGUI::handleSourceMessages()
+{
+ Message* message;
+
+ while ((message = getInputMessageQueue()->pop()) != 0)
+ {
+ if (handleMessage(*message))
+ {
+ delete message;
+ }
+ }
+}
+
+void DaemonSrcGUI::onWidgetRolled(QWidget* widget __attribute__((unused)), bool rollDown __attribute__((unused)))
+{
+}
+
+void DaemonSrcGUI::onMenuDialogCalled(const QPoint &p)
+{
+ BasicChannelSettingsDialog dialog(&m_channelMarker, this);
+ dialog.move(p);
+ dialog.exec();
+
+ m_settings.m_rgbColor = m_channelMarker.getColor().rgb();
+ m_settings.m_title = m_channelMarker.getTitle();
+
+ setWindowTitle(m_settings.m_title);
+ setTitleColor(m_settings.m_rgbColor);
+
+ applySettings();
}
diff --git a/plugins/channeltx/daemonsrc/daemonsrcgui.h b/plugins/channeltx/daemonsrc/daemonsrcgui.h
index 1f5afe88b..f8d87bcd6 100644
--- a/plugins/channeltx/daemonsrc/daemonsrcgui.h
+++ b/plugins/channeltx/daemonsrc/daemonsrcgui.h
@@ -20,12 +20,14 @@
#include "plugin/plugininstancegui.h"
#include "gui/rollupwidget.h"
#include "util/messagequeue.h"
+#include "dsp/channelmarker.h"
#include "daemonsrcsettings.h"
class PluginAPI;
class DeviceUISet;
class BasebandSampleSource;
+class DaemonSrc;
namespace Ui {
class DaemonSrcGUI;
@@ -53,10 +55,13 @@ private:
Ui::DaemonSrcGUI* ui;
PluginAPI* m_pluginAPI;
DeviceUISet* m_deviceUISet;
- MessageQueue m_inputMessageQueue;
+ ChannelMarker m_channelMarker;
DaemonSrcSettings m_settings;
bool m_doApplySettings;
+ DaemonSrc* m_daemonSrc;
+ MessageQueue m_inputMessageQueue;
+
explicit DaemonSrcGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx, QWidget* parent = 0);
virtual ~DaemonSrcGUI();
@@ -64,6 +69,13 @@ private:
void applySettings(bool force = false);
void displaySettings();
+ void leaveEvent(QEvent*);
+ void enterEvent(QEvent*);
+
+private slots:
+ void handleSourceMessages();
+ void onWidgetRolled(QWidget* widget, bool rollDown);
+ void onMenuDialogCalled(const QPoint& p);
};
diff --git a/plugins/channeltx/daemonsrc/daemonsrcgui.ui b/plugins/channeltx/daemonsrc/daemonsrcgui.ui
index 822b9bfe3..b4c03dffa 100644
--- a/plugins/channeltx/daemonsrc/daemonsrcgui.ui
+++ b/plugins/channeltx/daemonsrc/daemonsrcgui.ui
@@ -29,7 +29,7 @@
- LoRa Demodulator
+ Daemon source
diff --git a/plugins/channeltx/daemonsrc/daemonsrcsettings.cpp b/plugins/channeltx/daemonsrc/daemonsrcsettings.cpp
index f96414ff9..30db27dc6 100644
--- a/plugins/channeltx/daemonsrc/daemonsrcsettings.cpp
+++ b/plugins/channeltx/daemonsrc/daemonsrcsettings.cpp
@@ -31,9 +31,8 @@ void DaemonSrcSettings::resetToDefaults()
{
m_dataAddress = "127.0.0.1";
m_dataPort = 9090;
- m_rgbColor = QColor(0, 255, 255).rgb();
- m_title = "SDRDaemon sink";
-
+ m_rgbColor = QColor(140, 4, 4).rgb();
+ m_title = "Daemon source";
}
QByteArray DaemonSrcSettings::serialize() const