From a1c85aac172f26cfc964b220de2c347c8f875f29 Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 13 Jan 2022 02:45:25 +0100 Subject: [PATCH] API: fixed adding channels when device is MIMO --- sdrbase/maincore.h | 12 ++++++------ sdrbase/webapi/webapiadapter.cpp | 6 +++--- sdrgui/mainwindow.cpp | 32 ++++++++++++++++++++++++++++++-- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/sdrbase/maincore.h b/sdrbase/maincore.h index 2497112a1..6cbc0d0d0 100644 --- a/sdrbase/maincore.h +++ b/sdrbase/maincore.h @@ -340,23 +340,23 @@ public: public: int getDeviceSetIndex() const { return m_deviceSetIndex; } int getChannelRegistrationIndex() const { return m_channelRegistrationIndex; } - bool isTx() const { return m_tx; } + int getDirection() const { return m_direction; } - static MsgAddChannel* create(int deviceSetIndex, int channelRegistrationIndex, bool tx) + static MsgAddChannel* create(int deviceSetIndex, int channelRegistrationIndex, int direction) { - return new MsgAddChannel(deviceSetIndex, channelRegistrationIndex, tx); + return new MsgAddChannel(deviceSetIndex, channelRegistrationIndex, direction); } private: int m_deviceSetIndex; int m_channelRegistrationIndex; - bool m_tx; + int m_direction; - MsgAddChannel(int deviceSetIndex, int channelRegistrationIndex, bool tx) : + MsgAddChannel(int deviceSetIndex, int channelRegistrationIndex, int direction) : Message(), m_deviceSetIndex(deviceSetIndex), m_channelRegistrationIndex(channelRegistrationIndex), - m_tx(tx) + m_direction(direction) { } }; diff --git a/sdrbase/webapi/webapiadapter.cpp b/sdrbase/webapi/webapiadapter.cpp index cbff7ec26..c3266425f 100644 --- a/sdrbase/webapi/webapiadapter.cpp +++ b/sdrbase/webapi/webapiadapter.cpp @@ -2359,7 +2359,7 @@ int WebAPIAdapter::devicesetChannelPost( if (index < nbRegistrations) { - MainCore::MsgAddChannel *msg = MainCore::MsgAddChannel::create(deviceSetIndex, index, false); + MainCore::MsgAddChannel *msg = MainCore::MsgAddChannel::create(deviceSetIndex, index, 0); m_mainCore->m_mainMessageQueue->push(msg); response.init(); @@ -2395,7 +2395,7 @@ int WebAPIAdapter::devicesetChannelPost( if (index < nbRegistrations) { - MainCore::MsgAddChannel *msg = MainCore::MsgAddChannel::create(deviceSetIndex, index, true); + MainCore::MsgAddChannel *msg = MainCore::MsgAddChannel::create(deviceSetIndex, index, 1); m_mainCore->m_mainMessageQueue->push(msg); response.init(); @@ -2431,7 +2431,7 @@ int WebAPIAdapter::devicesetChannelPost( if (index < nbRegistrations) { - MainCore::MsgAddChannel *msg = MainCore::MsgAddChannel::create(deviceSetIndex, index, true); + MainCore::MsgAddChannel *msg = MainCore::MsgAddChannel::create(deviceSetIndex, index, 2); m_mainCore->m_mainMessageQueue->push(msg); response.init(); diff --git a/sdrgui/mainwindow.cpp b/sdrgui/mainwindow.cpp index 208902fce..f39810e73 100644 --- a/sdrgui/mainwindow.cpp +++ b/sdrgui/mainwindow.cpp @@ -1170,7 +1170,35 @@ bool MainWindow::handleMessage(const Message& cmd) { MainCore::MsgAddChannel& notif = (MainCore::MsgAddChannel&) cmd; ui->tabInputsView->setCurrentIndex(notif.getDeviceSetIndex()); - channelAddClicked(notif.getChannelRegistrationIndex()); + int currentChannelTabIndex = ui->tabChannels->currentIndex(); + + if (currentChannelTabIndex >= 0) + { + DeviceUISet *deviceUI = m_deviceUIs[currentChannelTabIndex]; + int channelRegistrationIndex; + + if (deviceUI->m_deviceMIMOEngine) + { + int nbMIMOChannels = deviceUI->getNumberOfAvailableMIMOChannels(); + int nbRxChannels = deviceUI->getNumberOfAvailableRxChannels(); + int nbTxChannels = deviceUI->getNumberOfAvailableTxChannels(); + int direction = notif.getDirection(); + + if (direction == 2) { + channelRegistrationIndex = notif.getChannelRegistrationIndex(); + } else if (direction == 0) { + channelRegistrationIndex = nbMIMOChannels + notif.getChannelRegistrationIndex(); + } else { + channelRegistrationIndex = nbMIMOChannels + nbRxChannels + notif.getChannelRegistrationIndex(); + } + } + else + { + channelRegistrationIndex = notif.getChannelRegistrationIndex(); + } + + channelAddClicked(channelRegistrationIndex); + } return true; } @@ -2247,7 +2275,7 @@ void MainWindow::channelAddClicked(int channelIndex) int nbMIMOChannels = deviceUI->getNumberOfAvailableMIMOChannels(); int nbRxChannels = deviceUI->getNumberOfAvailableRxChannels(); int nbTxChannels = deviceUI->getNumberOfAvailableTxChannels(); - qDebug("MainWindow::channelAddClicked: MIMO: tab: nbMIMO: %d %d nbRx: %d nbTx: %d selected: %d", + qDebug("MainWindow::channelAddClicked: MIMO: tab %d : nbMIMO: %d nbRx: %d nbTx: %d selected: %d", currentChannelTabIndex, nbMIMOChannels, nbRxChannels, nbTxChannels, channelIndex); if (channelIndex < nbMIMOChannels)