From 159d46ee364ab96e3d4944cb9ae4221f0d474e0e Mon Sep 17 00:00:00 2001 From: srcejon Date: Tue, 18 Jun 2024 09:06:15 +0100 Subject: [PATCH 1/2] ILS Demod: Add DDM/SDM/Deviation to channel report. --- plugins/channelrx/demodils/ilsdemod.cpp | 33 ++++++++++++++++++---- plugins/channelrx/demodils/ilsdemod.h | 8 ++++++ plugins/channelrx/demodils/ilsdemodgui.cpp | 1 + sdrbase/util/morse.cpp | 17 +++++------ sdrbase/util/morse.h | 14 ++++----- 5 files changed, 53 insertions(+), 20 deletions(-) diff --git a/plugins/channelrx/demodils/ilsdemod.cpp b/plugins/channelrx/demodils/ilsdemod.cpp index c93afac92d..1ca59c2a62 100644 --- a/plugins/channelrx/demodils/ilsdemod.cpp +++ b/plugins/channelrx/demodils/ilsdemod.cpp @@ -37,6 +37,7 @@ #include "device/deviceapi.h" #include "settings/serializable.h" #include "util/db.h" +#include "util/morse.h" #include "maincore.h" MESSAGE_CLASS_DEFINITION(ILSDemod::MsgConfigureILSDemod, Message) @@ -46,11 +47,17 @@ const char * const ILSDemod::m_channelIdURI = "sdrangel.channel.ilsdemod"; const char * const ILSDemod::m_channelId = "ILSDemod"; ILSDemod::ILSDemod(DeviceAPI *deviceAPI) : - ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSink), - m_deviceAPI(deviceAPI), - m_running(false), - m_spectrumVis(SDR_RX_SCALEF), - m_basebandSampleRate(0) + ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSink), + m_deviceAPI(deviceAPI), + m_running(false), + m_spectrumVis(SDR_RX_SCALEF), + m_basebandSampleRate(0), + m_ident(""), + m_dm90(NAN), + m_dm150(NAN), + m_sdm(NAN), + m_ddm(NAN), + m_angle(NAN) { setObjectName(m_channelId); @@ -201,6 +208,9 @@ bool ILSDemod::handleMessage(const Message& cmd) m_guiMessageQueue->push(msg); } + // Save for channel report + m_ident = Morse::toString(report.getIdent()); + return true; } else if (ILSDemod::MsgAngleEstimate::match(cmd)) @@ -246,6 +256,13 @@ bool ILSDemod::handleMessage(const Message& cmd) << "\n"; } + // Save for channel report + m_sdm = report.getSDM(); + m_ddm = report.getDDM(); + m_dm90 = report.getModDepth90(); + m_dm150 = report.getModDepth150(); + m_angle = report.getAngle(); + return true; } else if (MainCore::MsgChannelDemodQuery::match(cmd)) @@ -736,6 +753,12 @@ void ILSDemod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response response.getIlsDemodReport()->setChannelPowerDb(CalcDb::dbPower(magsqAvg)); response.getIlsDemodReport()->setChannelSampleRate(m_basebandSink->getChannelSampleRate()); + response.getIlsDemodReport()->setIdent(new QString(m_ident)); + response.getIlsDemodReport()->setDeviation(m_angle); + response.getIlsDemodReport()->setSdm(m_sdm); + response.getIlsDemodReport()->setDdm(m_ddm); + response.getIlsDemodReport()->setDm90(m_dm90); + response.getIlsDemodReport()->setDm150(m_dm150); } void ILSDemod::webapiReverseSendSettings(QList& channelSettingsKeys, const ILSDemodSettings& settings, bool force) diff --git a/plugins/channelrx/demodils/ilsdemod.h b/plugins/channelrx/demodils/ilsdemod.h index accc95ce7f..a636983eb4 100644 --- a/plugins/channelrx/demodils/ilsdemod.h +++ b/plugins/channelrx/demodils/ilsdemod.h @@ -205,6 +205,14 @@ class ILSDemod : public BasebandSampleSink, public ChannelAPI { QNetworkAccessManager *m_networkManager; QNetworkRequest m_networkRequest; + // Saved values from sink for channel report + QString m_ident; + Real m_dm90; + Real m_dm150; + Real m_sdm; + Real m_ddm; + Real m_angle; + virtual bool handleMessage(const Message& cmd); void applySettings(const ILSDemodSettings& settings, bool force = false); void sendSampleRateToDemodAnalyzer(); diff --git a/plugins/channelrx/demodils/ilsdemodgui.cpp b/plugins/channelrx/demodils/ilsdemodgui.cpp index f3f9235ab7..d6b5a5e250 100644 --- a/plugins/channelrx/demodils/ilsdemodgui.cpp +++ b/plugins/channelrx/demodils/ilsdemodgui.cpp @@ -93,6 +93,7 @@ const QList ILSDemodGUI::m_ils = { {"EGLC", "ILSR", "27", 111150000, 272.89, 5.5, 51.504927, 0.064960, 48, 10.7, 1580, 0.0}, {"EGSS", "ISX", "22", 110500000, 222.78, 3.0, 51.895165, 0.250051, 352, 14.9, 3430, 0.0}, {"EGSS", "ISED", "04", 110500000, 42.78, 3.0, 51.877054, 0.222887, 352, 16.2, 3130, 0.0}, + {"KGYH", "IGYH", "5", 108300000, 40.00, 3.0, 34.749987, -82.384983,850, 15.84, 2750, -0.6}, }; ILSDemodGUI* ILSDemodGUI::create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel) diff --git a/sdrbase/util/morse.cpp b/sdrbase/util/morse.cpp index 143fca5983..579f0154ff 100644 --- a/sdrbase/util/morse.cpp +++ b/sdrbase/util/morse.cpp @@ -131,7 +131,7 @@ QString Morse::toMorse(char ascii) } // Convert string to Morse code sequence consisting of . and - characters separated by spaces -QString Morse::toMorse(QString &string) +QString Morse::toMorse(const QString &string) { QStringList list; for (int i = 0; i < string.size(); i++) @@ -145,14 +145,15 @@ QString Morse::toMorse(QString &string) // Converts Morse code sequence using ASCII . and - to Unicode bullet and minus sign // which are horizontally aligned, so look nicer in GUIs -QString Morse::toUnicode(QString &morse) +QString Morse::toUnicode(const QString &morse) { - return morse.replace(QChar('.'), QChar(0x2022)).replace(QChar('-'), QChar(0x2212)); + QString s = morse; + return s.replace(QChar('.'), QChar(0x2022)).replace(QChar('-'), QChar(0x2212)); } // Converts a string to a unicode Morse sequence with extra space characters between // dots and dashes to improve readability in GUIs -QString Morse::toSpacedUnicode(QString &morse) +QString Morse::toSpacedUnicode(const QString &morse) { QString temp = toUnicode(morse); for (int i = 0; i < temp.size(); i+=2) @@ -161,14 +162,14 @@ QString Morse::toSpacedUnicode(QString &morse) } // Converts a string to a unicode Morse sequence -QString Morse::toUnicodeMorse(QString &string) +QString Morse::toUnicodeMorse(const QString &string) { QString ascii = toMorse(string); return ascii.replace(QChar('.'), QChar(0x2022)).replace(QChar('-'), QChar(0x2212)); } // Converts a string to a unicode Morse sequence with spacing between dots and dashes -QString Morse::toSpacedUnicodeMorse(QString &string) +QString Morse::toSpacedUnicodeMorse(const QString &string) { QString temp = toUnicodeMorse(string); for (int i = 0; i < temp.size(); i+=2) @@ -179,7 +180,7 @@ QString Morse::toSpacedUnicodeMorse(QString &string) #define COUNT_OF(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x]))))) // Converts a Morse sequence to an ASCII character. -1 if no mapping found. -int Morse::toASCII(QString &morse) +int Morse::toASCII(const QString &morse) { for (unsigned int i = 0; i < COUNT_OF(m_asciiToMorse); i++) { @@ -190,7 +191,7 @@ int Morse::toASCII(QString &morse) } // Converts a sequence of Morse code to a string. Unknown Morse codes are ignored. -QString Morse::toString(QString &morse) +QString Morse::toString(const QString &morse) { QString string(""); QStringList groups = morse.split(" "); diff --git a/sdrbase/util/morse.h b/sdrbase/util/morse.h index 4c27b61e9f..364579d2ef 100644 --- a/sdrbase/util/morse.h +++ b/sdrbase/util/morse.h @@ -30,13 +30,13 @@ class SDRBASE_API Morse { public: static QString toMorse(char asciiChar); - static QString toMorse(QString &string); - static QString toUnicode(QString &morse); - static QString toSpacedUnicode(QString &morse); - static QString toUnicodeMorse(QString &string); - static QString toSpacedUnicodeMorse(QString &string); - static int toASCII(QString &morse); - static QString toString(QString &morse); + static QString toMorse(const QString &string); + static QString toUnicode(const QString &morse); + static QString toSpacedUnicode(const QString &morse); + static QString toUnicodeMorse(const QString &string); + static QString toSpacedUnicodeMorse(const QString &string); + static int toASCII(const QString &morse); + static QString toString(const QString &morse); private: struct ASCIIToMorse { From c62f128ca190c883d4838c8a604d7b51053c0668 Mon Sep 17 00:00:00 2001 From: srcejon Date: Tue, 18 Jun 2024 09:14:22 +0100 Subject: [PATCH 2/2] Regenerate swagger API --- sdrbase/resources/webapi/doc/html2/index.html | 30 +++- .../webapi/doc/swagger/include/ILSDemod.yaml | 22 +++ .../api/swagger/include/ILSDemod.yaml | 22 +++ swagger/sdrangel/code/html2/index.html | 30 +++- .../code/qt5/client/SWGILSDemodReport.cpp | 140 ++++++++++++++++++ .../code/qt5/client/SWGILSDemodReport.h | 37 +++++ 6 files changed, 279 insertions(+), 2 deletions(-) diff --git a/sdrbase/resources/webapi/doc/html2/index.html b/sdrbase/resources/webapi/doc/html2/index.html index 15bab9f4eb..e602fe535c 100644 --- a/sdrbase/resources/webapi/doc/html2/index.html +++ b/sdrbase/resources/webapi/doc/html2/index.html @@ -8234,6 +8234,34 @@ }, "channelSampleRate" : { "type" : "integer" + }, + "ident" : { + "type" : "string" + }, + "deviation" : { + "type" : "number", + "format" : "float", + "description" : "deviation in degrees" + }, + "sdm" : { + "type" : "number", + "format" : "float", + "description" : "Sum of the Depth of Modulation in percent" + }, + "ddm" : { + "type" : "number", + "format" : "float", + "description" : "Difference in the Depth of Modulation in percent" + }, + "dm90" : { + "type" : "number", + "format" : "float", + "description" : "Depth of modulation of the 90Hz tone as a percentage of the carrier" + }, + "dm150" : { + "type" : "number", + "format" : "float", + "description" : "Depth of modulation of the 150Hz tone as percentage of the carrier" } }, "description" : "ILSDemod" @@ -59056,7 +59084,7 @@

