Web API: implemented channel reporting entry points in server instance

pull/154/head
f4exb 2018-03-19 00:20:54 +01:00
rodzic 6fbbd14fd1
commit 5cb64c3daa
6 zmienionych plików z 159 dodań i 11 usunięć

Wyświetl plik

@ -845,7 +845,6 @@ margin-bottom: 20px;
"description" : "Summarized information about channel plugin"
};
defs.ChannelReport = {
"required" : [ "channelType", "tx" ],
"discriminator" : "channelType",
"properties" : {
"channelType" : {
@ -863,7 +862,7 @@ margin-bottom: 20px;
"$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 = {
"required" : [ "channelType", "tx" ],
@ -17956,7 +17955,7 @@ except ApiException as e:
</div>
<div id="generator">
<div class="content">
Generated 2018-03-18T22:42:33.187+01:00
Generated 2018-03-19T00:19:38.769+01:00
</div>
</div>
</div>

Wyświetl plik

@ -1600,11 +1600,8 @@ definitions:
$ref: "/doc/swagger/include/NFMMod.yaml#/NFMModSettings"
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
required:
- channelType
- tx
properties:
channelType:
description: Channel type code

Wyświetl plik

@ -36,7 +36,9 @@
#include "SWGPresets.h"
#include "SWGPresetTransfer.h"
#include "SWGDeviceSettings.h"
#include "SWGChannelsDetail.h"
#include "SWGChannelSettings.h"
#include "SWGChannelReport.h"
#include "SWGSuccessResponse.h"
#include "SWGErrorResponse.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 deviceSetIndex,
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 deviceSetIndex,
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)
{
if (msgTypeString == "debug") {

Wyświetl plik

@ -169,6 +169,11 @@ public:
SWGSDRangel::SWGDeviceState& response,
SWGSDRangel::SWGErrorResponse& error);
virtual int devicesetChannelsReportGet(
int deviceSetIndex,
SWGSDRangel::SWGChannelsDetail& response,
SWGSDRangel::SWGErrorResponse& error);
virtual int devicesetChannelPost(
int deviceSetIndex,
SWGSDRangel::SWGChannelSettings& query,
@ -195,11 +200,18 @@ public:
SWGSDRangel::SWGChannelSettings& response,
SWGSDRangel::SWGErrorResponse& error);
virtual int devicesetChannelReportGet(
int deviceSetIndex,
int channelIndex,
SWGSDRangel::SWGChannelReport& response,
SWGSDRangel::SWGErrorResponse& error);
private:
MainCore& m_mainCore;
void getDeviceSetList(SWGSDRangel::SWGDeviceSetList* deviceSetList);
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 void getMsgTypeString(const QtMsgType& msgType, QString& level);
};

Wyświetl plik

@ -845,7 +845,6 @@ margin-bottom: 20px;
"description" : "Summarized information about channel plugin"
};
defs.ChannelReport = {
"required" : [ "channelType", "tx" ],
"discriminator" : "channelType",
"properties" : {
"channelType" : {
@ -863,7 +862,7 @@ margin-bottom: 20px;
"$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 = {
"required" : [ "channelType", "tx" ],
@ -17956,7 +17955,7 @@ except ApiException as e:
</div>
<div id="generator">
<div class="content">
Generated 2018-03-18T22:42:33.187+01:00
Generated 2018-03-19T00:19:38.769+01:00
</div>
</div>
</div>

Wyświetl plik

@ -13,7 +13,7 @@
/*
* 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_