mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-10-01 09:16:39 -04:00
Web API: implemented channel reporting entry points in server instance
This commit is contained in:
parent
6fbbd14fd1
commit
5cb64c3daa
@ -845,7 +845,6 @@ margin-bottom: 20px;
|
|||||||
"description" : "Summarized information about channel plugin"
|
"description" : "Summarized information about channel plugin"
|
||||||
};
|
};
|
||||||
defs.ChannelReport = {
|
defs.ChannelReport = {
|
||||||
"required" : [ "channelType", "tx" ],
|
|
||||||
"discriminator" : "channelType",
|
"discriminator" : "channelType",
|
||||||
"properties" : {
|
"properties" : {
|
||||||
"channelType" : {
|
"channelType" : {
|
||||||
@ -863,7 +862,7 @@ margin-bottom: 20px;
|
|||||||
"$ref" : "#/definitions/NFMModReport"
|
"$ref" : "#/definitions/NFMModReport"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"description" : "Base channel report. The specific channel report present depends on channelType."
|
"description" : "Base channel report. The specific channel report present depends on channelType or paremt context."
|
||||||
};
|
};
|
||||||
defs.ChannelSettings = {
|
defs.ChannelSettings = {
|
||||||
"required" : [ "channelType", "tx" ],
|
"required" : [ "channelType", "tx" ],
|
||||||
@ -17956,7 +17955,7 @@ except ApiException as e:
|
|||||||
</div>
|
</div>
|
||||||
<div id="generator">
|
<div id="generator">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
Generated 2018-03-18T22:42:33.187+01:00
|
Generated 2018-03-19T00:19:38.769+01:00
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1600,11 +1600,8 @@ definitions:
|
|||||||
$ref: "/doc/swagger/include/NFMMod.yaml#/NFMModSettings"
|
$ref: "/doc/swagger/include/NFMMod.yaml#/NFMModSettings"
|
||||||
|
|
||||||
ChannelReport:
|
ChannelReport:
|
||||||
description: Base channel report. The specific channel report present depends on channelType.
|
description: Base channel report. The specific channel report present depends on channelType or paremt context.
|
||||||
discriminator: channelType
|
discriminator: channelType
|
||||||
required:
|
|
||||||
- channelType
|
|
||||||
- tx
|
|
||||||
properties:
|
properties:
|
||||||
channelType:
|
channelType:
|
||||||
description: Channel type code
|
description: Channel type code
|
||||||
|
@ -36,7 +36,9 @@
|
|||||||
#include "SWGPresets.h"
|
#include "SWGPresets.h"
|
||||||
#include "SWGPresetTransfer.h"
|
#include "SWGPresetTransfer.h"
|
||||||
#include "SWGDeviceSettings.h"
|
#include "SWGDeviceSettings.h"
|
||||||
|
#include "SWGChannelsDetail.h"
|
||||||
#include "SWGChannelSettings.h"
|
#include "SWGChannelSettings.h"
|
||||||
|
#include "SWGChannelReport.h"
|
||||||
#include "SWGSuccessResponse.h"
|
#include "SWGSuccessResponse.h"
|
||||||
#include "SWGErrorResponse.h"
|
#include "SWGErrorResponse.h"
|
||||||
#include "SWGDeviceState.h"
|
#include "SWGDeviceState.h"
|
||||||
@ -1087,6 +1089,27 @@ int WebAPIAdapterSrv::devicesetDeviceRunDelete(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int WebAPIAdapterSrv::devicesetChannelsReportGet(
|
||||||
|
int deviceSetIndex,
|
||||||
|
SWGSDRangel::SWGChannelsDetail& response,
|
||||||
|
SWGSDRangel::SWGErrorResponse& error)
|
||||||
|
{
|
||||||
|
if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size()))
|
||||||
|
{
|
||||||
|
const DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex];
|
||||||
|
getChannelsDetail(&response, deviceSet);
|
||||||
|
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error.init();
|
||||||
|
*error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex);
|
||||||
|
|
||||||
|
return 404;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int WebAPIAdapterSrv::devicesetChannelPost(
|
int WebAPIAdapterSrv::devicesetChannelPost(
|
||||||
int deviceSetIndex,
|
int deviceSetIndex,
|
||||||
SWGSDRangel::SWGChannelSettings& query,
|
SWGSDRangel::SWGChannelSettings& query,
|
||||||
@ -1304,6 +1327,65 @@ int WebAPIAdapterSrv::devicesetChannelSettingsGet(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int WebAPIAdapterSrv::devicesetChannelReportGet(
|
||||||
|
int deviceSetIndex,
|
||||||
|
int channelIndex,
|
||||||
|
SWGSDRangel::SWGChannelReport& response,
|
||||||
|
SWGSDRangel::SWGErrorResponse& error)
|
||||||
|
{
|
||||||
|
error.init();
|
||||||
|
|
||||||
|
if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size()))
|
||||||
|
{
|
||||||
|
DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex];
|
||||||
|
|
||||||
|
if (deviceSet->m_deviceSourceEngine) // Rx
|
||||||
|
{
|
||||||
|
ChannelSinkAPI *channelAPI = deviceSet->m_deviceSourceAPI->getChanelAPIAt(channelIndex);
|
||||||
|
|
||||||
|
if (channelAPI == 0)
|
||||||
|
{
|
||||||
|
*error.getMessage() = QString("There is no channel with index %1").arg(channelIndex);
|
||||||
|
return 404;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
response.setChannelType(new QString());
|
||||||
|
channelAPI->getIdentifier(*response.getChannelType());
|
||||||
|
response.setTx(0);
|
||||||
|
return channelAPI->webapiReportGet(response, *error.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (deviceSet->m_deviceSinkEngine) // Tx
|
||||||
|
{
|
||||||
|
ChannelSourceAPI *channelAPI = deviceSet->m_deviceSinkAPI->getChanelAPIAt(channelIndex);
|
||||||
|
|
||||||
|
if (channelAPI == 0)
|
||||||
|
{
|
||||||
|
*error.getMessage() = QString("There is no channel with index %1").arg(channelIndex);
|
||||||
|
return 404;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
response.setChannelType(new QString());
|
||||||
|
channelAPI->getIdentifier(*response.getChannelType());
|
||||||
|
response.setTx(1);
|
||||||
|
return channelAPI->webapiReportGet(response, *error.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*error.getMessage() = QString("DeviceSet error");
|
||||||
|
return 500;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex);
|
||||||
|
return 404;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int WebAPIAdapterSrv::devicesetChannelSettingsPutPatch(
|
int WebAPIAdapterSrv::devicesetChannelSettingsPutPatch(
|
||||||
int deviceSetIndex,
|
int deviceSetIndex,
|
||||||
int channelIndex,
|
int channelIndex,
|
||||||
@ -1474,6 +1556,65 @@ void WebAPIAdapterSrv::getDeviceSet(SWGSDRangel::SWGDeviceSet *swgDeviceSet, con
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebAPIAdapterSrv::getChannelsDetail(SWGSDRangel::SWGChannelsDetail *channelsDetail, const DeviceSet* deviceSet)
|
||||||
|
{
|
||||||
|
channelsDetail->init();
|
||||||
|
SWGSDRangel::SWGChannelReport *channelReport;
|
||||||
|
QString channelReportError;
|
||||||
|
|
||||||
|
if (deviceSet->m_deviceSinkEngine) // Tx data
|
||||||
|
{
|
||||||
|
channelsDetail->setChannelcount(deviceSet->m_deviceSinkAPI->getNbChannels());
|
||||||
|
QList<SWGSDRangel::SWGChannel*> *channels = channelsDetail->getChannels();
|
||||||
|
|
||||||
|
for (int i = 0; i < channelsDetail->getChannelcount(); i++)
|
||||||
|
{
|
||||||
|
channels->append(new SWGSDRangel::SWGChannel);
|
||||||
|
channels->back()->init();
|
||||||
|
ChannelSourceAPI *channel = deviceSet->m_deviceSinkAPI->getChanelAPIAt(i);
|
||||||
|
channels->back()->setDeltaFrequency(channel->getCenterFrequency());
|
||||||
|
channels->back()->setIndex(channel->getIndexInDeviceSet());
|
||||||
|
channels->back()->setUid(channel->getUID());
|
||||||
|
channel->getIdentifier(*channels->back()->getId());
|
||||||
|
channel->getTitle(*channels->back()->getTitle());
|
||||||
|
|
||||||
|
channelReport = new SWGSDRangel::SWGChannelReport();
|
||||||
|
|
||||||
|
if (channel->webapiReportGet(*channelReport, channelReportError) != 501) {
|
||||||
|
channels->back()->setReport(channelReport);
|
||||||
|
} else {
|
||||||
|
delete channelReport;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deviceSet->m_deviceSourceEngine) // Rx data
|
||||||
|
{
|
||||||
|
channelsDetail->setChannelcount(deviceSet->m_deviceSourceAPI->getNbChannels());
|
||||||
|
QList<SWGSDRangel::SWGChannel*> *channels = channelsDetail->getChannels();
|
||||||
|
|
||||||
|
for (int i = 0; i < channelsDetail->getChannelcount(); i++)
|
||||||
|
{
|
||||||
|
channels->append(new SWGSDRangel::SWGChannel);
|
||||||
|
channels->back()->init();
|
||||||
|
ChannelSinkAPI *channel = deviceSet->m_deviceSourceAPI->getChanelAPIAt(i);
|
||||||
|
channels->back()->setDeltaFrequency(channel->getCenterFrequency());
|
||||||
|
channels->back()->setIndex(channel->getIndexInDeviceSet());
|
||||||
|
channels->back()->setUid(channel->getUID());
|
||||||
|
channel->getIdentifier(*channels->back()->getId());
|
||||||
|
channel->getTitle(*channels->back()->getTitle());
|
||||||
|
|
||||||
|
channelReport = new SWGSDRangel::SWGChannelReport();
|
||||||
|
|
||||||
|
if (channel->webapiReportGet(*channelReport, channelReportError) != 501) {
|
||||||
|
channels->back()->setReport(channelReport);
|
||||||
|
} else {
|
||||||
|
delete channelReport;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QtMsgType WebAPIAdapterSrv::getMsgTypeFromString(const QString& msgTypeString)
|
QtMsgType WebAPIAdapterSrv::getMsgTypeFromString(const QString& msgTypeString)
|
||||||
{
|
{
|
||||||
if (msgTypeString == "debug") {
|
if (msgTypeString == "debug") {
|
||||||
|
@ -169,6 +169,11 @@ public:
|
|||||||
SWGSDRangel::SWGDeviceState& response,
|
SWGSDRangel::SWGDeviceState& response,
|
||||||
SWGSDRangel::SWGErrorResponse& error);
|
SWGSDRangel::SWGErrorResponse& error);
|
||||||
|
|
||||||
|
virtual int devicesetChannelsReportGet(
|
||||||
|
int deviceSetIndex,
|
||||||
|
SWGSDRangel::SWGChannelsDetail& response,
|
||||||
|
SWGSDRangel::SWGErrorResponse& error);
|
||||||
|
|
||||||
virtual int devicesetChannelPost(
|
virtual int devicesetChannelPost(
|
||||||
int deviceSetIndex,
|
int deviceSetIndex,
|
||||||
SWGSDRangel::SWGChannelSettings& query,
|
SWGSDRangel::SWGChannelSettings& query,
|
||||||
@ -195,11 +200,18 @@ public:
|
|||||||
SWGSDRangel::SWGChannelSettings& response,
|
SWGSDRangel::SWGChannelSettings& response,
|
||||||
SWGSDRangel::SWGErrorResponse& error);
|
SWGSDRangel::SWGErrorResponse& error);
|
||||||
|
|
||||||
|
virtual int devicesetChannelReportGet(
|
||||||
|
int deviceSetIndex,
|
||||||
|
int channelIndex,
|
||||||
|
SWGSDRangel::SWGChannelReport& response,
|
||||||
|
SWGSDRangel::SWGErrorResponse& error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MainCore& m_mainCore;
|
MainCore& m_mainCore;
|
||||||
|
|
||||||
void getDeviceSetList(SWGSDRangel::SWGDeviceSetList* deviceSetList);
|
void getDeviceSetList(SWGSDRangel::SWGDeviceSetList* deviceSetList);
|
||||||
void getDeviceSet(SWGSDRangel::SWGDeviceSet *swgDeviceSet, const DeviceSet* deviceSet, int deviceUISetIndex);
|
void getDeviceSet(SWGSDRangel::SWGDeviceSet *swgDeviceSet, const DeviceSet* deviceSet, int deviceUISetIndex);
|
||||||
|
void getChannelsDetail(SWGSDRangel::SWGChannelsDetail *channelsDetail, const DeviceSet* deviceSet);
|
||||||
static QtMsgType getMsgTypeFromString(const QString& msgTypeString);
|
static QtMsgType getMsgTypeFromString(const QString& msgTypeString);
|
||||||
static void getMsgTypeString(const QtMsgType& msgType, QString& level);
|
static void getMsgTypeString(const QtMsgType& msgType, QString& level);
|
||||||
};
|
};
|
||||||
|
@ -845,7 +845,6 @@ margin-bottom: 20px;
|
|||||||
"description" : "Summarized information about channel plugin"
|
"description" : "Summarized information about channel plugin"
|
||||||
};
|
};
|
||||||
defs.ChannelReport = {
|
defs.ChannelReport = {
|
||||||
"required" : [ "channelType", "tx" ],
|
|
||||||
"discriminator" : "channelType",
|
"discriminator" : "channelType",
|
||||||
"properties" : {
|
"properties" : {
|
||||||
"channelType" : {
|
"channelType" : {
|
||||||
@ -863,7 +862,7 @@ margin-bottom: 20px;
|
|||||||
"$ref" : "#/definitions/NFMModReport"
|
"$ref" : "#/definitions/NFMModReport"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"description" : "Base channel report. The specific channel report present depends on channelType."
|
"description" : "Base channel report. The specific channel report present depends on channelType or paremt context."
|
||||||
};
|
};
|
||||||
defs.ChannelSettings = {
|
defs.ChannelSettings = {
|
||||||
"required" : [ "channelType", "tx" ],
|
"required" : [ "channelType", "tx" ],
|
||||||
@ -17956,7 +17955,7 @@ except ApiException as e:
|
|||||||
</div>
|
</div>
|
||||||
<div id="generator">
|
<div id="generator">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
Generated 2018-03-18T22:42:33.187+01:00
|
Generated 2018-03-19T00:19:38.769+01:00
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
/*
|
/*
|
||||||
* SWGChannelReport.h
|
* SWGChannelReport.h
|
||||||
*
|
*
|
||||||
* Base channel report. The specific channel report present depends on channelType.
|
* Base channel report. The specific channel report present depends on channelType or paremt context.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SWGChannelReport_H_
|
#ifndef SWGChannelReport_H_
|
||||||
|
Loading…
Reference in New Issue
Block a user