Skip to content

Commit

Permalink
Merge pull request #1956 from anton-kotenko/master
Browse files Browse the repository at this point in the history
Demod Analyzer plugin: channel selection via api
  • Loading branch information
f4exb authored Jan 22, 2024
2 parents 9bfeddf + 3a6fb11 commit 943105d
Show file tree
Hide file tree
Showing 15 changed files with 339 additions and 3 deletions.
31 changes: 31 additions & 0 deletions plugins/feature/demodanalyzer/demodanalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}



5 changes: 5 additions & 0 deletions plugins/feature/demodanalyzer/demodanalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ class DemodAnalyzer : public Feature
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);
Expand Down
18 changes: 17 additions & 1 deletion sdrbase/resources/webapi/doc/html2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5403,6 +5403,19 @@
}
},
"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" : {
Expand Down Expand Up @@ -6241,6 +6254,9 @@
},
"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."
Expand Down Expand Up @@ -58413,7 +58429,7 @@ <h3> Status: 501 - Function not implemented </h3>
</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>
Expand Down
12 changes: 12 additions & 0 deletions sdrbase/resources/webapi/doc/swagger/include/DemodAnalyzer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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"
6 changes: 6 additions & 0 deletions sdrbase/webapi/webapirequestmapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <boost/lexical_cast.hpp>

#include "SWGDemodAnalyzerActions.h"
#include "httpdocrootsettings.h"
#include "webapirequestmapper.h"
#include "webapiutils.h"
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion sdrbase/webapi/webapiutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
12 changes: 12 additions & 0 deletions swagger/sdrangel/api/swagger/include/DemodAnalyzer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 2 additions & 0 deletions swagger/sdrangel/api/swagger/include/FeatureActions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
18 changes: 17 additions & 1 deletion swagger/sdrangel/code/html2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5403,6 +5403,19 @@
}
},
"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" : {
Expand Down Expand Up @@ -6241,6 +6254,9 @@
},
"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."
Expand Down Expand Up @@ -58413,7 +58429,7 @@ <h3> Status: 501 - Function not implemented </h3>
</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>
Expand Down
131 changes: 131 additions & 0 deletions swagger/sdrangel/code/qt5/client/SWGDemodAnalyzerActions.cpp
Original file line number Diff line number Diff line change
@@ -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: [email protected]
*
* 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;
}
}

64 changes: 64 additions & 0 deletions swagger/sdrangel/code/qt5/client/SWGDemodAnalyzerActions.h
Original file line number Diff line number Diff line change
@@ -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: [email protected]
*
* 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_ */
Loading

0 comments on commit 943105d

Please sign in to comment.