2020-12-19 19:53:03 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2023-11-18 07:12:18 -05:00
|
|
|
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
|
|
|
|
// written by Christian Daniel //
|
|
|
|
// Copyright (C) 2015-2017, 2019-2020, 2022-2023 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
|
|
|
|
// Copyright (C) 2021-2023 Jon Beniston, M7RCE <jon@beniston.com> //
|
2020-12-19 19:53:03 -05:00
|
|
|
// //
|
|
|
|
// 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 //
|
|
|
|
// (at your option) any later version. //
|
|
|
|
// //
|
|
|
|
// 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 "util/simpleserializer.h"
|
|
|
|
#include "settings/serializable.h"
|
|
|
|
|
|
|
|
#include "demodanalyzersettings.h"
|
|
|
|
|
|
|
|
const QStringList DemodAnalyzerSettings::m_channelURIs = {
|
2021-05-07 16:50:27 -04:00
|
|
|
QStringLiteral("sdrangel.channel.aisdemod"),
|
|
|
|
QStringLiteral("sdrangel.channel.modais"),
|
2020-12-19 19:53:03 -05:00
|
|
|
QStringLiteral("sdrangel.channel.amdemod"),
|
2020-12-20 05:51:38 -05:00
|
|
|
QStringLiteral("sdrangel.channeltx.modam"),
|
2022-06-20 07:55:30 -04:00
|
|
|
QStringLiteral("sdrangel.channel.bfm"),
|
2021-04-16 17:56:15 -04:00
|
|
|
QStringLiteral("sdrangel.channel.dabdemod"),
|
2020-12-20 05:51:38 -05:00
|
|
|
QStringLiteral("sdrangel.channel.dsddemod"),
|
2024-03-03 08:40:42 -05:00
|
|
|
QStringLiteral("sdrangel.channel.endoftraindemod"),
|
2023-01-15 06:57:58 -05:00
|
|
|
QStringLiteral("sdrangel.channel.ft8demod"),
|
2022-06-30 05:09:08 -04:00
|
|
|
QStringLiteral("sdrangel.channel.m17demod"),
|
2022-06-30 23:56:12 -04:00
|
|
|
QStringLiteral("sdrangel.channeltx.modm17"),
|
2020-12-20 05:51:38 -05:00
|
|
|
QStringLiteral("sdrangel.channel.nfmdemod"),
|
2020-12-20 20:30:29 -05:00
|
|
|
QStringLiteral("sdrangel.channeltx.modnfm"),
|
2021-03-27 06:07:23 -04:00
|
|
|
QStringLiteral("sdrangel.channel.packetdemod"),
|
2020-12-20 20:30:29 -05:00
|
|
|
QStringLiteral("sdrangel.channeltx.modpacket"),
|
2022-03-01 12:24:35 -05:00
|
|
|
QStringLiteral("sdrangel.channel.radiosondedemod"),
|
2023-09-06 10:21:22 -04:00
|
|
|
QStringLiteral("sdrangel.channeltx.modpsk31"),
|
2023-09-04 04:36:19 -04:00
|
|
|
QStringLiteral("sdrangel.channeltx.modrtty"),
|
2020-12-20 20:30:29 -05:00
|
|
|
QStringLiteral("sdrangel.channel.ssbdemod"),
|
|
|
|
QStringLiteral("sdrangel.channeltx.modssb"),
|
|
|
|
QStringLiteral("sdrangel.channel.wfmdemod"),
|
|
|
|
QStringLiteral("sdrangel.channeltx.modwfm"),
|
2024-10-05 11:13:03 -04:00
|
|
|
QStringLiteral("sdrangel.channel.wdsprx"),
|
2020-12-19 19:53:03 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
DemodAnalyzerSettings::DemodAnalyzerSettings() :
|
|
|
|
m_spectrumGUI(nullptr),
|
2022-01-08 23:27:12 -05:00
|
|
|
m_scopeGUI(nullptr),
|
|
|
|
m_rollupState(nullptr)
|
2020-12-19 19:53:03 -05:00
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DemodAnalyzerSettings::resetToDefaults()
|
|
|
|
{
|
2020-12-20 05:51:38 -05:00
|
|
|
m_log2Decim = 0;
|
2020-12-19 19:53:03 -05:00
|
|
|
m_title = "Demod Analyzer";
|
|
|
|
m_rgbColor = QColor(128, 128, 128).rgb();
|
|
|
|
m_useReverseAPI = false;
|
|
|
|
m_reverseAPIAddress = "127.0.0.1";
|
|
|
|
m_reverseAPIPort = 8888;
|
|
|
|
m_reverseAPIFeatureSetIndex = 0;
|
|
|
|
m_reverseAPIFeatureIndex = 0;
|
2022-04-05 10:26:57 -04:00
|
|
|
m_workspaceIndex = 0;
|
2022-11-13 13:53:22 -05:00
|
|
|
m_fileRecordName.clear();
|
|
|
|
m_recordToFile = false;
|
|
|
|
m_recordSilenceTime = 0;
|
2020-12-19 19:53:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray DemodAnalyzerSettings::serialize() const
|
|
|
|
{
|
|
|
|
SimpleSerializer s(1);
|
|
|
|
|
2022-01-08 23:27:12 -05:00
|
|
|
if (m_spectrumGUI) {
|
|
|
|
s.writeBlob(1, m_spectrumGUI->serialize());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_scopeGUI) {
|
|
|
|
s.writeBlob(2, m_scopeGUI->serialize());
|
|
|
|
}
|
|
|
|
|
2020-12-20 05:51:38 -05:00
|
|
|
s.writeS32(3, m_log2Decim);
|
2020-12-19 19:53:03 -05:00
|
|
|
s.writeString(5, m_title);
|
|
|
|
s.writeU32(6, m_rgbColor);
|
|
|
|
s.writeBool(7, m_useReverseAPI);
|
|
|
|
s.writeString(8, m_reverseAPIAddress);
|
|
|
|
s.writeU32(9, m_reverseAPIPort);
|
|
|
|
s.writeU32(10, m_reverseAPIFeatureSetIndex);
|
|
|
|
s.writeU32(11, m_reverseAPIFeatureIndex);
|
2022-01-08 23:27:12 -05:00
|
|
|
|
|
|
|
if (m_rollupState) {
|
|
|
|
s.writeBlob(12, m_rollupState->serialize());
|
|
|
|
}
|
2020-12-19 19:53:03 -05:00
|
|
|
|
2022-04-05 10:26:57 -04:00
|
|
|
s.writeS32(13, m_workspaceIndex);
|
|
|
|
s.writeBlob(14, m_geometryBytes);
|
2022-11-13 13:53:22 -05:00
|
|
|
s.writeString(15, m_fileRecordName);
|
|
|
|
s.writeBool(16, m_recordToFile);
|
|
|
|
s.writeS32(17, m_recordSilenceTime);
|
2022-04-05 10:26:57 -04:00
|
|
|
|
2020-12-19 19:53:03 -05:00
|
|
|
return s.final();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DemodAnalyzerSettings::deserialize(const QByteArray& data)
|
|
|
|
{
|
|
|
|
SimpleDeserializer d(data);
|
|
|
|
|
|
|
|
if (!d.isValid())
|
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (d.getVersion() == 1)
|
|
|
|
{
|
|
|
|
QByteArray bytetmp;
|
|
|
|
uint32_t utmp;
|
|
|
|
QString strtmp;
|
|
|
|
|
|
|
|
if (m_spectrumGUI)
|
|
|
|
{
|
|
|
|
d.readBlob(1, &bytetmp);
|
|
|
|
m_spectrumGUI->deserialize(bytetmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_scopeGUI)
|
|
|
|
{
|
|
|
|
d.readBlob(2, &bytetmp);
|
|
|
|
m_scopeGUI->deserialize(bytetmp);
|
|
|
|
}
|
|
|
|
|
2020-12-20 05:51:38 -05:00
|
|
|
d.readS32(3, &m_log2Decim, 0);
|
|
|
|
d.readString(5, &m_title, "Demod Analyzer");
|
2020-12-19 19:53:03 -05:00
|
|
|
d.readU32(6, &m_rgbColor, QColor(128, 128, 128).rgb());
|
|
|
|
d.readBool(7, &m_useReverseAPI, false);
|
|
|
|
d.readString(8, &m_reverseAPIAddress, "127.0.0.1");
|
|
|
|
d.readU32(9, &utmp, 0);
|
|
|
|
|
|
|
|
if ((utmp > 1023) && (utmp < 65535)) {
|
|
|
|
m_reverseAPIPort = utmp;
|
|
|
|
} else {
|
|
|
|
m_reverseAPIPort = 8888;
|
|
|
|
}
|
|
|
|
|
|
|
|
d.readU32(10, &utmp, 0);
|
|
|
|
m_reverseAPIFeatureSetIndex = utmp > 99 ? 99 : utmp;
|
|
|
|
d.readU32(11, &utmp, 0);
|
|
|
|
m_reverseAPIFeatureIndex = utmp > 99 ? 99 : utmp;
|
2022-01-08 23:27:12 -05:00
|
|
|
|
|
|
|
if (m_rollupState)
|
|
|
|
{
|
|
|
|
d.readBlob(12, &bytetmp);
|
|
|
|
m_rollupState->deserialize(bytetmp);
|
|
|
|
}
|
2020-12-19 19:53:03 -05:00
|
|
|
|
2022-04-05 10:26:57 -04:00
|
|
|
d.readS32(13, &m_workspaceIndex, 0);
|
|
|
|
d.readBlob(14, &m_geometryBytes);
|
2022-11-13 13:53:22 -05:00
|
|
|
d.readString(15, &m_fileRecordName);
|
|
|
|
d.readBool(16, &m_recordToFile, false);
|
|
|
|
d.readS32(17, &m_recordSilenceTime, 0);
|
2022-04-05 10:26:57 -04:00
|
|
|
|
2020-12-19 19:53:03 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2022-11-23 17:08:41 -05:00
|
|
|
|
|
|
|
void DemodAnalyzerSettings::applySettings(const QStringList& settingsKeys, const DemodAnalyzerSettings& settings)
|
|
|
|
{
|
|
|
|
if (settingsKeys.contains("log2Decim")) {
|
|
|
|
m_log2Decim = settings.m_log2Decim;
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("title")) {
|
|
|
|
m_title = settings.m_title;
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("rgbColor")) {
|
|
|
|
m_rgbColor = settings.m_rgbColor;
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("useReverseAPI")) {
|
|
|
|
m_useReverseAPI = settings.m_useReverseAPI;
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("reverseAPIAddress")) {
|
|
|
|
m_reverseAPIAddress = settings.m_reverseAPIAddress;
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("reverseAPIPort")) {
|
|
|
|
m_reverseAPIPort = settings.m_reverseAPIPort;
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("reverseAPIFeatureSetIndex")) {
|
|
|
|
m_reverseAPIFeatureSetIndex = settings.m_reverseAPIFeatureSetIndex;
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("reverseAPIFeatureIndex")) {
|
|
|
|
m_reverseAPIFeatureIndex = settings.m_reverseAPIFeatureIndex;
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("workspaceIndex")) {
|
|
|
|
m_workspaceIndex = settings.m_workspaceIndex;
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("fileRecordName")) {
|
|
|
|
m_fileRecordName = settings.m_fileRecordName;
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("recordToFile")) {
|
|
|
|
m_recordToFile = settings.m_recordToFile;
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("recordSilenceTime")) {
|
|
|
|
m_recordSilenceTime = settings.m_recordSilenceTime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString DemodAnalyzerSettings::getDebugString(const QStringList& settingsKeys, bool force) const
|
|
|
|
{
|
|
|
|
std::ostringstream ostr;
|
|
|
|
|
|
|
|
if (settingsKeys.contains("log2Decim") || force) {
|
|
|
|
ostr << " m_log2Decim: " << m_log2Decim;
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("title") || force) {
|
|
|
|
ostr << " m_title: " << m_title.toStdString();
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("rgbColor") || force) {
|
|
|
|
ostr << " m_rgbColor: " << m_rgbColor;
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("useReverseAPI") || force) {
|
|
|
|
ostr << " m_useReverseAPI: " << m_useReverseAPI;
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("reverseAPIAddress") || force) {
|
|
|
|
ostr << " m_reverseAPIAddress: " << m_reverseAPIAddress.toStdString();
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("reverseAPIPort") || force) {
|
|
|
|
ostr << " m_reverseAPIPort: " << m_reverseAPIPort;
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("reverseAPIFeatureSetIndex") || force) {
|
|
|
|
ostr << " m_reverseAPIFeatureSetIndex: " << m_reverseAPIFeatureSetIndex;
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("reverseAPIFeatureIndex") || force) {
|
|
|
|
ostr << " m_reverseAPIFeatureIndex: " << m_reverseAPIFeatureIndex;
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("workspaceIndex") || force) {
|
|
|
|
ostr << " m_workspaceIndex: " << m_workspaceIndex;
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("fileRecordName") || force) {
|
|
|
|
ostr << " m_fileRecordName: " << m_fileRecordName.toStdString();
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("recordToFile") || force) {
|
|
|
|
ostr << " m_recordToFile: " << m_recordToFile;
|
|
|
|
}
|
|
|
|
if (settingsKeys.contains("recordSilenceTime") || force) {
|
|
|
|
ostr << " m_recordSilenceTime: " << m_recordSilenceTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
return QString(ostr.str().c_str());
|
|
|
|
}
|