From c9e042561695085f98eaa4da3a85030ceaedb254 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 11 Oct 2020 09:36:27 +0200 Subject: [PATCH] Implement MainCore in MainWindow step3: device sets: fixes --- sdrbase/device/deviceset.cpp | 32 +++++++++++++++++++++++++++++++- sdrbase/device/deviceset.h | 2 +- sdrsrv/mainserver.cpp | 4 ++-- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/sdrbase/device/deviceset.cpp b/sdrbase/device/deviceset.cpp index f86b89840..c816ccc55 100644 --- a/sdrbase/device/deviceset.cpp +++ b/sdrbase/device/deviceset.cpp @@ -34,8 +34,9 @@ DeviceSet::ChannelInstanceRegistration::ChannelInstanceRegistration(const QStrin m_channelAPI(channelAPI) {} -DeviceSet::DeviceSet(int tabIndex) +DeviceSet::DeviceSet(int tabIndex, int deviceType) { + (void) deviceType; m_deviceAPI = nullptr; m_deviceSourceEngine = nullptr; m_deviceSinkEngine = nullptr; @@ -413,3 +414,32 @@ bool DeviceSet::ChannelInstanceRegistration::operator<(const ChannelInstanceRegi } } +void DeviceSet::addChannelInstance(const QString& channelURI, ChannelAPI *channelAPI) +{ + ChannelInstanceRegistration reg = ChannelInstanceRegistration(channelURI, channelAPI); + m_channelInstanceRegistrations.append(reg); +} + +void DeviceSet::removeChannelInstanceAt(int index) +{ + if (index < m_channelInstanceRegistrations.size()) { + m_channelInstanceRegistrations.removeAt(index); + } +} + +void DeviceSet::removeChannelInstance(ChannelAPI *channelAPI) +{ + for (int i = 0; i < m_channelInstanceRegistrations.count(); i++) + { + if (m_channelInstanceRegistrations.at(i).m_channelAPI == channelAPI) + { + m_channelInstanceRegistrations.removeAt(i); + break; + } + } +} + +void DeviceSet::clearChannels() +{ + m_channelInstanceRegistrations.clear(); +} diff --git a/sdrbase/device/deviceset.h b/sdrbase/device/deviceset.h index d7aab449c..40dbd1a37 100644 --- a/sdrbase/device/deviceset.h +++ b/sdrbase/device/deviceset.h @@ -38,7 +38,7 @@ public: DSPDeviceSinkEngine *m_deviceSinkEngine; DSPDeviceMIMOEngine *m_deviceMIMOEngine; - DeviceSet(int tabIndex); + DeviceSet(int tabIndex, int deviceType); ~DeviceSet(); int getNumberOfChannels() const { return m_channelInstanceRegistrations.size(); } diff --git a/sdrsrv/mainserver.cpp b/sdrsrv/mainserver.cpp index 654a78f03..407f2c366 100644 --- a/sdrsrv/mainserver.cpp +++ b/sdrsrv/mainserver.cpp @@ -262,7 +262,7 @@ void MainServer::addSinkDevice() sprintf(uidCStr, "UID:%d", dspDeviceSinkEngineUID); int deviceTabIndex = m_mainCore->m_deviceSets.size(); - m_mainCore->m_deviceSets.push_back(new DeviceSet(deviceTabIndex)); + m_mainCore->m_deviceSets.push_back(new DeviceSet(deviceTabIndex, 1)); m_mainCore->m_deviceSets.back()->m_deviceSourceEngine = nullptr; m_mainCore->m_deviceSets.back()->m_deviceSinkEngine = dspDeviceSinkEngine; m_mainCore->m_deviceSets.back()->m_deviceMIMOEngine = nullptr; @@ -308,7 +308,7 @@ void MainServer::addSourceDevice() sprintf(uidCStr, "UID:%d", dspDeviceSourceEngineUID); int deviceTabIndex = m_mainCore->m_deviceSets.size(); - m_mainCore->m_deviceSets.push_back(new DeviceSet(deviceTabIndex)); + m_mainCore->m_deviceSets.push_back(new DeviceSet(deviceTabIndex, 0)); m_mainCore->m_deviceSets.back()->m_deviceSourceEngine = dspDeviceSourceEngine; m_mainCore->m_deviceSets.back()->m_deviceSinkEngine = nullptr; m_mainCore->m_deviceSets.back()->m_deviceMIMOEngine = nullptr;