2018-05-18 23:03:56 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2018 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 //
|
2019-04-11 00:39:30 -04:00
|
|
|
// (at your option) any later version. //
|
2018-05-18 23:03:56 -04:00
|
|
|
// //
|
|
|
|
// 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 <QColor>
|
|
|
|
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "util/simpleserializer.h"
|
|
|
|
#include "settings/serializable.h"
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
#include "chanalyzersettings.h"
|
|
|
|
|
|
|
|
ChannelAnalyzerSettings::ChannelAnalyzerSettings() :
|
2018-05-19 19:10:08 -04:00
|
|
|
m_channelMarker(0),
|
|
|
|
m_spectrumGUI(0),
|
|
|
|
m_scopeGUI(0)
|
2018-05-18 23:03:56 -04:00
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
void ChannelAnalyzerSettings::resetToDefaults()
|
2018-05-18 23:03:56 -04:00
|
|
|
{
|
2019-11-24 04:12:58 -05:00
|
|
|
m_inputFrequencyOffset = 0;
|
|
|
|
m_rationalDownSample = false;
|
|
|
|
m_rationalDownSamplerRate = 0;
|
2018-05-18 23:03:56 -04:00
|
|
|
m_bandwidth = 5000;
|
|
|
|
m_lowCutoff = 300;
|
2019-11-24 04:12:58 -05:00
|
|
|
m_log2Decim = 0;
|
2018-05-18 23:03:56 -04:00
|
|
|
m_ssb = false;
|
|
|
|
m_pll = false;
|
|
|
|
m_fll = false;
|
2021-03-05 08:37:49 -05:00
|
|
|
m_costasLoop = false;
|
2018-05-21 20:20:36 -04:00
|
|
|
m_rrc = false;
|
2018-05-22 13:25:55 -04:00
|
|
|
m_rrcRolloff = 35; // 0.35
|
2018-05-18 23:03:56 -04:00
|
|
|
m_pllPskOrder = 1;
|
2021-03-05 08:37:49 -05:00
|
|
|
m_pllBandwidth = 0.002f;
|
|
|
|
m_pllDampingFactor = 0.5f;
|
|
|
|
m_pllLoopGain = 10.0f;
|
2018-05-20 05:54:05 -04:00
|
|
|
m_inputType = InputSignal;
|
2018-05-19 19:10:08 -04:00
|
|
|
m_rgbColor = QColor(128, 128, 128).rgb();
|
2018-05-30 05:49:54 -04:00
|
|
|
m_title = "Channel Analyzer";
|
2021-12-01 02:25:32 -05:00
|
|
|
m_streamIndex = 0;
|
|
|
|
m_useReverseAPI = false;
|
|
|
|
m_reverseAPIAddress = "127.0.0.1";
|
|
|
|
m_reverseAPIPort = 8888;
|
|
|
|
m_reverseAPIDeviceIndex = 0;
|
|
|
|
m_reverseAPIChannelIndex = 0;
|
2018-05-18 23:03:56 -04:00
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
QByteArray ChannelAnalyzerSettings::serialize() const
|
2018-05-18 23:03:56 -04:00
|
|
|
{
|
|
|
|
SimpleSerializer s(1);
|
|
|
|
|
2019-11-24 04:12:58 -05:00
|
|
|
s.writeS32(1, m_inputFrequencyOffset);
|
2018-05-18 23:03:56 -04:00
|
|
|
s.writeS32(2, m_bandwidth);
|
|
|
|
s.writeBlob(3, m_spectrumGUI->serialize());
|
|
|
|
s.writeU32(4, m_rgbColor);
|
|
|
|
s.writeS32(5, m_lowCutoff);
|
2019-11-24 04:12:58 -05:00
|
|
|
s.writeS32(6, m_log2Decim);
|
2018-05-18 23:03:56 -04:00
|
|
|
s.writeBool(7, m_ssb);
|
|
|
|
s.writeBlob(8, m_scopeGUI->serialize());
|
2019-11-24 04:12:58 -05:00
|
|
|
s.writeBool(9, m_rationalDownSample);
|
|
|
|
s.writeU32(10, m_rationalDownSamplerRate);
|
2018-05-18 23:03:56 -04:00
|
|
|
s.writeBool(11, m_pll);
|
|
|
|
s.writeBool(12, m_fll);
|
|
|
|
s.writeU32(13, m_pllPskOrder);
|
2018-05-20 05:54:05 -04:00
|
|
|
s.writeS32(14, (int) m_inputType);
|
2018-05-20 19:40:21 -04:00
|
|
|
s.writeString(15, m_title);
|
2018-05-21 20:20:36 -04:00
|
|
|
s.writeBool(16, m_rrc);
|
|
|
|
s.writeU32(17, m_rrcRolloff);
|
2021-03-05 08:37:49 -05:00
|
|
|
s.writeFloat(18, m_pllBandwidth);
|
|
|
|
s.writeFloat(19, m_pllDampingFactor);
|
|
|
|
s.writeFloat(20, m_pllLoopGain);
|
|
|
|
s.writeBool(21, m_costasLoop);
|
2021-11-24 04:50:42 -05:00
|
|
|
s.writeBlob(22, m_rollupState);
|
2021-12-01 02:25:32 -05:00
|
|
|
s.writeBool(23, m_useReverseAPI);
|
|
|
|
s.writeString(24, m_reverseAPIAddress);
|
|
|
|
s.writeU32(25, m_reverseAPIPort);
|
|
|
|
s.writeU32(26, m_reverseAPIDeviceIndex);
|
|
|
|
s.writeU32(27, m_reverseAPIChannelIndex);
|
|
|
|
s.writeS32(28, m_streamIndex);
|
2018-05-18 23:03:56 -04:00
|
|
|
|
|
|
|
return s.final();
|
|
|
|
}
|
|
|
|
|
2018-05-30 09:37:56 -04:00
|
|
|
bool ChannelAnalyzerSettings::deserialize(const QByteArray& data)
|
2018-05-18 23:03:56 -04:00
|
|
|
{
|
|
|
|
SimpleDeserializer d(data);
|
|
|
|
|
|
|
|
if(!d.isValid())
|
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(d.getVersion() == 1)
|
|
|
|
{
|
|
|
|
QByteArray bytetmp;
|
2018-05-20 05:54:05 -04:00
|
|
|
int tmp;
|
2021-12-01 02:25:32 -05:00
|
|
|
unsigned int utmp;
|
2018-05-18 23:03:56 -04:00
|
|
|
|
2019-11-24 04:12:58 -05:00
|
|
|
d.readS32(1, &m_inputFrequencyOffset, 0);
|
2018-05-18 23:03:56 -04:00
|
|
|
d.readS32(2, &m_bandwidth, 5000);
|
|
|
|
|
|
|
|
if (m_spectrumGUI) {
|
|
|
|
d.readBlob(3, &bytetmp);
|
|
|
|
m_spectrumGUI->deserialize(bytetmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
d.readU32(4, &m_rgbColor);
|
|
|
|
d.readS32(5, &m_lowCutoff, 3);
|
2019-11-24 04:12:58 -05:00
|
|
|
d.readS32(6, &m_log2Decim, 0);
|
2018-05-18 23:03:56 -04:00
|
|
|
d.readBool(7, &m_ssb, false);
|
|
|
|
|
|
|
|
if (m_scopeGUI) {
|
|
|
|
d.readBlob(8, &bytetmp);
|
|
|
|
m_scopeGUI->deserialize(bytetmp);
|
|
|
|
}
|
|
|
|
|
2019-11-24 04:12:58 -05:00
|
|
|
d.readBool(9, &m_rationalDownSample, false);
|
|
|
|
d.readU32(10, &m_rationalDownSamplerRate, 2000U);
|
2018-05-18 23:03:56 -04:00
|
|
|
d.readBool(11, &m_pll, false);
|
|
|
|
d.readBool(12, &m_fll, false);
|
|
|
|
d.readU32(13, &m_pllPskOrder, 1);
|
2018-05-20 05:54:05 -04:00
|
|
|
d.readS32(14, &tmp, 0);
|
|
|
|
m_inputType = (InputType) tmp;
|
2018-05-30 09:49:28 -04:00
|
|
|
d.readString(15, &m_title, "Channel Analyzer");
|
2018-05-21 20:20:36 -04:00
|
|
|
d.readBool(16, &m_rrc, false);
|
2018-05-22 13:25:55 -04:00
|
|
|
d.readU32(17, &m_rrcRolloff, 35);
|
2021-03-05 08:37:49 -05:00
|
|
|
d.readFloat(18, &m_pllBandwidth, 0.002f);
|
|
|
|
d.readFloat(19, &m_pllDampingFactor, 0.5f);
|
|
|
|
d.readFloat(20, &m_pllLoopGain, 10.0f);
|
|
|
|
d.readBool(21, &m_costasLoop, false);
|
2021-11-24 04:50:42 -05:00
|
|
|
d.readBlob(22, &m_rollupState);
|
2021-12-01 02:25:32 -05:00
|
|
|
d.readBool(18, &m_useReverseAPI, false);
|
|
|
|
d.readString(19, &m_reverseAPIAddress, "127.0.0.1");
|
|
|
|
d.readU32(20, &utmp, 0);
|
|
|
|
|
|
|
|
if ((utmp > 1023) && (utmp < 65535)) {
|
|
|
|
m_reverseAPIPort = utmp;
|
|
|
|
} else {
|
|
|
|
m_reverseAPIPort = 8888;
|
|
|
|
}
|
|
|
|
|
|
|
|
d.readU32(21, &utmp, 0);
|
|
|
|
m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp;
|
|
|
|
d.readU32(22, &utmp, 0);
|
|
|
|
m_reverseAPIChannelIndex = utmp > 99 ? 99 : utmp;
|
|
|
|
d.readS32(23, &m_streamIndex, 0);
|
2018-05-18 23:03:56 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|