Demod Analyzer plugin: channel selection via api

Problem: It's not possible to select channel in Demod Analyzer feature
via api.

Solution:
Add new "action" into
POST /sdrangel/featureset/feature/{featureIndex}/actions
endpoint
This commit is contained in:
Anton Kotenko 2024-01-21 13:47:07 +01:00
parent 9bfeddfea5
commit 3a6fb11a4c
15 changed files with 339 additions and 3 deletions

View File

@ -708,3 +708,34 @@ void DemodAnalyzer::handleDataPipeToBeDeleted(int reason, QObject *object)
}
}
}
int DemodAnalyzer::webapiActionsPost(
const QStringList& featureActionsKeys,
SWGSDRangel::SWGFeatureActions& query,
QString& errorMessage) {
MainCore* m_core = MainCore::instance();
auto action = query.getDemodAnalyzerActions();
if (action == nullptr) {
errorMessage = QString("missing DemodAnalyzerActions in request");
return 404;
}
auto deviceId = action->getDeviceId();
auto chanId = action->getChannelId();
ChannelAPI * chan = m_core->getChannel(deviceId, chanId);
if (chan == nullptr) {
errorMessage = QString("device(%1) or channel (%2) on the device does not exist").arg(deviceId).arg(chanId);
return 404;
}
MsgRefreshChannels *m1 = MsgRefreshChannels::create();
getInputMessageQueue()->push(m1);
MsgSelectChannel *msg = MsgSelectChannel::create(chan);
getInputMessageQueue()->push(msg);
return 200;
}

View File

@ -187,6 +187,11 @@ public:
SWGSDRangel::SWGFeatureSettings& response,
QString& errorMessage);
virtual int webapiActionsPost(
const QStringList& featureActionsKeys,
SWGSDRangel::SWGFeatureActions& query,
QString& errorMessage);
static void webapiFormatFeatureSettings(
SWGSDRangel::SWGFeatureSettings& response,
const DemodAnalyzerSettings& settings);

View File

@ -5403,6 +5403,19 @@ margin-bottom: 20px;
}
},
"description" : "List of DV serial devices available in the system"
};
defs.DemodAnalyzerActions = {
"properties" : {
"deviceId" : {
"type" : "integer",
"description" : "Device Id/Number that channel belongs to"
},
"channelId" : {
"type" : "integer",
"description" : "Channel Id/Number of the channel within the device"
}
},
"description" : "Demod Analyzer actions"
};
defs.DemodAnalyzerSettings = {
"properties" : {
@ -6241,6 +6254,9 @@ margin-bottom: 20px;
},
"VORLocalizerActions" : {
"$ref" : "#/definitions/VORLocalizerActions"
},
"DemodAnalyzerActions" : {
"$ref" : "#/definitions/DemodAnalyzerActions"
}
},
"description" : "Base feature actions. Only the feature actions corresponding to the feature specified in the featureType field is or should be present."
@ -58413,7 +58429,7 @@ except ApiException as e:
</div>
<div id="generator">
<div class="content">
Generated 2023-11-30T13:04:24.913+01:00
Generated 2024-01-21T13:22:02.160+01:00
</div>
</div>
</div>

View File

@ -39,3 +39,15 @@ DemodAnalyzerSettings:
$ref: "/doc/swagger/include/GLScope.yaml#/GLScope"
rollupState:
$ref: "/doc/swagger/include/RollupState.yaml#/RollupState"
DemodAnalyzerActions:
description: "Demod Analyzer actions"
properties:
deviceId:
type: integer
required: true
description: "Device Id/Number that channel belongs to"
channelId:
type: integer
required: true
description: "Channel Id/Number of the channel within the device"

View File

@ -35,3 +35,5 @@ FeatureActions:
$ref: "/doc/swagger/include/StarTracker.yaml#/StarTrackerActions"
VORLocalizerActions:
$ref: "/doc/swagger/include/VORLocalizer.yaml#/VORLocalizerActions"
DemodAnalyzerActions:
$ref: "/doc/swagger/include/DemodAnalyzer.yaml#/DemodAnalyzerActions"

View File

