2020-11-29 19:30:18 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// 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_
|
|
|
|
|
2022-09-24 06:41:05 -04:00
|
|
|
#include <QRecursiveMutex>
|
2020-11-29 19:30:18 -05:00
|
|
|
#include <QNetworkRequest>
|
|
|
|
|
|
|
|
#include "feature/feature.h"
|
|
|
|
#include "util/message.h"
|
2020-12-07 13:32:43 -05:00
|
|
|
#include "util/average.h"
|
2020-11-29 19:30:18 -05:00
|
|
|
|
|
|
|
#include "vorlocalizersettings.h"
|
|
|
|
|
|
|
|
class WebAPIAdapterInterface;
|
|
|
|
class VorLocalizerWorker;
|
|
|
|
class QNetworkAccessManager;
|
|
|
|
class QNetworkReply;
|
2022-09-24 06:41:05 -04:00
|
|
|
class QThread;
|
2020-11-29 19:30:18 -05:00
|
|
|
|
|
|
|
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(); }
|
2022-03-26 07:25:35 -04:00
|
|
|
virtual QString getIdentifier() const { return objectName(); }
|
2020-11-29 19:30:18 -05:00
|
|
|
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);
|
|
|
|
|
2021-10-23 15:24:25 -04:00
|
|
|
virtual int webapiReportGet(
|
|
|
|
SWGSDRangel::SWGFeatureReport& response,
|
|
|
|
QString& errorMessage);
|
|
|
|
|
2021-10-21 20:01:33 -04:00
|
|
|
virtual int webapiActionsPost(
|
|
|
|
const QStringList& featureActionsKeys,
|
|
|
|
SWGSDRangel::SWGFeatureActions& query,
|
|
|
|
QString& errorMessage);
|
|
|
|
|
2020-11-29 19:30:18 -05:00
|
|
|
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:
|
2020-12-07 13:32:43 -05:00
|
|
|
struct VORChannelReport
|
|
|
|
{
|
|
|
|
float m_radial; //!< current detected radial
|
|
|
|
float m_refMag; //!< current reference signal magnitude
|
|
|
|
float m_varMag; //!< current variable signal magnitude
|
|
|
|
AverageUtil<float, double> m_radialAvg;
|
|
|
|
AverageUtil<float, double> m_refMagAvg;
|
|
|
|
AverageUtil<float, double> m_varMagAvg;
|
|
|
|
bool m_validRadial;
|
|
|
|
bool m_validRefMag;
|
|
|
|
bool m_validVarMag;
|
|
|
|
QString m_morseIdent; //!< identification morse code transcript
|
|
|
|
|
|
|
|
VORChannelReport() = default;
|
|
|
|
VORChannelReport(const VORChannelReport&) = default;
|
|
|
|
VORChannelReport& operator=(const VORChannelReport&) = default;
|
|
|
|
};
|
|
|
|
|
2022-09-24 06:41:05 -04:00
|
|
|
QThread *m_thread;
|
2020-11-29 19:30:18 -05:00
|
|
|
VorLocalizerWorker *m_worker;
|
2022-09-24 06:41:05 -04:00
|
|
|
bool m_running;
|
|
|
|
QRecursiveMutex m_mutex;
|
2020-11-29 19:30:18 -05:00
|
|
|
VORLocalizerSettings m_settings;
|
2020-12-07 13:32:43 -05:00
|
|
|
QHash<ChannelAPI*, VORLocalizerSettings::AvailableChannel> m_availableChannels;
|
|
|
|
QHash<int, VORChannelReport> m_vorChannelReports;
|
|
|
|
QHash<int, bool> m_vorSinglePlans;
|
2020-11-29 19:30:18 -05:00
|
|
|
|
|
|
|
QNetworkAccessManager *m_networkManager;
|
|
|
|
QNetworkRequest m_networkRequest;
|
|
|
|
|
|
|
|
void start();
|
|
|
|
void stop();
|
|
|
|
void applySettings(const VORLocalizerSettings& settings, bool force = false);
|
2020-12-07 13:32:43 -05:00
|
|
|
void updateChannels();
|
2022-03-11 23:45:54 -05:00
|
|
|
void notifyUpdateChannels();
|
2020-11-29 19:30:18 -05:00
|
|
|
void webapiReverseSendSettings(QList<QString>& featureSettingsKeys, const VORLocalizerSettings& settings, bool force);
|
2021-10-23 15:24:25 -04:00
|
|
|
void webapiFormatFeatureReport(SWGSDRangel::SWGFeatureReport& response);
|
2020-11-29 19:30:18 -05:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void networkManagerFinished(QNetworkReply *reply);
|
2020-12-07 13:32:43 -05:00
|
|
|
void handleChannelMessageQueue(MessageQueue* messageQueue);
|
2022-02-26 07:44:46 -05:00
|
|
|
void handleMessagePipeToBeDeleted(int reason, QObject* object);
|
2022-03-11 23:45:54 -05:00
|
|
|
void handleChannelAdded(int deviceSetIndex, ChannelAPI *channel);
|
2020-11-29 19:30:18 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDE_FEATURE_VORLOCALIZER_H_
|