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.
amdemodsettings.cpp
Go to the documentation of this file.
1 // Copyright (C) 2015 Edouard Griffiths, F4EXB. //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #include <QColor>
19 
20 #include "dsp/dspengine.h"
21 #include "util/simpleserializer.h"
22 #include "settings/serializable.h"
23 #include "amdemodsettings.h"
24 
26  m_channelMarker(0)
27 {
29 }
30 
32 {
34  m_rfBandwidth = 5000;
35  m_squelch = -40.0;
36  m_volume = 2.0;
37  m_audioMute = false;
38  m_bandpassEnable = false;
39  m_rgbColor = QColor(255, 255, 0).rgb();
40  m_title = "AM Demodulator";
42  m_pll = false;
44  m_streamIndex = 0;
45  m_useReverseAPI = false;
46  m_reverseAPIAddress = "127.0.0.1";
47  m_reverseAPIPort = 8888;
50 }
51 
52 QByteArray AMDemodSettings::serialize() const
53 {
54  SimpleSerializer s(1);
56  s.writeS32(2, m_rfBandwidth/100);
57  s.writeS32(3, m_streamIndex);
58  s.writeS32(4, m_volume*10);
59  s.writeS32(5, m_squelch);
60 
61  if (m_channelMarker) {
63  }
64 
65  s.writeU32(7, m_rgbColor);
67  s.writeString(9, m_title);
69  s.writeBool(12, m_pll);
70  s.writeS32(13, (int) m_syncAMOperation);
76 
77  return s.final();
78 }
79 
80 bool AMDemodSettings::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 
98  d.readS32(2, &tmp, 4);
99  m_rfBandwidth = 100 * tmp;
100  d.readS32(3, &m_streamIndex, 0);
101  d.readS32(4, &tmp, 20);
102  m_volume = tmp * 0.1;
103  d.readS32(5, &tmp, -40);
104  m_squelch = tmp;
105  d.readBlob(6, &bytetmp);
106 
107  if (m_channelMarker) {
108  m_channelMarker->deserialize(bytetmp);
109  }
110 
111  d.readU32(7, &m_rgbColor);
112  d.readBool(8, &m_bandpassEnable, false);
113  d.readString(9, &m_title, "AM Demodulator");
115  d.readBool(12, &m_pll, false);
116  d.readS32(13, &tmp, 0);
117  m_syncAMOperation = tmp < 0 ? SyncAMDSB : tmp > 2 ? SyncAMDSB : (SyncAMOperation) tmp;
118  d.readBool(14, &m_useReverseAPI, false);
119  d.readString(15, &m_reverseAPIAddress, "127.0.0.1");
120  d.readU32(16, &utmp, 0);
121 
122  if ((utmp > 1023) && (utmp < 65535)) {
123  m_reverseAPIPort = utmp;
124  } else {
125  m_reverseAPIPort = 8888;
126  }
127 
128  d.readU32(17, &utmp, 0);
129  m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp;
130  d.readU32(18, &utmp, 0);
131  m_reverseAPIChannelIndex = utmp > 99 ? 99 : utmp;
132 
133  return true;
134  }
135  else
136  {
137  resetToDefaults();
138  return false;
139  }
140 }
141 
142 
static const QString m_defaultDeviceName
void writeBlob(quint32 id, const QByteArray &value)
uint16_t m_reverseAPIChannelIndex
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
Serializable * m_channelMarker
unsigned int uint32_t
Definition: rtptypes_win.h:46
int m_streamIndex
MIMO channel. Not relevant when connected to SI (single Rx).
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
uint16_t m_reverseAPIDeviceIndex
bool readBlob(quint32 id, QByteArray *result, const QByteArray &def=QByteArray()) const
QByteArray serialize() const
SyncAMOperation m_syncAMOperation
QString m_audioDeviceName
bool deserialize(const QByteArray &data)
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
QString m_reverseAPIAddress
void writeBool(quint32 id, bool value)
uint16_t m_reverseAPIPort
qint32 m_inputFrequencyOffset
void writeString(quint32 id, const QString &value)
const QByteArray & final()