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.
testsourcesettings.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 <QtGlobal>
19 #include "util/simpleserializer.h"
20 #include "testsourcesettings.h"
21 
23 {
25 }
26 
28 {
29  m_centerFrequency = 435000*1000;
30  m_frequencyShift = 0;
31  m_sampleRate = 768*1000;
32  m_log2Decim = 4;
35  m_amplitudeBits = 127;
38  m_modulationTone = 44; // 440 Hz
39  m_amModulation = 50; // 50%
40  m_fmDeviation = 50; // 5 kHz
41  m_dcFactor = 0.0f;
42  m_iFactor = 0.0f;
43  m_qFactor = 0.0f;
44  m_phaseImbalance = 0.0f;
45  m_fileRecordName = "";
46  m_useReverseAPI = false;
47  m_reverseAPIAddress = "127.0.0.1";
48  m_reverseAPIPort = 8888;
50 }
51 
53 {
54  SimpleSerializer s(1);
55 
57  s.writeU32(3, m_sampleRate);
58  s.writeU32(4, m_log2Decim);
59  s.writeS32(5, (int) m_fcPos);
62  s.writeS32(8, (int) m_autoCorrOptions);
63  s.writeFloat(10, m_dcFactor);
64  s.writeFloat(11, m_iFactor);
65  s.writeFloat(12, m_qFactor);
67  s.writeS32(14, (int) m_modulation);
69  s.writeS32(16, m_amModulation);
70  s.writeS32(17, m_fmDeviation);
75  return s.final();
76 }
77 
78 bool TestSourceSettings::deserialize(const QByteArray& data)
79 {
80  SimpleDeserializer d(data);
81 
82  if (!d.isValid())
83  {
85  return false;
86  }
87 
88  if (d.getVersion() == 1)
89  {
90  int intval;
91  uint32_t utmp;
92 
93  d.readS32(2, &m_frequencyShift, 0);
94  d.readU32(3, &m_sampleRate, 768*1000);
95  d.readU32(4, &m_log2Decim, 4);
96  d.readS32(5, &intval, 0);
97  m_fcPos = (fcPos_t) intval;
98  d.readU32(6, &m_sampleSizeIndex, 0);
99  d.readS32(7, &m_amplitudeBits, 128);
100  d.readS32(8, &intval, 0);
101 
102  if (intval < 0 || intval > (int) AutoCorrLast) {
104  } else {
106  }
107 
108  d.readFloat(10, &m_dcFactor, 0.0f);
109  d.readFloat(11, &m_iFactor, 0.0f);
110  d.readFloat(12, &m_qFactor, 0.0f);
111  d.readFloat(13, &m_phaseImbalance, 0.0f);
112  d.readS32(14, &intval, 0);
113 
114  if (intval < 0 || intval > (int) ModulationLast) {
116  } else {
117  m_modulation = (Modulation) intval;
118  }
119 
120  d.readS32(15, &m_modulationTone, 44);
121  d.readS32(16, &m_amModulation, 50);
122  d.readS32(17, &m_fmDeviation, 50);
123 
124  d.readBool(18, &m_useReverseAPI, false);
125  d.readString(19, &m_reverseAPIAddress, "127.0.0.1");
126  d.readU32(20, &utmp, 0);
127 
128  if ((utmp > 1023) && (utmp < 65535)) {
129  m_reverseAPIPort = utmp;
130  } else {
131  m_reverseAPIPort = 8888;
132  }
133 
134  d.readU32(21, &utmp, 0);
135  m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp;
136 
137  return true;
138  }
139  else
140  {
141  resetToDefaults();
142  return false;
143  }
144 }
145 
146 
147 
148 
149 
150 
bool readFloat(quint32 id, float *result, float def=0) const
bool deserialize(const QByteArray &data)
float m_qFactor
-1.0 < x < 1.0
void writeFloat(quint32 id, float value)
float m_phaseImbalance
-1.0 < x < 1.0
QByteArray serialize() const
bool readU32(quint32 id, quint32 *result, quint32 def=0) const
AutoCorrOptions m_autoCorrOptions
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
float m_iFactor
-1.0 < x < 1.0
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
uint16_t m_reverseAPIDeviceIndex
void writeS32(quint32 id, qint32 value)
quint32 getVersion() const
void writeU32(quint32 id, quint32 value)
int m_modulationTone
10&#39;Hz
void writeBool(quint32 id, bool value)
void writeString(quint32 id, const QString &value)
int m_fmDeviation
100&#39;Hz
const QByteArray & final()
int m_amModulation
percent
float m_dcFactor
-1.0 < x < 1.0