Skip to content

Commit

Permalink
Merge pull request f4exb#2174 from srcejon/freq_scanner
Browse files Browse the repository at this point in the history
ILS Demod: Add DDM/SDM/Deviation to ILS channel report
  • Loading branch information
f4exb committed Jun 18, 2024
2 parents 4770e2d + c62f128 commit deb4fee
Show file tree
Hide file tree
Showing 11 changed files with 332 additions and 22 deletions.
33 changes: 28 additions & 5 deletions plugins/channelrx/demodils/ilsdemod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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<QString>& channelSettingsKeys, const ILSDemodSettings& settings, bool force)
Expand Down
8 changes: 8 additions & 0 deletions plugins/channelrx/demodils/ilsdemod.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions plugins/channelrx/demodils/ilsdemodgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const QList<ILSDemodGUI::ILS> 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)
Expand Down
30 changes: 29 additions & 1 deletion sdrbase/resources/webapi/doc/html2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -59056,7 +59084,7 @@ <h3> Status: 501 - Function not implemented </h3>
</div>
<div id="generator">
<div class="content">
Generated 2024-05-23T18:36:35.471+02:00
Generated 2024-06-18T10:11:11.522+02:00
</div>
</div>
</div>
Expand Down
22 changes: 22 additions & 0 deletions sdrbase/resources/webapi/doc/swagger/include/ILSDemod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

17 changes: 9 additions & 8 deletions sdrbase/util/morse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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++)
{
Expand All @@ -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(" ");
Expand Down
14 changes: 7 additions & 7 deletions sdrbase/util/morse.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
22 changes: 22 additions & 0 deletions swagger/sdrangel/api/swagger/include/ILSDemod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

30 changes: 29 additions & 1 deletion swagger/sdrangel/code/html2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -59056,7 +59084,7 @@ <h3> Status: 501 - Function not implemented </h3>
</div>
<div id="generator">
<div class="content">
Generated 2024-05-23T18:36:35.471+02:00
Generated 2024-06-18T10:11:11.522+02:00
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit deb4fee

Please sign in to comment.