REST API: updates for MIMO (3)

pull/480/head
f4exb 2019-12-23 23:00:11 +01:00
rodzic 0a9e7f5154
commit a0830f8ba2
3 zmienionych plików z 294 dodań i 4 usunięć

Wyświetl plik

@ -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);
}
}
}

Wyświetl plik

@ -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");

Wyświetl plik

@ -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");