mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-03-21 03:38:38 -04:00
VOR localizer feature: initial commit
This commit is contained in:
parent
38787f2a19
commit
ffe515fb63
@ -3,6 +3,11 @@ project(feature)
|
||||
if (Qt5SerialPort_FOUND)
|
||||
add_subdirectory(gs232controller)
|
||||
endif()
|
||||
|
||||
if (Qt5Quick_FOUND AND Qt5QuickWidgets_FOUND AND Qt5Positioning_FOUND)
|
||||
add_subdirectory(vorlocalizer)
|
||||
endif()
|
||||
|
||||
add_subdirectory(afc)
|
||||
add_subdirectory(rigctlserver)
|
||||
add_subdirectory(simpleptt)
|
||||
|
62
plugins/feature/vorlocalizer/CMakeLists.txt
Normal file
62
plugins/feature/vorlocalizer/CMakeLists.txt
Normal file
@ -0,0 +1,62 @@
|
||||
project(vorlocalizer)
|
||||
|
||||
set(vor_SOURCES
|
||||
vorlocalizer.cpp
|
||||
vorlocalizersettings.cpp
|
||||
vorlocalizerworker.cpp
|
||||
vorlocalizerplugin.cpp
|
||||
vorlocalizerwebapiadapter.cpp
|
||||
vorlocalizerreport.cpp
|
||||
)
|
||||
|
||||
set(vor_HEADERS
|
||||
vorlocalizer.h
|
||||
vorlocalizersettings.h
|
||||
vorlocalizerworker.h
|
||||
vorlocalizerplugin.h
|
||||
vorlocalizerwebapiadapter.h
|
||||
vorlocalizerreport.h
|
||||
)
|
||||
|
||||
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
|
||||
)
|
||||
|
||||
if(NOT SERVER_MODE)
|
||||
set(vor_SOURCES
|
||||
${vor_SOURCES}
|
||||
vorlocalizergui.cpp
|
||||
vorlocalizergui.ui
|
||||
map.qrc
|
||||
icons.qrc
|
||||
)
|
||||
set(vor_HEADERS
|
||||
${vor_HEADERS}
|
||||
vorlocalizergui.h
|
||||
navaid.h
|
||||
)
|
||||
|
||||
set(TARGET_NAME vorlocalizer)
|
||||
set(TARGET_LIB "Qt5::Widgets" Qt5::Quick Qt5::QuickWidgets Qt5::Positioning)
|
||||
set(TARGET_LIB_GUI "sdrgui")
|
||||
set(INSTALL_FOLDER ${INSTALL_PLUGINS_DIR})
|
||||
else()
|
||||
set(TARGET_NAME vorlocalizersrv)
|
||||
set(TARGET_LIB "")
|
||||
set(TARGET_LIB_GUI "")
|
||||
set(INSTALL_FOLDER ${INSTALL_PLUGINSSRV_DIR})
|
||||
endif()
|
||||
|
||||
add_library(${TARGET_NAME} SHARED
|
||||
${vor_SOURCES}
|
||||
)
|
||||
|
||||
target_link_libraries(${TARGET_NAME}
|
||||
Qt5::Core
|
||||
${TARGET_LIB}
|
||||
sdrbase
|
||||
${TARGET_LIB_GUI}
|
||||
)
|
||||
|
||||
install(TARGETS ${TARGET_NAME} DESTINATION ${INSTALL_FOLDER})
|
6
plugins/feature/vorlocalizer/icons.qrc
Normal file
6
plugins/feature/vorlocalizer/icons.qrc
Normal file
@ -0,0 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/demodvor/">
|
||||
<file>icons/compass.png</file>
|
||||
<file>icons/vor.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
BIN
plugins/feature/vorlocalizer/icons/compass.png
Normal file
BIN
plugins/feature/vorlocalizer/icons/compass.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 547 B |
BIN
plugins/feature/vorlocalizer/icons/vor.png
Normal file
BIN
plugins/feature/vorlocalizer/icons/vor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 365 B |
10
plugins/feature/vorlocalizer/map.qrc
Normal file
10
plugins/feature/vorlocalizer/map.qrc
Normal file
@ -0,0 +1,10 @@
|
||||
<RCC>
|
||||
<qresource prefix="/demodvor/">
|
||||
<file>map/map.qml</file>
|
||||
<file>map/MapStation.qml</file>
|
||||
<file>map/antenna.png</file>
|
||||
<file>map/VOR.png</file>
|
||||
<file>map/VOR-DME.png</file>
|
||||
<file>map/VORTAC.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
40
plugins/feature/vorlocalizer/map/MapStation.qml
Normal file
40
plugins/feature/vorlocalizer/map/MapStation.qml
Normal file
@ -0,0 +1,40 @@
|
||||
import QtQuick 2.12
|
||||
import QtLocation 5.12
|
||||
import QtPositioning 5.12
|
||||
|
||||
MapQuickItem {
|
||||
id: station
|
||||
property string stationName // Name of the station, E.g. Home
|
||||
|
||||
coordinate: QtPositioning.coordinate(51.5, 0.125) // Location of the antenna (QTH) - London
|
||||
zoomLevel: 11
|
||||
|
||||
anchorPoint.x: image.width/2
|
||||
anchorPoint.y: image.height/2
|
||||
|
||||
sourceItem: Grid {
|
||||
columns: 1
|
||||
Grid {
|
||||
horizontalItemAlignment: Grid.AlignHCenter
|
||||
layer.enabled: true
|
||||
layer.smooth: true
|
||||
Image {
|
||||
id: image
|
||||
source: "antenna.png"
|
||||
}
|
||||
Rectangle {
|
||||
id: bubble
|
||||
color: "lightblue"
|
||||
border.width: 1
|
||||
width: text.width * 1.3
|
||||
height: text.height * 1.3
|
||||
radius: 5
|
||||
Text {
|
||||
id: text
|
||||
anchors.centerIn: parent
|
||||
text: stationName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
plugins/feature/vorlocalizer/map/VOR-DME.png
Normal file
BIN
plugins/feature/vorlocalizer/map/VOR-DME.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 652 B |
BIN
plugins/feature/vorlocalizer/map/VOR.png
Normal file
BIN
plugins/feature/vorlocalizer/map/VOR.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 415 B |
BIN
plugins/feature/vorlocalizer/map/VORTAC.png
Normal file
BIN
plugins/feature/vorlocalizer/map/VORTAC.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 847 B |
BIN
plugins/feature/vorlocalizer/map/antenna.png
Normal file
BIN
plugins/feature/vorlocalizer/map/antenna.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
115
plugins/feature/vorlocalizer/map/map.qml
Normal file
115
plugins/feature/vorlocalizer/map/map.qml
Normal file
@ -0,0 +1,115 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Window 2.12
|
||||
import QtLocation 5.12
|
||||
import QtPositioning 5.12
|
||||
|
||||
Item {
|
||||
id: qmlMap
|
||||
property int vorZoomLevel: 11
|
||||
|
||||
Plugin {
|
||||
id: mapPlugin
|
||||
name: "osm"
|
||||
}
|
||||
|
||||
Map {
|
||||
id: map
|
||||
objectName: "map"
|
||||
anchors.fill: parent
|
||||
plugin: mapPlugin
|
||||
center: QtPositioning.coordinate(51.5, 0.125) // London
|
||||
zoomLevel: 10
|
||||
|
||||
|
||||
MapItemView {
|
||||
model: vorModel
|
||||
delegate: vorRadialComponent
|
||||
}
|
||||
|
||||
MapStation {
|
||||
id: station
|
||||
objectName: "station"
|
||||
stationName: "Home"
|
||||
coordinate: QtPositioning.coordinate(51.5, 0.125)
|
||||
}
|
||||
|
||||
MapItemView {
|
||||
model: vorModel
|
||||
delegate: vorComponent
|
||||
}
|
||||
|
||||
onZoomLevelChanged: {
|
||||
if (zoomLevel > 11) {
|
||||
station.zoomLevel = zoomLevel
|
||||
vorZoomLevel = zoomLevel
|
||||
} else {
|
||||
station.zoomLevel = 11
|
||||
vorZoomLevel = 11
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Component {
|
||||
id: vorRadialComponent
|
||||
MapPolyline {
|
||||
line.width: 2
|
||||
line.color: 'gray'
|
||||
path: vorRadial
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: vorComponent
|
||||
MapQuickItem {
|
||||
id: vor
|
||||
anchorPoint.x: image.width/2
|
||||
anchorPoint.y: bubble.height/2
|
||||
coordinate: position
|
||||
zoomLevel: vorZoomLevel
|
||||
|
||||
sourceItem: Grid {
|
||||
columns: 1
|
||||
Grid {
|
||||
horizontalItemAlignment: Grid.AlignHCenter
|
||||
verticalItemAlignment: Grid.AlignVCenter
|
||||
columnSpacing: 5
|
||||
layer.enabled: true
|
||||
layer.smooth: true
|
||||
Image {
|
||||
id: image
|
||||
source: vorImage
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onDoubleClicked: (mouse) => {
|
||||
selected = !selected
|
||||
}
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
id: bubble
|
||||
color: bubbleColour
|
||||
border.width: 1
|
||||
width: text.width + 5
|
||||
height: text.height + 5
|
||||
radius: 5
|
||||
Text {
|
||||
id: text
|
||||
anchors.centerIn: parent
|
||||
text: vorData
|
||||
}
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onDoubleClicked: (mouse) => {
|
||||
selected = !selected
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
367
plugins/feature/vorlocalizer/navaid.h
Normal file
367
plugins/feature/vorlocalizer/navaid.h
Normal file
@ -0,0 +1,367 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_NAVAID_H
|
||||
#define INCLUDE_NAVAID_H
|
||||
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
#include <QByteArray>
|
||||
#include <QHash>
|
||||
#include <QList>
|
||||
#include <QDebug>
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "util/units.h"
|
||||
#include "util/csv.h"
|
||||
|
||||
#define OURAIRPORTS_NAVAIDS_URL "https://ourairports.com/data/navaids.csv"
|
||||
#define OPENAIP_NAVAIDS_URL "https://www.openaip.net/customer_export_akfshb9237tgwiuvb4tgiwbf/%1_nav.aip"
|
||||
|
||||
struct NavAid {
|
||||
|
||||
int m_id;
|
||||
QString m_ident; // 2 or 3 character ident
|
||||
QString m_type; // VOR, VOR-DME or VORTAC
|
||||
QString m_name;
|
||||
float m_latitude;
|
||||
float m_longitude;
|
||||
float m_elevation;
|
||||
int m_frequencykHz;
|
||||
QString m_channel;
|
||||
int m_range; // Nautical miles
|
||||
float m_magneticDeclination;
|
||||
bool m_alignedTrueNorth; // Is the VOR aligned to true North, rather than magnetic (may be the case at high latitudes)
|
||||
|
||||
static QString trimQuotes(const QString s)
|
||||
{
|
||||
if (s.startsWith('\"') && s.endsWith('\"'))
|
||||
return s.mid(1, s.size() - 2);
|
||||
else
|
||||
return s;
|
||||
}
|
||||
|
||||
int getRangeMetres()
|
||||
{
|
||||
return Units::nauticalMilesToIntegerMetres((float)m_range);
|
||||
}
|
||||
|
||||
// OpenAIP XML file
|
||||
static void readNavAidsXML(QHash<int, NavAid *> *navAidInfo, const QString &filename)
|
||||
{
|
||||
QFile file(filename);
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
QXmlStreamReader xmlReader(&file);
|
||||
|
||||
while(!xmlReader.atEnd() && !xmlReader.hasError())
|
||||
{
|
||||
if (xmlReader.readNextStartElement())
|
||||
{
|
||||
if (xmlReader.name() == "NAVAID")
|
||||
{
|
||||
QStringRef typeRef = xmlReader.attributes().value("TYPE");
|
||||
if ((typeRef == QLatin1String("VOR"))
|
||||
|| (typeRef== QLatin1String("VOR-DME"))
|
||||
|| (typeRef == QLatin1String("VORTAC")))
|
||||
{
|
||||
QString type = typeRef.toString();
|
||||
int identifier = 0;
|
||||
QString name;
|
||||
QString id;
|
||||
float lat = 0.0f;
|
||||
float lon = 0.0f;
|
||||
float elevation = 0.0f;
|
||||
int frequency = 0;
|
||||
QString channel;
|
||||
int range = 25;
|
||||
float declination = 0.0f;
|
||||
bool alignedTrueNorth = false;
|
||||
while(xmlReader.readNextStartElement())
|
||||
{
|
||||
if (xmlReader.name() == QLatin1String("IDENTIFIER"))
|
||||
identifier = xmlReader.readElementText().toInt();
|
||||
else if (xmlReader.name() == QLatin1String("NAME"))
|
||||
name = xmlReader.readElementText();
|
||||
else if (xmlReader.name() == QLatin1String("ID"))
|
||||
id = xmlReader.readElementText();
|
||||
else if (xmlReader.name() == QLatin1String("GEOLOCATION"))
|
||||
{
|
||||
while(xmlReader.readNextStartElement())
|
||||
{
|
||||
if (xmlReader.name() == QLatin1String("LAT"))
|
||||
lat = xmlReader.readElementText().toFloat();
|
||||
else if (xmlReader.name() == QLatin1String("LON"))
|
||||
lon = xmlReader.readElementText().toFloat();
|
||||
else if (xmlReader.name() == QLatin1String("ELEV"))
|
||||
elevation = xmlReader.readElementText().toFloat();
|
||||
else
|
||||
xmlReader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
else if (xmlReader.name() == QLatin1String("RADIO"))
|
||||
{
|
||||
while(xmlReader.readNextStartElement())
|
||||
{
|
||||
if (xmlReader.name() == QLatin1String("FREQUENCY"))
|
||||
frequency = (int)(xmlReader.readElementText().toFloat() * 1000);
|
||||
else if (xmlReader.name() == QLatin1String("CHANNEL"))
|
||||
channel = xmlReader.readElementText();
|
||||
else
|
||||
xmlReader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
else if (xmlReader.name() == QLatin1String("PARAMS"))
|
||||
{
|
||||
while(xmlReader.readNextStartElement())
|
||||
{
|
||||
if (xmlReader.name() == QLatin1String("RANGE"))
|
||||
range = xmlReader.readElementText().toInt();
|
||||
else if (xmlReader.name() == QLatin1String("DECLINATION"))
|
||||
declination = xmlReader.readElementText().toFloat();
|
||||
else if (xmlReader.name() == QLatin1String("ALIGNEDTOTRUENORTH"))
|
||||
alignedTrueNorth = xmlReader.readElementText() == "TRUE";
|
||||
else
|
||||
xmlReader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
else
|
||||
xmlReader.skipCurrentElement();
|
||||
}
|
||||
NavAid *vor = new NavAid();
|
||||
vor->m_id = identifier;
|
||||
vor->m_ident = id;
|
||||
// Check idents conform to our filtering rules
|
||||
if (vor->m_ident.size() < 2)
|
||||
qDebug() << "Warning: VOR Ident less than 2 characters: " << vor->m_ident;
|
||||
else if (vor->m_ident.size() > 3)
|
||||
qDebug() << "Warning: VOR Ident greater than 3 characters: " << vor->m_ident;
|
||||
vor->m_type = type;
|
||||
vor->m_name = name;
|
||||
vor->m_frequencykHz = frequency;
|
||||
vor->m_channel = channel;
|
||||
vor->m_latitude = lat;
|
||||
vor->m_longitude = lon;
|
||||
vor->m_elevation = elevation;
|
||||
vor->m_range = range;
|
||||
vor->m_magneticDeclination = declination;
|
||||
vor->m_alignedTrueNorth = alignedTrueNorth;
|
||||
navAidInfo->insert(identifier, vor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
file.close();
|
||||
}
|
||||
else
|
||||
qDebug() << "NavAid::readNavAidsXML: Could not open " << filename << " for reading.";
|
||||
}
|
||||
|
||||
// Read OurAirport's NavAids CSV file
|
||||
// See comments for readOSNDB
|
||||
static QHash<int, NavAid *> *readNavAidsDB(const QString &filename)
|
||||
{
|
||||
int cnt = 0;
|
||||
QHash<int, NavAid *> *navAidInfo = nullptr;
|
||||
|
||||
// Column numbers used for the data as of 2020/10/28
|
||||
int idCol = 0;
|
||||
int identCol = 2;
|
||||
int typeCol = 4;
|
||||
int nameCol = 3;
|
||||
int frequencyCol = 5;
|
||||
int latitudeCol = 6;
|
||||
int longitudeCol = 7;
|
||||
int elevationCol = 8;
|
||||
int powerCol = 18;
|
||||
|
||||
qDebug() << "NavAid::readNavAidsDB: " << filename;
|
||||
|
||||
FILE *file;
|
||||
QByteArray utfFilename = filename.toUtf8();
|
||||
if ((file = fopen(utfFilename.constData(), "r")) != NULL)
|
||||
{
|
||||
char row[2048];
|
||||
|
||||
if (fgets(row, sizeof(row), file))
|
||||
{
|
||||
navAidInfo = new QHash<int, NavAid *>();
|
||||
navAidInfo->reserve(15000);
|
||||
|
||||
// Read header
|
||||
int idx = 0;
|
||||
char *p = strtok(row, ",");
|
||||
while (p != NULL)
|
||||
{
|
||||
if (!strcmp(p, "id"))
|
||||
idCol = idx;
|
||||
else if (!strcmp(p, "ident"))
|
||||
identCol = idx;
|
||||
else if (!strcmp(p, "type"))
|
||||
typeCol = idx;
|
||||
else if (!strcmp(p, "name"))
|
||||
nameCol = idx;
|
||||
else if (!strcmp(p, "frequency_khz"))
|
||||
frequencyCol = idx;
|
||||
else if (!strcmp(p, "latitude_deg"))
|
||||
latitudeCol = idx;
|
||||
else if (!strcmp(p, "longitude_deg"))
|
||||
longitudeCol = idx;
|
||||
else if (!strcmp(p, "elevation_ft"))
|
||||
elevationCol = idx;
|
||||
else if (!strcmp(p, "power"))
|
||||
powerCol = idx;
|
||||
p = strtok(NULL, ",");
|
||||
idx++;
|
||||
}
|
||||
// Read data
|
||||
while (fgets(row, sizeof(row), file))
|
||||
{
|
||||
int id = 0;
|
||||
char *idString = NULL;
|
||||
char *ident = NULL;
|
||||
size_t identLen = 0;
|
||||
char *type = NULL;
|
||||
size_t typeLen = 0;
|
||||
char *name = NULL;
|
||||
size_t nameLen = 0;
|
||||
char *frequencyString = NULL;
|
||||
int frequency;
|
||||
float latitude = 0.0f;
|
||||
char *latitudeString = NULL;
|
||||
size_t latitudeLen = 0;
|
||||
float longitude = 0.0f;
|
||||
char *longitudeString = NULL;
|
||||
size_t longitudeLen = 0;
|
||||
float elevation = 0.0f;
|
||||
char *elevationString = NULL;
|
||||
size_t elevationLen = 0;
|
||||
char *power = NULL;
|
||||
size_t powerLen = 0;
|
||||
|
||||
char *q = row;
|
||||
idx = 0;
|
||||
while ((p = csvNext(&q)) != nullptr)
|
||||
{
|
||||
// Read strings, stripping quotes
|
||||
if (idx == idCol)
|
||||
{
|
||||
idString = p;
|
||||
idString[strlen(idString)] = '\0';
|
||||
id = strtol(idString, NULL, 10);
|
||||
}
|
||||
else if ((idx == identCol) && (p[0] == '\"'))
|
||||
{
|
||||
ident = p+1;
|
||||
identLen = strlen(ident)-1;
|
||||
ident[identLen] = '\0';
|
||||
}
|
||||
else if ((idx == typeCol) && (p[0] == '\"'))
|
||||
{
|
||||
type = p+1;
|
||||
typeLen = strlen(type)-1;
|
||||
type[typeLen] = '\0';
|
||||
}
|
||||
else if ((idx == nameCol) && (p[0] == '\"'))
|
||||
{
|
||||
name = p+1;
|
||||
nameLen = strlen(name)-1;
|
||||
name[nameLen] = '\0';
|
||||
}
|
||||
if (idx == frequencyCol)
|
||||
{
|
||||
frequencyString = p;
|
||||
frequencyString[strlen(frequencyString)] = '\0';
|
||||
frequency = strtol(frequencyString, NULL, 10);
|
||||
}
|
||||
else if (idx == latitudeCol)
|
||||
{
|
||||
latitudeString = p;
|
||||
latitudeLen = strlen(latitudeString)-1;
|
||||
latitudeString[latitudeLen] = '\0';
|
||||
latitude = atof(latitudeString);
|
||||
}
|
||||
else if (idx == longitudeCol)
|
||||
{
|
||||
longitudeString = p;
|
||||
longitudeLen = strlen(longitudeString)-1;
|
||||
longitudeString[longitudeLen] = '\0';
|
||||
longitude = atof(longitudeString);
|
||||
}
|
||||
else if (idx == elevationCol)
|
||||
{
|
||||
elevationString = p;
|
||||
elevationLen = strlen(elevationString)-1;
|
||||
elevationString[elevationLen] = '\0';
|
||||
elevation = atof(elevationString);
|
||||
}
|
||||
else if ((idx == powerCol) && (p[0] == '\"'))
|
||||
{
|
||||
power = p+1;
|
||||
powerLen = strlen(power)-1;
|
||||
power[powerLen] = '\0';
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
|
||||
// For now, we only want VORs
|
||||
if (type && !strncmp(type, "VOR", 3))
|
||||
{
|
||||
NavAid *vor = new NavAid();
|
||||
vor->m_id = id;
|
||||
vor->m_ident = QString(ident);
|
||||
// Check idents conform to our filtering rules
|
||||
if (vor->m_ident.size() < 2)
|
||||
qDebug() << "Warning: VOR Ident less than 2 characters: " << vor->m_ident;
|
||||
else if (vor->m_ident.size() > 3)
|
||||
qDebug() << "Warning: VOR Ident greater than 3 characters: " << vor->m_ident;
|
||||
vor->m_type = QString(type);
|
||||
vor->m_name = QString(name);
|
||||
vor->m_frequencykHz = frequency;
|
||||
vor->m_latitude = latitude;
|
||||
vor->m_longitude = longitude;
|
||||
vor->m_elevation = elevation;
|
||||
if (power && !strcmp(power, "HIGH"))
|
||||
vor->m_range = 100;
|
||||
else if (power && !strcmp(power, "MEDIUM"))
|
||||
vor->m_range = 40;
|
||||
else
|
||||
vor->m_range = 25;
|
||||
vor->m_magneticDeclination = 0.0f;
|
||||
vor->m_alignedTrueNorth = false;
|
||||
navAidInfo->insert(id, vor);
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
else
|
||||
qDebug() << "NavAid::readNavAidsDB: Failed to open " << filename;
|
||||
|
||||
qDebug() << "NavAid::readNavAidsDB: Read " << cnt << " VORs";
|
||||
|
||||
return navAidInfo;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // INCLUDE_NAVAID_H
|
345
plugins/feature/vorlocalizer/vorlocalizer.cpp
Normal file
345
plugins/feature/vorlocalizer/vorlocalizer.cpp
Normal file
@ -0,0 +1,345 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 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 //
|
||||
// (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 <QDebug>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QBuffer>
|
||||
|
||||
#include "SWGFeatureSettings.h"
|
||||
#include "SWGFeatureReport.h"
|
||||
#include "SWGFeatureActions.h"
|
||||
#include "SWGSimplePTTReport.h"
|
||||
#include "SWGDeviceState.h"
|
||||
|
||||
#include "dsp/dspengine.h"
|
||||
|
||||
#include "vorlocalizerworker.h"
|
||||
#include "vorlocalizer.h"
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(VORLocalizer::MsgConfigureVORLocalizer, Message)
|
||||
MESSAGE_CLASS_DEFINITION(VORLocalizer::MsgStartStop, Message)
|
||||
MESSAGE_CLASS_DEFINITION(VORLocalizer::MsgAddVORChannel, Message)
|
||||
MESSAGE_CLASS_DEFINITION(VORLocalizer::MsgRemoveVORChannel, Message)
|
||||
MESSAGE_CLASS_DEFINITION(VORLocalizer::MsgRefreshChannels, Message)
|
||||
|
||||
const char* const VORLocalizer::m_featureIdURI = "sdrangel.feature.vorlocalizer";
|
||||
const char* const VORLocalizer::m_featureId = "VORLocalizer";
|
||||
|
||||
VORLocalizer::VORLocalizer(WebAPIAdapterInterface *webAPIAdapterInterface) :
|
||||
Feature(m_featureIdURI, webAPIAdapterInterface),
|
||||
m_ptt(false)
|
||||
{
|
||||
setObjectName(m_featureId);
|
||||
m_worker = new VorLocalizerWorker(webAPIAdapterInterface);
|
||||
m_state = StIdle;
|
||||
m_errorMessage = "VORLocalizer error";
|
||||
}
|
||||
|
||||
VORLocalizer::~VORLocalizer()
|
||||
{
|
||||
if (m_worker->isRunning()) {
|
||||
stop();
|
||||
}
|
||||
|
||||
delete m_worker;
|
||||
}
|
||||
|
||||
void VORLocalizer::start()
|
||||
{
|
||||
qDebug("VORLocalizer::start");
|
||||
|
||||
m_worker->reset();
|
||||
m_worker->setMessageQueueToGUI(getMessageQueueToGUI());
|
||||
bool ok = m_worker->startWork();
|
||||
m_state = ok ? StRunning : StError;
|
||||
m_thread.start();
|
||||
|
||||
VorLocalizerWorker::MsgConfigureVORLocalizerWorker *msg = VorLocalizerWorker::MsgConfigureVORLocalizerWorker::create(m_settings, true);
|
||||
m_worker->getInputMessageQueue()->push(msg);
|
||||
}
|
||||
|
||||
void VORLocalizer::stop()
|
||||
{
|
||||
qDebug("VORLocalizer::stop");
|
||||
m_worker->stopWork();
|
||||
m_state = StIdle;
|
||||
m_thread.quit();
|
||||
m_thread.wait();
|
||||
}
|
||||
|
||||
bool VORLocalizer::handleMessage(const Message& cmd)
|
||||
{
|
||||
if (MsgConfigureVORLocalizer::match(cmd))
|
||||
{
|
||||
MsgConfigureVORLocalizer& cfg = (MsgConfigureVORLocalizer&) cmd;
|
||||
qDebug() << "VORLocalizer::handleMessage: MsgConfigureVORLocalizer";
|
||||
applySettings(cfg.getSettings(), cfg.getForce());
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgStartStop::match(cmd))
|
||||
{
|
||||
MsgStartStop& cfg = (MsgStartStop&) cmd;
|
||||
qDebug() << "VORLocalizer::handleMessage: MsgStartStop: start:" << cfg.getStartStop();
|
||||
|
||||
if (cfg.getStartStop()) {
|
||||
start();
|
||||
} else {
|
||||
stop();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgRefreshChannels::match(cmd))
|
||||
{
|
||||
qDebug() << "VORLocalizer::handleMessage: MsgRefreshChannels";
|
||||
VorLocalizerWorker::MsgRefreshChannels *msg = VorLocalizerWorker::MsgRefreshChannels::create();
|
||||
m_worker->getInputMessageQueue()->push(msg);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray VORLocalizer::serialize() const
|
||||
{
|
||||
return m_settings.serialize();
|
||||
}
|
||||
|
||||
bool VORLocalizer::deserialize(const QByteArray& data)
|
||||
{
|
||||
if (m_settings.deserialize(data))
|
||||
{
|
||||
MsgConfigureVORLocalizer *msg = MsgConfigureVORLocalizer::create(m_settings, true);
|
||||
m_inputMessageQueue.push(msg);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_settings.resetToDefaults();
|
||||
MsgConfigureVORLocalizer *msg = MsgConfigureVORLocalizer::create(m_settings, true);
|
||||
m_inputMessageQueue.push(msg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void VORLocalizer::applySettings(const VORLocalizerSettings& settings, bool force)
|
||||
{
|
||||
qDebug() << "VORLocalizer::applySettings:"
|
||||
<< " m_title: " << settings.m_title
|
||||
<< " m_rgbColor: " << settings.m_rgbColor
|
||||
<< " m_magDecAdjust: " << settings.m_magDecAdjust
|
||||
<< " force: " << force;
|
||||
|
||||
QList<QString> reverseAPIKeys;
|
||||
|
||||
if ((m_settings.m_title != settings.m_title) || force) {
|
||||
reverseAPIKeys.append("title");
|
||||
}
|
||||
if ((m_settings.m_rgbColor != settings.m_rgbColor) || force) {
|
||||
reverseAPIKeys.append("rgbColor");
|
||||
}
|
||||
if ((m_settings.m_magDecAdjust != settings.m_magDecAdjust) || force) {
|
||||
reverseAPIKeys.append("magDecAdjust");
|
||||
}
|
||||
|
||||
VorLocalizerWorker::MsgConfigureVORLocalizerWorker *msg = VorLocalizerWorker::MsgConfigureVORLocalizerWorker::create(
|
||||
settings, force
|
||||
);
|
||||
m_worker->getInputMessageQueue()->push(msg);
|
||||
|
||||
if (settings.m_useReverseAPI)
|
||||
{
|
||||
bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
|
||||
(m_settings.m_reverseAPIAddress != settings.m_reverseAPIAddress) ||
|
||||
(m_settings.m_reverseAPIPort != settings.m_reverseAPIPort) ||
|
||||
(m_settings.m_reverseAPIFeatureSetIndex != settings.m_reverseAPIFeatureSetIndex) ||
|
||||
(m_settings.m_reverseAPIFeatureIndex != settings.m_reverseAPIFeatureIndex);
|
||||
webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
|
||||
}
|
||||
|
||||
m_settings = settings;
|
||||
}
|
||||
|
||||
int VORLocalizer::webapiRun(bool run,
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage)
|
||||
{
|
||||
(void) errorMessage;
|
||||
getFeatureStateStr(*response.getState());
|
||||
MsgStartStop *msg = MsgStartStop::create(run);
|
||||
getInputMessageQueue()->push(msg);
|
||||
return 202;
|
||||
}
|
||||
|
||||
int VORLocalizer::webapiSettingsGet(
|
||||
SWGSDRangel::SWGFeatureSettings& response,
|
||||
QString& errorMessage)
|
||||
{
|
||||
(void) errorMessage;
|
||||
response.setSimplePttSettings(new SWGSDRangel::SWGSimplePTTSettings());
|
||||
response.getSimplePttSettings()->init();
|
||||
webapiFormatFeatureSettings(response, m_settings);
|
||||
return 200;
|
||||
}
|
||||
|
||||
int VORLocalizer::webapiSettingsPutPatch(
|
||||
bool force,
|
||||
const QStringList& featureSettingsKeys,
|
||||
SWGSDRangel::SWGFeatureSettings& response,
|
||||
QString& errorMessage)
|
||||
{
|
||||
(void) errorMessage;
|
||||
VORLocalizerSettings settings = m_settings;
|
||||
webapiUpdateFeatureSettings(settings, featureSettingsKeys, response);
|
||||
|
||||
MsgConfigureVORLocalizer *msg = MsgConfigureVORLocalizer::create(settings, force);
|
||||
m_inputMessageQueue.push(msg);
|
||||
|
||||
qDebug("VORLocalizer::webapiSettingsPutPatch: forward to GUI: %p", m_guiMessageQueue);
|
||||
if (m_guiMessageQueue) // forward to GUI if any
|
||||
{
|
||||
MsgConfigureVORLocalizer *msgToGUI = MsgConfigureVORLocalizer::create(settings, force);
|
||||
m_guiMessageQueue->push(msgToGUI);
|
||||
}
|
||||
|
||||
webapiFormatFeatureSettings(response, settings);
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
void VORLocalizer::webapiFormatFeatureSettings(
|
||||
SWGSDRangel::SWGFeatureSettings& response,
|
||||
const VORLocalizerSettings& settings)
|
||||
{
|
||||
if (response.getVorLocalizerSettings()->getTitle()) {
|
||||
*response.getVorLocalizerSettings()->getTitle() = settings.m_title;
|
||||
} else {
|
||||
response.getVorLocalizerSettings()->setTitle(new QString(settings.m_title));
|
||||
}
|
||||
|
||||
response.getVorLocalizerSettings()->setRgbColor(settings.m_rgbColor);
|
||||
response.getVorLocalizerSettings()->setMagDecAdjust(settings.m_magDecAdjust);
|
||||
|
||||
response.getVorLocalizerSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
|
||||
|
||||
if (response.getVorLocalizerSettings()->getReverseApiAddress()) {
|
||||
*response.getVorLocalizerSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
|
||||
} else {
|
||||
response.getVorLocalizerSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
|
||||
}
|
||||
|
||||
response.getVorLocalizerSettings()->setReverseApiPort(settings.m_reverseAPIPort);
|
||||
response.getVorLocalizerSettings()->setReverseApiFeatureSetIndex(settings.m_reverseAPIFeatureSetIndex);
|
||||
response.getVorLocalizerSettings()->setReverseApiFeatureIndex(settings.m_reverseAPIFeatureIndex);
|
||||
}
|
||||
|
||||
void VORLocalizer::webapiUpdateFeatureSettings(
|
||||
VORLocalizerSettings& settings,
|
||||
const QStringList& featureSettingsKeys,
|
||||
SWGSDRangel::SWGFeatureSettings& response)
|
||||
{
|
||||
if (featureSettingsKeys.contains("title")) {
|
||||
settings.m_title = *response.getVorLocalizerSettings()->getTitle();
|
||||
}
|
||||
if (featureSettingsKeys.contains("rgbColor")) {
|
||||
settings.m_rgbColor = response.getVorLocalizerSettings()->getRgbColor();
|
||||
}
|
||||
if (featureSettingsKeys.contains("magDecAdjust")) {
|
||||
settings.m_magDecAdjust = response.getVorLocalizerSettings()->getMagDecAdjust();
|
||||
}
|
||||
if (featureSettingsKeys.contains("useReverseAPI")) {
|
||||
settings.m_useReverseAPI = response.getVorLocalizerSettings()->getUseReverseApi() != 0;
|
||||
}
|
||||
if (featureSettingsKeys.contains("reverseAPIAddress")) {
|
||||
settings.m_reverseAPIAddress = *response.getVorLocalizerSettings()->getReverseApiAddress();
|
||||
}
|
||||
if (featureSettingsKeys.contains("reverseAPIPort")) {
|
||||
settings.m_reverseAPIPort = response.getVorLocalizerSettings()->getReverseApiPort();
|
||||
}
|
||||
if (featureSettingsKeys.contains("reverseAPIFeatureSetIndex")) {
|
||||
settings.m_reverseAPIFeatureSetIndex = response.getVorLocalizerSettings()->getReverseApiFeatureSetIndex();
|
||||
}
|
||||
if (featureSettingsKeys.contains("reverseAPIFeatureIndex")) {
|
||||
settings.m_reverseAPIFeatureIndex = response.getVorLocalizerSettings()->getReverseApiFeatureIndex();
|
||||
}
|
||||
}
|
||||
|
||||
void VORLocalizer::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const VORLocalizerSettings& settings, bool force)
|
||||
{
|
||||
SWGSDRangel::SWGFeatureSettings *swgFeatureSettings = new SWGSDRangel::SWGFeatureSettings();
|
||||
// swgFeatureSettings->setOriginatorFeatureIndex(getIndexInDeviceSet());
|
||||
// swgFeatureSettings->setOriginatorFeatureSetIndex(getDeviceSetIndex());
|
||||
swgFeatureSettings->setFeatureType(new QString("VORLocalizer"));
|
||||
swgFeatureSettings->setVorLocalizerSettings(new SWGSDRangel::SWGVORLocalizerSettings());
|
||||
SWGSDRangel::SWGVORLocalizerSettings *swgVORLocalizerSettings = swgFeatureSettings->getVorLocalizerSettings();
|
||||
|
||||
// transfer data that has been modified. When force is on transfer all data except reverse API data
|
||||
|
||||
if (channelSettingsKeys.contains("title") || force) {
|
||||
swgVORLocalizerSettings->setTitle(new QString(settings.m_title));
|
||||
}
|
||||
if (channelSettingsKeys.contains("rgbColor") || force) {
|
||||
swgVORLocalizerSettings->setRgbColor(settings.m_rgbColor);
|
||||
}
|
||||
if (channelSettingsKeys.contains("magDecAdjust") || force) {
|
||||
swgVORLocalizerSettings->setMagDecAdjust(settings.m_magDecAdjust);
|
||||
}
|
||||
|
||||
QString channelSettingsURL = QString("http://%1:%2/sdrangel/featureset/%3/feature/%4/settings")
|
||||
.arg(settings.m_reverseAPIAddress)
|
||||
.arg(settings.m_reverseAPIPort)
|
||||
.arg(settings.m_reverseAPIFeatureSetIndex)
|
||||
.arg(settings.m_reverseAPIFeatureIndex);
|
||||
m_networkRequest.setUrl(QUrl(channelSettingsURL));
|
||||
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||
|
||||
QBuffer *buffer = new QBuffer();
|
||||
buffer->open((QBuffer::ReadWrite));
|
||||
buffer->write(swgFeatureSettings->asJson().toUtf8());
|
||||
buffer->seek(0);
|
||||
|
||||
// Always use PATCH to avoid passing reverse API settings
|
||||
QNetworkReply *reply = m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
|
||||
buffer->setParent(reply);
|
||||
|
||||
delete swgFeatureSettings;
|
||||
}
|
||||
|
||||
void VORLocalizer::networkManagerFinished(QNetworkReply *reply)
|
||||
{
|
||||
QNetworkReply::NetworkError replyError = reply->error();
|
||||
|
||||
if (replyError)
|
||||
{
|
||||
qWarning() << "VORLocalizer::networkManagerFinished:"
|
||||
<< " error(" << (int) replyError
|
||||
<< "): " << replyError
|
||||
<< ": " << reply->errorString();
|
||||
}
|
||||
else
|
||||
{
|
||||
QString answer = reply->readAll();
|
||||
answer.chop(1); // remove last \n
|
||||
qDebug("VORLocalizer::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
|
||||
}
|
||||
|
||||
reply->deleteLater();
|
||||
}
|
190
plugins/feature/vorlocalizer/vorlocalizer.h
Normal file
190
plugins/feature/vorlocalizer/vorlocalizer.h
Normal file
@ -0,0 +1,190 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 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 //
|
||||
// (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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_FEATURE_VORLOCALIZER_H_
|
||||
#define INCLUDE_FEATURE_VORLOCALIZER_H_
|
||||
|
||||
#include <QThread>
|
||||
#include <QNetworkRequest>
|
||||
|
||||
#include "feature/feature.h"
|
||||
#include "util/message.h"
|
||||
|
||||
#include "vorlocalizersettings.h"
|
||||
|
||||
class WebAPIAdapterInterface;
|
||||
class VorLocalizerWorker;
|
||||
class QNetworkAccessManager;
|
||||
class QNetworkReply;
|
||||
|
||||
namespace SWGSDRangel {
|
||||
class SWGDeviceState;
|
||||
}
|
||||
|
||||
class VORLocalizer : public Feature
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
class MsgConfigureVORLocalizer : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
const VORLocalizerSettings& getSettings() const { return m_settings; }
|
||||
bool getForce() const { return m_force; }
|
||||
|
||||
static MsgConfigureVORLocalizer* create(const VORLocalizerSettings& settings, bool force) {
|
||||
return new MsgConfigureVORLocalizer(settings, force);
|
||||
}
|
||||
|
||||
private:
|
||||
VORLocalizerSettings m_settings;
|
||||
bool m_force;
|
||||
|
||||
MsgConfigureVORLocalizer(const VORLocalizerSettings& settings, bool force) :
|
||||
Message(),
|
||||
m_settings(settings),
|
||||
m_force(force)
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgStartStop : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
bool getStartStop() const { return m_startStop; }
|
||||
|
||||
static MsgStartStop* create(bool startStop) {
|
||||
return new MsgStartStop(startStop);
|
||||
}
|
||||
|
||||
protected:
|
||||
bool m_startStop;
|
||||
|
||||
MsgStartStop(bool startStop) :
|
||||
Message(),
|
||||
m_startStop(startStop)
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgAddVORChannel : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
bool getNavId() const { return m_navId; }
|
||||
|
||||
static MsgAddVORChannel* create(int navId) {
|
||||
return new MsgAddVORChannel(navId);
|
||||
}
|
||||
|
||||
protected:
|
||||
int m_navId;
|
||||
|
||||
MsgAddVORChannel(int navId) :
|
||||
Message(),
|
||||
m_navId(navId)
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgRemoveVORChannel : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
bool getNavId() const { return m_navId; }
|
||||
|
||||
static MsgRemoveVORChannel* create(int navId) {
|
||||
return new MsgRemoveVORChannel(navId);
|
||||
}
|
||||
|
||||
protected:
|
||||
int m_navId;
|
||||
|
||||
MsgRemoveVORChannel(int navId) :
|
||||
Message(),
|
||||
m_navId(navId)
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgRefreshChannels : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
static MsgRefreshChannels* create() {
|
||||
return new MsgRefreshChannels();
|
||||
}
|
||||
|
||||
protected:
|
||||
MsgRefreshChannels() :
|
||||
Message()
|
||||
{ }
|
||||
};
|
||||
|
||||
VORLocalizer(WebAPIAdapterInterface *webAPIAdapterInterface);
|
||||
virtual ~VORLocalizer();
|
||||
virtual void destroy() { delete this; }
|
||||
virtual bool handleMessage(const Message& cmd);
|
||||
|
||||
virtual void getIdentifier(QString& id) const { id = objectName(); }
|
||||
virtual void getTitle(QString& title) const { title = m_settings.m_title; }
|
||||
|
||||
virtual QByteArray serialize() const;
|
||||
virtual bool deserialize(const QByteArray& data);
|
||||
|
||||
virtual int webapiRun(bool run,
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage);
|
||||
|
||||
virtual int webapiSettingsGet(
|
||||
SWGSDRangel::SWGFeatureSettings& response,
|
||||
QString& errorMessage);
|
||||
|
||||
virtual int webapiSettingsPutPatch(
|
||||
bool force,
|
||||
const QStringList& featureSettingsKeys,
|
||||
SWGSDRangel::SWGFeatureSettings& response,
|
||||
QString& errorMessage);
|
||||
|
||||
static void webapiFormatFeatureSettings(
|
||||
SWGSDRangel::SWGFeatureSettings& response,
|
||||
const VORLocalizerSettings& settings);
|
||||
|
||||
static void webapiUpdateFeatureSettings(
|
||||
VORLocalizerSettings& settings,
|
||||
const QStringList& featureSettingsKeys,
|
||||
SWGSDRangel::SWGFeatureSettings& response);
|
||||
|
||||
static const char* const m_featureIdURI;
|
||||
static const char* const m_featureId;
|
||||
|
||||
private:
|
||||
QThread m_thread;
|
||||
VorLocalizerWorker *m_worker;
|
||||
VORLocalizerSettings m_settings;
|
||||
bool m_ptt;
|
||||
|
||||
QNetworkAccessManager *m_networkManager;
|
||||
QNetworkRequest m_networkRequest;
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
void applySettings(const VORLocalizerSettings& settings, bool force = false);
|
||||
void webapiReverseSendSettings(QList<QString>& featureSettingsKeys, const VORLocalizerSettings& settings, bool force);
|
||||
|
||||
private slots:
|
||||
void networkManagerFinished(QNetworkReply *reply);
|
||||
};
|
||||
|
||||
#endif // INCLUDE_FEATURE_VORLOCALIZER_H_
|
1340
plugins/feature/vorlocalizer/vorlocalizergui.cpp
Normal file
1340
plugins/feature/vorlocalizer/vorlocalizergui.cpp
Normal file
File diff suppressed because it is too large
Load Diff
287
plugins/feature/vorlocalizer/vorlocalizergui.h
Normal file
287
plugins/feature/vorlocalizer/vorlocalizergui.h
Normal file
@ -0,0 +1,287 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
|
||||
// Copyright (C) 2020 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_VORLOCALIZERGUI_H
|
||||
#define INCLUDE_VORLOCALIZERGUI_H
|
||||
|
||||
#include <QIcon>
|
||||
#include <QAbstractListModel>
|
||||
#include <QModelIndex>
|
||||
#include <QProgressDialog>
|
||||
#include <QGeoLocation>
|
||||
#include <QGeoCoordinate>
|
||||
#include <QTableWidgetItem>
|
||||
#include <QPushButton>
|
||||
#include <QToolButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <QMenu>
|
||||
#include <QTimer>
|
||||
|
||||
#include "feature/featuregui.h"
|
||||
#include "dsp/movingaverage.h"
|
||||
#include "util/messagequeue.h"
|
||||
#include "util/httpdownloadmanager.h"
|
||||
#include "util/azel.h"
|
||||
#include "vorlocalizersettings.h"
|
||||
#include "navaid.h"
|
||||
|
||||
class PluginAPI;
|
||||
class FeatureUISet;
|
||||
class Feature;
|
||||
class BasebandSampleSink;
|
||||
class VORLocalizer;
|
||||
class VORLocalizerGUI;
|
||||
|
||||
namespace Ui {
|
||||
class VORLocalizerGUI;
|
||||
}
|
||||
class VORLocalizerGUI;
|
||||
|
||||
// Table items for each VOR
|
||||
class VORGUI : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
NavAid *m_navAid;
|
||||
QVariantList m_coordinates;
|
||||
VORLocalizerGUI *m_gui;
|
||||
|
||||
QTableWidgetItem *m_nameItem;
|
||||
QTableWidgetItem *m_frequencyItem;
|
||||
QTableWidgetItem *m_offsetItem;
|
||||
QTableWidgetItem *m_identItem;
|
||||
QTableWidgetItem *m_morseItem;
|
||||
QTableWidgetItem *m_radialItem;
|
||||
QTableWidgetItem *m_rxIdentItem;
|
||||
QTableWidgetItem *m_rxMorseItem;
|
||||
QTableWidgetItem *m_varMagItem;
|
||||
QTableWidgetItem *m_refMagItem;
|
||||
QWidget *m_muteItem;
|
||||
QToolButton *m_muteButton;
|
||||
|
||||
VORGUI(NavAid *navAid, VORLocalizerGUI *gui);
|
||||
private slots:
|
||||
void on_audioMute_toggled(bool checked);
|
||||
};
|
||||
|
||||
// VOR model used for each VOR on the map
|
||||
class VORModel : public QAbstractListModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using QAbstractListModel::QAbstractListModel;
|
||||
enum MarkerRoles{
|
||||
positionRole = Qt::UserRole + 1,
|
||||
vorDataRole = Qt::UserRole + 2,
|
||||
vorImageRole = Qt::UserRole + 3,
|
||||
vorRadialRole = Qt::UserRole + 4,
|
||||
bubbleColourRole = Qt::UserRole + 5,
|
||||
selectedRole = Qt::UserRole + 6
|
||||
};
|
||||
|
||||
VORModel(VORLocalizerGUI *gui) :
|
||||
m_gui(gui),
|
||||
m_radialsVisible(true)
|
||||
{
|
||||
}
|
||||
|
||||
Q_INVOKABLE void addVOR(NavAid *vor) {
|
||||
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||
m_vors.append(vor);
|
||||
m_selected.append(false);
|
||||
m_radials.append(-1.0f);
|
||||
m_vorGUIs.append(nullptr);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override {
|
||||
Q_UNUSED(parent)
|
||||
return m_vors.count();
|
||||
}
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
bool setData(const QModelIndex &index, const QVariant& value, int role = Qt::EditRole) override;
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override {
|
||||
(void) index;
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
|
||||
}
|
||||
|
||||
void allVORUpdated() {
|
||||
for (int i = 0; i < m_vors.count(); i++)
|
||||
{
|
||||
QModelIndex idx = index(i);
|
||||
emit dataChanged(idx, idx);
|
||||
}
|
||||
}
|
||||
|
||||
void removeVOR(NavAid *vor) {
|
||||
int row = m_vors.indexOf(vor);
|
||||
if (row >= 0)
|
||||
{
|
||||
beginRemoveRows(QModelIndex(), row, row);
|
||||
m_vors.removeAt(row);
|
||||
m_selected.removeAt(row);
|
||||
m_radials.removeAt(row);
|
||||
m_vorGUIs.removeAt(row);
|
||||
endRemoveRows();
|
||||
}
|
||||
}
|
||||
|
||||
void removeAllVORs() {
|
||||
beginRemoveRows(QModelIndex(), 0, m_vors.count());
|
||||
m_vors.clear();
|
||||
m_selected.clear();
|
||||
m_radials.clear();
|
||||
m_vorGUIs.clear();
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> roleNames() const {
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[positionRole] = "position";
|
||||
roles[vorDataRole] = "vorData";
|
||||
roles[vorImageRole] = "vorImage";
|
||||
roles[vorRadialRole] = "vorRadial";
|
||||
roles[bubbleColourRole] = "bubbleColour";
|
||||
roles[selectedRole] = "selected";
|
||||
return roles;
|
||||
}
|
||||
|
||||
void setRadialsVisible(bool radialsVisible)
|
||||
{
|
||||
m_radialsVisible = radialsVisible;
|
||||
allVORUpdated();
|
||||
}
|
||||
|
||||
void setRadial(int id, bool valid, Real radial)
|
||||
{
|
||||
for (int i = 0; i < m_vors.count(); i++)
|
||||
{
|
||||
if (m_vors[i]->m_id == id)
|
||||
{
|
||||
if (valid)
|
||||
m_radials[i] = radial;
|
||||
else
|
||||
m_radials[i] = -1; // -1 to indicate invalid
|
||||
QModelIndex idx = index(i);
|
||||
emit dataChanged(idx, idx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool findIntersection(float &lat, float &lon);
|
||||
|
||||
private:
|
||||
VORLocalizerGUI *m_gui;
|
||||
bool m_radialsVisible;
|
||||
QList<NavAid *> m_vors;
|
||||
QList<bool> m_selected;
|
||||
QList<Real> m_radials;
|
||||
QList<VORGUI *> m_vorGUIs;
|
||||
};
|
||||
|
||||
class VORLocalizerGUI : public FeatureGUI {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static VORLocalizerGUI* create(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *feature);
|
||||
virtual void destroy();
|
||||
|
||||
void resetToDefaults();
|
||||
QByteArray serialize() const;
|
||||
bool deserialize(const QByteArray& data);
|
||||
virtual MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
|
||||
void selectVOR(VORGUI *vorGUI, bool selected);
|
||||
|
||||
private:
|
||||
friend class VORGUI;
|
||||
friend class VORModel;
|
||||
|
||||
Ui::VORLocalizerGUI* ui;
|
||||
PluginAPI* m_pluginAPI;
|
||||
FeatureUISet* m_featureUISet;
|
||||
VORLocalizerSettings m_settings;
|
||||
bool m_doApplySettings;
|
||||
|
||||
VORLocalizer* m_vorLocalizer;
|
||||
bool m_squelchOpen;
|
||||
int m_basebandSampleRate;
|
||||
uint32_t m_tickCount;
|
||||
MessageQueue m_inputMessageQueue;
|
||||
|
||||
QMenu *menu; // Column select context menu
|
||||
HttpDownloadManager m_dlm;
|
||||
QProgressDialog *m_progressDialog;
|
||||
int m_countryIndex;
|
||||
VORModel m_vorModel;
|
||||
QHash<int, NavAid *> *m_vors;
|
||||
QHash<int, VORGUI *> m_selectedVORs;
|
||||
AzEl m_azEl; // Position of station
|
||||
QIcon m_muteIcon;
|
||||
QTimer m_statusTimer;
|
||||
int m_lastFeatureState;
|
||||
|
||||
explicit VORLocalizerGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *feature, QWidget* parent = nullptr);
|
||||
virtual ~VORLocalizerGUI();
|
||||
|
||||
void blockApplySettings(bool block);
|
||||
void applySettings(bool force = false);
|
||||
void displaySettings();
|
||||
bool handleMessage(const Message& message);
|
||||
|
||||
void leaveEvent(QEvent*);
|
||||
void enterEvent(QEvent*);
|
||||
|
||||
void resizeTable();
|
||||
QAction *createCheckableItem(QString& text, int idx, bool checked);
|
||||
|
||||
void calculateFreqOffset(VORGUI *vorGUI);
|
||||
void calculateFreqOffsets();
|
||||
void updateVORs();
|
||||
QString getOpenAIPVORDBURL(int i);
|
||||
QString getOpenAIPVORDBFilename(int i);
|
||||
QString getVORDBFilename();
|
||||
void readNavAids();
|
||||
// Move to util
|
||||
QString getDataDir();
|
||||
qint64 fileAgeInDays(QString filename);
|
||||
bool confirmDownload(QString filename);
|
||||
void updateChannelList();
|
||||
|
||||
private slots:
|
||||
void on_startStop_toggled(bool checked);
|
||||
void on_getOurAirportsVORDB_clicked();
|
||||
void on_getOpenAIPVORDB_clicked();
|
||||
void on_magDecAdjust_clicked(bool checked);
|
||||
void on_channelsRefresh_clicked();
|
||||
void vorData_sectionMoved(int logicalIndex, int oldVisualIndex, int newVisualIndex);
|
||||
void vorData_sectionResized(int logicalIndex, int oldSize, int newSize);
|
||||
void columnSelectMenu(QPoint pos);
|
||||
void columnSelectMenuChecked(bool checked = false);
|
||||
void onWidgetRolled(QWidget* widget, bool rollDown);
|
||||
void onMenuDialogCalled(const QPoint& p);
|
||||
void updateDownloadProgress(qint64 bytesRead, qint64 totalBytes);
|
||||
void downloadFinished(const QString& filename, bool success);
|
||||
void handleInputMessages();
|
||||
void updateStatus();
|
||||
void tick();
|
||||
};
|
||||
|
||||
#endif // INCLUDE_VORLOCALIZERGUI_H
|
434
plugins/feature/vorlocalizer/vorlocalizergui.ui
Normal file
434
plugins/feature/vorlocalizer/vorlocalizergui.ui
Normal file
@ -0,0 +1,434 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>VORLocalizerGUI</class>
|
||||
<widget class="RollupWidget" name="VORLocalizerGUI">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>398</width>
|
||||
<height>893</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>352</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Liberation Sans</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>VOR Localizer</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>VOR Localizer</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="settingsContainer" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>390</width>
|
||||
<height>61</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>350</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="buttonLayout">
|
||||
<item>
|
||||
<widget class="ButtonSwitch" name="startStop">
|
||||
<property name="toolTip">
|
||||
<string>start/stop acquisition</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../sdrgui/resources/res.qrc">
|
||||
<normaloff>:/play.png</normaloff>
|
||||
<normalon>:/stop.png</normalon>:/play.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="getOurAirportsVORDB">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Download OurAirports VOR database</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<normaloff>:/demodvor/icons/vor.png</normaloff>:/demodvor/icons/vor.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="getOpenAIPVORDB">
|
||||
<property name="toolTip">
|
||||
<string>Download OpenAIP VOR database</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<normaloff>:/demodvor/icons/vor.png</normaloff>:/demodvor/icons/vor.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="magDecAdjust">
|
||||
<property name="toolTip">
|
||||
<string>Draw radials adjusted for magnetic declination</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<normaloff>:/demodvor/icons/compass.png</normaloff>:/demodvor/icons/compass.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="vorsLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="channelsLabel">
|
||||
<property name="text">
|
||||
<string>VORs</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="channels">
|
||||
<property name="toolTip">
|
||||
<string>Select VOR channel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="channelsRefresh">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Refresh VOR channels available</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../sdrgui/resources/res.qrc">
|
||||
<normaloff>:/recycle.png</normaloff>:/recycle.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="dataContainer" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>110</y>
|
||||
<width>391</width>
|
||||
<height>140</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>VORs</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayoutTable">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="vorData">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Name of the VOR</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Freq (MHz)</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Frequency of the VOR in MHz</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Offset (kHz)</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Offset of the VOR's frequency from the current center frequency. Red indicates out of range.</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Ident</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Ident for the VOR</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Morse</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Morse code ident for the VOR</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>RX Ident</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Received ident</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>RX Morse</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Received Morse code ident</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Radial (°)</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Calculated radial from the VOR</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Ref (dB)</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Magnitude of received reference signal in dB</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Var (dB)</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Magnitude of received variable signal in dB</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Mute</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Mute/unmute audio from selected VORs</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="mapContainer" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>260</y>
|
||||
<width>391</width>
|
||||
<height>581</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Map</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayoutMap" stretch="0">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QQuickWidget" name="map">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>500</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>VOR map</string>
|
||||
</property>
|
||||
<property name="resizeMode">
|
||||
<enum>QQuickWidget::SizeRootObjectToView</enum>
|
||||
</property>
|
||||
<property name="source">
|
||||
<url>
|
||||
<string/>
|
||||
</url>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QQuickWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">QtQuickWidgets/QQuickWidget</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>RollupWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>gui/rollupwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ButtonSwitch</class>
|
||||
<extends>QToolButton</extends>
|
||||
<header>gui/buttonswitch.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>getOurAirportsVORDB</tabstop>
|
||||
<tabstop>vorData</tabstop>
|
||||
<tabstop>map</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../../../sdrgui/resources/res.qrc"/>
|
||||
<include location="map.qrc"/>
|
||||
<include location="icons.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
80
plugins/feature/vorlocalizer/vorlocalizerplugin.cpp
Normal file
80
plugins/feature/vorlocalizer/vorlocalizerplugin.cpp
Normal file
@ -0,0 +1,80 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 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 //
|
||||
// (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 <QtPlugin>
|
||||
#include "plugin/pluginapi.h"
|
||||
|
||||
#ifndef SERVER_MODE
|
||||
#include "vorlocalizergui.h"
|
||||
#endif
|
||||
#include "vorlocalizer.h"
|
||||
#include "vorlocalizerplugin.h"
|
||||
#include "vorlocalizerwebapiadapter.h"
|
||||
|
||||
const PluginDescriptor VORLocalizerPlugin::m_pluginDescriptor = {
|
||||
VORLocalizer::m_featureId,
|
||||
QStringLiteral("VOR Localizer"),
|
||||
QStringLiteral("6.3.0"),
|
||||
QStringLiteral("(c) Jon Beniston, M7RCE"),
|
||||
QStringLiteral("https://github.com/f4exb/sdrangel"),
|
||||
true,
|
||||
QStringLiteral("https://github.com/f4exb/sdrangel")
|
||||
};
|
||||
|
||||
VORLocalizerPlugin::VORLocalizerPlugin(QObject* parent) :
|
||||
QObject(parent),
|
||||
m_pluginAPI(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
const PluginDescriptor& VORLocalizerPlugin::getPluginDescriptor() const
|
||||
{
|
||||
return m_pluginDescriptor;
|
||||
}
|
||||
|
||||
void VORLocalizerPlugin::initPlugin(PluginAPI* pluginAPI)
|
||||
{
|
||||
m_pluginAPI = pluginAPI;
|
||||
|
||||
// register Simple PTT feature
|
||||
m_pluginAPI->registerFeature(VORLocalizer::m_featureIdURI, VORLocalizer::m_featureId, this);
|
||||
}
|
||||
|
||||
#ifdef SERVER_MODE
|
||||
FeatureGUI* VORLocalizerPlugin::createFeatureGUI(FeatureUISet *featureUISet, Feature *feature) const
|
||||
{
|
||||
(void) featureUISet;
|
||||
(void) feature;
|
||||
return nullptr;
|
||||
}
|
||||
#else
|
||||
FeatureGUI* VORLocalizerPlugin::createFeatureGUI(FeatureUISet *featureUISet, Feature *feature) const
|
||||
{
|
||||
return VORLocalizerGUI::create(m_pluginAPI, featureUISet, feature);
|
||||
}
|
||||
#endif
|
||||
|
||||
Feature* VORLocalizerPlugin::createFeature(WebAPIAdapterInterface* webAPIAdapterInterface) const
|
||||
{
|
||||
return new VORLocalizer(webAPIAdapterInterface);
|
||||
}
|
||||
|
||||
FeatureWebAPIAdapter* VORLocalizerPlugin::createFeatureWebAPIAdapter() const
|
||||
{
|
||||
return new VORLocalizerWebAPIAdapter();
|
||||
}
|
48
plugins/feature/vorlocalizer/vorlocalizerplugin.h
Normal file
48
plugins/feature/vorlocalizer/vorlocalizerplugin.h
Normal file
@ -0,0 +1,48 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 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 //
|
||||
// (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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_FEATURE_SIMPLEPTTPLUGIN_H
|
||||
#define INCLUDE_FEATURE_SIMPLEPTTPLUGIN_H
|
||||
|
||||
#include <QObject>
|
||||
#include "plugin/plugininterface.h"
|
||||
|
||||
class FeatureGUI;
|
||||
class WebAPIAdapterInterface;
|
||||
|
||||
class VORLocalizerPlugin : public QObject, PluginInterface {
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(PluginInterface)
|
||||
Q_PLUGIN_METADATA(IID "sdrangel.feature.vorlocalizer")
|
||||
|
||||
public:
|
||||
explicit VORLocalizerPlugin(QObject* parent = nullptr);
|
||||
|
||||
const PluginDescriptor& getPluginDescriptor() const;
|
||||
void initPlugin(PluginAPI* pluginAPI);
|
||||
|
||||
virtual FeatureGUI* createFeatureGUI(FeatureUISet *featureUISet, Feature *feature) const;
|
||||
virtual Feature* createFeature(WebAPIAdapterInterface *webAPIAdapterInterface) const;
|
||||
virtual FeatureWebAPIAdapter* createFeatureWebAPIAdapter() const;
|
||||
|
||||
private:
|
||||
static const PluginDescriptor m_pluginDescriptor;
|
||||
|
||||
PluginAPI* m_pluginAPI;
|
||||
};
|
||||
|
||||
#endif // INCLUDE_FEATURE_SIMPLEPTTPLUGIN_H
|
23
plugins/feature/vorlocalizer/vorlocalizerreport.cpp
Normal file
23
plugins/feature/vorlocalizer/vorlocalizerreport.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// 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 "vorlocalizerreport.h"
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(VORLocalizerReport::MsgReportFreqOffset, Message)
|
||||
MESSAGE_CLASS_DEFINITION(VORLocalizerReport::MsgReportRadial, Message)
|
||||
MESSAGE_CLASS_DEFINITION(VORLocalizerReport::MsgReportIdent, Message)
|
||||
MESSAGE_CLASS_DEFINITION(VORLocalizerReport::MsgReportChannels, Message)
|
172
plugins/feature/vorlocalizer/vorlocalizerreport.h
Normal file
172
plugins/feature/vorlocalizer/vorlocalizerreport.h
Normal file
@ -0,0 +1,172 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
|
||||
// Copyright (C) 2020 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_VORLOCALIZERREPORT_H
|
||||
#define INCLUDE_VORLOCALIZERREPORT_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "util/message.h"
|
||||
|
||||
class VORLocalizerReport : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
class MsgReportRadial : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
int getSubChannelId() const { return m_subChannelId; }
|
||||
float getRadial() const { return m_radial; }
|
||||
float getRefMag() const { return m_refMag; }
|
||||
float getVarMag() const { return m_varMag; }
|
||||
bool getValidRadial() const { return m_validRadial; }
|
||||
bool getValidRefMag() const { return m_validRefMag; }
|
||||
bool getValidVarMag() const { return m_validVarMag; }
|
||||
|
||||
static MsgReportRadial* create(
|
||||
int subChannelId,
|
||||
float radial,
|
||||
float refMag,
|
||||
float varMag,
|
||||
bool validRadial,
|
||||
bool validRefMag,
|
||||
bool validVarMag
|
||||
)
|
||||
{
|
||||
return new MsgReportRadial(
|
||||
subChannelId,
|
||||
radial,
|
||||
refMag,
|
||||
varMag,
|
||||
validRadial,
|
||||
validRefMag,
|
||||
validVarMag
|
||||
);
|
||||
}
|
||||
|
||||
private:
|
||||
int m_subChannelId;
|
||||
float m_radial;
|
||||
float m_refMag;
|
||||
float m_varMag;
|
||||
bool m_validRadial;
|
||||
bool m_validRefMag;
|
||||
bool m_validVarMag;
|
||||
|
||||
MsgReportRadial(
|
||||
int subChannelId,
|
||||
float radial,
|
||||
float refMag,
|
||||
float varMag,
|
||||
bool validRadial,
|
||||
bool validRefMag,
|
||||
bool validVarMag
|
||||
) :
|
||||
Message(),
|
||||
m_subChannelId(subChannelId),
|
||||
m_radial(radial),
|
||||
m_refMag(refMag),
|
||||
m_varMag(varMag),
|
||||
m_validRadial(validRadial),
|
||||
m_validRefMag(validRefMag),
|
||||
m_validVarMag(validVarMag)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class MsgReportFreqOffset : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
int getSubChannelId() const { return m_subChannelId; }
|
||||
int getFreqOffset() const { return m_freqOffset; }
|
||||
bool getOutOfBand() const { return m_outOfBand; }
|
||||
|
||||
static MsgReportFreqOffset* create(int subChannelId, int freqOffset, bool outOfBand)
|
||||
{
|
||||
return new MsgReportFreqOffset(subChannelId, freqOffset, outOfBand);
|
||||
}
|
||||
|
||||
private:
|
||||
int m_subChannelId;
|
||||
int m_freqOffset;
|
||||
bool m_outOfBand;
|
||||
|
||||
MsgReportFreqOffset(int subChannelId, int freqOffset, bool outOfBand) :
|
||||
Message(),
|
||||
m_subChannelId(subChannelId),
|
||||
m_freqOffset(freqOffset),
|
||||
m_outOfBand(outOfBand)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class MsgReportIdent : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
int getSubChannelId() const { return m_subChannelId; }
|
||||
QString getIdent() const { return m_ident; }
|
||||
|
||||
static MsgReportIdent* create(int subChannelId, QString ident)
|
||||
{
|
||||
return new MsgReportIdent(subChannelId, ident);
|
||||
}
|
||||
|
||||
private:
|
||||
int m_subChannelId;
|
||||
QString m_ident;
|
||||
|
||||
MsgReportIdent(int subChannelId, QString ident) :
|
||||
Message(),
|
||||
m_subChannelId(subChannelId),
|
||||
m_ident(ident)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class MsgReportChannels : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
struct Channel {
|
||||
int m_deviceSetIndex;
|
||||
int m_channelIndex;
|
||||
};
|
||||
|
||||
std::vector<Channel>& getChannels() { return m_channels; }
|
||||
|
||||
static MsgReportChannels* create() {
|
||||
return new MsgReportChannels();
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<Channel> m_channels;
|
||||
|
||||
MsgReportChannels() :
|
||||
Message()
|
||||
{}
|
||||
};
|
||||
|
||||
public:
|
||||
VORLocalizerReport() {}
|
||||
~VORLocalizerReport() {}
|
||||
};
|
||||
|
||||
#endif // INCLUDE_VORLOCALIZERREPORT_H
|
126
plugins/feature/vorlocalizer/vorlocalizersettings.cpp
Normal file
126
plugins/feature/vorlocalizer/vorlocalizersettings.cpp
Normal file
@ -0,0 +1,126 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015 Edouard Griffiths, F4EXB. //
|
||||
// Copyright (C) 2020 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// 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 "dsp/dspengine.h"
|
||||
#include "util/simpleserializer.h"
|
||||
#include "settings/serializable.h"
|
||||
#include "vorlocalizersettings.h"
|
||||
|
||||
VORLocalizerSettings::VORLocalizerSettings()
|
||||
{
|
||||
resetToDefaults();
|
||||
}
|
||||
|
||||
void VORLocalizerSettings::resetToDefaults()
|
||||
{
|
||||
m_rgbColor = QColor(255, 255, 0).rgb();
|
||||
m_title = "VOR Localizer";
|
||||
m_magDecAdjust = true;
|
||||
m_useReverseAPI = false;
|
||||
m_reverseAPIAddress = "127.0.0.1";
|
||||
m_reverseAPIPort = 8888;
|
||||
m_reverseAPIFeatureSetIndex = 0;
|
||||
m_reverseAPIFeatureIndex = 0;
|
||||
|
||||
|
||||
for (int i = 0; i < VORDEMOD_COLUMNS; i++)
|
||||
{
|
||||
m_columnIndexes[i] = i;
|
||||
m_columnSizes[i] = -1; // Autosize
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray VORLocalizerSettings::serialize() const
|
||||
{
|
||||
SimpleSerializer s(1);
|
||||
|
||||
s.writeU32(7, m_rgbColor);
|
||||
s.writeString(9, m_title);
|
||||
s.writeBool(10, m_magDecAdjust);
|
||||
s.writeBool(14, m_useReverseAPI);
|
||||
s.writeString(15, m_reverseAPIAddress);
|
||||
s.writeU32(16, m_reverseAPIPort);
|
||||
s.writeU32(17, m_reverseAPIFeatureSetIndex);
|
||||
s.writeU32(18, m_reverseAPIFeatureIndex);
|
||||
|
||||
for (int i = 0; i < VORDEMOD_COLUMNS; i++) {
|
||||
s.writeS32(100 + i, m_columnIndexes[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < VORDEMOD_COLUMNS; i++) {
|
||||
s.writeS32(200 + i, m_columnSizes[i]);
|
||||
}
|
||||
|
||||
return s.final();
|
||||
}
|
||||
|
||||
bool VORLocalizerSettings::deserialize(const QByteArray& data)
|
||||
{
|
||||
SimpleDeserializer d(data);
|
||||
|
||||
if(!d.isValid())
|
||||
{
|
||||
resetToDefaults();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(d.getVersion() == 1)
|
||||
{
|
||||
QByteArray bytetmp;
|
||||
uint32_t utmp;
|
||||
QString strtmp;
|
||||
|
||||
d.readBlob(6, &bytetmp);
|
||||
d.readU32(7, &m_rgbColor);
|
||||
d.readString(9, &m_title, "VOR Localizer");
|
||||
d.readBool(10, &m_magDecAdjust, true);
|
||||
d.readBool(14, &m_useReverseAPI, false);
|
||||
d.readString(15, &m_reverseAPIAddress, "127.0.0.1");
|
||||
d.readU32(16, &utmp, 0);
|
||||
|
||||
if ((utmp > 1023) && (utmp < 65535)) {
|
||||
m_reverseAPIPort = utmp;
|
||||
} else {
|
||||
m_reverseAPIPort = 8888;
|
||||
}
|
||||
|
||||
d.readU32(17, &utmp, 0);
|
||||
m_reverseAPIFeatureSetIndex = utmp > 99 ? 99 : utmp;
|
||||
d.readU32(18, &utmp, 0);
|
||||
m_reverseAPIFeatureIndex = utmp > 99 ? 99 : utmp;
|
||||
|
||||
for (int i = 0; i < VORDEMOD_COLUMNS; i++) {
|
||||
d.readS32(100 + i, &m_columnIndexes[i], i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < VORDEMOD_COLUMNS; i++) {
|
||||
d.readS32(200 + i, &m_columnSizes[i], -1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
resetToDefaults();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
77
plugins/feature/vorlocalizer/vorlocalizersettings.h
Normal file
77
plugins/feature/vorlocalizer/vorlocalizersettings.h
Normal file
@ -0,0 +1,77 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017 Edouard Griffiths, F4EXB. //
|
||||
// Copyright (C) 2020 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_VORLOCALIZERSETTINGS_H
|
||||
#define INCLUDE_VORLOCALIZERSETTINGS_H
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QHash>
|
||||
|
||||
class Serializable;
|
||||
|
||||
// Number of columns in the table
|
||||
|
||||
struct VORLocalizerSubChannelSettings {
|
||||
int m_id; //!< Unique VOR identifier (from database)
|
||||
int m_frequency; //!< Frequency the VOR is on
|
||||
bool m_audioMute; //!< Mute the audio from this VOR
|
||||
};
|
||||
|
||||
struct VORLocalizerSettings
|
||||
{
|
||||
struct VORDemodChannels
|
||||
{
|
||||
int m_deviceSetIndex;
|
||||
int m_channelIndex;
|
||||
};
|
||||
|
||||
quint32 m_rgbColor;
|
||||
QString m_title;
|
||||
bool m_magDecAdjust; //!< Adjust for magnetic declination when drawing radials on the map
|
||||
bool m_useReverseAPI;
|
||||
QString m_reverseAPIAddress;
|
||||
uint16_t m_reverseAPIPort;
|
||||
uint16_t m_reverseAPIFeatureSetIndex;
|
||||
uint16_t m_reverseAPIFeatureIndex;
|
||||
|
||||
|
||||
static const int VORDEMOD_COLUMNS = 11;
|
||||
static const int VOR_COL_NAME = 0;
|
||||
static const int VOR_COL_FREQUENCY = 1;
|
||||
static const int VOR_COL_OFFSET = 2;
|
||||
static const int VOR_COL_IDENT = 3;
|
||||
static const int VOR_COL_MORSE = 4;
|
||||
static const int VOR_COL_RX_IDENT = 5;
|
||||
static const int VOR_COL_RX_MORSE = 6;
|
||||
static const int VOR_COL_RADIAL = 7;
|
||||
static const int VOR_COL_REF_MAG = 8;
|
||||
static const int VOR_COL_VAR_MAG = 9;
|
||||
static const int VOR_COL_MUTE = 10;
|
||||
|
||||
int m_columnIndexes[VORDEMOD_COLUMNS];//!< How the columns are ordered in the table
|
||||
int m_columnSizes[VORDEMOD_COLUMNS]; //!< Size of the coumns in the table
|
||||
|
||||
QHash<int, VORLocalizerSubChannelSettings *> m_subChannelSettings;
|
||||
|
||||
VORLocalizerSettings();
|
||||
void resetToDefaults();
|
||||
QByteArray serialize() const;
|
||||
bool deserialize(const QByteArray& data);
|
||||
};
|
||||
|
||||
#endif /* INCLUDE_VORLOCALIZERSETTINGS_H */
|
52
plugins/feature/vorlocalizer/vorlocalizerwebapiadapter.cpp
Normal file
52
plugins/feature/vorlocalizer/vorlocalizerwebapiadapter.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2019 Edouard Griffiths, F4EXB. //
|
||||
// Copyright (C) 2020 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// 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 "SWGFeatureSettings.h"
|
||||
#include "vorlocalizer.h"
|
||||
#include "vorlocalizerwebapiadapter.h"
|
||||
|
||||
VORLocalizerWebAPIAdapter::VORLocalizerWebAPIAdapter()
|
||||
{}
|
||||
|
||||
VORLocalizerWebAPIAdapter::~VORLocalizerWebAPIAdapter()
|
||||
{}
|
||||
|
||||
int VORLocalizerWebAPIAdapter::webapiSettingsGet(
|
||||
SWGSDRangel::SWGFeatureSettings& response,
|
||||
QString& errorMessage)
|
||||
{
|
||||
(void) errorMessage;
|
||||
response.setVorLocalizerSettings(new SWGSDRangel::SWGVORLocalizerSettings());
|
||||
response.getVorLocalizerSettings()->init();
|
||||
VORLocalizer::webapiFormatFeatureSettings(response, m_settings);
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
int VORLocalizerWebAPIAdapter::webapiSettingsPutPatch(
|
||||
bool force,
|
||||
const QStringList& featureSettingsKeys,
|
||||
SWGSDRangel::SWGFeatureSettings& response,
|
||||
QString& errorMessage)
|
||||
{
|
||||
(void) force;
|
||||
(void) errorMessage;
|
||||
VORLocalizer::webapiUpdateFeatureSettings(m_settings, featureSettingsKeys, response);
|
||||
|
||||
return 200;
|
||||
}
|
50
plugins/feature/vorlocalizer/vorlocalizerwebapiadapter.h
Normal file
50
plugins/feature/vorlocalizer/vorlocalizerwebapiadapter.h
Normal file
@ -0,0 +1,50 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2019 Edouard Griffiths, F4EXB. //
|
||||
// Copyright (C) 2020 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_VORLOCALIZER_WEBAPIADAPTER_H
|
||||
#define INCLUDE_VORLOCALIZER_WEBAPIADAPTER_H
|
||||
|
||||
#include "feature/featurewebapiadapter.h"
|
||||
#include "vorlocalizersettings.h"
|
||||
|
||||
/**
|
||||
* Standalone API adapter only for the settings
|
||||
*/
|
||||
class VORLocalizerWebAPIAdapter : public FeatureWebAPIAdapter {
|
||||
public:
|
||||
VORLocalizerWebAPIAdapter();
|
||||
virtual ~VORLocalizerWebAPIAdapter();
|
||||
|
||||
virtual QByteArray serialize() const { return m_settings.serialize(); }
|
||||
virtual bool deserialize(const QByteArray& data) { return m_settings.deserialize(data); }
|
||||
|
||||
virtual int webapiSettingsGet(
|
||||
SWGSDRangel::SWGFeatureSettings& response,
|
||||
QString& errorMessage);
|
||||
|
||||
virtual int webapiSettingsPutPatch(
|
||||
bool force,
|
||||
const QStringList& featureSettingsKeys,
|
||||
SWGSDRangel::SWGFeatureSettings& response,
|
||||
QString& errorMessage);
|
||||
|
||||
private:
|
||||
VORLocalizerSettings m_settings;
|
||||
};
|
||||
|
||||
#endif // INCLUDE_VORDEMOD_WEBAPIADAPTER_H
|
223
plugins/feature/vorlocalizer/vorlocalizerworker.cpp
Normal file
223
plugins/feature/vorlocalizer/vorlocalizerworker.cpp
Normal file
@ -0,0 +1,223 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 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 //
|
||||
// (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 <QDebug>
|
||||
|
||||
#include "SWGDeviceState.h"
|
||||
#include "SWGSuccessResponse.h"
|
||||
#include "SWGErrorResponse.h"
|
||||
|
||||
#include "webapi/webapiadapterinterface.h"
|
||||
#include "device/deviceset.h"
|
||||
#include "channel/channelapi.h"
|
||||
#include "maincore.h"
|
||||
|
||||
#include "vorlocalizerreport.h"
|
||||
#include "vorlocalizerworker.h"
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(VorLocalizerWorker::MsgConfigureVORLocalizerWorker, Message)
|
||||
MESSAGE_CLASS_DEFINITION(VorLocalizerWorker::MsgRefreshChannels, Message)
|
||||
|
||||
class DSPDeviceSourceEngine;
|
||||
|
||||
VorLocalizerWorker::VorLocalizerWorker(WebAPIAdapterInterface *webAPIAdapterInterface) :
|
||||
m_webAPIAdapterInterface(webAPIAdapterInterface),
|
||||
m_msgQueueToGUI(nullptr),
|
||||
m_running(false),
|
||||
m_mutex(QMutex::Recursive)
|
||||
{
|
||||
qDebug("VorLocalizerWorker::VorLocalizerWorker");
|
||||
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
|
||||
}
|
||||
|
||||
VorLocalizerWorker::~VorLocalizerWorker()
|
||||
{
|
||||
m_inputMessageQueue.clear();
|
||||
}
|
||||
|
||||
void VorLocalizerWorker::reset()
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
m_inputMessageQueue.clear();
|
||||
}
|
||||
|
||||
bool VorLocalizerWorker::startWork()
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
||||
m_running = true;
|
||||
return m_running;
|
||||
}
|
||||
|
||||
void VorLocalizerWorker::stopWork()
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
disconnect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
||||
m_running = false;
|
||||
}
|
||||
|
||||
void VorLocalizerWorker::handleInputMessages()
|
||||
{
|
||||
Message* message;
|
||||
|
||||
while ((message = m_inputMessageQueue.pop()) != nullptr)
|
||||
{
|
||||
if (handleMessage(*message)) {
|
||||
delete message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool VorLocalizerWorker::handleMessage(const Message& cmd)
|
||||
{
|
||||
if (MsgConfigureVORLocalizerWorker::match(cmd))
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
MsgConfigureVORLocalizerWorker& cfg = (MsgConfigureVORLocalizerWorker&) cmd;
|
||||
qDebug() << "VorLocalizerWorker::handleMessage: MsgConfigureVORLocalizerWorker";
|
||||
|
||||
applySettings(cfg.getSettings(), cfg.getForce());
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgRefreshChannels::match(cmd))
|
||||
{
|
||||
qDebug() << "VorLocalizerWorker::handleMessage: MsgRefreshChannels";
|
||||
updateChannels();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void VorLocalizerWorker::applySettings(const VORLocalizerSettings& settings, bool force)
|
||||
{
|
||||
qDebug() << "VorLocalizerWorker::applySettings:"
|
||||
<< " m_title: " << settings.m_title
|
||||
<< " m_rgbColor: " << settings.m_rgbColor
|
||||
<< " force: " << force;
|
||||
|
||||
// Remove sub-channels no longer needed
|
||||
for (int i = 0; i < m_vorChannels.size(); i++)
|
||||
{
|
||||
if (!settings.m_subChannelSettings.contains(m_vorChannels[i].m_subChannelId))
|
||||
{
|
||||
qDebug() << "VorLocalizerWorker::applySettings: Removing sink " << m_vorChannels[i].m_subChannelId;
|
||||
removeVORChannel(m_vorChannels[i].m_subChannelId);
|
||||
}
|
||||
}
|
||||
|
||||
// Add new sub channels
|
||||
QHash<int, VORLocalizerSubChannelSettings *>::const_iterator itr = settings.m_subChannelSettings.begin();
|
||||
while (itr != settings.m_subChannelSettings.end())
|
||||
{
|
||||
VORLocalizerSubChannelSettings *subChannelSettings = itr.value();
|
||||
int j = 0;
|
||||
|
||||
for (; j < m_vorChannels.size(); j++)
|
||||
{
|
||||
if (subChannelSettings->m_id == m_vorChannels[j].m_subChannelId)
|
||||
break;
|
||||
}
|
||||
|
||||
if (j == m_vorChannels.size())
|
||||
{
|
||||
// Add a sub-channel sink
|
||||
qDebug() << "VorLocalizerWorker::applySettings: Adding sink " << subChannelSettings->m_id;
|
||||
addVORChannel(subChannelSettings);
|
||||
}
|
||||
|
||||
++itr;
|
||||
}
|
||||
|
||||
m_settings = settings;
|
||||
}
|
||||
|
||||
void VorLocalizerWorker::updateHardware()
|
||||
{
|
||||
SWGSDRangel::SWGSuccessResponse response;
|
||||
SWGSDRangel::SWGErrorResponse error;
|
||||
m_updateTimer.stop();
|
||||
m_mutex.unlock();
|
||||
}
|
||||
|
||||
void VorLocalizerWorker::removeVORChannel(int navId)
|
||||
{
|
||||
for (int i = 0; i < m_vorChannels.size(); i++)
|
||||
{
|
||||
if (m_vorChannels[i].m_subChannelId == navId)
|
||||
{
|
||||
m_vorChannels.removeAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VorLocalizerWorker::addVORChannel(const VORLocalizerSubChannelSettings *subChannelSettings)
|
||||
{
|
||||
VORChannel vorChannel = VORChannel{subChannelSettings->m_id, subChannelSettings->m_frequency, subChannelSettings->m_audioMute};
|
||||
m_vorChannels.push_back(vorChannel);
|
||||
}
|
||||
|
||||
void VorLocalizerWorker::updateChannels()
|
||||
{
|
||||
MainCore *mainCore = MainCore::instance();
|
||||
std::vector<DeviceSet*>& deviceSets = mainCore->getDeviceSets();
|
||||
std::vector<DeviceSet*>::const_iterator it = deviceSets.begin();
|
||||
m_availableChannels.clear();
|
||||
|
||||
int deviceIndex = 0;
|
||||
|
||||
for (; it != deviceSets.end(); ++it, deviceIndex++)
|
||||
{
|
||||
DSPDeviceSourceEngine *deviceSourceEngine = (*it)->m_deviceSourceEngine;
|
||||
|
||||
if (deviceSourceEngine)
|
||||
{
|
||||
for (int chi = 0; chi < (*it)->getNumberOfChannels(); chi++)
|
||||
{
|
||||
ChannelAPI *channel = (*it)->getChannelAt(chi);
|
||||
|
||||
if (channel->getURI() == "sdrangel.channel.vordemodsc")
|
||||
{
|
||||
AvailableChannel availableChannel = AvailableChannel{deviceIndex, chi, channel};
|
||||
m_availableChannels.push_back(availableChannel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_msgQueueToGUI)
|
||||
{
|
||||
VORLocalizerReport::MsgReportChannels *msg = VORLocalizerReport::MsgReportChannels::create();
|
||||
std::vector<VORLocalizerReport::MsgReportChannels::Channel>& msgChannels = msg->getChannels();
|
||||
|
||||
for (int i = 0; i < m_availableChannels.size(); i++)
|
||||
{
|
||||
VORLocalizerReport::MsgReportChannels::Channel msgChannel =
|
||||
VORLocalizerReport::MsgReportChannels::Channel{
|
||||
m_availableChannels[i].m_deviceSetIndex,
|
||||
m_availableChannels[i].m_channelIndex
|
||||
};
|
||||
msgChannels.push_back(msgChannel);
|
||||
}
|
||||
|
||||
m_msgQueueToGUI->push(msg);
|
||||
}
|
||||
}
|
118
plugins/feature/vorlocalizer/vorlocalizerworker.h
Normal file
118
plugins/feature/vorlocalizer/vorlocalizerworker.h
Normal file
@ -0,0 +1,118 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 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 //
|
||||
// (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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_FEATURE_VORLOCALIZERWORKER_H_
|
||||
#define INCLUDE_FEATURE_VORLOCALIZERWORKER_H_
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
|
||||
#include "util/message.h"
|
||||
#include "util/messagequeue.h"
|
||||
|
||||
#include "vorlocalizersettings.h"
|
||||
|
||||
class WebAPIAdapterInterface;
|
||||
class ChannelAPI;
|
||||
|
||||
class VorLocalizerWorker : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
class MsgConfigureVORLocalizerWorker : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
const VORLocalizerSettings& getSettings() const { return m_settings; }
|
||||
bool getForce() const { return m_force; }
|
||||
|
||||
static MsgConfigureVORLocalizerWorker* create(const VORLocalizerSettings& settings, bool force)
|
||||
{
|
||||
return new MsgConfigureVORLocalizerWorker(settings, force);
|
||||
}
|
||||
|
||||
private:
|
||||
VORLocalizerSettings m_settings;
|
||||
bool m_force;
|
||||
|
||||
MsgConfigureVORLocalizerWorker(const VORLocalizerSettings& settings, bool force) :
|
||||
Message(),
|
||||
m_settings(settings),
|
||||
m_force(force)
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgRefreshChannels : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
static MsgRefreshChannels* create() {
|
||||
return new MsgRefreshChannels();
|
||||
}
|
||||
|
||||
protected:
|
||||
MsgRefreshChannels() :
|
||||
Message()
|
||||
{ }
|
||||
};
|
||||
|
||||
VorLocalizerWorker(WebAPIAdapterInterface *webAPIAdapterInterface);
|
||||
~VorLocalizerWorker();
|
||||
void reset();
|
||||
bool startWork();
|
||||
void stopWork();
|
||||
bool isRunning() const { return m_running; }
|
||||
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
|
||||
void setMessageQueueToGUI(MessageQueue *messageQueue) { m_msgQueueToGUI = messageQueue; }
|
||||
|
||||
private:
|
||||
struct VORChannel
|
||||
{
|
||||
int m_subChannelId; //!< Unique VOR identifier (from database)
|
||||
int m_frequency; //!< Frequency the VOR is on
|
||||
bool m_audioMute; //!< Mute the audio from this VOR
|
||||
};
|
||||
|
||||
struct AvailableChannel
|
||||
{
|
||||
int m_deviceSetIndex;
|
||||
int m_channelIndex;
|
||||
ChannelAPI *m_channelAPI;
|
||||
};
|
||||
|
||||
WebAPIAdapterInterface *m_webAPIAdapterInterface;
|
||||
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
|
||||
MessageQueue *m_msgQueueToGUI; //!< Queue to report state to GUI
|
||||
VORLocalizerSettings m_settings;
|
||||
QList<VORChannel> m_vorChannels;
|
||||
QList<AvailableChannel> m_availableChannels;
|
||||
bool m_running;
|
||||
QTimer m_updateTimer;
|
||||
QMutex m_mutex;
|
||||
|
||||
bool handleMessage(const Message& cmd);
|
||||
void applySettings(const VORLocalizerSettings& settings, bool force = false);
|
||||
void updateChannels();
|
||||
void removeVORChannel(int navId);
|
||||
void addVORChannel(const VORLocalizerSubChannelSettings *subChannelSettings);
|
||||
|
||||
private slots:
|
||||
void handleInputMessages();
|
||||
void updateHardware();
|
||||
};
|
||||
|
||||
#endif // INCLUDE_FEATURE_VORLOCALIZERWORKER_H_
|
@ -170,6 +170,7 @@ set(sdrbase_SOURCES
|
||||
util/azel.cpp
|
||||
util/crc.cpp
|
||||
util/CRC64.cpp
|
||||
util/csv.cpp
|
||||
util/db.cpp
|
||||
util/fixedtraits.cpp
|
||||
util/httpdownloadmanager.cpp
|
||||
@ -346,6 +347,7 @@ set(sdrbase_HEADERS
|
||||
|
||||
util/azel.h
|
||||
util/CRC64.h
|
||||
util/csv.h
|
||||
util/db.h
|
||||
util/doublebuffer.h
|
||||
util/doublebufferfifo.h
|
||||
|
@ -84,6 +84,7 @@
|
||||
<file>webapi/doc/swagger/include/User.yaml</file>
|
||||
<file>webapi/doc/swagger/include/USRP.yaml</file>
|
||||
<file>webapi/doc/swagger/include/VORDemod.yaml</file>
|
||||
<file>webapi/doc/swagger/include/VORLocalizer.yaml</file>
|
||||
<file>webapi/doc/swagger/include/VORDemodSC.yaml</file>
|
||||
<file>webapi/doc/swagger/include/WFMDemod.yaml</file>
|
||||
<file>webapi/doc/swagger/include/WFMMod.yaml</file>
|
||||
|
@ -4094,6 +4094,9 @@ margin-bottom: 20px;
|
||||
},
|
||||
"RigCtlServerSettings" : {
|
||||
"$ref" : "#/definitions/RigCtlServerSettings"
|
||||
},
|
||||
"VORLocalizerSettings" : {
|
||||
"$ref" : "#/definitions/VORLocalizerSettings"
|
||||
}
|
||||
},
|
||||
"description" : "Base feature settings. Only the feature settings corresponding to the feature specified in the featureType field is or should be present."
|
||||
@ -9614,6 +9617,37 @@ margin-bottom: 20px;
|
||||
}
|
||||
},
|
||||
"description" : "VORDemod"
|
||||
};
|
||||
defs.VORLocalizerSettings = {
|
||||
"properties" : {
|
||||
"rgbColor" : {
|
||||
"type" : "integer"
|
||||
},
|
||||
"title" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"useReverseAPI" : {
|
||||
"type" : "integer",
|
||||
"description" : "Synchronize with reverse API (1 for yes, 0 for no)"
|
||||
},
|
||||
"reverseAPIAddress" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"reverseAPIPort" : {
|
||||
"type" : "integer"
|
||||
},
|
||||
"reverseAPIFeatureSetIndex" : {
|
||||
"type" : "integer"
|
||||
},
|
||||
"reverseAPIFeatureIndex" : {
|
||||
"type" : "integer"
|
||||
},
|
||||
"magDecAdjust" : {
|
||||
"type" : "integer",
|
||||
"description" : "Adjust radial lines on map for magnetic declination of VOR"
|
||||
}
|
||||
},
|
||||
"description" : "VORLocalizer"
|
||||
};
|
||||
defs.WFMDemodReport = {
|
||||
"properties" : {
|
||||
@ -44816,7 +44850,7 @@ except ApiException as e:
|
||||
</div>
|
||||
<div id="generator">
|
||||
<div class="content">
|
||||
Generated 2020-11-29T08:58:14.732+01:00
|
||||
Generated 2020-11-29T21:00:18.945+01:00
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -21,3 +21,5 @@ FeatureSettings:
|
||||
$ref: "/doc/swagger/include/SimplePTT.yaml#/SimplePTTSettings"
|
||||
RigCtlServerSettings:
|
||||
$ref: "/doc/swagger/include/RigCtlServer.yaml#/RigCtlServerSettings"
|
||||
VORLocalizerSettings:
|
||||
$ref: "/doc/swagger/include/VORLocalizer.yaml#/VORLocalizerSettings"
|
||||
|
@ -0,0 +1,21 @@
|
||||
VORLocalizerSettings:
|
||||
description: VORLocalizer
|
||||
properties:
|
||||
rgbColor:
|
||||
type: integer
|
||||
title:
|
||||
type: string
|
||||
useReverseAPI:
|
||||
description: Synchronize with reverse API (1 for yes, 0 for no)
|
||||
type: integer
|
||||
reverseAPIAddress:
|
||||
type: string
|
||||
reverseAPIPort:
|
||||
type: integer
|
||||
reverseAPIFeatureSetIndex:
|
||||
type: integer
|
||||
reverseAPIFeatureIndex:
|
||||
type: integer
|
||||
magDecAdjust:
|
||||
description: Adjust radial lines on map for magnetic declination of VOR
|
||||
type: integer
|
69
sdrbase/util/csv.cpp
Normal file
69
sdrbase/util/csv.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// 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 "csv.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
#include <QByteArray>
|
||||
#include <QHash>
|
||||
#include <QList>
|
||||
#include <QDebug>
|
||||
|
||||
// Create a hash map from a CSV file with two columns
|
||||
QHash<QString, QString> *csvHash(const QString& filename, int reserve)
|
||||
{
|
||||
int cnt = 0;
|
||||
QHash<QString, QString> *map = nullptr;
|
||||
|
||||
qDebug() << "csvHash: " << filename;
|
||||
|
||||
QFile file(filename);
|
||||
if (file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
// Read header
|
||||
if (!file.atEnd())
|
||||
{
|
||||
QByteArray row = file.readLine().trimmed();
|
||||
if (row.split(',').size() == 2)
|
||||
{
|
||||
map = new QHash<QString, QString>();
|
||||
if (reserve > 0)
|
||||
map->reserve(reserve);
|
||||
// Read data
|
||||
while (!file.atEnd())
|
||||
{
|
||||
row = file.readLine().trimmed();
|
||||
QList<QByteArray> cols = row.split(',');
|
||||
map->insert(QString(cols[0]), QString(cols[1]));
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
else
|
||||
qDebug() << "csvHash: Unexpected header";
|
||||
}
|
||||
else
|
||||
qDebug() << "csvHash: Empty file";
|
||||
file.close();
|
||||
}
|
||||
else
|
||||
qDebug() << "csvHash: Failed to open " << filename;
|
||||
|
||||
qDebug() << "csvHash: " << filename << ": read " << cnt << " entries";
|
||||
|
||||
return map;
|
||||
}
|
44
sdrbase/util/csv.h
Normal file
44
sdrbase/util/csv.h
Normal file
@ -0,0 +1,44 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_CSV_H
|
||||
#define INCLUDE_CSV_H
|
||||
|
||||
#include <QString>
|
||||
#include <QHash>
|
||||
|
||||
// Extract string from CSV line, updating pp to next column
|
||||
static inline char *csvNext(char **pp)
|
||||
{
|
||||
char *p = *pp;
|
||||
|
||||
if (p[0] == '\0')
|
||||
return nullptr;
|
||||
|
||||
char *start = p;
|
||||
|
||||
while ((*p != ',') && (*p != '\n'))
|
||||
p++;
|
||||
*p++ = '\0';
|
||||
*pp = p;
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
QHash<QString, QString> *csvHash(const QString& filename, int reserve=0);
|
||||
|
||||
#endif /* INCLUDE_CSV_H */
|
@ -21,3 +21,5 @@ FeatureSettings:
|
||||
$ref: "http://swgserver:8081/api/swagger/include/SimplePTT.yaml#/SimplePTTSettings"
|
||||
RigCtlServerSettings:
|
||||
$ref: "http://swgserver:8081/api/swagger/include/RigCtlServer.yaml#/RigCtlServerSettings"
|
||||
VORLocalizerSettings:
|
||||
$ref: "http://swgserver:8081/api/swagger/include/VORLocalizer.yaml#/VORLocalizerSettings"
|
||||
|
21
swagger/sdrangel/api/swagger/include/VORLocalizer.yaml
Normal file
21
swagger/sdrangel/api/swagger/include/VORLocalizer.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
VORLocalizerSettings:
|
||||
description: VORLocalizer
|
||||
properties:
|
||||
rgbColor:
|
||||
type: integer
|
||||
title:
|
||||
type: string
|
||||
useReverseAPI:
|
||||
description: Synchronize with reverse API (1 for yes, 0 for no)
|
||||
type: integer
|
||||
reverseAPIAddress:
|
||||
type: string
|
||||
reverseAPIPort:
|
||||
type: integer
|
||||
reverseAPIFeatureSetIndex:
|
||||
type: integer
|
||||
reverseAPIFeatureIndex:
|
||||
type: integer
|
||||
magDecAdjust:
|
||||
description: Adjust radial lines on map for magnetic declination of VOR
|
||||
type: integer
|
@ -4094,6 +4094,9 @@ margin-bottom: 20px;
|
||||
},
|
||||
"RigCtlServerSettings" : {
|
||||
"$ref" : "#/definitions/RigCtlServerSettings"
|
||||
},
|
||||
"VORLocalizerSettings" : {
|
||||
"$ref" : "#/definitions/VORLocalizerSettings"
|
||||
}
|
||||
},
|
||||
"description" : "Base feature settings. Only the feature settings corresponding to the feature specified in the featureType field is or should be present."
|
||||
@ -9614,6 +9617,37 @@ margin-bottom: 20px;
|
||||
}
|
||||
},
|
||||
"description" : "VORDemod"
|
||||
};
|
||||
defs.VORLocalizerSettings = {
|
||||
"properties" : {
|
||||
"rgbColor" : {
|
||||
"type" : "integer"
|
||||
},
|
||||
"title" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"useReverseAPI" : {
|
||||
"type" : "integer",
|
||||
"description" : "Synchronize with reverse API (1 for yes, 0 for no)"
|
||||
},
|
||||
"reverseAPIAddress" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"reverseAPIPort" : {
|
||||
"type" : "integer"
|
||||
},
|
||||
"reverseAPIFeatureSetIndex" : {
|
||||
"type" : "integer"
|
||||
},
|
||||
"reverseAPIFeatureIndex" : {
|
||||
"type" : "integer"
|
||||
},
|
||||
"magDecAdjust" : {
|
||||
"type" : "integer",
|
||||
"description" : "Adjust radial lines on map for magnetic declination of VOR"
|
||||
}
|
||||
},
|
||||
"description" : "VORLocalizer"
|
||||
};
|
||||
defs.WFMDemodReport = {
|
||||
"properties" : {
|
||||
@ -44816,7 +44850,7 @@ except ApiException as e:
|
||||
</div>
|
||||
<div id="generator">
|
||||
<div class="content">
|
||||
Generated 2020-11-29T08:58:14.732+01:00
|
||||
Generated 2020-11-29T21:00:18.945+01:00
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -42,6 +42,8 @@ SWGFeatureSettings::SWGFeatureSettings() {
|
||||
m_simple_ptt_settings_isSet = false;
|
||||
rig_ctl_server_settings = nullptr;
|
||||
m_rig_ctl_server_settings_isSet = false;
|
||||
vor_localizer_settings = nullptr;
|
||||
m_vor_localizer_settings_isSet = false;
|
||||
}
|
||||
|
||||
SWGFeatureSettings::~SWGFeatureSettings() {
|
||||
@ -64,6 +66,8 @@ SWGFeatureSettings::init() {
|
||||
m_simple_ptt_settings_isSet = false;
|
||||
rig_ctl_server_settings = new SWGRigCtlServerSettings();
|
||||
m_rig_ctl_server_settings_isSet = false;
|
||||
vor_localizer_settings = new SWGVORLocalizerSettings();
|
||||
m_vor_localizer_settings_isSet = false;
|
||||
}
|
||||
|
||||
void
|
||||
@ -85,6 +89,9 @@ SWGFeatureSettings::cleanup() {
|
||||
if(rig_ctl_server_settings != nullptr) {
|
||||
delete rig_ctl_server_settings;
|
||||
}
|
||||
if(vor_localizer_settings != nullptr) {
|
||||
delete vor_localizer_settings;
|
||||
}
|
||||
}
|
||||
|
||||
SWGFeatureSettings*
|
||||
@ -112,6 +119,8 @@ SWGFeatureSettings::fromJsonObject(QJsonObject &pJson) {
|
||||
|
||||
::SWGSDRangel::setValue(&rig_ctl_server_settings, pJson["RigCtlServerSettings"], "SWGRigCtlServerSettings", "SWGRigCtlServerSettings");
|
||||
|
||||
::SWGSDRangel::setValue(&vor_localizer_settings, pJson["VORLocalizerSettings"], "SWGVORLocalizerSettings", "SWGVORLocalizerSettings");
|
||||
|
||||
}
|
||||
|
||||
QString
|
||||
@ -149,6 +158,9 @@ SWGFeatureSettings::asJsonObject() {
|
||||
if((rig_ctl_server_settings != nullptr) && (rig_ctl_server_settings->isSet())){
|
||||
toJsonValue(QString("RigCtlServerSettings"), rig_ctl_server_settings, obj, QString("SWGRigCtlServerSettings"));
|
||||
}
|
||||
if((vor_localizer_settings != nullptr) && (vor_localizer_settings->isSet())){
|
||||
toJsonValue(QString("VORLocalizerSettings"), vor_localizer_settings, obj, QString("SWGVORLocalizerSettings"));
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
@ -223,6 +235,16 @@ SWGFeatureSettings::setRigCtlServerSettings(SWGRigCtlServerSettings* rig_ctl_ser
|
||||
this->m_rig_ctl_server_settings_isSet = true;
|
||||
}
|
||||
|
||||
SWGVORLocalizerSettings*
|
||||
SWGFeatureSettings::getVorLocalizerSettings() {
|
||||
return vor_localizer_settings;
|
||||
}
|
||||
void
|
||||
SWGFeatureSettings::setVorLocalizerSettings(SWGVORLocalizerSettings* vor_localizer_settings) {
|
||||
this->vor_localizer_settings = vor_localizer_settings;
|
||||
this->m_vor_localizer_settings_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SWGFeatureSettings::isSet(){
|
||||
@ -249,6 +271,9 @@ SWGFeatureSettings::isSet(){
|
||||
if(rig_ctl_server_settings && rig_ctl_server_settings->isSet()){
|
||||
isObjectUpdated = true; break;
|
||||
}
|
||||
if(vor_localizer_settings && vor_localizer_settings->isSet()){
|
||||
isObjectUpdated = true; break;
|
||||
}
|
||||
}while(false);
|
||||
return isObjectUpdated;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "SWGGS232ControllerSettings.h"
|
||||
#include "SWGRigCtlServerSettings.h"
|
||||
#include "SWGSimplePTTSettings.h"
|
||||
#include "SWGVORLocalizerSettings.h"
|
||||
#include <QString>
|
||||
|
||||
#include "SWGObject.h"
|
||||
@ -67,6 +68,9 @@ public:
|
||||
SWGRigCtlServerSettings* getRigCtlServerSettings();
|
||||
void setRigCtlServerSettings(SWGRigCtlServerSettings* rig_ctl_server_settings);
|
||||
|
||||
SWGVORLocalizerSettings* getVorLocalizerSettings();
|
||||
void setVorLocalizerSettings(SWGVORLocalizerSettings* vor_localizer_settings);
|
||||
|
||||
|
||||
virtual bool isSet() override;
|
||||
|
||||
@ -92,6 +96,9 @@ private:
|
||||
SWGRigCtlServerSettings* rig_ctl_server_settings;
|
||||
bool m_rig_ctl_server_settings_isSet;
|
||||
|
||||
SWGVORLocalizerSettings* vor_localizer_settings;
|
||||
bool m_vor_localizer_settings_isSet;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -225,6 +225,7 @@
|
||||
#include "SWGVORDemodSCReport.h"
|
||||
#include "SWGVORDemodSCSettings.h"
|
||||
#include "SWGVORDemodSettings.h"
|
||||
#include "SWGVORLocalizerSettings.h"
|
||||
#include "SWGWFMDemodReport.h"
|
||||
#include "SWGWFMDemodSettings.h"
|
||||
#include "SWGWFMModReport.h"
|
||||
@ -872,6 +873,9 @@ namespace SWGSDRangel {
|
||||
if(QString("SWGVORDemodSettings").compare(type) == 0) {
|
||||
return new SWGVORDemodSettings();
|
||||
}
|
||||
if(QString("SWGVORLocalizerSettings").compare(type) == 0) {
|
||||
return new SWGVORLocalizerSettings();
|
||||
}
|
||||
if(QString("SWGWFMDemodReport").compare(type) == 0) {
|
||||
return new SWGWFMDemodReport();
|
||||
}
|
||||
|
273
swagger/sdrangel/code/qt5/client/SWGVORLocalizerSettings.cpp
Normal file
273
swagger/sdrangel/code/qt5/client/SWGVORLocalizerSettings.cpp
Normal file
@ -0,0 +1,273 @@
|
||||
/**
|
||||
* SDRangel
|
||||
* This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time ---
|
||||
*
|
||||
* OpenAPI spec version: 6.0.0
|
||||
* Contact: f4exb06@gmail.com
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
#include "SWGVORLocalizerSettings.h"
|
||||
|
||||
#include "SWGHelpers.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
namespace SWGSDRangel {
|
||||
|
||||
SWGVORLocalizerSettings::SWGVORLocalizerSettings(QString* json) {
|
||||
init();
|
||||
this->fromJson(*json);
|
||||
}
|
||||
|
||||
SWGVORLocalizerSettings::SWGVORLocalizerSettings() {
|
||||
rgb_color = 0;
|
||||
m_rgb_color_isSet = false;
|
||||
title = nullptr;
|
||||
m_title_isSet = false;
|
||||
use_reverse_api = 0;
|
||||
m_use_reverse_api_isSet = false;
|
||||
reverse_api_address = nullptr;
|
||||
m_reverse_api_address_isSet = false;
|
||||
reverse_api_port = 0;
|
||||
m_reverse_api_port_isSet = false;
|
||||
reverse_api_feature_set_index = 0;
|
||||
m_reverse_api_feature_set_index_isSet = false;
|
||||
reverse_api_feature_index = 0;
|
||||
m_reverse_api_feature_index_isSet = false;
|
||||
mag_dec_adjust = 0;
|
||||
m_mag_dec_adjust_isSet = false;
|
||||
}
|
||||
|
||||
SWGVORLocalizerSettings::~SWGVORLocalizerSettings() {
|
||||
this->cleanup();
|
||||
}
|
||||
|
||||
void
|
||||
SWGVORLocalizerSettings::init() {
|
||||
rgb_color = 0;
|
||||
m_rgb_color_isSet = false;
|
||||
title = new QString("");
|
||||
m_title_isSet = false;
|
||||
use_reverse_api = 0;
|
||||
m_use_reverse_api_isSet = false;
|
||||
reverse_api_address = new QString("");
|
||||
m_reverse_api_address_isSet = false;
|
||||
reverse_api_port = 0;
|
||||
m_reverse_api_port_isSet = false;
|
||||
reverse_api_feature_set_index = 0;
|
||||
m_reverse_api_feature_set_index_isSet = false;
|
||||
reverse_api_feature_index = 0;
|
||||
m_reverse_api_feature_index_isSet = false;
|
||||
mag_dec_adjust = 0;
|
||||
m_mag_dec_adjust_isSet = false;
|
||||
}
|
||||
|
||||
void
|
||||
SWGVORLocalizerSettings::cleanup() {
|
||||
|
||||
if(title != nullptr) {
|
||||
delete title;
|
||||
}
|
||||
|
||||
if(reverse_api_address != nullptr) {
|
||||
delete reverse_api_address;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
SWGVORLocalizerSettings*
|
||||
SWGVORLocalizerSettings::fromJson(QString &json) {
|
||||
QByteArray array (json.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject jsonObject = doc.object();
|
||||
this->fromJsonObject(jsonObject);
|
||||
return this;
|
||||
}
|
||||
|
||||
void
|
||||
SWGVORLocalizerSettings::fromJsonObject(QJsonObject &pJson) {
|
||||
::SWGSDRangel::setValue(&rgb_color, pJson["rgbColor"], "qint32", "");
|
||||
|
||||
::SWGSDRangel::setValue(&title, pJson["title"], "QString", "QString");
|
||||
|
||||
::SWGSDRangel::setValue(&use_reverse_api, pJson["useReverseAPI"], "qint32", "");
|
||||
|
||||
::SWGSDRangel::setValue(&reverse_api_address, pJson["reverseAPIAddress"], "QString", "QString");
|
||||
|
||||
::SWGSDRangel::setValue(&reverse_api_port, pJson["reverseAPIPort"], "qint32", "");
|
||||
|
||||
::SWGSDRangel::setValue(&reverse_api_feature_set_index, pJson["reverseAPIFeatureSetIndex"], "qint32", "");
|
||||
|
||||
::SWGSDRangel::setValue(&reverse_api_feature_index, pJson["reverseAPIFeatureIndex"], "qint32", "");
|
||||
|
||||
::SWGSDRangel::setValue(&mag_dec_adjust, pJson["magDecAdjust"], "qint32", "");
|
||||
|
||||
}
|
||||
|
||||
QString
|
||||
SWGVORLocalizerSettings::asJson ()
|
||||
{
|
||||
QJsonObject* obj = this->asJsonObject();
|
||||
|
||||
QJsonDocument doc(*obj);
|
||||
QByteArray bytes = doc.toJson();
|
||||
delete obj;
|
||||
return QString(bytes);
|
||||
}
|
||||
|
||||
QJsonObject*
|
||||
SWGVORLocalizerSettings::asJsonObject() {
|
||||
QJsonObject* obj = new QJsonObject();
|
||||
if(m_rgb_color_isSet){
|
||||
obj->insert("rgbColor", QJsonValue(rgb_color));
|
||||
}
|
||||
if(title != nullptr && *title != QString("")){
|
||||
toJsonValue(QString("title"), title, obj, QString("QString"));
|
||||
}
|
||||
if(m_use_reverse_api_isSet){
|
||||
obj->insert("useReverseAPI", QJsonValue(use_reverse_api));
|
||||
}
|
||||
if(reverse_api_address != nullptr && *reverse_api_address != QString("")){
|
||||
toJsonValue(QString("reverseAPIAddress"), reverse_api_address, obj, QString("QString"));
|
||||
}
|
||||
if(m_reverse_api_port_isSet){
|
||||
obj->insert("reverseAPIPort", QJsonValue(reverse_api_port));
|
||||
}
|
||||
if(m_reverse_api_feature_set_index_isSet){
|
||||
obj->insert("reverseAPIFeatureSetIndex", QJsonValue(reverse_api_feature_set_index));
|
||||
}
|
||||
if(m_reverse_api_feature_index_isSet){
|
||||
obj->insert("reverseAPIFeatureIndex", QJsonValue(reverse_api_feature_index));
|
||||
}
|
||||
if(m_mag_dec_adjust_isSet){
|
||||
obj->insert("magDecAdjust", QJsonValue(mag_dec_adjust));
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
qint32
|
||||
SWGVORLocalizerSettings::getRgbColor() {
|
||||
return rgb_color;
|
||||
}
|
||||
void
|
||||
SWGVORLocalizerSettings::setRgbColor(qint32 rgb_color) {
|
||||
this->rgb_color = rgb_color;
|
||||
this->m_rgb_color_isSet = true;
|
||||
}
|
||||
|
||||
QString*
|
||||
SWGVORLocalizerSettings::getTitle() {
|
||||
return title;
|
||||
}
|
||||
void
|
||||
SWGVORLocalizerSettings::setTitle(QString* title) {
|
||||
this->title = title;
|
||||
this->m_title_isSet = true;
|
||||
}
|
||||
|
||||
qint32
|
||||
SWGVORLocalizerSettings::getUseReverseApi() {
|
||||
return use_reverse_api;
|
||||
}
|
||||
void
|
||||
SWGVORLocalizerSettings::setUseReverseApi(qint32 use_reverse_api) {
|
||||
this->use_reverse_api = use_reverse_api;
|
||||
this->m_use_reverse_api_isSet = true;
|
||||
}
|
||||
|
||||
QString*
|
||||
SWGVORLocalizerSettings::getReverseApiAddress() {
|
||||
return reverse_api_address;
|
||||
}
|
||||
void
|
||||
SWGVORLocalizerSettings::setReverseApiAddress(QString* reverse_api_address) {
|
||||
this->reverse_api_address = reverse_api_address;
|
||||
this->m_reverse_api_address_isSet = true;
|
||||
}
|
||||
|
||||
qint32
|
||||
SWGVORLocalizerSettings::getReverseApiPort() {
|
||||
return reverse_api_port;
|
||||
}
|
||||
void
|
||||
SWGVORLocalizerSettings::setReverseApiPort(qint32 reverse_api_port) {
|
||||
this->reverse_api_port = reverse_api_port;
|
||||
this->m_reverse_api_port_isSet = true;
|
||||
}
|
||||
|
||||
qint32
|
||||
SWGVORLocalizerSettings::getReverseApiFeatureSetIndex() {
|
||||
return reverse_api_feature_set_index;
|
||||
}
|
||||
void
|
||||
SWGVORLocalizerSettings::setReverseApiFeatureSetIndex(qint32 reverse_api_feature_set_index) {
|
||||
this->reverse_api_feature_set_index = reverse_api_feature_set_index;
|
||||
this->m_reverse_api_feature_set_index_isSet = true;
|
||||
}
|
||||
|
||||
qint32
|
||||
SWGVORLocalizerSettings::getReverseApiFeatureIndex() {
|
||||
return reverse_api_feature_index;
|
||||
}
|
||||
void
|
||||
SWGVORLocalizerSettings::setReverseApiFeatureIndex(qint32 reverse_api_feature_index) {
|
||||
this->reverse_api_feature_index = reverse_api_feature_index;
|
||||
this->m_reverse_api_feature_index_isSet = true;
|
||||
}
|
||||
|
||||
qint32
|
||||
SWGVORLocalizerSettings::getMagDecAdjust() {
|
||||
return mag_dec_adjust;
|
||||
}
|
||||
void
|
||||
SWGVORLocalizerSettings::setMagDecAdjust(qint32 mag_dec_adjust) {
|
||||
this->mag_dec_adjust = mag_dec_adjust;
|
||||
this->m_mag_dec_adjust_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SWGVORLocalizerSettings::isSet(){
|
||||
bool isObjectUpdated = false;
|
||||
do{
|
||||
if(m_rgb_color_isSet){
|
||||
isObjectUpdated = true; break;
|
||||
}
|
||||
if(title && *title != QString("")){
|
||||
isObjectUpdated = true; break;
|
||||
}
|
||||
if(m_use_reverse_api_isSet){
|
||||
isObjectUpdated = true; break;
|
||||
}
|
||||
if(reverse_api_address && *reverse_api_address != QString("")){
|
||||
isObjectUpdated = true; break;
|
||||
}
|
||||
if(m_reverse_api_port_isSet){
|
||||
isObjectUpdated = true; break;
|
||||
}
|
||||
if(m_reverse_api_feature_set_index_isSet){
|
||||
isObjectUpdated = true; break;
|
||||
}
|
||||
if(m_reverse_api_feature_index_isSet){
|
||||
isObjectUpdated = true; break;
|
||||
}
|
||||
if(m_mag_dec_adjust_isSet){
|
||||
isObjectUpdated = true; break;
|
||||
}
|
||||
}while(false);
|
||||
return isObjectUpdated;
|
||||
}
|
||||
}
|
||||
|
101
swagger/sdrangel/code/qt5/client/SWGVORLocalizerSettings.h
Normal file
101
swagger/sdrangel/code/qt5/client/SWGVORLocalizerSettings.h
Normal file
@ -0,0 +1,101 @@
|
||||
/**
|
||||
* SDRangel
|
||||
* This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time ---
|
||||
*
|
||||
* OpenAPI spec version: 6.0.0
|
||||
* Contact: f4exb06@gmail.com
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* SWGVORLocalizerSettings.h
|
||||
*
|
||||
* VORLocalizer
|
||||
*/
|
||||
|
||||
#ifndef SWGVORLocalizerSettings_H_
|
||||
#define SWGVORLocalizerSettings_H_
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "SWGObject.h"
|
||||
#include "export.h"
|
||||
|
||||
namespace SWGSDRangel {
|
||||
|
||||
class SWG_API SWGVORLocalizerSettings: public SWGObject {
|
||||
public:
|
||||
SWGVORLocalizerSettings();
|
||||
SWGVORLocalizerSettings(QString* json);
|
||||
virtual ~SWGVORLocalizerSettings();
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
virtual QString asJson () override;
|
||||
virtual QJsonObject* asJsonObject() override;
|
||||
virtual void fromJsonObject(QJsonObject &json) override;
|
||||
virtual SWGVORLocalizerSettings* fromJson(QString &jsonString) override;
|
||||
|
||||
qint32 getRgbColor();
|
||||
void setRgbColor(qint32 rgb_color);
|
||||
|
||||
QString* getTitle();
|
||||
void setTitle(QString* title);
|
||||
|
||||
qint32 getUseReverseApi();
|
||||
void setUseReverseApi(qint32 use_reverse_api);
|
||||
|
||||
QString* getReverseApiAddress();
|
||||
void setReverseApiAddress(QString* reverse_api_address);
|
||||
|
||||
qint32 getReverseApiPort();
|
||||
void setReverseApiPort(qint32 reverse_api_port);
|
||||
|
||||
qint32 getReverseApiFeatureSetIndex();
|
||||
void setReverseApiFeatureSetIndex(qint32 reverse_api_feature_set_index);
|
||||
|
||||
qint32 getReverseApiFeatureIndex();
|
||||
void setReverseApiFeatureIndex(qint32 reverse_api_feature_index);
|
||||
|
||||
qint32 getMagDecAdjust();
|
||||
void setMagDecAdjust(qint32 mag_dec_adjust);
|
||||
|
||||
|
||||
virtual bool isSet() override;
|
||||
|
||||
private:
|
||||
qint32 rgb_color;
|
||||
bool m_rgb_color_isSet;
|
||||
|
||||
QString* title;
|
||||
bool m_title_isSet;
|
||||
|
||||
qint32 use_reverse_api;
|
||||
bool m_use_reverse_api_isSet;
|
||||
|
||||
QString* reverse_api_address;
|
||||
bool m_reverse_api_address_isSet;
|
||||
|
||||
qint32 reverse_api_port;
|
||||
bool m_reverse_api_port_isSet;
|
||||
|
||||
qint32 reverse_api_feature_set_index;
|
||||
bool m_reverse_api_feature_set_index_isSet;
|
||||
|
||||
qint32 reverse_api_feature_index;
|
||||
bool m_reverse_api_feature_index_isSet;
|
||||
|
||||
qint32 mag_dec_adjust;
|
||||
bool m_mag_dec_adjust_isSet;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* SWGVORLocalizerSettings_H_ */
|
@ -0,0 +1,131 @@
|
||||
/**
|
||||
* SDRangel
|
||||
* This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time ---
|
||||
*
|
||||
* OpenAPI spec version: 6.0.0
|
||||
* Contact: f4exb06@gmail.com
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
#include "SWGVORLocalizerSettings_vorDemodChannels.h"
|
||||
|
||||
#include "SWGHelpers.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
namespace SWGSDRangel {
|
||||
|
||||
SWGVORLocalizerSettings_vorDemodChannels::SWGVORLocalizerSettings_vorDemodChannels(QString* json) {
|
||||
init();
|
||||
this->fromJson(*json);
|
||||
}
|
||||
|
||||
SWGVORLocalizerSettings_vorDemodChannels::SWGVORLocalizerSettings_vorDemodChannels() {
|
||||
device_set_index = 0;
|
||||
m_device_set_index_isSet = false;
|
||||
channel_index = 0;
|
||||
m_channel_index_isSet = false;
|
||||
}
|
||||
|
||||
SWGVORLocalizerSettings_vorDemodChannels::~SWGVORLocalizerSettings_vorDemodChannels() {
|
||||
this->cleanup();
|
||||
}
|
||||
|
||||
void
|
||||
SWGVORLocalizerSettings_vorDemodChannels::init() {
|
||||
device_set_index = 0;
|
||||
m_device_set_index_isSet = false;
|
||||
channel_index = 0;
|
||||
m_channel_index_isSet = false;
|
||||
}
|
||||
|
||||
void
|
||||
SWGVORLocalizerSettings_vorDemodChannels::cleanup() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
SWGVORLocalizerSettings_vorDemodChannels*
|
||||
SWGVORLocalizerSettings_vorDemodChannels::fromJson(QString &json) {
|
||||
QByteArray array (json.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject jsonObject = doc.object();
|
||||
this->fromJsonObject(jsonObject);
|
||||
return this;
|
||||
}
|
||||
|
||||
void
|
||||
SWGVORLocalizerSettings_vorDemodChannels::fromJsonObject(QJsonObject &pJson) {
|
||||
::SWGSDRangel::setValue(&device_set_index, pJson["deviceSetIndex"], "qint32", "");
|
||||
|
||||
::SWGSDRangel::setValue(&channel_index, pJson["channelIndex"], "qint32", "");
|
||||
|
||||
}
|
||||
|
||||
QString
|
||||
SWGVORLocalizerSettings_vorDemodChannels::asJson ()
|
||||
{
|
||||
QJsonObject* obj = this->asJsonObject();
|
||||
|
||||
QJsonDocument doc(*obj);
|
||||
QByteArray bytes = doc.toJson();
|
||||
delete obj;
|
||||
return QString(bytes);
|
||||
}
|
||||
|
||||
QJsonObject*
|
||||
SWGVORLocalizerSettings_vorDemodChannels::asJsonObject() {
|
||||
QJsonObject* obj = new QJsonObject();
|
||||
if(m_device_set_index_isSet){
|
||||
obj->insert("deviceSetIndex", QJsonValue(device_set_index));
|
||||
}
|
||||
if(m_channel_index_isSet){
|
||||
obj->insert("channelIndex", QJsonValue(channel_index));
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
qint32
|
||||
SWGVORLocalizerSettings_vorDemodChannels::getDeviceSetIndex() {
|
||||
return device_set_index;
|
||||
}
|
||||
void
|
||||
SWGVORLocalizerSettings_vorDemodChannels::setDeviceSetIndex(qint32 device_set_index) {
|
||||
this->device_set_index = device_set_index;
|
||||
this->m_device_set_index_isSet = true;
|
||||
}
|
||||
|
||||
qint32
|
||||
SWGVORLocalizerSettings_vorDemodChannels::getChannelIndex() {
|
||||
return channel_index;
|
||||
}
|
||||
void
|
||||
SWGVORLocalizerSettings_vorDemodChannels::setChannelIndex(qint32 channel_index) {
|
||||
this->channel_index = channel_index;
|
||||
this->m_channel_index_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SWGVORLocalizerSettings_vorDemodChannels::isSet(){
|
||||
bool isObjectUpdated = false;
|
||||
do{
|
||||
if(m_device_set_index_isSet){
|
||||
isObjectUpdated = true; break;
|
||||
}
|
||||
if(m_channel_index_isSet){
|
||||
isObjectUpdated = true; break;
|
||||
}
|
||||
}while(false);
|
||||
return isObjectUpdated;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* SDRangel
|
||||
* This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time ---
|
||||
*
|
||||
* OpenAPI spec version: 6.0.0
|
||||
* Contact: f4exb06@gmail.com
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* SWGVORLocalizerSettings_vorDemodChannels.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SWGVORLocalizerSettings_vorDemodChannels_H_
|
||||
#define SWGVORLocalizerSettings_vorDemodChannels_H_
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
|
||||
#include "SWGObject.h"
|
||||
#include "export.h"
|
||||
|
||||
namespace SWGSDRangel {
|
||||
|
||||
class SWG_API SWGVORLocalizerSettings_vorDemodChannels: public SWGObject {
|
||||
public:
|
||||
SWGVORLocalizerSettings_vorDemodChannels();
|
||||
SWGVORLocalizerSettings_vorDemodChannels(QString* json);
|
||||
virtual ~SWGVORLocalizerSettings_vorDemodChannels();
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
virtual QString asJson () override;
|
||||
virtual QJsonObject* asJsonObject() override;
|
||||
virtual void fromJsonObject(QJsonObject &json) override;
|
||||
virtual SWGVORLocalizerSettings_vorDemodChannels* fromJson(QString &jsonString) override;
|
||||
|
||||
qint32 getDeviceSetIndex();
|
||||
void setDeviceSetIndex(qint32 device_set_index);
|
||||
|
||||
qint32 getChannelIndex();
|
||||
void setChannelIndex(qint32 channel_index);
|
||||
|
||||
|
||||
virtual bool isSet() override;
|
||||
|
||||
private:
|
||||
qint32 device_set_index;
|
||||
bool m_device_set_index_isSet;
|
||||
|
||||
qint32 channel_index;
|
||||
bool m_channel_index_isSet;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* SWGVORLocalizerSettings_vorDemodChannels_H_ */
|
Loading…
Reference in New Issue
Block a user