From ddc4667bdbb6bb67eec10a79d69c175a76fb1a5c Mon Sep 17 00:00:00 2001 From: f4exb Date: Mon, 23 Dec 2019 18:49:06 +0100 Subject: [PATCH] REST API: updates for MIMO --- plugins/samplemimo/testmi/testmi.h | 1 + sdrbase/device/deviceapi.cpp | 67 ++++---- sdrbase/device/deviceapi.h | 8 +- sdrbase/dsp/devicesamplemimo.h | 1 + .../resources/webapi/doc/swagger/swagger.yaml | 12 +- sdrgui/webapi/webapiadaptergui.cpp | 143 ++++++++++++++++++ sdrsrv/webapi/webapiadaptersrv.cpp | 141 +++++++++++++++++ swagger/sdrangel/api/swagger/swagger.yaml | 12 +- .../sdrangel/code/qt5/client/SWGChannel.cpp | 23 +++ swagger/sdrangel/code/qt5/client/SWGChannel.h | 6 + .../code/qt5/client/SWGSamplingDevice.cpp | 50 ++++++ .../code/qt5/client/SWGSamplingDevice.h | 12 ++ 12 files changed, 443 insertions(+), 33 deletions(-) diff --git a/plugins/samplemimo/testmi/testmi.h b/plugins/samplemimo/testmi/testmi.h index 885ee63d9..18df632a5 100644 --- a/plugins/samplemimo/testmi/testmi.h +++ b/plugins/samplemimo/testmi/testmi.h @@ -126,6 +126,7 @@ public: virtual void setSinkCenterFrequency(qint64 centerFrequency, int index) { (void) centerFrequency; (void) index; } virtual quint64 getMIMOCenterFrequency() const { return getSourceCenterFrequency(0); } + virtual unsigned int getMIMOSampleRate() const { return getSourceSampleRate(0); } virtual bool handleMessage(const Message& message); diff --git a/sdrbase/device/deviceapi.cpp b/sdrbase/device/deviceapi.cpp index a3ce2c558..da68f8a88 100644 --- a/sdrbase/device/deviceapi.cpp +++ b/sdrbase/device/deviceapi.cpp @@ -382,7 +382,7 @@ void DeviceAPI::setSamplingDevicePluginInstanceGUI(PluginInstanceGUI *gui) m_samplingDevicePluginInstanceUI = gui; } -void DeviceAPI::getDeviceEngineStateStr(QString& state) +void DeviceAPI::getDeviceEngineStateStr(QString& state, int subsystemIndex) { if (m_deviceSourceEngine) { @@ -432,44 +432,59 @@ void DeviceAPI::getDeviceEngineStateStr(QString& state) break; } } + else if (m_deviceMIMOEngine) + { + switch(m_deviceMIMOEngine->state(subsystemIndex)) + { + case DSPDeviceSinkEngine::StNotStarted: + state = "notStarted"; + break; + case DSPDeviceSinkEngine::StIdle: + state = "idle"; + break; + case DSPDeviceSinkEngine::StReady: + state = "ready"; + break; + case DSPDeviceSinkEngine::StRunning: + state = "running"; + break; + case DSPDeviceSinkEngine::StError: + state = "error"; + break; + default: + state = "notStarted"; + break; + } + } else { state = "notStarted"; } } -ChannelAPI *DeviceAPI::getChanelSinkAPIAt(int index, int streamIndex) +ChannelAPI *DeviceAPI::getChanelSinkAPIAt(int index) { - (void) streamIndex; - - if (m_streamType == StreamSingleRx) - { - if (index < m_channelSinkAPIs.size()) { - return m_channelSinkAPIs.at(index); - } else { - return nullptr; - } - } - else // TODO: not implemented - { + if (index < m_channelSinkAPIs.size()) { + return m_channelSinkAPIs.at(index); + } else { return nullptr; } } -ChannelAPI *DeviceAPI::getChanelSourceAPIAt(int index, int streamIndex) +ChannelAPI *DeviceAPI::getChanelSourceAPIAt(int index) { - (void) streamIndex; - - if (m_streamType == StreamSingleTx) - { - if (index < m_channelSourceAPIs.size()) { - return m_channelSourceAPIs.at(index); - } else { - return nullptr; - } + if (index < m_channelSourceAPIs.size()) { + return m_channelSourceAPIs.at(index); + } else { + return nullptr; } - else // TODO: not implemented - { +} + +ChannelAPI *DeviceAPI::getMIMOChannelAPIAt(int index) +{ + if (index < m_mimoChannelAPIs.size()) { + return m_mimoChannelAPIs.at(index); + } else { return nullptr; } } diff --git a/sdrbase/device/deviceapi.h b/sdrbase/device/deviceapi.h index ba8fbebf3..3b1b938a8 100644 --- a/sdrbase/device/deviceapi.h +++ b/sdrbase/device/deviceapi.h @@ -133,13 +133,15 @@ public: // PluginInstanceGUI *getSampleSourcePluginInstanceGUI() { return m_sampleSourcePluginInstanceUI; } // PluginInstanceGUI *getSampleSinkPluginInstanceGUI() { return m_sampleSinkPluginInstanceUI; } - void getDeviceEngineStateStr(QString& state); + void getDeviceEngineStateStr(QString& state, int subsystemIndex = 0); - ChannelAPI *getChanelSinkAPIAt(int index, int streamIndex = 0); - ChannelAPI *getChanelSourceAPIAt(int index, int streamIndex = 0); + ChannelAPI *getChanelSinkAPIAt(int index); + ChannelAPI *getChanelSourceAPIAt(int index); + ChannelAPI *getMIMOChannelAPIAt(int index); int getNbSourceChannels() const { return m_channelSourceAPIs.size(); } int getNbSinkChannels() const { return m_channelSinkAPIs.size(); } + int getNbMIMOChannels() const { return m_mimoChannelAPIs.size(); } void loadSamplingDeviceSettings(const Preset* preset); // void loadSourceSettings(const Preset* preset); diff --git a/sdrbase/dsp/devicesamplemimo.h b/sdrbase/dsp/devicesamplemimo.h index 0a5de4f5c..ea0c4f980 100644 --- a/sdrbase/dsp/devicesamplemimo.h +++ b/sdrbase/dsp/devicesamplemimo.h @@ -77,6 +77,7 @@ public: virtual void setSourceCenterFrequency(qint64 centerFrequency, int index) = 0; virtual quint64 getMIMOCenterFrequency() const = 0; //!< Unique center frequency for preset identification or any unique reference + virtual unsigned int getMIMOSampleRate() const = 0; //!< Unique sample rate for any unique reference virtual bool handleMessage(const Message& message) = 0; diff --git a/sdrbase/resources/webapi/doc/swagger/swagger.yaml b/sdrbase/resources/webapi/doc/swagger/swagger.yaml index d6d38d0c6..68c2e1fac 100644 --- a/sdrbase/resources/webapi/doc/swagger/swagger.yaml +++ b/sdrbase/resources/webapi/doc/swagger/swagger.yaml @@ -1596,7 +1596,6 @@ definitions: - serial - centerFrequency - bandwidth - - state properties: index: description: "Index in the list of device sets opened in this instance" @@ -1627,7 +1626,13 @@ definitions: description: "Bandwidth in Hz or complex S/s of baseband" type: integer state: - description: "State: notStarted, idle, ready, running, error" + description: "Single subsystem state: notStarted, idle, ready, running, error" + type: string + stateRx: + description: "Rx subsystem state (MIMO): notStarted, idle, ready, running, error" + type: string + stateTx: + description: "Tx subsystem state (MIMO): notStarted, idle, ready, running, error" type: string Channel: @@ -1639,6 +1644,9 @@ definitions: - title - deltaFrequency properties: + direction: + description: 0 for Rx only, 1 for Tx only or 2 for any direction (MIMO) + type: integer index: description: "Index in the list of channels" type: integer diff --git a/sdrgui/webapi/webapiadaptergui.cpp b/sdrgui/webapi/webapiadaptergui.cpp index f20deeab9..6b32116de 100644 --- a/sdrgui/webapi/webapiadaptergui.cpp +++ b/sdrgui/webapi/webapiadaptergui.cpp @@ -29,8 +29,10 @@ #include "device/deviceenumerator.h" #include "dsp/devicesamplesource.h" #include "dsp/devicesamplesink.h" +#include "dsp/devicesamplemimo.h" #include "dsp/dspdevicesourceengine.h" #include "dsp/dspdevicesinkengine.h" +#include "dsp/dspdevicemimoengine.h" #include "dsp/dspengine.h" #include "plugin/pluginapi.h" #include "plugin/pluginmanager.h" @@ -1944,6 +1946,7 @@ void WebAPIAdapterGUI::getDeviceSet(SWGSDRangel::SWGDeviceSet *deviceSet, const channels->back()->init(); ChannelAPI *channel = deviceUISet->m_deviceAPI->getChanelSourceAPIAt(i); channels->back()->setDeltaFrequency(channel->getCenterFrequency()); + channels->back()->setDirection(1); channels->back()->setIndex(channel->getIndexInDeviceSet()); channels->back()->setUid(channel->getUID()); channel->getIdentifier(*channels->back()->getId()); @@ -1976,6 +1979,72 @@ void WebAPIAdapterGUI::getDeviceSet(SWGSDRangel::SWGDeviceSet *deviceSet, const channels->back()->init(); ChannelAPI *channel = deviceUISet->m_deviceAPI->getChanelSinkAPIAt(i); channels->back()->setDeltaFrequency(channel->getCenterFrequency()); + channels->back()->setDirection(0); + channels->back()->setIndex(channel->getIndexInDeviceSet()); + channels->back()->setUid(channel->getUID()); + channel->getIdentifier(*channels->back()->getId()); + channel->getTitle(*channels->back()->getTitle()); + } + } + + if (deviceUISet->m_deviceMIMOEngine) // MIMO data + { + samplingDevice->setDirection(2); + *samplingDevice->getHwType() = deviceUISet->m_deviceAPI->getHardwareId(); + *samplingDevice->getSerial() = deviceUISet->m_deviceAPI->getSamplingDeviceSerial(); + samplingDevice->setSequence(deviceUISet->m_deviceAPI->getSamplingDeviceSequence()); + samplingDevice->setDeviceNbStreams(deviceUISet->m_deviceAPI->getDeviceNbItems()); + samplingDevice->setDeviceStreamIndex(deviceUISet->m_deviceAPI->getDeviceItemIndex()); + samplingDevice->setState(new QString("notStarted")); + deviceUISet->m_deviceAPI->getDeviceEngineStateStr(*samplingDevice->getStateRx(), 0); + deviceUISet->m_deviceAPI->getDeviceEngineStateStr(*samplingDevice->getStateTx(), 1); + DeviceSampleMIMO *sampleMIMO = deviceUISet->m_deviceMIMOEngine->getMIMO(); + + if (sampleMIMO) + { + samplingDevice->setCenterFrequency(sampleMIMO->getMIMOCenterFrequency()); + samplingDevice->setBandwidth(sampleMIMO->getMIMOSampleRate()); + } + + int nbSinkChannels = deviceUISet->m_deviceAPI->getNbSinkChannels(); + int nbSourceChannels = deviceUISet->m_deviceAPI->getNbSourceChannels(); + int nbMIMOChannels = deviceUISet->m_deviceAPI->getNbMIMOChannels(); + deviceSet->setChannelcount(nbSinkChannels + nbSourceChannels + nbMIMOChannels); + QList *channels = deviceSet->getChannels(); + + for (int i = 0; i < nbSinkChannels; i++) + { + channels->append(new SWGSDRangel::SWGChannel); + channels->back()->init(); + ChannelAPI *channel = deviceUISet->m_deviceAPI->getChanelSinkAPIAt(i); + channels->back()->setDeltaFrequency(channel->getCenterFrequency()); + channels->back()->setDirection(0); + channels->back()->setIndex(channel->getIndexInDeviceSet()); + channels->back()->setUid(channel->getUID()); + channel->getIdentifier(*channels->back()->getId()); + channel->getTitle(*channels->back()->getTitle()); + } + + for (int i = 0; i < nbSourceChannels; i++) + { + channels->append(new SWGSDRangel::SWGChannel); + channels->back()->init(); + ChannelAPI *channel = deviceUISet->m_deviceAPI->getChanelSourceAPIAt(i); + channels->back()->setDeltaFrequency(channel->getCenterFrequency()); + channels->back()->setDirection(1); + channels->back()->setIndex(channel->getIndexInDeviceSet()); + channels->back()->setUid(channel->getUID()); + channel->getIdentifier(*channels->back()->getId()); + channel->getTitle(*channels->back()->getTitle()); + } + + for (int i = 0; i < nbMIMOChannels; i++) + { + channels->append(new SWGSDRangel::SWGChannel); + channels->back()->init(); + ChannelAPI *channel = deviceUISet->m_deviceAPI->getMIMOChannelAPIAt(i); + channels->back()->setDeltaFrequency(channel->getCenterFrequency()); + channels->back()->setDirection(2); channels->back()->setIndex(channel->getIndexInDeviceSet()); channels->back()->setUid(channel->getUID()); channel->getIdentifier(*channels->back()->getId()); @@ -2001,6 +2070,7 @@ void WebAPIAdapterGUI::getChannelsDetail(SWGSDRangel::SWGChannelsDetail *channel channels->back()->init(); ChannelAPI *channel = deviceUISet->m_deviceAPI->getChanelSourceAPIAt(i); channels->back()->setDeltaFrequency(channel->getCenterFrequency()); + channels->back()->setDirection(1); channels->back()->setIndex(channel->getIndexInDeviceSet()); channels->back()->setUid(channel->getUID()); channel->getIdentifier(*channels->back()->getId()); @@ -2027,6 +2097,79 @@ void WebAPIAdapterGUI::getChannelsDetail(SWGSDRangel::SWGChannelsDetail *channel channels->back()->init(); ChannelAPI *channel = deviceUISet->m_deviceAPI->getChanelSinkAPIAt(i); channels->back()->setDeltaFrequency(channel->getCenterFrequency()); + channels->back()->setDirection(0); + 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 (deviceUISet->m_deviceMIMOEngine) // MIMO data + { + int nbSinkChannels = deviceUISet->m_deviceAPI->getNbSinkChannels(); + int nbSourceChannels = deviceUISet->m_deviceAPI->getNbSourceChannels(); + int nbMIMOChannels = deviceUISet->m_deviceAPI->getNbMIMOChannels(); + QList *channels = channelsDetail->getChannels(); + channelsDetail->setChannelcount(nbSinkChannels + nbSourceChannels + nbMIMOChannels); + + for (int i = 0; i < nbSinkChannels; i++) + { + channels->append(new SWGSDRangel::SWGChannel); + channels->back()->init(); + ChannelAPI *channel = deviceUISet->m_deviceAPI->getChanelSinkAPIAt(i); + channels->back()->setDeltaFrequency(channel->getCenterFrequency()); + channels->back()->setDirection(0); + 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; + } + } + + for (int i = 0; i < nbSourceChannels; i++) + { + channels->append(new SWGSDRangel::SWGChannel); + channels->back()->init(); + ChannelAPI *channel = deviceUISet->m_deviceAPI->getChanelSourceAPIAt(i); + channels->back()->setDeltaFrequency(channel->getCenterFrequency()); + channels->back()->setDirection(1); + 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; + } + } + + for (int i = 0; i < nbMIMOChannels; i++) + { + channels->append(new SWGSDRangel::SWGChannel); + channels->back()->init(); + ChannelAPI *channel = deviceUISet->m_deviceAPI->getMIMOChannelAPIAt(i); + channels->back()->setDeltaFrequency(channel->getCenterFrequency()); + channels->back()->setDirection(2); channels->back()->setIndex(channel->getIndexInDeviceSet()); channels->back()->setUid(channel->getUID()); channel->getIdentifier(*channels->back()->getId()); diff --git a/sdrsrv/webapi/webapiadaptersrv.cpp b/sdrsrv/webapi/webapiadaptersrv.cpp index ded0ce19d..3a700e24f 100644 --- a/sdrsrv/webapi/webapiadaptersrv.cpp +++ b/sdrsrv/webapi/webapiadaptersrv.cpp @@ -2028,6 +2028,7 @@ void WebAPIAdapterSrv::getDeviceSet(SWGSDRangel::SWGDeviceSet *swgDeviceSet, con channels->back()->init(); ChannelAPI *channel = deviceSet->m_deviceAPI->getChanelSourceAPIAt(i); channels->back()->setDeltaFrequency(channel->getCenterFrequency()); + channels->back()->setDirection(1); channels->back()->setIndex(channel->getIndexInDeviceSet()); channels->back()->setUid(channel->getUID()); channel->getIdentifier(*channels->back()->getId()); @@ -2060,6 +2061,72 @@ void WebAPIAdapterSrv::getDeviceSet(SWGSDRangel::SWGDeviceSet *swgDeviceSet, con channels->back()->init(); ChannelAPI *channel = deviceSet->m_deviceAPI->getChanelSinkAPIAt(i); channels->back()->setDeltaFrequency(channel->getCenterFrequency()); + channels->back()->setDirection(0); + channels->back()->setIndex(channel->getIndexInDeviceSet()); + channels->back()->setUid(channel->getUID()); + channel->getIdentifier(*channels->back()->getId()); + channel->getTitle(*channels->back()->getTitle()); + } + } + + if (deviceSet->m_deviceMIMOEngine) // MIMO data + { + samplingDevice->setDirection(2); + *samplingDevice->getHwType() = deviceSet->m_deviceAPI->getHardwareId(); + *samplingDevice->getSerial() = deviceSet->m_deviceAPI->getSamplingDeviceSerial(); + samplingDevice->setSequence(deviceSet->m_deviceAPI->getSamplingDeviceSequence()); + samplingDevice->setDeviceNbStreams(deviceSet->m_deviceAPI->getDeviceNbItems()); + samplingDevice->setDeviceStreamIndex(deviceSet->m_deviceAPI->getDeviceItemIndex()); + samplingDevice->setState(new QString("notStarted")); + deviceSet->m_deviceAPI->getDeviceEngineStateStr(*samplingDevice->getStateRx(), 0); + deviceSet->m_deviceAPI->getDeviceEngineStateStr(*samplingDevice->getStateTx(), 1); + DeviceSampleMIMO *sampleMIMO = deviceSet->m_deviceMIMOEngine->getMIMO(); + + if (sampleMIMO) + { + samplingDevice->setCenterFrequency(sampleMIMO->getMIMOCenterFrequency()); + samplingDevice->setBandwidth(sampleMIMO->getMIMOSampleRate()); + } + + int nbSinkChannels = deviceSet->m_deviceAPI->getNbSinkChannels(); + int nbSourceChannels = deviceSet->m_deviceAPI->getNbSourceChannels(); + int nbMIMOChannels = deviceSet->m_deviceAPI->getNbMIMOChannels(); + swgDeviceSet->setChannelcount(nbSinkChannels + nbSourceChannels + nbMIMOChannels); + QList *channels = swgDeviceSet->getChannels(); + + for (int i = 0; i < nbSinkChannels; i++) + { + channels->append(new SWGSDRangel::SWGChannel); + channels->back()->init(); + ChannelAPI *channel = deviceSet->m_deviceAPI->getChanelSinkAPIAt(i); + channels->back()->setDeltaFrequency(channel->getCenterFrequency()); + channels->back()->setDirection(0); + channels->back()->setIndex(channel->getIndexInDeviceSet()); + channels->back()->setUid(channel->getUID()); + channel->getIdentifier(*channels->back()->getId()); + channel->getTitle(*channels->back()->getTitle()); + } + + for (int i = 0; i < nbSourceChannels; i++) + { + channels->append(new SWGSDRangel::SWGChannel); + channels->back()->init(); + ChannelAPI *channel = deviceSet->m_deviceAPI->getChanelSourceAPIAt(i); + channels->back()->setDeltaFrequency(channel->getCenterFrequency()); + channels->back()->setDirection(1); + channels->back()->setIndex(channel->getIndexInDeviceSet()); + channels->back()->setUid(channel->getUID()); + channel->getIdentifier(*channels->back()->getId()); + channel->getTitle(*channels->back()->getTitle()); + } + + for (int i = 0; i < nbMIMOChannels; i++) + { + channels->append(new SWGSDRangel::SWGChannel); + channels->back()->init(); + ChannelAPI *channel = deviceSet->m_deviceAPI->getMIMOChannelAPIAt(i); + channels->back()->setDeltaFrequency(channel->getCenterFrequency()); + channels->back()->setDirection(2); channels->back()->setIndex(channel->getIndexInDeviceSet()); channels->back()->setUid(channel->getUID()); channel->getIdentifier(*channels->back()->getId()); @@ -2085,6 +2152,7 @@ void WebAPIAdapterSrv::getChannelsDetail(SWGSDRangel::SWGChannelsDetail *channel channels->back()->init(); ChannelAPI *channel = deviceSet->m_deviceAPI->getChanelSourceAPIAt(i); channels->back()->setDeltaFrequency(channel->getCenterFrequency()); + channels->back()->setDirection(1); channels->back()->setIndex(channel->getIndexInDeviceSet()); channels->back()->setUid(channel->getUID()); channel->getIdentifier(*channels->back()->getId()); @@ -2111,6 +2179,79 @@ void WebAPIAdapterSrv::getChannelsDetail(SWGSDRangel::SWGChannelsDetail *channel channels->back()->init(); ChannelAPI *channel = deviceSet->m_deviceAPI->getChanelSinkAPIAt(i); channels->back()->setDeltaFrequency(channel->getCenterFrequency()); + channels->back()->setDirection(0); + 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_deviceMIMOEngine) // MIMO data + { + int nbSinkChannels = deviceSet->m_deviceAPI->getNbSinkChannels(); + int nbSourceChannels = deviceSet->m_deviceAPI->getNbSourceChannels(); + int nbMIMOChannels = deviceSet->m_deviceAPI->getNbMIMOChannels(); + QList *channels = channelsDetail->getChannels(); + channelsDetail->setChannelcount(nbSinkChannels + nbSourceChannels + nbMIMOChannels); + + for (int i = 0; i < nbSinkChannels; i++) + { + channels->append(new SWGSDRangel::SWGChannel); + channels->back()->init(); + ChannelAPI *channel = deviceSet->m_deviceAPI->getChanelSinkAPIAt(i); + channels->back()->setDeltaFrequency(channel->getCenterFrequency()); + channels->back()->setDirection(0); + 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; + } + } + + for (int i = 0; i < nbSourceChannels; i++) + { + channels->append(new SWGSDRangel::SWGChannel); + channels->back()->init(); + ChannelAPI *channel = deviceSet->m_deviceAPI->getChanelSourceAPIAt(i); + channels->back()->setDeltaFrequency(channel->getCenterFrequency()); + channels->back()->setDirection(1); + 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; + } + } + + for (int i = 0; i < nbMIMOChannels; i++) + { + channels->append(new SWGSDRangel::SWGChannel); + channels->back()->init(); + ChannelAPI *channel = deviceSet->m_deviceAPI->getMIMOChannelAPIAt(i); + channels->back()->setDeltaFrequency(channel->getCenterFrequency()); + channels->back()->setDirection(2); channels->back()->setIndex(channel->getIndexInDeviceSet()); channels->back()->setUid(channel->getUID()); channel->getIdentifier(*channels->back()->getId()); diff --git a/swagger/sdrangel/api/swagger/swagger.yaml b/swagger/sdrangel/api/swagger/swagger.yaml index 5dbe9ffe3..255dd27e4 100644 --- a/swagger/sdrangel/api/swagger/swagger.yaml +++ b/swagger/sdrangel/api/swagger/swagger.yaml @@ -1596,7 +1596,6 @@ definitions: - serial - centerFrequency - bandwidth - - state properties: index: description: "Index in the list of device sets opened in this instance" @@ -1627,7 +1626,13 @@ definitions: description: "Bandwidth in Hz or complex S/s of baseband" type: integer state: - description: "State: notStarted, idle, ready, running, error" + description: "Single subsystem state: notStarted, idle, ready, running, error" + type: string + stateRx: + description: "Rx subsystem state (MIMO): notStarted, idle, ready, running, error" + type: string + stateTx: + description: "Tx subsystem state (MIMO): notStarted, idle, ready, running, error" type: string Channel: @@ -1639,6 +1644,9 @@ definitions: - title - deltaFrequency properties: + direction: + description: 0 for Rx only, 1 for Tx only or 2 for any direction (MIMO) + type: integer index: description: "Index in the list of channels" type: integer diff --git a/swagger/sdrangel/code/qt5/client/SWGChannel.cpp b/swagger/sdrangel/code/qt5/client/SWGChannel.cpp index 0f8048e9f..e1c6a5d5a 100644 --- a/swagger/sdrangel/code/qt5/client/SWGChannel.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGChannel.cpp @@ -28,6 +28,8 @@ SWGChannel::SWGChannel(QString* json) { } SWGChannel::SWGChannel() { + direction = 0; + m_direction_isSet = false; index = 0; m_index_isSet = false; id = nullptr; @@ -48,6 +50,8 @@ SWGChannel::~SWGChannel() { void SWGChannel::init() { + direction = 0; + m_direction_isSet = false; index = 0; m_index_isSet = false; id = new QString(""); @@ -65,6 +69,7 @@ SWGChannel::init() { void SWGChannel::cleanup() { + if(id != nullptr) { delete id; } @@ -89,6 +94,8 @@ SWGChannel::fromJson(QString &json) { void SWGChannel::fromJsonObject(QJsonObject &pJson) { + ::SWGSDRangel::setValue(&direction, pJson["direction"], "qint32", ""); + ::SWGSDRangel::setValue(&index, pJson["index"], "qint32", ""); ::SWGSDRangel::setValue(&id, pJson["id"], "QString", "QString"); @@ -117,6 +124,9 @@ SWGChannel::asJson () QJsonObject* SWGChannel::asJsonObject() { QJsonObject* obj = new QJsonObject(); + if(m_direction_isSet){ + obj->insert("direction", QJsonValue(direction)); + } if(m_index_isSet){ obj->insert("index", QJsonValue(index)); } @@ -139,6 +149,16 @@ SWGChannel::asJsonObject() { return obj; } +qint32 +SWGChannel::getDirection() { + return direction; +} +void +SWGChannel::setDirection(qint32 direction) { + this->direction = direction; + this->m_direction_isSet = true; +} + qint32 SWGChannel::getIndex() { return index; @@ -204,6 +224,9 @@ bool SWGChannel::isSet(){ bool isObjectUpdated = false; do{ + if(m_direction_isSet){ + isObjectUpdated = true; break; + } if(m_index_isSet){ isObjectUpdated = true; break; } diff --git a/swagger/sdrangel/code/qt5/client/SWGChannel.h b/swagger/sdrangel/code/qt5/client/SWGChannel.h index 245d51319..32bb61b7d 100644 --- a/swagger/sdrangel/code/qt5/client/SWGChannel.h +++ b/swagger/sdrangel/code/qt5/client/SWGChannel.h @@ -43,6 +43,9 @@ public: virtual void fromJsonObject(QJsonObject &json) override; virtual SWGChannel* fromJson(QString &jsonString) override; + qint32 getDirection(); + void setDirection(qint32 direction); + qint32 getIndex(); void setIndex(qint32 index); @@ -65,6 +68,9 @@ public: virtual bool isSet() override; private: + qint32 direction; + bool m_direction_isSet; + qint32 index; bool m_index_isSet; diff --git a/swagger/sdrangel/code/qt5/client/SWGSamplingDevice.cpp b/swagger/sdrangel/code/qt5/client/SWGSamplingDevice.cpp index 617c4cd32..a035d02d7 100644 --- a/swagger/sdrangel/code/qt5/client/SWGSamplingDevice.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGSamplingDevice.cpp @@ -48,6 +48,10 @@ SWGSamplingDevice::SWGSamplingDevice() { m_bandwidth_isSet = false; state = nullptr; m_state_isSet = false; + state_rx = nullptr; + m_state_rx_isSet = false; + state_tx = nullptr; + m_state_tx_isSet = false; } SWGSamplingDevice::~SWGSamplingDevice() { @@ -76,6 +80,10 @@ SWGSamplingDevice::init() { m_bandwidth_isSet = false; state = new QString(""); m_state_isSet = false; + state_rx = new QString(""); + m_state_rx_isSet = false; + state_tx = new QString(""); + m_state_tx_isSet = false; } void @@ -96,6 +104,12 @@ SWGSamplingDevice::cleanup() { if(state != nullptr) { delete state; } + if(state_rx != nullptr) { + delete state_rx; + } + if(state_tx != nullptr) { + delete state_tx; + } } SWGSamplingDevice* @@ -129,6 +143,10 @@ SWGSamplingDevice::fromJsonObject(QJsonObject &pJson) { ::SWGSDRangel::setValue(&state, pJson["state"], "QString", "QString"); + ::SWGSDRangel::setValue(&state_rx, pJson["stateRx"], "QString", "QString"); + + ::SWGSDRangel::setValue(&state_tx, pJson["stateTx"], "QString", "QString"); + } QString @@ -175,6 +193,12 @@ SWGSamplingDevice::asJsonObject() { if(state != nullptr && *state != QString("")){ toJsonValue(QString("state"), state, obj, QString("QString")); } + if(state_rx != nullptr && *state_rx != QString("")){ + toJsonValue(QString("stateRx"), state_rx, obj, QString("QString")); + } + if(state_tx != nullptr && *state_tx != QString("")){ + toJsonValue(QString("stateTx"), state_tx, obj, QString("QString")); + } return obj; } @@ -279,6 +303,26 @@ SWGSamplingDevice::setState(QString* state) { this->m_state_isSet = true; } +QString* +SWGSamplingDevice::getStateRx() { + return state_rx; +} +void +SWGSamplingDevice::setStateRx(QString* state_rx) { + this->state_rx = state_rx; + this->m_state_rx_isSet = true; +} + +QString* +SWGSamplingDevice::getStateTx() { + return state_tx; +} +void +SWGSamplingDevice::setStateTx(QString* state_tx) { + this->state_tx = state_tx; + this->m_state_tx_isSet = true; +} + bool SWGSamplingDevice::isSet(){ @@ -314,6 +358,12 @@ SWGSamplingDevice::isSet(){ if(state && *state != QString("")){ isObjectUpdated = true; break; } + if(state_rx && *state_rx != QString("")){ + isObjectUpdated = true; break; + } + if(state_tx && *state_tx != QString("")){ + isObjectUpdated = true; break; + } }while(false); return isObjectUpdated; } diff --git a/swagger/sdrangel/code/qt5/client/SWGSamplingDevice.h b/swagger/sdrangel/code/qt5/client/SWGSamplingDevice.h index af109ab83..38410292b 100644 --- a/swagger/sdrangel/code/qt5/client/SWGSamplingDevice.h +++ b/swagger/sdrangel/code/qt5/client/SWGSamplingDevice.h @@ -72,6 +72,12 @@ public: QString* getState(); void setState(QString* state); + QString* getStateRx(); + void setStateRx(QString* state_rx); + + QString* getStateTx(); + void setStateTx(QString* state_tx); + virtual bool isSet() override; @@ -106,6 +112,12 @@ private: QString* state; bool m_state_isSet; + QString* state_rx; + bool m_state_rx_isSet; + + QString* state_tx; + bool m_state_tx_isSet; + }; }