mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-05 15:34:57 -04:00
Web API: implemented channel reporting entry points in server instance
This commit is contained in:
@@ -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") {
|
||||
|
||||
Reference in New Issue
Block a user