mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-09-02 21:27:48 -04:00
Daemon channel source new plugin (2)
This commit is contained in:
parent
5151f38977
commit
4f4d417d5a
@ -14,12 +14,16 @@
|
|||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#include "device/devicesinkapi.h"
|
#include "device/devicesinkapi.h"
|
||||||
#include "dsp/upchannelizer.h"
|
#include "dsp/upchannelizer.h"
|
||||||
#include "dsp/threadedbasebandsamplesource.h"
|
#include "dsp/threadedbasebandsamplesource.h"
|
||||||
|
|
||||||
#include "daemonsrc.h"
|
#include "daemonsrc.h"
|
||||||
|
|
||||||
|
MESSAGE_CLASS_DEFINITION(DaemonSrc::MsgSampleRateNotification, Message)
|
||||||
|
|
||||||
const QString DaemonSrc::m_channelIdURI = "sdrangel.channeltx.daemonsrc";
|
const QString DaemonSrc::m_channelIdURI = "sdrangel.channeltx.daemonsrc";
|
||||||
const QString DaemonSrc::m_channelId ="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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "dsp/basebandsamplesource.h"
|
#include "dsp/basebandsamplesource.h"
|
||||||
#include "channel/channelsourceapi.h"
|
#include "channel/channelsourceapi.h"
|
||||||
|
#include "util/message.h"
|
||||||
|
|
||||||
#include "daemonsrcsettings.h"
|
#include "daemonsrcsettings.h"
|
||||||
|
|
||||||
@ -27,6 +28,26 @@ class DaemonSrc : public BasebandSampleSource, public ChannelSourceAPI {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
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(DeviceSinkAPI *deviceAPI);
|
||||||
~DaemonSrc();
|
~DaemonSrc();
|
||||||
|
|
||||||
|
@ -16,7 +16,10 @@
|
|||||||
|
|
||||||
#include "device/devicesinkapi.h"
|
#include "device/devicesinkapi.h"
|
||||||
#include "device/deviceuiset.h"
|
#include "device/deviceuiset.h"
|
||||||
|
#include "gui/basicchannelsettingsdialog.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
#include "daemonsrc.h"
|
||||||
#include "ui_daemonsrcgui.h"
|
#include "ui_daemonsrcgui.h"
|
||||||
#include "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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,6 +96,27 @@ DaemonSrcGUI::DaemonSrcGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
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()
|
DaemonSrcGUI::~DaemonSrcGUI()
|
||||||
@ -106,4 +136,60 @@ void DaemonSrcGUI::applySettings(bool force __attribute((unused)))
|
|||||||
|
|
||||||
void DaemonSrcGUI::displaySettings()
|
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();
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,14 @@
|
|||||||
#include "plugin/plugininstancegui.h"
|
#include "plugin/plugininstancegui.h"
|
||||||
#include "gui/rollupwidget.h"
|
#include "gui/rollupwidget.h"
|
||||||
#include "util/messagequeue.h"
|
#include "util/messagequeue.h"
|
||||||
|
#include "dsp/channelmarker.h"
|
||||||
|
|
||||||
#include "daemonsrcsettings.h"
|
#include "daemonsrcsettings.h"
|
||||||
|
|
||||||
class PluginAPI;
|
class PluginAPI;
|
||||||
class DeviceUISet;
|
class DeviceUISet;
|
||||||
class BasebandSampleSource;
|
class BasebandSampleSource;
|
||||||
|
class DaemonSrc;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class DaemonSrcGUI;
|
class DaemonSrcGUI;
|
||||||
@ -53,10 +55,13 @@ private:
|
|||||||
Ui::DaemonSrcGUI* ui;
|
Ui::DaemonSrcGUI* ui;
|
||||||
PluginAPI* m_pluginAPI;
|
PluginAPI* m_pluginAPI;
|
||||||
DeviceUISet* m_deviceUISet;
|
DeviceUISet* m_deviceUISet;
|
||||||
MessageQueue m_inputMessageQueue;
|
ChannelMarker m_channelMarker;
|
||||||
DaemonSrcSettings m_settings;
|
DaemonSrcSettings m_settings;
|
||||||
bool m_doApplySettings;
|
bool m_doApplySettings;
|
||||||
|
|
||||||
|
DaemonSrc* m_daemonSrc;
|
||||||
|
MessageQueue m_inputMessageQueue;
|
||||||
|
|
||||||
explicit DaemonSrcGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx, QWidget* parent = 0);
|
explicit DaemonSrcGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx, QWidget* parent = 0);
|
||||||
virtual ~DaemonSrcGUI();
|
virtual ~DaemonSrcGUI();
|
||||||
|
|
||||||
@ -64,6 +69,13 @@ private:
|
|||||||
void applySettings(bool force = false);
|
void applySettings(bool force = false);
|
||||||
void displaySettings();
|
void displaySettings();
|
||||||
|
|
||||||
|
void leaveEvent(QEvent*);
|
||||||
|
void enterEvent(QEvent*);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void handleSourceMessages();
|
||||||
|
void onWidgetRolled(QWidget* widget, bool rollDown);
|
||||||
|
void onMenuDialogCalled(const QPoint& p);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>LoRa Demodulator</string>
|
<string>Daemon source</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="settingsContainer" native="true">
|
<widget class="QWidget" name="settingsContainer" native="true">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
|
@ -31,9 +31,8 @@ void DaemonSrcSettings::resetToDefaults()
|
|||||||
{
|
{
|
||||||
m_dataAddress = "127.0.0.1";
|
m_dataAddress = "127.0.0.1";
|
||||||
m_dataPort = 9090;
|
m_dataPort = 9090;
|
||||||
m_rgbColor = QColor(0, 255, 255).rgb();
|
m_rgbColor = QColor(140, 4, 4).rgb();
|
||||||
m_title = "SDRDaemon sink";
|
m_title = "Daemon source";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray DaemonSrcSettings::serialize() const
|
QByteArray DaemonSrcSettings::serialize() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user