From 25acf953a7d35c14ca5d9f4975e4b1c8934fab63 Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 10 Nov 2020 12:15:19 +0100 Subject: [PATCH] MIMO activation in Main Server --- sdrsrv/mainserver.cpp | 62 +++++++++++++++++++++++++++++++++++++++++-- sdrsrv/mainserver.h | 7 +---- 2 files changed, 61 insertions(+), 8 deletions(-) diff --git a/sdrsrv/mainserver.cpp b/sdrsrv/mainserver.cpp index 5fb2dce41..2e2dc7b2a 100644 --- a/sdrsrv/mainserver.cpp +++ b/sdrsrv/mainserver.cpp @@ -72,8 +72,6 @@ MainServer::MainServer(qtwebapp::LoggerWithFile *logger, const MainParser& parse m_apiAdapter = new WebAPIAdapter(); m_requestMapper = new WebAPIRequestMapper(this); m_requestMapper->setAdapter(m_apiAdapter); - m_apiHost = parser.getServerAddress(); - m_apiPort = parser.getServerPort(); m_apiServer = new WebAPIServer(parser.getServerAddress(), parser.getServerPort(), m_requestMapper); m_apiServer->start(); @@ -164,6 +162,8 @@ bool MainServer::handleMessage(const Message& cmd) addSinkDevice(); } else if (direction == 0) { // Single stream Rx addSourceDevice(); + } else if (direction == 2) { // MIMO + addMIMODevice(); } return true; @@ -343,6 +343,49 @@ void MainServer::addSourceDevice() deviceAPI->setSampleSource(source); } +void MainServer::addMIMODevice() +{ + DSPDeviceMIMOEngine *dspDeviceMIMOEngine = m_dspEngine->addDeviceMIMOEngine(); + dspDeviceMIMOEngine->start(); + + uint dspDeviceMIMOEngineUID = dspDeviceMIMOEngine->getUID(); + char uidCStr[16]; + sprintf(uidCStr, "UID:%d", dspDeviceMIMOEngineUID); + + int deviceTabIndex = m_mainCore->m_deviceSets.size(); + m_mainCore->m_deviceSets.push_back(new DeviceSet(deviceTabIndex, 2)); + m_mainCore->m_deviceSets.back()->m_deviceSourceEngine = nullptr; + m_mainCore->m_deviceSets.back()->m_deviceSinkEngine = nullptr; + m_mainCore->m_deviceSets.back()->m_deviceMIMOEngine = dspDeviceMIMOEngine; + + char tabNameCStr[16]; + sprintf(tabNameCStr, "M%d", deviceTabIndex); + + DeviceAPI *deviceAPI = new DeviceAPI(DeviceAPI::StreamMIMO, deviceTabIndex, nullptr, nullptr, dspDeviceMIMOEngine); + + // create a test MIMO by default + int testMIMODeviceIndex = DeviceEnumerator::instance()->getTestMIMODeviceIndex(); + const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getMIMOSamplingDevice(testMIMODeviceIndex); + deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence); + deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems); + deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex); + deviceAPI->setHardwareId(samplingDevice->hardwareId); + deviceAPI->setSamplingDeviceId(samplingDevice->id); + deviceAPI->setSamplingDeviceSerial(samplingDevice->serial); + deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName); + deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getMIMOPluginInterface(testMIMODeviceIndex)); + + QString userArgs = m_mainCore->m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence); + + if (userArgs.size() > 0) { + deviceAPI->setHardwareUserArguments(userArgs); + } + + DeviceSampleMIMO *mimo = deviceAPI->getPluginInterface()->createSampleMIMOPluginInstance( + deviceAPI->getSamplingDeviceId(), deviceAPI); + m_mainCore->m_deviceSets.back()->m_deviceAPI->setSampleMIMO(mimo); +} + void MainServer::removeLastDevice() { if (m_mainCore->m_deviceSets.back()->m_deviceSourceEngine) // source set @@ -579,6 +622,21 @@ void MainServer::changeSampleMIMO(int deviceSetIndex, int selectedDeviceIndex) deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName); deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getMIMOPluginInterface(selectedDeviceIndex)); + if (deviceSet->m_deviceAPI->getSamplingDeviceId().size() == 0) // non existent device => replace by default + { + qDebug("MainServer::changeSampleMIMO: non existent device replaced by Test MIMO"); + int testMIMODeviceIndex = DeviceEnumerator::instance()->getTestMIMODeviceIndex(); + const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getMIMOSamplingDevice(testMIMODeviceIndex); + deviceSet->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence); + deviceSet->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems); + deviceSet->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex); + deviceSet->m_deviceAPI->setHardwareId(samplingDevice->hardwareId); + deviceSet->m_deviceAPI->setSamplingDeviceId(samplingDevice->id); + deviceSet->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial); + deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName); + deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getMIMOPluginInterface(testMIMODeviceIndex)); + } + QString userArgs = m_mainCore->m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence); if (userArgs.size() > 0) { diff --git a/sdrsrv/mainserver.h b/sdrsrv/mainserver.h index 7a17931c2..db8a3cea0 100644 --- a/sdrsrv/mainserver.h +++ b/sdrsrv/mainserver.h @@ -59,6 +59,7 @@ public: void addSourceDevice(); void addSinkDevice(); + void addMIMODevice(); void removeLastDevice(); void changeSampleSource(int deviceSetIndex, int selectedDeviceIndex); void changeSampleSink(int deviceSetIndex, int selectedDeviceIndex); @@ -68,9 +69,6 @@ public: void addFeature(int featureSetIndex, int featureIndex); void deleteFeature(int featureSetIndex, int featureIndex); - const QString& getAPIHost() const { return m_apiHost; } - int getAPIPort() const { return m_apiPort; } - signals: void finished(); @@ -78,9 +76,6 @@ private: static MainServer *m_instance; MainCore *m_mainCore; DSPEngine* m_dspEngine; - int m_lastEngineState; - QString m_apiHost; - int m_apiPort; MessageQueue m_inputMessageQueue;