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.
freqtrackersettings.cpp
Go to the documentation of this file.
1 // Copyright (C) 2019 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 "freqtrackersettings.h"
24 
26  m_channelMarker(0)
27 {
29 }
30 
32 {
34  m_rfBandwidth = 6000;
35  m_log2Decim = 0;
36  m_squelch = -40.0;
37  m_rgbColor = QColor(200, 244, 66).rgb();
38  m_title = "Frequency Tracker";
39  m_alphaEMA = 0.1;
40  m_tracking = false;
42  m_pllPskOrder = 2; // BPSK
43  m_rrc = false;
44  m_rrcRolloff = 35;
45  m_squelchGate = 5; // 50 ms
46  m_useReverseAPI = false;
47  m_reverseAPIAddress = "127.0.0.1";
48  m_reverseAPIPort = 8888;
51 }
52 
54 {
55  SimpleSerializer s(1);
57  s.writeS32(2, m_rfBandwidth/100);
58  s.writeU32(3, m_log2Decim);
59  s.writeS32(5, m_squelch);
60 
61  if (m_channelMarker) {
63  }
64 
65  s.writeU32(7, m_rgbColor);
66  s.writeFloat(8, m_alphaEMA);
67  s.writeString(9, m_title);
68  s.writeBool(10, m_tracking);
69  s.writeS32(12, (int) m_trackerType);
70  s.writeU32(13, m_pllPskOrder);
71  s.writeBool(14, m_rrc);
72  s.writeU32(15, m_rrcRolloff);
78  s.writeS32(21, m_squelchGate);
79 
80  return s.final();
81 }
82 
83 bool FreqTrackerSettings::deserialize(const QByteArray& data)
84 {
85  SimpleDeserializer d(data);
86 
87  if(!d.isValid())
88  {
90  return false;
91  }
92 
93  if(d.getVersion() == 1)
94  {
95  QByteArray bytetmp;
96  qint32 tmp;
97  uint32_t utmp;
98  QString strtmp;
99  float ftmp;
100 
102  d.readS32(2, &tmp, 4);
103  m_rfBandwidth = 100 * tmp;
104  d.readU32(3, &utmp, 0);
105  m_log2Decim = utmp > 6 ? 6 : utmp;
106  d.readS32(4, &tmp, 20);
107  d.readS32(5, &tmp, -40);
108  m_squelch = tmp;
109  d.readBlob(6, &bytetmp);
110 
111  if (m_channelMarker) {
112  m_channelMarker->deserialize(bytetmp);
113  }
114 
115  d.readU32(7, &m_rgbColor, QColor(200, 244, 66).rgb());
116  d.readFloat(8, &ftmp, 0.1);
117  m_alphaEMA = ftmp < 0.01 ? 0.01 : ftmp > 1.0 ? 1.0 : ftmp;
118  d.readString(9, &m_title, "Frequency Tracker");
119  d.readBool(10, &m_tracking, false);
120  d.readS32(12, &tmp, 0);
121  m_trackerType = tmp < 0 ? TrackerFLL : tmp > 2 ? TrackerPLL : (TrackerType) tmp;
122  d.readU32(13, &utmp, 2);
123  m_pllPskOrder = utmp > 32 ? 32 : utmp;
124  d.readBool(14, &m_rrc, false);
125  d.readU32(15, &utmp, 35);
126  m_rrcRolloff = utmp > 100 ? 100 : utmp;
127  d.readBool(16, &m_useReverseAPI, false);
128  d.readString(17, &m_reverseAPIAddress, "127.0.0.1");
129  d.readU32(18, &utmp, 0);
130 
131  if ((utmp > 1023) && (utmp < 65535)) {
132  m_reverseAPIPort = utmp;
133  } else {
134  m_reverseAPIPort = 8888;
135  }
136 
137  d.readU32(19, &utmp, 0);
138  m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp;
139  d.readU32(20, &utmp, 0);
140  m_reverseAPIChannelIndex = utmp > 99 ? 99 : utmp;
141  d.readS32(21, &tmp, 5);
142  m_squelchGate = tmp < 0 ? 0 : tmp > 99 ? 99 : tmp;
143 
144  return true;
145  }
146  else
147  {
148  resetToDefaults();
149  return false;
150  }
151 }
bool readFloat(quint32 id, float *result, float def=0) const
int m_squelchGate
in 10s of ms
void writeFloat(quint32 id, float value)
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 readS32(quint32 id, qint32 *result, qint32 def=0) const
bool readBlob(quint32 id, QByteArray *result, const QByteArray &def=QByteArray()) const
QByteArray serialize() const
Serializable * m_channelMarker
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)
uint32_t m_rrcRolloff
in 100ths
bool deserialize(const QByteArray &data)
void writeString(quint32 id, const QString &value)
const QByteArray & final()
float m_alphaEMA
alpha factor for delta frequency EMA