Status: 501 - Function not implemented

- Generated 2024-05-23T18:36:35.471+02:00 + Generated 2024-06-18T10:11:11.522+02:00
diff --git a/sdrbase/resources/webapi/doc/swagger/include/ILSDemod.yaml b/sdrbase/resources/webapi/doc/swagger/include/ILSDemod.yaml index 1a3decc8a3..450a939c1b 100644 --- a/sdrbase/resources/webapi/doc/swagger/include/ILSDemod.yaml +++ b/sdrbase/resources/webapi/doc/swagger/include/ILSDemod.yaml @@ -95,4 +95,26 @@ ILSDemodReport: format: float channelSampleRate: type: integer + ident: + type: string + deviation: + description: deviation in degrees + type: number + format: float + sdm: + description: Sum of the Depth of Modulation in percent + type: number + format: float + ddm: + description: Difference in the Depth of Modulation in percent + type: number + format: float + dm90: + description: Depth of modulation of the 90Hz tone as a percentage of the carrier + type: number + format: float + dm150: + description: Depth of modulation of the 150Hz tone as percentage of the carrier + type: number + format: float diff --git a/swagger/sdrangel/api/swagger/include/ILSDemod.yaml b/swagger/sdrangel/api/swagger/include/ILSDemod.yaml index 7b98f7b9ad..f41090ddd0 100644 --- a/swagger/sdrangel/api/swagger/include/ILSDemod.yaml +++ b/swagger/sdrangel/api/swagger/include/ILSDemod.yaml @@ -95,4 +95,26 @@ ILSDemodReport: format: float channelSampleRate: type: integer + ident: + type: string + deviation: + description: deviation in degrees + type: number + format: float + sdm: + description: Sum of the Depth of Modulation in percent + type: number + format: float + ddm: + description: Difference in the Depth of Modulation in percent + type: number + format: float + dm90: + description: Depth of modulation of the 90Hz tone as a percentage of the carrier + type: number + format: float + dm150: + description: Depth of modulation of the 150Hz tone as percentage of the carrier + type: number + format: float diff --git a/swagger/sdrangel/code/html2/index.html b/swagger/sdrangel/code/html2/index.html index 15bab9f4eb..e602fe535c 100644 --- a/swagger/sdrangel/code/html2/index.html +++ b/swagger/sdrangel/code/html2/index.html @@ -8234,6 +8234,34 @@ }, "channelSampleRate" : { "type" : "integer" + }, + "ident" : { + "type" : "string" + }, + "deviation" : { + "type" : "number", + "format" : "float", + "description" : "deviation in degrees" + }, + "sdm" : { + "type" : "number", + "format" : "float", + "description" : "Sum of the Depth of Modulation in percent" + }, + "ddm" : { + "type" : "number", + "format" : "float", + "description" : "Difference in the Depth of Modulation in percent" + }, + "dm90" : { + "type" : "number", + "format" : "float", + "description" : "Depth of modulation of the 90Hz tone as a percentage of the carrier" + }, + "dm150" : { + "type" : "number", + "format" : "float", + "description" : "Depth of modulation of the 150Hz tone as percentage of the carrier" } }, "description" : "ILSDemod" @@ -59056,7 +59084,7 @@