@ -27,6 +27,7 @@
#include <boost/lexical_cast.hpp>
#include "SWGDemodAnalyzerActions.h"
#include "httpdocrootsettings.h"
#include "webapirequestmapper.h"
#include "webapiutils.h"
@ -5375,6 +5376,11 @@ bool WebAPIRequestMapper::getFeatureActions(
featureActions->setVorLocalizerActions(new SWGSDRangel::SWGVORLocalizerActions());
featureActions->getVorLocalizerActions()->fromJsonObject(actionsJsonObject);
}
else if (featureActionsKey == "DemodAnalyzerActions")
{
featureActions->setDemodAnalyzerActions(new SWGSDRangel::SWGDemodAnalyzerActions());
featureActions->getDemodAnalyzerActions()->fromJsonObject(actionsJsonObject);
}
else
{
return false;

View File

@ -335,7 +335,8 @@ const QMap<QString, QString> WebAPIUtils::m_featureTypeToActionsKey = {
{"SatelliteTracker", "SatelliteTrackerActions"},
{"SimplePTT", "SimplePTTActions"},
{"StarTracker", "StarTrackerActions"},
{"VORLocalizer", "VORLocalizerActions"}
{"VORLocalizer", "VORLocalizerActions"},
{"DemodAnalyzer", "DemodAnalyzerActions"}
};
const QMap<QString, QString> WebAPIUtils::m_featureURIToSettingsKey = {

View File

@ -39,3 +39,15 @@ DemodAnalyzerSettings:
$ref: "http://swgserver:8081/api/swagger/include/GLScope.yaml#/GLScope"
rollupState:
$ref: "http://swgserver:8081/api/swagger/include/RollupState.yaml#/RollupState"
DemodAnalyzerActions:
description: "Demod Analyzer actions"
properties:
deviceId:
type: integer
required: true
description: "Device Id/Number that channel belongs to"
channelId:
type: integer
required: true
description: "Channel Id/Number of the channel within the device"

View File

@ -35,3 +35,5 @@ FeatureActions:
$ref: "http://swgserver:8081/api/swagger/include/StarTracker.yaml#/StarTrackerActions"
VORLocalizerActions:
$ref: "http://swgserver:8081/api/swagger/include/VORLocalizer.yaml#/VORLocalizerActions"
DemodAnalyzerActions:
$ref: "http://swgserver:8081/api/swagger/include/DemodAnalyzer.yaml#/DemodAnalyzerActions"

View File

@ -5403,6 +5403,19 @@ margin-bottom: 20px;
}
},
"description" : "List of DV serial devices available in the system"
};
defs.DemodAnalyzerActions = {
"properties" : {
"deviceId" : {
"type" : "integer",
"description" : "Device Id/Number that channel belongs to"
},
"channelId" : {
"type" : "integer",
"description" : "Channel Id/Number of the channel within the device"
}
},
"description" : "Demod Analyzer actions"
};
defs.DemodAnalyzerSettings = {
"properties" : {
@ -6241,6 +6254,9 @@ margin-bottom: 20px;
},
"VORLocalizerActions" : {
"$ref" : "#/definitions/VORLocalizerActions"
},
"DemodAnalyzerActions" : {
"$ref" : "#/definitions/DemodAnalyzerActions"
}
},
"description" : "Base feature actions. Only the feature actions corresponding to the feature specified in the featureType field is or should be present."
@ -58413,7 +58429,7 @@ except ApiException as e:
</div>
<div id="generator">
<div class="content">
Generated 2023-11-30T13:04:24.913+01:00
Generated 2024-01-21T13:22:02.160+01:00
</div>
</div>
</div>

View File

