1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-09 09:25:07 -04:00

Deep redesign: fixed FCD serialization. Pretty print utilities. Reverted optimization of source serializer

This commit is contained in:
f4exb
2015-08-28 11:12:31 +02:00
parent 38485ae0d0
commit 5101a08632
10 changed files with 218 additions and 9 deletions
+30 -4
View File
@@ -25,7 +25,7 @@
#include "fcdgui.h"
#include "qthid.h"
#include "dsp/dspcommands.h"
#include "util/simpleserializer.h"
#include "fcdserializer.h"
MESSAGE_CLASS_DEFINITION(FCDInput::MsgConfigureFCD, Message)
//MESSAGE_CLASS_DEFINITION(FCDInput::MsgReportFCD, Message)
@@ -48,16 +48,42 @@ void FCDInput::Settings::resetToDefaults()
QByteArray FCDInput::Settings::serialize() const
{
FCDSerializer::FCDData data;
data.m_data.m_lnaGain = gain;
data.m_data.m_frequency = centerFrequency;
data.m_range = range;
data.m_bias = bias;
QByteArray byteArray;
FCDSerializer::writeSerializedData(data, byteArray);
return byteArray;
/*
SimpleSerializer s(1);
s.writeU64(1, centerFrequency);
s.writeS32(2, range);
s.writeS32(3, gain);
s.writeS32(4, bias);
return s.final();
return s.final();*/
}
bool FCDInput::Settings::deserialize(const QByteArray& data)
bool FCDInput::Settings::deserialize(const QByteArray& serializedData)
{
FCDSerializer::FCDData data;
bool valid = FCDSerializer::readSerializedData(serializedData, data);
gain = data.m_data.m_lnaGain;
centerFrequency = data.m_data.m_frequency;
range = data.m_range;
bias = data.m_bias;
return valid;
/*
SimpleDeserializer d(data);
if (d.isValid() && d.getVersion() == 1)
@@ -70,7 +96,7 @@ bool FCDInput::Settings::deserialize(const QByteArray& data)
}
resetToDefaults();
return true;
return true;*/
}
FCDInput::FCDInput() :
@@ -0,0 +1,68 @@
///////////////////////////////////////////////////////////////////////////////////
// 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 "fcdserializer.h"
void FCDSerializer::writeSerializedData(const FCDData& data, QByteArray& serializedData)
{
QByteArray sampleSourceSerialized;
SampleSourceSerializer::writeSerializedData(data.m_data, sampleSourceSerialized);
SimpleSerializer s(1);
s.writeBlob(1, sampleSourceSerialized);
s.writeS32(2, data.m_bias);
s.writeS32(3, data.m_range);
serializedData = s.final();
}
bool FCDSerializer::readSerializedData(const QByteArray& serializedData, FCDData& data)
{
bool valid = SampleSourceSerializer::readSerializedData(serializedData, data.m_data);
QByteArray sampleSourceSerialized;
SimpleDeserializer d(serializedData);
if (!d.isValid())
{
setDefaults(data);
return false;
}
if (d.getVersion() == SampleSourceSerializer::getSerializerVersion())
{
int intval;
d.readBlob(1, &sampleSourceSerialized);
d.readS32(2, &data.m_bias);
d.readS32(3, &data.m_range);
return SampleSourceSerializer::readSerializedData(sampleSourceSerialized, data.m_data);
}
else
{
setDefaults(data);
return false;
}
}
void FCDSerializer::setDefaults(FCDData& data)
{
data.m_range = 0;
data.m_bias = 0;
}
+39
View File
@@ -0,0 +1,39 @@
///////////////////////////////////////////////////////////////////////////////////
// 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_FCD_FCDSERIALIZER_H_
#define PLUGINS_SAMPLESOURCE_FCD_FCDSERIALIZER_H_
#include "util/samplesourceserializer.h"
class FCDSerializer
{
public:
struct FCDData
{
SampleSourceSerializer::Data m_data;
qint32 m_bias;
qint32 m_range;
};
static void writeSerializedData(const FCDData& data, QByteArray& serializedData);
static bool readSerializedData(const QByteArray& serializedData, FCDData& data);
static void setDefaults(FCDData& data);
};
#endif /* PLUGINS_SAMPLESOURCE_FCD_FCDSERIALIZER_H_ */