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.
perseussettings.cpp
Go to the documentation of this file.
1 // Copyright (C) 2018 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 "perseussettings.h"
19 #include "util/simpleserializer.h"
20 
21 
23 {
25 }
26 
28 {
29  m_centerFrequency = 7150*1000;
30  m_LOppmTenths = 0;
32  m_log2Decim = 0;
33  m_transverterMode = false;
35  m_adcDither = false;
36  m_adcPreamp = false;
37  m_wideBand = false;
39  m_fileRecordName = "";
40  m_useReverseAPI = false;
41  m_reverseAPIAddress = "127.0.0.1";
42  m_reverseAPIPort = 8888;
44 }
45 
46 QByteArray PerseusSettings::serialize() const
47 {
48  SimpleSerializer s(1);
49 
51  s.writeS32(2, m_LOppmTenths);
52  s.writeU32(3, m_log2Decim);
55  s.writeBool(6, m_adcDither);
56  s.writeBool(7, m_adcPreamp);
57  s.writeBool(8, m_wideBand);
58  s.writeS32(9, (int) m_attenuator);
63 
64  return s.final();
65 }
66 
67 bool PerseusSettings::deserialize(const QByteArray& data)
68 {
69  SimpleDeserializer d(data);
70 
71  if (!d.isValid())
72  {
74  return false;
75  }
76 
77  if (d.getVersion() == 1)
78  {
79  int intval;
80  uint32_t uintval;
81 
82  d.readU32(1, &m_devSampleRateIndex, 0);
83  d.readS32(2, &m_LOppmTenths, 0);
84  d.readU32(3, &m_log2Decim, 0);
85  d.readBool(4, &m_transverterMode, false);
87  d.readBool(6, &m_adcDither, false);
88  d.readBool(7, &m_adcPreamp, false);
89  d.readBool(8, &m_wideBand, false);
90  d.readS32(9, &intval, 0);
91 
92  if ((intval >= 0) && (intval < (int) Attenuator_last)) {
93  m_attenuator = (Attenuator) intval;
94  } else {
96  }
97 
98  d.readBool(10, &m_useReverseAPI, false);
99  d.readString(11, &m_reverseAPIAddress, "127.0.0.1");
100  d.readU32(12, &uintval, 0);
101 
102  if ((uintval > 1023) && (uintval < 65535)) {
103  m_reverseAPIPort = uintval;
104  } else {
105  m_reverseAPIPort = 8888;
106  }
107 
108  d.readU32(13, &uintval, 0);
109  m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
110 
111  return true;
112  }
113  else
114  {
115  resetToDefaults();
116  return false;
117  }
118 }
119 
qint64 m_transverterDeltaFrequency
Attenuator m_attenuator
quint32 m_devSampleRateIndex
QString m_fileRecordName
uint16_t m_reverseAPIDeviceIndex
bool readS64(quint32 id, qint64 *result, qint64 def=0) const
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
quint64 m_centerFrequency
QByteArray serialize() const
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
QString m_reverseAPIAddress
void writeS32(quint32 id, qint32 value)
quint32 getVersion() const
bool deserialize(const QByteArray &data)
void writeU32(quint32 id, quint32 value)
void writeBool(quint32 id, bool value)
void writeS64(quint32 id, qint64 value)
uint16_t m_reverseAPIPort
void writeString(quint32 id, const QString &value)
const QByteArray & final()