@ -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: 7.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 "SWGDemodAnalyzerActions.h"
#include "SWGHelpers.h"
#include <QJsonDocument>
#include <QJsonArray>
#include <QObject>
#include <QDebug>
namespace SWGSDRangel {
SWGDemodAnalyzerActions::SWGDemodAnalyzerActions(QString* json) {
init();
this->fromJson(*json);
}
SWGDemodAnalyzerActions::SWGDemodAnalyzerActions() {
device_id = 0;
m_device_id_isSet = false;
channel_id = 0;
m_channel_id_isSet = false;
}
SWGDemodAnalyzerActions::~SWGDemodAnalyzerActions() {
this->cleanup();
}
void
SWGDemodAnalyzerActions::init() {
device_id = 0;
m_device_id_isSet = false;
channel_id = 0;
m_channel_id_isSet = false;
}
void
SWGDemodAnalyzerActions::cleanup() {
}
SWGDemodAnalyzerActions*
SWGDemodAnalyzerActions::fromJson(QString &json) {
QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object();
this->fromJsonObject(jsonObject);
return this;
}
void
SWGDemodAnalyzerActions::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&device_id, pJson["deviceId"], "qint32", "");
::SWGSDRangel::setValue(&channel_id, pJson["channelId"], "qint32", "");
}
QString
SWGDemodAnalyzerActions::asJson ()
{
QJsonObject* obj = this->asJsonObject();
QJsonDocument doc(*obj);
QByteArray bytes = doc.toJson();
delete obj;
return QString(bytes);
}
QJsonObject*
SWGDemodAnalyzerActions::asJsonObject() {
QJsonObject* obj = new QJsonObject();
if(m_device_id_isSet){
obj->insert("deviceId", QJsonValue(device_id));
}
if(m_channel_id_isSet){
obj->insert("channelId", QJsonValue(channel_id));
}
return obj;
}
qint32
SWGDemodAnalyzerActions::getDeviceId() {
return device_id;
}
void
SWGDemodAnalyzerActions::setDeviceId(qint32 device_id) {
this->device_id = device_id;
this->m_device_id_isSet = true;
}
qint32
SWGDemodAnalyzerActions::getChannelId() {
return channel_id;
}
void
SWGDemodAnalyzerActions::setChannelId(qint32 channel_id) {
this->channel_id = channel_id;
this->m_channel_id_isSet = true;
}
bool
SWGDemodAnalyzerActions::isSet(){
bool isObjectUpdated = false;
do{
if(m_device_id_isSet){
isObjectUpdated = true; break;
}
if(m_channel_id_isSet){
isObjectUpdated = true; break;
}
}while(false);
return isObjectUpdated;
}
}

View File

@ -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: 7.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.
*/
/*
* SWGDemodAnalyzerActions.h
*
* Demod Analyzer actions
*/
#ifndef SWGDemodAnalyzerActions_H_
#define SWGDemodAnalyzerActions_H_
#include <QJsonObject>
#include "SWGObject.h"
#include "export.h"
namespace SWGSDRangel {
class SWG_API SWGDemodAnalyzerActions: public SWGObject {
public:
SWGDemodAnalyzerActions();
SWGDemodAnalyzerActions(QString* json);
virtual ~SWGDemodAnalyzerActions();
void init();
void cleanup();
virtual QString asJson () override;
virtual QJsonObject* asJsonObject() override;
virtual void fromJsonObject(QJsonObject &json) override;
virtual SWGDemodAnalyzerActions* fromJson(QString &jsonString) override;
qint32 getDeviceId();
void setDeviceId(qint32 device_id);
qint32 getChannelId();
void setChannelId(qint32 channel_id);
virtual bool isSet() override;
private:
qint32 device_id;
bool m_device_id_isSet;
qint32 channel_id;
bool m_channel_id_isSet;
};
}
#endif /* SWGDemodAnalyzerActions_H_ */

View File

