From a0830f8ba2cd8797d9b70d468e25a089718970c7 Mon Sep 17 00:00:00 2001 From: f4exb Date: Mon, 23 Dec 2019 23:00:11 +0100 Subject: [PATCH] REST API: updates for MIMO (3) --- sdrbase/device/deviceapi.cpp | 24 ++++- sdrgui/webapi/webapiadaptergui.cpp | 137 +++++++++++++++++++++++++++++ sdrsrv/webapi/webapiadaptersrv.cpp | 137 +++++++++++++++++++++++++++++ 3 files changed, 294 insertions(+), 4 deletions(-) diff --git a/sdrbase/device/deviceapi.cpp b/sdrbase/device/deviceapi.cpp index da68f8a88..557efe165 100644 --- a/sdrbase/device/deviceapi.cpp +++ b/sdrbase/device/deviceapi.cpp @@ -857,11 +857,27 @@ void DeviceAPI::renumerateChannels() } else if (m_streamType == StreamMIMO) { - for (int i = 0; i < m_mimoChannelAPIs.size(); ++i) + int index = 0; + + for (; index < m_channelSinkAPIs.size(); ++index) { - m_mimoChannelAPIs.at(i)->setIndexInDeviceSet(i); - m_mimoChannelAPIs.at(i)->setDeviceSetIndex(m_deviceTabIndex); - m_mimoChannelAPIs.at(i)->setDeviceAPI(this); + m_channelSinkAPIs.at(index)->setIndexInDeviceSet(index); + m_channelSinkAPIs.at(index)->setDeviceSetIndex(m_deviceTabIndex); + m_channelSinkAPIs.at(index)->setDeviceAPI(this); + } + + for (; index < m_channelSourceAPIs.size() + m_channelSinkAPIs.size(); ++index) + { + m_channelSourceAPIs.at(index)->setIndexInDeviceSet(index); + m_channelSourceAPIs.at(index)->setDeviceSetIndex(m_deviceTabIndex); + m_channelSourceAPIs.at(index)->setDeviceAPI(this); + } + + for (; index < m_mimoChannelAPIs.size() + m_channelSourceAPIs.size() + m_channelSinkAPIs.size(); ++index) + { + m_mimoChannelAPIs.at(index)->setIndexInDeviceSet(index); + m_mimoChannelAPIs.at(index)->setDeviceSetIndex(m_deviceTabIndex); + m_mimoChannelAPIs.at(index)->setDeviceAPI(this); } } } \ No newline at end of file diff --git a/sdrgui/webapi/webapiadaptergui.cpp b/sdrgui/webapi/webapiadaptergui.cpp index 5294205e3..91bdf0077 100644 --- a/sdrgui/webapi/webapiadaptergui.cpp +++ b/sdrgui/webapi/webapiadaptergui.cpp @@ -268,6 +268,11 @@ int WebAPIAdapterGUI::instanceChannels( channelRegistrations = m_mainWindow.m_pluginManager->getTxChannelRegistrations(); nbChannelDevices = channelRegistrations->size(); } + else if (direction == 2) // MIMO channel + { + channelRegistrations = m_mainWindow.m_pluginManager->getMIMOChannelRegistrations(); + nbChannelDevices = channelRegistrations->size(); + } else // not supported { channelRegistrations = nullptr; @@ -1839,6 +1844,46 @@ int WebAPIAdapterGUI::devicesetChannelSettingsGet( return channelAPI->webapiSettingsGet(response, *error.getMessage()); } } + else if (deviceSet->m_deviceMIMOEngine) // MIMO + { + int nbSinkChannels = deviceSet->m_deviceAPI->getNbSinkChannels(); + int nbSourceChannels = deviceSet->m_deviceAPI->getNbSourceChannels(); + int nbMIMOChannels = deviceSet->m_deviceAPI->getNbMIMOChannels(); + ChannelAPI *channelAPI = nullptr; + + if (channelIndex < nbSinkChannels) + { + channelAPI = deviceSet->m_deviceAPI->getChanelSinkAPIAt(channelIndex); + response.setDirection(0); + } + else if (channelIndex < nbSinkChannels + nbSourceChannels) + { + channelAPI = deviceSet->m_deviceAPI->getChanelSourceAPIAt(channelIndex - nbSinkChannels); + response.setDirection(1); + } + else if (channelIndex < nbSinkChannels + nbSourceChannels + nbMIMOChannels) + { + channelAPI = deviceSet->m_deviceAPI->getMIMOChannelAPIAt(channelIndex - nbSinkChannels - nbSourceChannels); + response.setDirection(2); + } + else + { + *error.getMessage() = QString("Ther is no channel with index %1").arg(channelIndex); + return 404; + } + + if (channelAPI) + { + response.setChannelType(new QString()); + channelAPI->getIdentifier(*response.getChannelType()); + return channelAPI->webapiSettingsGet(response, *error.getMessage()); + } + else + { + *error.getMessage() = QString("Ther is no channel with index %1").arg(channelIndex); + return 404; + } + } else { *error.getMessage() = QString("DeviceSet error"); @@ -1899,6 +1944,46 @@ int WebAPIAdapterGUI::devicesetChannelReportGet( return channelAPI->webapiReportGet(response, *error.getMessage()); } } + else if (deviceSet->m_deviceMIMOEngine) // MIMO + { + int nbSinkChannels = deviceSet->m_deviceAPI->getNbSinkChannels(); + int nbSourceChannels = deviceSet->m_deviceAPI->getNbSourceChannels(); + int nbMIMOChannels = deviceSet->m_deviceAPI->getNbMIMOChannels(); + ChannelAPI *channelAPI = nullptr; + + if (channelIndex < nbSinkChannels) + { + channelAPI = deviceSet->m_deviceAPI->getChanelSinkAPIAt(channelIndex); + response.setDirection(0); + } + else if (channelIndex < nbSinkChannels + nbSourceChannels) + { + channelAPI = deviceSet->m_deviceAPI->getChanelSourceAPIAt(channelIndex - nbSinkChannels); + response.setDirection(1); + } + else if (channelIndex < nbSinkChannels + nbSourceChannels + nbMIMOChannels) + { + channelAPI = deviceSet->m_deviceAPI->getMIMOChannelAPIAt(channelIndex - nbSinkChannels - nbSourceChannels); + response.setDirection(2); + } + else + { + *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); + return 404; + } + + if (channelAPI) + { + response.setChannelType(new QString()); + channelAPI->getIdentifier(*response.getChannelType()); + return channelAPI->webapiReportGet(response, *error.getMessage()); + } + else + { + *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); + return 404; + } + } else { *error.getMessage() = QString("DeviceSet error"); @@ -1982,6 +2067,58 @@ int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch( } } } + else if (deviceSet->m_deviceMIMOEngine) // MIMO + { + int nbSinkChannels = deviceSet->m_deviceAPI->getNbSinkChannels(); + int nbSourceChannels = deviceSet->m_deviceAPI->getNbSourceChannels(); + int nbMIMOChannels = deviceSet->m_deviceAPI->getNbMIMOChannels(); + ChannelAPI *channelAPI = nullptr; + + if (channelIndex < nbSinkChannels) + { + channelAPI = deviceSet->m_deviceAPI->getChanelSinkAPIAt(channelIndex); + response.setDirection(0); + } + else if (channelIndex < nbSinkChannels + nbSourceChannels) + { + channelAPI = deviceSet->m_deviceAPI->getChanelSourceAPIAt(channelIndex - nbSinkChannels); + response.setDirection(1); + } + else if (channelIndex < nbSinkChannels + nbSourceChannels + nbMIMOChannels) + { + channelAPI = deviceSet->m_deviceAPI->getMIMOChannelAPIAt(channelIndex - nbSinkChannels - nbSourceChannels); + response.setDirection(2); + } + else + { + *error.getMessage() = QString("here is no channel with index %1").arg(channelIndex); + return 404; + } + + if (channelAPI) + { + QString channelType; + channelAPI->getIdentifier(channelType); + + if (channelType == *response.getChannelType()) + { + return channelAPI->webapiSettingsPutPatch(force, channelSettingsKeys, response, *error.getMessage()); + } + else + { + *error.getMessage() = QString("There is no channel type %1 at index %2. Found %3.") + .arg(*response.getChannelType()) + .arg(channelIndex) + .arg(channelType); + return 404; + } + } + else + { + *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); + return 404; + } + } else { *error.getMessage() = QString("DeviceSet error"); diff --git a/sdrsrv/webapi/webapiadaptersrv.cpp b/sdrsrv/webapi/webapiadaptersrv.cpp index 990c18a3b..2bca2a6d2 100644 --- a/sdrsrv/webapi/webapiadaptersrv.cpp +++ b/sdrsrv/webapi/webapiadaptersrv.cpp @@ -266,6 +266,11 @@ int WebAPIAdapterSrv::instanceChannels( channelRegistrations = m_mainCore.m_pluginManager->getTxChannelRegistrations(); nbChannelDevices = channelRegistrations->size(); } + else if (direction == 2) // MIMO channel + { + channelRegistrations = m_mainCore.m_pluginManager->getMIMOChannelRegistrations(); + nbChannelDevices = channelRegistrations->size(); + } else // not supported { channelRegistrations = nullptr; @@ -1925,6 +1930,46 @@ int WebAPIAdapterSrv::devicesetChannelSettingsGet( return channelAPI->webapiSettingsGet(response, *error.getMessage()); } } + else if (deviceSet->m_deviceMIMOEngine) // MIMO + { + int nbSinkChannels = deviceSet->m_deviceAPI->getNbSinkChannels(); + int nbSourceChannels = deviceSet->m_deviceAPI->getNbSourceChannels(); + int nbMIMOChannels = deviceSet->m_deviceAPI->getNbMIMOChannels(); + ChannelAPI *channelAPI = nullptr; + + if (channelIndex < nbSinkChannels) + { + channelAPI = deviceSet->m_deviceAPI->getChanelSinkAPIAt(channelIndex); + response.setDirection(0); + } + else if (channelIndex < nbSinkChannels + nbSourceChannels) + { + channelAPI = deviceSet->m_deviceAPI->getChanelSourceAPIAt(channelIndex - nbSinkChannels); + response.setDirection(1); + } + else if (channelIndex < nbSinkChannels + nbSourceChannels + nbMIMOChannels) + { + channelAPI = deviceSet->m_deviceAPI->getMIMOChannelAPIAt(channelIndex - nbSinkChannels - nbSourceChannels); + response.setDirection(2); + } + else + { + *error.getMessage() = QString("Ther is no channel with index %1").arg(channelIndex); + return 404; + } + + if (channelAPI) + { + response.setChannelType(new QString()); + channelAPI->getIdentifier(*response.getChannelType()); + return channelAPI->webapiSettingsGet(response, *error.getMessage()); + } + else + { + *error.getMessage() = QString("Ther is no channel with index %1").arg(channelIndex); + return 404; + } + } else { *error.getMessage() = QString("DeviceSet error"); @@ -1984,6 +2029,46 @@ int WebAPIAdapterSrv::devicesetChannelReportGet( return channelAPI->webapiReportGet(response, *error.getMessage()); } } + else if (deviceSet->m_deviceMIMOEngine) // MIMO + { + int nbSinkChannels = deviceSet->m_deviceAPI->getNbSinkChannels(); + int nbSourceChannels = deviceSet->m_deviceAPI->getNbSourceChannels(); + int nbMIMOChannels = deviceSet->m_deviceAPI->getNbMIMOChannels(); + ChannelAPI *channelAPI = nullptr; + + if (channelIndex < nbSinkChannels) + { + channelAPI = deviceSet->m_deviceAPI->getChanelSinkAPIAt(channelIndex); + response.setDirection(0); + } + else if (channelIndex < nbSinkChannels + nbSourceChannels) + { + channelAPI = deviceSet->m_deviceAPI->getChanelSourceAPIAt(channelIndex - nbSinkChannels); + response.setDirection(1); + } + else if (channelIndex < nbSinkChannels + nbSourceChannels + nbMIMOChannels) + { + channelAPI = deviceSet->m_deviceAPI->getMIMOChannelAPIAt(channelIndex - nbSinkChannels - nbSourceChannels); + response.setDirection(2); + } + else + { + *error.getMessage() = QString("Ther is no channel with index %1").arg(channelIndex); + return 404; + } + + if (channelAPI) + { + response.setChannelType(new QString()); + channelAPI->getIdentifier(*response.getChannelType()); + return channelAPI->webapiReportGet(response, *error.getMessage()); + } + else + { + *error.getMessage() = QString("Ther is no channel with index %1").arg(channelIndex); + return 404; + } + } else { *error.getMessage() = QString("DeviceSet error"); @@ -2067,6 +2152,58 @@ int WebAPIAdapterSrv::devicesetChannelSettingsPutPatch( } } } + else if (deviceSet->m_deviceMIMOEngine) // MIMO + { + int nbSinkChannels = deviceSet->m_deviceAPI->getNbSinkChannels(); + int nbSourceChannels = deviceSet->m_deviceAPI->getNbSourceChannels(); + int nbMIMOChannels = deviceSet->m_deviceAPI->getNbMIMOChannels(); + ChannelAPI *channelAPI = nullptr; + + if (channelIndex < nbSinkChannels) + { + channelAPI = deviceSet->m_deviceAPI->getChanelSinkAPIAt(channelIndex); + response.setDirection(0); + } + else if (channelIndex < nbSinkChannels + nbSourceChannels) + { + channelAPI = deviceSet->m_deviceAPI->getChanelSourceAPIAt(channelIndex - nbSinkChannels); + response.setDirection(1); + } + else if (channelIndex < nbSinkChannels + nbSourceChannels + nbMIMOChannels) + { + channelAPI = deviceSet->m_deviceAPI->getMIMOChannelAPIAt(channelIndex - nbSinkChannels - nbSourceChannels); + response.setDirection(2); + } + else + { + *error.getMessage() = QString("here is no channel with index %1").arg(channelIndex); + return 404; + } + + if (channelAPI) + { + QString channelType; + channelAPI->getIdentifier(channelType); + + if (channelType == *response.getChannelType()) + { + return channelAPI->webapiSettingsPutPatch(force, channelSettingsKeys, response, *error.getMessage()); + } + else + { + *error.getMessage() = QString("There is no channel type %1 at index %2. Found %3.") + .arg(*response.getChannelType()) + .arg(channelIndex) + .arg(channelType); + return 404; + } + } + else + { + *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); + return 404; + } + } else { *error.getMessage() = QString("DeviceSet error");