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.
samplesourceserializer.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 
19 
21 
22 void SampleSourceSerializer::writeSerializedData(const Data& data, QByteArray& serializedData)
23 {
24  SimpleSerializer s(1);
25 
26  s.writeU64(1, data.m_frequency);
27  s.writeS32(2, data.m_correction);
28  s.writeS32(3, data.m_rate);
29  s.writeU32(4, data.m_log2Decim);
30  s.writeS32(5, data.m_bandwidth);
31  s.writeS32(6, data.m_fcPosition);
32  s.writeS32(7, data.m_lnaGain);
33  s.writeS32(8, data.m_RxGain1);
34  s.writeS32(9, data.m_RxGain2);
35  s.writeS32(10, data.m_RxGain3);
36 
37  serializedData = s.final();
38 }
39 
40 bool SampleSourceSerializer::readSerializedData(const QByteArray& serializedData, Data& data)
41 {
42  SimpleDeserializer d(serializedData);
43 
44  if (!d.isValid())
45  {
46  setDefaults(data);
47  return false;
48  }
49 
50  if (d.getVersion() == m_version)
51  {
52  d.readU64(1, &data.m_frequency, 0);
53  d.readS32(2, &data.m_correction, 0);
54  d.readS32(3, &data.m_rate, 0);
55  d.readU32(4, &data.m_log2Decim, 0);
56  d.readS32(5, &data.m_bandwidth, 0);
57  d.readS32(6, &data.m_fcPosition, 0);
58  d.readS32(7, &data.m_lnaGain, 0);
59  d.readS32(8, &data.m_RxGain1, 0);
60  d.readS32(9, &data.m_RxGain2, 0);
61  d.readS32(10, &data.m_RxGain3, 0);
62 
63  return true;
64  }
65  else
66  {
67  setDefaults(data);
68  return false;
69  }
70 }
71 
73 {
74  data.m_frequency = 0;
75  data.m_correction = 0;
76  data.m_rate = 0;
77  data.m_log2Decim = 0;
78  data.m_bandwidth = 0;
79  data.m_fcPosition = 0;
80  data.m_lnaGain = 0;
81  data.m_RxGain1 = 0;
82  data.m_RxGain2 = 0;
83  data.m_RxGain3 = 0;
84 }
static void writeSerializedData(const Data &data, QByteArray &serializedData)
static void setDefaults(Data &data)
qint32 m_RxGain2
Rx second stage amplifier gain.
quint64 m_frequency
RF center frequency.
qint32 m_correction
LO correction factor.
qint32 m_rate
RF sampler sample rate.
bool readU32(quint32 id, quint32 *result, quint32 def=0) const
qint32 m_RxGain1
Rx first stage amplifier gain.
bool isValid() const
qint32 m_fcPosition
Decimated band placement (infradyne, supradyne, centered)
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
qint32 m_RxGain3
Rx third stage amplifier gain.
void writeS32(quint32 id, qint32 value)
quint32 getVersion() const
bool readU64(quint32 id, quint64 *result, quint64 def=0) const
void writeU32(quint32 id, quint32 value)
static bool readSerializedData(const QByteArray &serializedData, Data &data)
quint32 m_log2Decim
Decimation ratio log2.
const QByteArray & final()
void writeU64(quint32 id, quint64 value)