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.
wfmdemodsettings.cpp
Go to the documentation of this file.
1 // Copyright (C) 2017 F4EXB //
3 // written by Edouard Griffiths //
4 // //
5 // This program is free software; you can redistribute it and/or modify //
6 // it under the terms of the GNU General Public License as published by //
7 // the Free Software Foundation as version 3 of the License, or //
8 // (at your option) any later version. //
9 // //
10 // This program is distributed in the hope that it will be useful, //
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
13 // GNU General Public License V3 for more details. //
14 // //
15 // You should have received a copy of the GNU General Public License //
16 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
18 
19 #include <QColor>
20 
21 #include "dsp/dspengine.h"
22 #include "util/simpleserializer.h"
23 #include "settings/serializable.h"
24 
25 #include "wfmdemodsettings.h"
26 
27 const int WFMDemodSettings::m_rfBWMin = 10000;
28 const int WFMDemodSettings::m_rfBWMax = 300000;
29 const int WFMDemodSettings::m_rfBWDigits = 6;
30 
32  m_channelMarker(0)
33 {
35 }
36 
38 {
40  m_rfBandwidth = 80000;
41  m_afBandwidth = 15000;
42  m_volume = 2.0;
43  m_squelch = -60.0;
44  m_audioMute = false;
45  m_rgbColor = QColor(0, 0, 255).rgb();
46  m_title = "WFM Demodulator";
48  m_useReverseAPI = false;
49  m_reverseAPIAddress = "127.0.0.1";
50  m_reverseAPIPort = 8888;
53 }
54 
55 QByteArray WFMDemodSettings::serialize() const
56 {
57  SimpleSerializer s(1);
59  s.writeS32(2, m_rfBandwidth);
60  s.writeS32(3, m_afBandwidth/1000.0);
61  s.writeS32(4, m_volume*10.0);
62  s.writeS32(5, m_squelch);
63  s.writeU32(7, m_rgbColor);
64  s.writeString(8, m_title);
66 
67  if (m_channelMarker) {
69  }
70 
76 
77  return s.final();
78 }
79 
80 bool WFMDemodSettings::deserialize(const QByteArray& data)
81 {
82  SimpleDeserializer d(data);
83 
84  if(!d.isValid())
85  {
87  return false;
88  }
89 
90  if(d.getVersion() == 1)
91  {
92  QByteArray bytetmp;
93  qint32 tmp;
94  uint32_t utmp;
95  QString strtmp;
96 
97  d.readS32(1, &tmp, 0);
99  d.readS32(2, &tmp, 4);
100  m_rfBandwidth = tmp < m_rfBWMin ? m_rfBWMin : tmp > m_rfBWMax ? m_rfBWMax : tmp;
101  d.readS32(3, &tmp, 3);
102  m_afBandwidth = tmp * 1000.0;
103  d.readS32(4, &tmp, 20);
104  m_volume = tmp * 0.1;
105  d.readS32(5, &tmp, -60);
106  m_squelch = tmp;
107  d.readU32(7, &m_rgbColor);
108  d.readString(8, &m_title, "WFM Demodulator");
110 
111  d.readBlob(11, &bytetmp);
112 
113  if (m_channelMarker) {
114  m_channelMarker->deserialize(bytetmp);
115  }
116 
117  d.readBool(12, &m_useReverseAPI, false);
118  d.readString(13, &m_reverseAPIAddress, "127.0.0.1");
119  d.readU32(14, &utmp, 0);
120 
121  if ((utmp > 1023) && (utmp < 65535)) {
122  m_reverseAPIPort = utmp;
123  } else {
124  m_reverseAPIPort = 8888;
125  }
126 
127  d.readU32(15, &utmp, 0);
128  m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp;
129  d.readU32(16, &utmp, 0);
130  m_reverseAPIChannelIndex = utmp > 99 ? 99 : utmp;
131 
132  return true;
133  }
134  else
135  {
136  resetToDefaults();
137  return false;
138  }
139 }
static const QString m_defaultDeviceName
qint64 m_inputFrequencyOffset
static const int m_rfBWDigits
Serializable * m_channelMarker
uint16_t m_reverseAPIPort
uint16_t m_reverseAPIChannelIndex
static const int m_rfBWMin
QByteArray serialize() const
void writeBlob(quint32 id, const QByteArray &value)
bool readU32(quint32 id, quint32 *result, quint32 def=0) const
bool readString(quint32 id, QString *result, const QString &def=QString::null) const
bool readBool(quint32 id, bool *result, bool def=false) const
bool isValid() const
unsigned int uint32_t
Definition: rtptypes_win.h:46
bool deserialize(const QByteArray &data)
uint16_t m_reverseAPIDeviceIndex
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
bool readBlob(quint32 id, QByteArray *result, const QByteArray &def=QByteArray()) const
QString m_reverseAPIAddress
void writeS32(quint32 id, qint32 value)
quint32 getVersion() const
virtual bool deserialize(const QByteArray &data)=0
void writeU32(quint32 id, quint32 value)
virtual QByteArray serialize() const =0
void writeBool(quint32 id, bool value)
void writeString(quint32 id, const QString &value)
const QByteArray & final()
static const int m_rfBWMax