Status: 501 - Function not implemented

- Generated 2024-05-23T18:36:35.471+02:00 + Generated 2024-06-18T10:11:11.522+02:00
diff --git a/swagger/sdrangel/code/qt5/client/SWGILSDemodReport.cpp b/swagger/sdrangel/code/qt5/client/SWGILSDemodReport.cpp index 4fb7a9c16a..75bde5ec2b 100644 --- a/swagger/sdrangel/code/qt5/client/SWGILSDemodReport.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGILSDemodReport.cpp @@ -32,6 +32,18 @@ SWGILSDemodReport::SWGILSDemodReport() { m_channel_power_db_isSet = false; channel_sample_rate = 0; m_channel_sample_rate_isSet = false; + ident = nullptr; + m_ident_isSet = false; + deviation = 0.0f; + m_deviation_isSet = false; + sdm = 0.0f; + m_sdm_isSet = false; + ddm = 0.0f; + m_ddm_isSet = false; + dm90 = 0.0f; + m_dm90_isSet = false; + dm150 = 0.0f; + m_dm150_isSet = false; } SWGILSDemodReport::~SWGILSDemodReport() { @@ -44,12 +56,32 @@ SWGILSDemodReport::init() { m_channel_power_db_isSet = false; channel_sample_rate = 0; m_channel_sample_rate_isSet = false; + ident = new QString(""); + m_ident_isSet = false; + deviation = 0.0f; + m_deviation_isSet = false; + sdm = 0.0f; + m_sdm_isSet = false; + ddm = 0.0f; + m_ddm_isSet = false; + dm90 = 0.0f; + m_dm90_isSet = false; + dm150 = 0.0f; + m_dm150_isSet = false; } void SWGILSDemodReport::cleanup() { + if(ident != nullptr) { + delete ident; + } + + + + + } SWGILSDemodReport* @@ -67,6 +99,18 @@ SWGILSDemodReport::fromJsonObject(QJsonObject &pJson) { ::SWGSDRangel::setValue(&channel_sample_rate, pJson["channelSampleRate"], "qint32", ""); + ::SWGSDRangel::setValue(&ident, pJson["ident"], "QString", "QString"); + + ::SWGSDRangel::setValue(&deviation, pJson["deviation"], "float", ""); + + ::SWGSDRangel::setValue(&sdm, pJson["sdm"], "float", ""); + + ::SWGSDRangel::setValue(&ddm, pJson["ddm"], "float", ""); + + ::SWGSDRangel::setValue(&dm90, pJson["dm90"], "float", ""); + + ::SWGSDRangel::setValue(&dm150, pJson["dm150"], "float", ""); + } QString @@ -89,6 +133,24 @@ SWGILSDemodReport::asJsonObject() { if(m_channel_sample_rate_isSet){ obj->insert("channelSampleRate", QJsonValue(channel_sample_rate)); } + if(ident != nullptr && *ident != QString("")){ + toJsonValue(QString("ident"), ident, obj, QString("QString")); + } + if(m_deviation_isSet){ + obj->insert("deviation", QJsonValue(deviation)); + } + if(m_sdm_isSet){ + obj->insert("sdm", QJsonValue(sdm)); + } + if(m_ddm_isSet){ + obj->insert("ddm", QJsonValue(ddm)); + } + if(m_dm90_isSet){ + obj->insert("dm90", QJsonValue(dm90)); + } + if(m_dm150_isSet){ + obj->insert("dm150", QJsonValue(dm150)); + } return obj; } @@ -113,6 +175,66 @@ SWGILSDemodReport::setChannelSampleRate(qint32 channel_sample_rate) { this->m_channel_sample_rate_isSet = true; } +QString* +SWGILSDemodReport::getIdent() { + return ident; +} +void +SWGILSDemodReport::setIdent(QString* ident) { + this->ident = ident; + this->m_ident_isSet = true; +} + +float +SWGILSDemodReport::getDeviation() { + return deviation; +} +void +SWGILSDemodReport::setDeviation(float deviation) { + this->deviation = deviation; + this->m_deviation_isSet = true; +} + +float +SWGILSDemodReport::getSdm() { + return sdm; +} +void +SWGILSDemodReport::setSdm(float sdm) { + this->sdm = sdm; + this->m_sdm_isSet = true; +} + +float +SWGILSDemodReport::getDdm() { + return ddm; +} +void +SWGILSDemodReport::setDdm(float ddm) { + this->ddm = ddm; + this->m_ddm_isSet = true; +} + +float +SWGILSDemodReport::getDm90() { + return dm90; +} +void +SWGILSDemodReport::setDm90(float dm90) { + this->dm90 = dm90; + this->m_dm90_isSet = true; +} + +float +SWGILSDemodReport::getDm150() { + return dm150; +} +void +SWGILSDemodReport::setDm150(float dm150) { + this->dm150 = dm150; + this->m_dm150_isSet = true; +} + bool SWGILSDemodReport::isSet(){ @@ -124,6 +246,24 @@ SWGILSDemodReport::isSet(){ if(m_channel_sample_rate_isSet){ isObjectUpdated = true; break; } + if(ident && *ident != QString("")){ + isObjectUpdated = true; break; + } + if(m_deviation_isSet){ + isObjectUpdated = true; break; + } + if(m_sdm_isSet){ + isObjectUpdated = true; break; + } + if(m_ddm_isSet){ + isObjectUpdated = true; break; + } + if(m_dm90_isSet){ + isObjectUpdated = true; break; + } + if(m_dm150_isSet){ + isObjectUpdated = true; break; + } }while(false); return isObjectUpdated; } diff --git a/swagger/sdrangel/code/qt5/client/SWGILSDemodReport.h b/swagger/sdrangel/code/qt5/client/SWGILSDemodReport.h index a8ac863154..8f8c8eca32 100644 --- a/swagger/sdrangel/code/qt5/client/SWGILSDemodReport.h +++ b/swagger/sdrangel/code/qt5/client/SWGILSDemodReport.h @@ -22,6 +22,7 @@ #include +#include #include "SWGObject.h" #include "export.h" @@ -47,6 +48,24 @@ class SWG_API SWGILSDemodReport: public SWGObject { qint32 getChannelSampleRate(); void setChannelSampleRate(qint32 channel_sample_rate); + QString* getIdent(); + void setIdent(QString* ident); + + float getDeviation(); + void setDeviation(float deviation); + + float getSdm(); + void setSdm(float sdm); + + float getDdm(); + void setDdm(float ddm); + + float getDm90(); + void setDm90(float dm90); + + float getDm150(); + void setDm150(float dm150); + virtual bool isSet() override; @@ -57,6 +76,24 @@ class SWG_API SWGILSDemodReport: public SWGObject { qint32 channel_sample_rate; bool m_channel_sample_rate_isSet; + QString* ident; + bool m_ident_isSet; + + float deviation; + bool m_deviation_isSet; + + float sdm; + bool m_sdm_isSet; + + float ddm; + bool m_ddm_isSet; + + float dm90; + bool m_dm90_isSet; + + float dm150; + bool m_dm150_isSet; + }; }