mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-22 16:08:39 -05:00
Deep redesign: revised RTLSDR source serialization. Optimisation of data to blob serialization
This commit is contained in:
parent
5f0056f442
commit
77fed9a1c7
@ -36,7 +36,7 @@ public:
|
||||
qint32 m_RxGain3; //!< Rx third stage amplifier gain
|
||||
};
|
||||
|
||||
static void writeSerializedData(const Data& data, QByteArray& serializedData);
|
||||
static const QByteArray& writeSerializedData(const Data& data);
|
||||
static bool readSerializedData(const QByteArray& serializedData, Data& data);
|
||||
static void setDefaults(Data& data);
|
||||
|
||||
|
@ -19,8 +19,7 @@
|
||||
|
||||
void BladeRFSerializer::writeSerializedData(const BladeRFData& data, QByteArray& serializedData)
|
||||
{
|
||||
QByteArray sampleSourceSerialized;
|
||||
SampleSourceSerializer::writeSerializedData(data.m_data, sampleSourceSerialized);
|
||||
const QByteArray& sampleSourceSerialized = SampleSourceSerializer::writeSerializedData(data.m_data);
|
||||
|
||||
SimpleSerializer s(1);
|
||||
|
||||
|
@ -4,6 +4,7 @@ set(rtlsdr_SOURCES
|
||||
rtlsdrgui.cpp
|
||||
rtlsdrinput.cpp
|
||||
rtlsdrplugin.cpp
|
||||
rtlsdrserializer.cpp
|
||||
rtlsdrthread.cpp
|
||||
)
|
||||
|
||||
@ -11,6 +12,7 @@ set(rtlsdr_HEADERS
|
||||
rtlsdrgui.h
|
||||
rtlsdrinput.h
|
||||
rtlsdrplugin.h
|
||||
rtlsdrserializer.h
|
||||
rtlsdrthread.h
|
||||
)
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include "rtlsdrthread.h"
|
||||
#include "rtlsdrgui.h"
|
||||
#include "dsp/dspcommands.h"
|
||||
#include "util/simpleserializer.h"
|
||||
#include "rtlsdrserializer.h"
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgConfigureRTLSDR, Message)
|
||||
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgReportRTLSDR, Message)
|
||||
@ -47,39 +47,34 @@ void RTLSDRInput::Settings::resetToDefaults()
|
||||
|
||||
QByteArray RTLSDRInput::Settings::serialize() const
|
||||
{
|
||||
SimpleSerializer s(1);
|
||||
s.writeS32(1, m_devSampleRate);
|
||||
s.writeU64(2, m_centerFrequency);
|
||||
s.writeS32(3, m_gain);
|
||||
s.writeS32(4, m_loPpmCorrection);
|
||||
s.writeU32(5, m_log2Decim);
|
||||
return s.final();
|
||||
SampleSourceSerializer::Data data;
|
||||
|
||||
data.m_lnaGain = m_gain;
|
||||
data.m_log2Decim = m_log2Decim;
|
||||
data.m_frequency = m_centerFrequency;
|
||||
data.m_rate = m_devSampleRate;
|
||||
data.m_correction = m_loPpmCorrection;
|
||||
|
||||
QByteArray byteArray;
|
||||
|
||||
RTLSDRSerializer::writeSerializedData(data, byteArray);
|
||||
|
||||
return byteArray;
|
||||
}
|
||||
|
||||
bool RTLSDRInput::Settings::deserialize(const QByteArray& data)
|
||||
bool RTLSDRInput::Settings::deserialize(const QByteArray& serializedData)
|
||||
{
|
||||
SimpleDeserializer d(data);
|
||||
SampleSourceSerializer::Data data;
|
||||
|
||||
if (!d.isValid())
|
||||
{
|
||||
resetToDefaults();
|
||||
return false;
|
||||
}
|
||||
bool valid = RTLSDRSerializer::readSerializedData(serializedData, data);
|
||||
|
||||
if(d.getVersion() == 1)
|
||||
{
|
||||
d.readS32(1, &m_devSampleRate, 1024*1000);
|
||||
d.readU64(2, &m_centerFrequency, 435000*1000);
|
||||
d.readS32(3, &m_gain, 0);
|
||||
d.readS32(4, &m_loPpmCorrection, 0);
|
||||
d.readU32(5, &m_log2Decim, 4);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
resetToDefaults();
|
||||
return false;
|
||||
}
|
||||
m_gain = data.m_lnaGain;
|
||||
m_log2Decim = data.m_log2Decim;
|
||||
m_centerFrequency = data.m_frequency;
|
||||
m_devSampleRate = data.m_rate;
|
||||
m_loPpmCorrection = data.m_correction;
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
RTLSDRInput::RTLSDRInput() :
|
||||
|
32
plugins/samplesource/rtlsdr/rtlsdrserializer.cpp
Normal file
32
plugins/samplesource/rtlsdr/rtlsdrserializer.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "rtlsdrserializer.h"
|
||||
|
||||
void RTLSDRSerializer::writeSerializedData(const SampleSourceSerializer::Data& data, QByteArray& serializedData)
|
||||
{
|
||||
serializedData = SampleSourceSerializer::writeSerializedData(data);
|
||||
}
|
||||
|
||||
bool RTLSDRSerializer::readSerializedData(const QByteArray& serializedData, SampleSourceSerializer::Data& data)
|
||||
{
|
||||
return SampleSourceSerializer::readSerializedData(serializedData, data);
|
||||
}
|
||||
|
||||
void RTLSDRSerializer::setDefaults(SampleSourceSerializer::Data& data)
|
||||
{
|
||||
SampleSourceSerializer::setDefaults(data);
|
||||
}
|
32
plugins/samplesource/rtlsdr/rtlsdrserializer.h
Normal file
32
plugins/samplesource/rtlsdr/rtlsdrserializer.h
Normal file
@ -0,0 +1,32 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef PLUGINS_SAMPLESOURCE_RTLSDR_RTLSDRSERIALIZER_H_
|
||||
#define PLUGINS_SAMPLESOURCE_RTLSDR_RTLSDRSERIALIZER_H_
|
||||
|
||||
#include "util/samplesourceserializer.h"
|
||||
|
||||
class RTLSDRSerializer
|
||||
{
|
||||
public:
|
||||
SampleSourceSerializer::Data m_data;
|
||||
|
||||
static void writeSerializedData(const SampleSourceSerializer::Data& data, QByteArray& serializedData);
|
||||
static bool readSerializedData(const QByteArray& serializedData, SampleSourceSerializer::Data& data);
|
||||
static void setDefaults(SampleSourceSerializer::Data& data);
|
||||
};
|
||||
|
||||
#endif /* PLUGINS_SAMPLESOURCE_RTLSDR_RTLSDRSERIALIZER_H_ */
|
@ -18,7 +18,7 @@
|
||||
|
||||
const uint SampleSourceSerializer::m_version = 1;
|
||||
|
||||
void SampleSourceSerializer::writeSerializedData(const Data& data, QByteArray& serializedData)
|
||||
const QByteArray& SampleSourceSerializer::writeSerializedData(const Data& data)
|
||||
{
|
||||
SimpleSerializer s(1);
|
||||
|
||||
@ -33,7 +33,7 @@ void SampleSourceSerializer::writeSerializedData(const Data& data, QByteArray& s
|
||||
s.writeS32(9, data.m_RxGain2);
|
||||
s.writeS32(10, data.m_RxGain3);
|
||||
|
||||
serializedData = s.final();
|
||||
return s.final();
|
||||
}
|
||||
|
||||
bool SampleSourceSerializer::readSerializedData(const QByteArray& serializedData, Data& data)
|
||||
|
Loading…
Reference in New Issue
Block a user