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.
lorademodgui.cpp
Go to the documentation of this file.
1 
2 #include "device/deviceuiset.h"
3 #include <dsp/downchannelizer.h>
4 #include <QDockWidget>
5 #include <QMainWindow>
6 
7 #include "ui_lorademodgui.h"
8 #include "dsp/spectrumvis.h"
9 #include "gui/glspectrum.h"
10 #include "plugin/pluginapi.h"
11 #include "util/simpleserializer.h"
12 #include "dsp/dspengine.h"
13 
14 #include "lorademod.h"
15 #include "lorademodgui.h"
16 
18 {
19  LoRaDemodGUI* gui = new LoRaDemodGUI(pluginAPI, deviceUISet, rxChannel);
20  return gui;
21 }
22 
24 {
25  delete this;
26 }
27 
28 void LoRaDemodGUI::setName(const QString& name)
29 {
30  setObjectName(name);
31 }
32 
33 QString LoRaDemodGUI::getName() const
34 {
35  return objectName();
36 }
37 
40 }
41 
42 void LoRaDemodGUI::setCenterFrequency(qint64 centerFrequency)
43 {
44  m_channelMarker.setCenterFrequency(centerFrequency);
45  applySettings();
46 }
47 
49 {
52  applySettings(true);
53 }
54 
55 QByteArray LoRaDemodGUI::serialize() const
56 {
57  return m_settings.serialize();
58 }
59 
60 bool LoRaDemodGUI::deserialize(const QByteArray& data)
61 {
62  if(m_settings.deserialize(data)) {
64  applySettings(true);
65  return true;
66  } else {
68  return false;
69  }
70 }
71 
73 {
74  (void) message;
75  return false;
76 }
77 
79 {
80  applySettings();
81 }
82 
84 {
85  if (value < 0) {
87  } else if (value < LoRaDemodSettings::nb_bandwidths) {
89  } else {
91  }
92 
93  int thisBW = LoRaDemodSettings::bandwidths[value];
94  ui->BWText->setText(QString("%1 Hz").arg(thisBW));
96 
97  applySettings();
98 }
99 
101 {
102  (void) value;
103 }
104 
105 void LoRaDemodGUI::onWidgetRolled(QWidget* widget, bool rollDown)
106 {
107  (void) widget;
108  (void) rollDown;
109 }
110 
111 LoRaDemodGUI::LoRaDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel, QWidget* parent) :
112  RollupWidget(parent),
113  ui(new Ui::LoRaDemodGUI),
114  m_pluginAPI(pluginAPI),
115  m_deviceUISet(deviceUISet),
116  m_channelMarker(this),
117  m_doApplySettings(true)
118 {
119  ui->setupUi(this);
120  setAttribute(Qt::WA_DeleteOnClose, true);
121  connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
122 
123  m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum);
124  m_LoRaDemod = (LoRaDemod*) rxChannel; //new LoRaDemod(m_deviceUISet->m_deviceSourceAPI);
126 
127  ui->glSpectrum->setCenterFrequency(16000);
128  ui->glSpectrum->setSampleRate(32000);
129  ui->glSpectrum->setDisplayWaterfall(true);
130  ui->glSpectrum->setDisplayMaxHold(true);
131 
134 
135  connect(&m_channelMarker, SIGNAL(changedByCursor()), this, SLOT(viewChanged()));
136 
140 
141  ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum);
142 
144  m_settings.setSpectrumGUI(ui->spectrumGUI);
145 
146  displaySettings();
147  applySettings(true);
148 }
149 
151 {
153  delete m_LoRaDemod; // TODO: check this: when the GUI closes it has to delete the demodulator
154  delete m_spectrumVis;
155  delete ui;
156 }
157 
159 {
160  m_doApplySettings = !block;
161 }
162 
164 {
165  if (m_doApplySettings)
166  {
168 
172  m_LoRaDemod->getInputMessageQueue()->push(channelConfigMsg);
173 
176  }
177 }
178 
180 {
182 
183  m_channelMarker.blockSignals(true);
188  m_channelMarker.blockSignals(false);
189 
190  blockApplySettings(true);
191  ui->BWText->setText(QString("%1 Hz").arg(thisBW));
192  ui->BW->setValue(m_settings.m_bandwidthIndex);
193  blockApplySettings(false);
194 }
void on_Spread_valueChanged(int value)
static LoRaDemodGUI * create(PluginAPI *pluginAPI, DeviceUISet *deviceAPI, BasebandSampleSink *rxChannel)
int getCenterFrequency() const
Definition: channelmarker.h:42
void blockApplySettings(bool block)
void push(Message *message, bool emitSignal=true)
Push message onto queue.
DeviceUISet * m_deviceUISet
Definition: lorademodgui.h:48
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
virtual qint64 getCenterFrequency() const
LoRaDemod * m_LoRaDemod
Definition: lorademodgui.h:53
void applySettings(bool force=false)
virtual void destroy()
void resetToDefaults()
virtual void setCenterFrequency(qint64 centerFrequency)
virtual ~LoRaDemodGUI()
void addChannelMarker(ChannelMarker *channelMarker)
Add channel marker to spectrum.
Definition: deviceuiset.cpp:72
static const int bandwidths[]
LoRaDemodGUI(PluginAPI *pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel, QWidget *parent=0)
bool deserialize(const QByteArray &data)
void on_BW_valueChanged(int value)
void setSpectrumGUI(Serializable *spectrumGUI)
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
static MsgConfigureLoRaDemod * create(const LoRaDemodSettings &settings, bool force)
Definition: lorademod.h:53
#define SDR_RX_SCALEF
Definition: dsptypes.h:33
virtual bool handleMessage(const Message &message)
bool m_doApplySettings
Definition: lorademodgui.h:51
void setChannelMarker(Serializable *channelMarker)
static const int nb_bandwidths
void viewChanged()
LoRaDemodSettings m_settings
Definition: lorademodgui.h:50
void setMovable(bool movable)
Definition: channelmarker.h:66
void setTitleColor(const QColor &c)
void onWidgetRolled(QWidget *widget, bool rollDown)
void registerRxChannelInstance(const QString &channelName, PluginInstanceGUI *pluginGUI)
Definition: deviceuiset.cpp:82
void addRollupWidget(QWidget *widget)
Add rollup widget to channel window.
Definition: deviceuiset.cpp:77
void removeRxChannelInstance(PluginInstanceGUI *pluginGUI)
Definition: deviceuiset.cpp:94
static MsgConfigureChannelizer * create(int sampleRate, int centerFrequency)
Definition: lorademod.h:76
ChannelMarker m_channelMarker
Definition: lorademodgui.h:49
QByteArray serialize() const
void setSpectrumSink(BasebandSampleSink *sampleSink)
Definition: lorademod.h:95
Ui::LoRaDemodGUI * ui
Definition: lorademodgui.h:46
void setName(const QString &name)
void setColor(const QColor &color)
static const QString m_channelIdURI
Definition: lorademod.h:119
bool deserialize(const QByteArray &data)
void setVisible(bool visible)
QByteArray serialize() const
void setBandwidth(int bandwidth)
const QColor & getColor() const
Definition: channelmarker.h:64
void setCenterFrequency(int centerFrequency)
void widgetRolled(QWidget *widget, bool rollDown)
SpectrumVis * m_spectrumVis
Definition: lorademodgui.h:54
QString getName() const
void displaySettings()
PluginAPI * m_pluginAPI
Definition: lorademodgui.h:47