@ -56,6 +56,8 @@ SWGFeatureActions::SWGFeatureActions() {
m_star_tracker_actions_isSet = false;
vor_localizer_actions = nullptr;
m_vor_localizer_actions_isSet = false;
demod_analyzer_actions = nullptr;
m_demod_analyzer_actions_isSet = false;
}
SWGFeatureActions::~SWGFeatureActions() {
@ -92,6 +94,8 @@ SWGFeatureActions::init() {
m_star_tracker_actions_isSet = false;
vor_localizer_actions = new SWGVORLocalizerActions();
m_vor_localizer_actions_isSet = false;
demod_analyzer_actions = new SWGDemodAnalyzerActions();
m_demod_analyzer_actions_isSet = false;
}
void
@ -134,6 +138,9 @@ SWGFeatureActions::cleanup() {
if(vor_localizer_actions != nullptr) {
delete vor_localizer_actions;
}
if(demod_analyzer_actions != nullptr) {
delete demod_analyzer_actions;
}
}
SWGFeatureActions*
@ -175,6 +182,8 @@ SWGFeatureActions::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&vor_localizer_actions, pJson["VORLocalizerActions"], "SWGVORLocalizerActions", "SWGVORLocalizerActions");
::SWGSDRangel::setValue(&demod_analyzer_actions, pJson["DemodAnalyzerActions"], "SWGDemodAnalyzerActions", "SWGDemodAnalyzerActions");
}
QString
@ -233,6 +242,9 @@ SWGFeatureActions::asJsonObject() {
if((vor_localizer_actions != nullptr) && (vor_localizer_actions->isSet())){
toJsonValue(QString("VORLocalizerActions"), vor_localizer_actions, obj, QString("SWGVORLocalizerActions"));
}
if((demod_analyzer_actions != nullptr) && (demod_analyzer_actions->isSet())){
toJsonValue(QString("DemodAnalyzerActions"), demod_analyzer_actions, obj, QString("SWGDemodAnalyzerActions"));
}
return obj;
}
@ -377,6 +389,16 @@ SWGFeatureActions::setVorLocalizerActions(SWGVORLocalizerActions* vor_localizer_
this->m_vor_localizer_actions_isSet = true;
}
SWGDemodAnalyzerActions*
SWGFeatureActions::getDemodAnalyzerActions() {
return demod_analyzer_actions;
}
void
SWGFeatureActions::setDemodAnalyzerActions(SWGDemodAnalyzerActions* demod_analyzer_actions) {
this->demod_analyzer_actions = demod_analyzer_actions;
this->m_demod_analyzer_actions_isSet = true;
}
bool
SWGFeatureActions::isSet(){
@ -424,6 +446,9 @@ SWGFeatureActions::isSet(){
if(vor_localizer_actions && vor_localizer_actions->isSet()){
isObjectUpdated = true; break;
}
if(demod_analyzer_actions && demod_analyzer_actions->isSet()){
isObjectUpdated = true; break;
}
}while(false);
return isObjectUpdated;
}

View File

@ -24,6 +24,7 @@
#include "SWGAFCActions.h"
#include "SWGAMBEActions.h"
#include "SWGDemodAnalyzerActions.h"
#include "SWGGS232ControllerActions.h"
#include "SWGLimeRFEActions.h"
#include "SWGMapActions.h"
@ -95,6 +96,9 @@ public:
SWGVORLocalizerActions* getVorLocalizerActions();
void setVorLocalizerActions(SWGVORLocalizerActions* vor_localizer_actions);
SWGDemodAnalyzerActions* getDemodAnalyzerActions();
void setDemodAnalyzerActions(SWGDemodAnalyzerActions* demod_analyzer_actions);
virtual bool isSet() override;
@ -141,6 +145,9 @@ private:
SWGVORLocalizerActions* vor_localizer_actions;
bool m_vor_localizer_actions_isSet;
SWGDemodAnalyzerActions* demod_analyzer_actions;
bool m_demod_analyzer_actions_isSet;
};
}

View File

@ -111,6 +111,7 @@
#include "SWGDSDDemodSettings.h"
#include "SWGDVSerialDevice.h"
#include "SWGDVSerialDevices.h"
#include "SWGDemodAnalyzerActions.h"
#include "SWGDemodAnalyzerSettings.h"
#include "SWGDeviceActions.h"
#include "SWGDeviceConfig.h"
@ -859,6 +860,11 @@ namespace SWGSDRangel {
obj->init();
return obj;
}
if(QString("SWGDemodAnalyzerActions").compare(type) == 0) {
SWGDemodAnalyzerActions *obj = new SWGDemodAnalyzerActions();
obj->init();
return obj;
}
if(QString("SWGDemodAnalyzerSettings").compare(type) == 0) {
SWGDemodAnalyzerSettings *obj = new SWGDemodAnalyzerSettings();
obj->init();