From eff28e8b6341b648d304000b9e89884fb027b442 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 26 May 2019 02:14:35 +0200 Subject: [PATCH 1/8] MIMO: add channel to TestMI (1) --- plugins/samplemimo/testmi/testmi.cpp | 728 ++++++++++-------- plugins/samplemimo/testmi/testmi.h | 10 +- plugins/samplemimo/testmi/testmigui.cpp | 98 +-- plugins/samplemimo/testmi/testmigui.h | 2 + plugins/samplemimo/testmi/testmigui.ui | 157 ++-- plugins/samplemimo/testmi/testmisettings.cpp | 143 ++-- plugins/samplemimo/testmi/testmisettings.h | 13 +- plugins/samplemimo/testmi/testmithread.cpp | 16 +- plugins/samplemimo/testmi/testmithread.h | 4 +- sdrbase/resources/webapi/doc/html2/index.html | 52 +- .../webapi/doc/swagger/include/TestMI.yaml | 89 ++- sdrbase/webapi/webapirequestmapper.cpp | 45 ++ sdrbase/webapi/webapirequestmapper.h | 5 + .../sdrangel/api/swagger/include/TestMI.yaml | 89 ++- swagger/sdrangel/code/html2/index.html | 52 +- .../code/qt5/client/SWGModelFactory.h | 4 + .../code/qt5/client/SWGTestMISettings.cpp | 363 +-------- .../code/qt5/client/SWGTestMISettings.h | 106 +-- .../qt5/client/SWGTestMiStreamSettings.cpp | 442 +++++++++++ .../code/qt5/client/SWGTestMiStreamSettings.h | 154 ++++ 20 files changed, 1523 insertions(+), 1049 deletions(-) create mode 100644 swagger/sdrangel/code/qt5/client/SWGTestMiStreamSettings.cpp create mode 100644 swagger/sdrangel/code/qt5/client/SWGTestMiStreamSettings.h diff --git a/plugins/samplemimo/testmi/testmi.cpp b/plugins/samplemimo/testmi/testmi.cpp index 8e11b548c..8780743b4 100644 --- a/plugins/samplemimo/testmi/testmi.cpp +++ b/plugins/samplemimo/testmi/testmi.cpp @@ -25,6 +25,7 @@ #include "SWGDeviceSettings.h" #include "SWGDeviceState.h" +#include "SWGTestMISettings.h" #include "device/deviceapi.h" #include "dsp/dspcommands.h" @@ -44,16 +45,17 @@ MESSAGE_CLASS_DEFINITION(TestMI::MsgStartStop, Message) TestMI::TestMI(DeviceAPI *deviceAPI) : m_deviceAPI(deviceAPI), m_settings(), - m_testSourceThread(0), m_deviceDescription(), m_running(false), m_masterTimer(deviceAPI->getMasterTimer()) { m_fileSink = new FileRecord(QString("test_%1.sdriq").arg(m_deviceAPI->getDeviceUID())); - m_deviceAPI->setNbSourceStreams(1); + m_deviceAPI->setNbSourceStreams(2); + m_deviceAPI->addSourceStream(); // Add a new source stream data set in the engine m_deviceAPI->addSourceStream(); // Add a new source stream data set in the engine m_deviceAPI->addAncillarySink(m_fileSink); m_sampleSinkFifos.push_back(SampleSinkFifo(96000 * 4)); + m_sampleSinkFifos.push_back(SampleSinkFifo(96000 * 4)); m_networkManager = new QNetworkAccessManager(); connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); } @@ -69,6 +71,7 @@ TestMI::~TestMI() m_deviceAPI->removeAncillarySink(m_fileSink); m_deviceAPI->removeLastSourceStream(); // Remove the last source stream data set in the engine + m_deviceAPI->removeLastSourceStream(); // Remove the last source stream data set in the engine delete m_fileSink; } @@ -88,9 +91,13 @@ bool TestMI::start() if (m_running) stop(); - m_testSourceThread = new TestMIThread(&m_sampleSinkFifos[0]); - m_testSourceThread->setSamplerate(m_settings.m_sampleRate); - m_testSourceThread->startStop(true); + m_testSourceThreads.push_back(new TestMIThread(&m_sampleSinkFifos[0])); + m_testSourceThreads.back()->setSamplerate(m_settings.m_streams[0].m_sampleRate); + m_testSourceThreads.back()->startStop(true); + + m_testSourceThreads.push_back(new TestMIThread(&m_sampleSinkFifos[1])); + m_testSourceThreads.back()->setSamplerate(m_settings.m_streams[1].m_sampleRate); + m_testSourceThreads.back()->startStop(true); mutexLocker.unlock(); @@ -104,13 +111,15 @@ void TestMI::stop() { QMutexLocker mutexLocker(&m_mutex); - if (m_testSourceThread != 0) - { - m_testSourceThread->startStop(false); - m_testSourceThread->deleteLater(); - m_testSourceThread = 0; - } + std::vector::iterator it = m_testSourceThreads.begin(); + for (; it != m_testSourceThreads.end(); ++it) + { + (*it)->startStop(false); + (*it)->deleteLater(); + } + + m_testSourceThreads.clear(); m_running = false; } @@ -148,29 +157,38 @@ const QString& TestMI::getDeviceDescription() const int TestMI::getSourceSampleRate(int index) const { - (void) index; - return m_settings.m_sampleRate/(1<push(messageToGUI); + settings.m_streams[index].m_centerFrequency = centerFrequency; + + MsgConfigureTestSource* message = MsgConfigureTestSource::create(settings, false); + m_inputMessageQueue.push(message); + + if (m_guiMessageQueue) + { + MsgConfigureTestSource* messageToGUI = MsgConfigureTestSource::create(settings, false); + m_guiMessageQueue->push(messageToGUI); + } } } @@ -243,204 +261,213 @@ bool TestMI::handleMessage(const Message& message) bool TestMI::applySettings(const TestMISettings& settings, bool force) { - QList reverseAPIKeys; + DeviceSettingsKeys deviceSettingsKeys; - if ((m_settings.m_autoCorrOptions != settings.m_autoCorrOptions) || force) + QList> streamReverseAPIKeys; // FIXME: one set of keys per streams + + for (unsigned int istream = 0; istream < m_settings.m_streams.size(); istream++) { - reverseAPIKeys.append("autoCorrOptions"); + deviceSettingsKeys.m_streamsSettingsKeys.push_back(QList()); + QList& reverseAPIKeys = streamReverseAPIKeys.back(); - switch(settings.m_autoCorrOptions) + if ((m_settings.m_streams[istream].m_autoCorrOptions != settings.m_streams[istream].m_autoCorrOptions) || force) { - case TestMISettings::AutoCorrDC: - m_deviceAPI->configureCorrections(true, false); - break; - case TestMISettings::AutoCorrDCAndIQ: - m_deviceAPI->configureCorrections(true, true); - break; - case TestMISettings::AutoCorrNone: - default: - m_deviceAPI->configureCorrections(false, false); - break; - } - } + reverseAPIKeys.append("autoCorrOptions"); - if ((m_settings.m_sampleRate != settings.m_sampleRate) || force) - { - reverseAPIKeys.append("sampleRate"); - - if (m_testSourceThread != 0) - { - m_testSourceThread->setSamplerate(settings.m_sampleRate); - qDebug("TestMI::applySettings: sample rate set to %d", settings.m_sampleRate); - } - } - - if ((m_settings.m_log2Decim != settings.m_log2Decim) || force) - { - reverseAPIKeys.append("log2Decim"); - - if (m_testSourceThread != 0) - { - m_testSourceThread->setLog2Decimation(settings.m_log2Decim); - qDebug() << "TestMI::applySettings: set decimation to " << (1<setFcPos((int) settings.m_fcPos); - m_testSourceThread->setFrequencyShift(frequencyShift); - qDebug() << "TestMI::applySettings:" - << " center freq: " << settings.m_centerFrequency << " Hz" - << " device center freq: " << deviceCenterFrequency << " Hz" - << " device sample rate: " << devSampleRate << "Hz" - << " Actual sample rate: " << devSampleRate/(1<setAmplitudeBits(settings.m_amplitudeBits); - } - } - - if ((m_settings.m_dcFactor != settings.m_dcFactor) || force) - { - reverseAPIKeys.append("dcFactor"); - - if (m_testSourceThread != 0) { - m_testSourceThread->setDCFactor(settings.m_dcFactor); - } - } - - if ((m_settings.m_iFactor != settings.m_iFactor) || force) - { - reverseAPIKeys.append("iFactor"); - - if (m_testSourceThread != 0) { - m_testSourceThread->setIFactor(settings.m_iFactor); - } - } - - if ((m_settings.m_qFactor != settings.m_qFactor) || force) - { - reverseAPIKeys.append("qFactor"); - - if (m_testSourceThread != 0) { - m_testSourceThread->setQFactor(settings.m_qFactor); - } - } - - if ((m_settings.m_phaseImbalance != settings.m_phaseImbalance) || force) - { - reverseAPIKeys.append("phaseImbalance"); - - if (m_testSourceThread != 0) { - m_testSourceThread->setPhaseImbalance(settings.m_phaseImbalance); - } - } - - if ((m_settings.m_sampleSizeIndex != settings.m_sampleSizeIndex) || force) - { - reverseAPIKeys.append("sampleSizeIndex"); - - if (m_testSourceThread != 0) { - m_testSourceThread->setBitSize(settings.m_sampleSizeIndex); - } - } - - if ((m_settings.m_sampleRate != settings.m_sampleRate) - || (m_settings.m_centerFrequency != settings.m_centerFrequency) - || (m_settings.m_log2Decim != settings.m_log2Decim) - || (m_settings.m_fcPos != settings.m_fcPos) || force) - { - int sampleRate = settings.m_sampleRate/(1<handleMessage(*notif); // forward to file sink - DSPDeviceMIMOEngine::SignalNotification *engineNotif = new DSPDeviceMIMOEngine::SignalNotification( - sampleRate, settings.m_centerFrequency, true, 0); - m_deviceAPI->getDeviceEngineInputMessageQueue()->push(engineNotif); - } - - if ((m_settings.m_modulationTone != settings.m_modulationTone) || force) - { - reverseAPIKeys.append("modulationTone"); - - if (m_testSourceThread != 0) { - m_testSourceThread->setToneFrequency(settings.m_modulationTone * 10); - } - } - - if ((m_settings.m_modulation != settings.m_modulation) || force) - { - reverseAPIKeys.append("modulation"); - - if (m_testSourceThread != 0) - { - m_testSourceThread->setModulation(settings.m_modulation); - - if (settings.m_modulation == TestMISettings::ModulationPattern0) { - m_testSourceThread->setPattern0(); - } else if (settings.m_modulation == TestMISettings::ModulationPattern1) { - m_testSourceThread->setPattern1(); - } else if (settings.m_modulation == TestMISettings::ModulationPattern2) { - m_testSourceThread->setPattern2(); + switch(settings.m_streams[istream].m_autoCorrOptions) + { + case TestMIStreamSettings::AutoCorrDC: + m_deviceAPI->configureCorrections(true, false, istream); + break; + case TestMIStreamSettings::AutoCorrDCAndIQ: + m_deviceAPI->configureCorrections(true, true, istream); + break; + case TestMIStreamSettings::AutoCorrNone: + default: + m_deviceAPI->configureCorrections(false, false, istream); + break; } } - } - if ((m_settings.m_amModulation != settings.m_amModulation) || force) - { - reverseAPIKeys.append("amModulation"); + if ((m_settings.m_streams[istream].m_sampleRate != settings.m_streams[istream].m_sampleRate) || force) + { + reverseAPIKeys.append("sampleRate"); - if (m_testSourceThread != 0) { - m_testSourceThread->setAMModulation(settings.m_amModulation / 100.0f); + if ((istream < m_testSourceThreads.size()) && (m_testSourceThreads[istream])) + { + m_testSourceThreads[istream]->setSamplerate(settings.m_streams[istream].m_sampleRate); + qDebug("TestMI::applySettings: sample rate set to %d", settings.m_streams[istream].m_sampleRate); + } } - } - if ((m_settings.m_fmDeviation != settings.m_fmDeviation) || force) - { - reverseAPIKeys.append("fmDeviation"); + if ((m_settings.m_streams[istream].m_log2Decim != settings.m_streams[istream].m_log2Decim) || force) + { + reverseAPIKeys.append("log2Decim"); - if (m_testSourceThread != 0) { - m_testSourceThread->setFMDeviation(settings.m_fmDeviation * 100.0f); + if ((istream < m_testSourceThreads.size()) && (m_testSourceThreads[istream])) + { + m_testSourceThreads[istream]->setLog2Decimation(settings.m_streams[istream].m_log2Decim); + qDebug() << "TestMI::applySettings: set decimation to " << (1<setFcPos((int) settings.m_streams[istream].m_fcPos); + m_testSourceThreads[istream]->setFrequencyShift(frequencyShift); + qDebug() << "TestMI::applySettings:" + << " istream: " << istream + << " center freq: " << settings.m_streams[istream].m_centerFrequency << " Hz" + << " device center freq: " << deviceCenterFrequency << " Hz" + << " device sample rate: " << devSampleRate << "Hz" + << " Actual sample rate: " << devSampleRate/(1<setAmplitudeBits(settings.m_streams[istream].m_amplitudeBits); + } + } + + if ((m_settings.m_streams[istream].m_dcFactor != settings.m_streams[istream].m_dcFactor) || force) + { + reverseAPIKeys.append("dcFactor"); + + if ((istream < m_testSourceThreads.size()) && (m_testSourceThreads[istream])) { + m_testSourceThreads[istream]->setDCFactor(settings.m_streams[istream].m_dcFactor); + } + } + + if ((m_settings.m_streams[istream].m_iFactor != settings.m_streams[istream].m_iFactor) || force) + { + reverseAPIKeys.append("iFactor"); + + if ((istream < m_testSourceThreads.size()) && (m_testSourceThreads[istream])) { + m_testSourceThreads[istream]->setIFactor(settings.m_streams[istream].m_iFactor); + } + } + + if ((m_settings.m_streams[istream].m_qFactor != settings.m_streams[istream].m_qFactor) || force) + { + reverseAPIKeys.append("qFactor"); + + if ((istream < m_testSourceThreads.size()) && (m_testSourceThreads[istream])) { + m_testSourceThreads[istream]->setQFactor(settings.m_streams[istream].m_qFactor); + } + } + + if ((m_settings.m_streams[istream].m_phaseImbalance != settings.m_streams[istream].m_phaseImbalance) || force) + { + reverseAPIKeys.append("phaseImbalance"); + + if ((istream < m_testSourceThreads.size()) && (m_testSourceThreads[istream])) { + m_testSourceThreads[istream]->setPhaseImbalance(settings.m_streams[istream].m_phaseImbalance); + } + } + + if ((m_settings.m_streams[istream].m_sampleSizeIndex != settings.m_streams[istream].m_sampleSizeIndex) || force) + { + reverseAPIKeys.append("sampleSizeIndex"); + + if ((istream < m_testSourceThreads.size()) && (m_testSourceThreads[istream])) { + m_testSourceThreads[istream]->setBitSize(settings.m_streams[istream].m_sampleSizeIndex); + } + } + + if ((m_settings.m_streams[istream].m_sampleRate != settings.m_streams[istream].m_sampleRate) + || (m_settings.m_streams[istream].m_centerFrequency != settings.m_streams[istream].m_centerFrequency) + || (m_settings.m_streams[istream].m_log2Decim != settings.m_streams[istream].m_log2Decim) + || (m_settings.m_streams[istream].m_fcPos != settings.m_streams[istream].m_fcPos) || force) + { + int sampleRate = settings.m_streams[istream].m_sampleRate/(1<handleMessage(*notif); // forward to file sink + DSPDeviceMIMOEngine::SignalNotification *engineNotif = new DSPDeviceMIMOEngine::SignalNotification( + sampleRate, settings.m_streams[istream].m_centerFrequency, true, 0); + m_deviceAPI->getDeviceEngineInputMessageQueue()->push(engineNotif); + } + + if ((m_settings.m_streams[istream].m_modulationTone != settings.m_streams[istream].m_modulationTone) || force) + { + reverseAPIKeys.append("modulationTone"); + + if ((istream < m_testSourceThreads.size()) && (m_testSourceThreads[istream])) { + m_testSourceThreads[istream]->setToneFrequency(settings.m_streams[istream].m_modulationTone * 10); + } + } + + if ((m_settings.m_streams[istream].m_modulation != settings.m_streams[istream].m_modulation) || force) + { + reverseAPIKeys.append("modulation"); + + if ((istream < m_testSourceThreads.size()) && (m_testSourceThreads[istream])) + { + m_testSourceThreads[istream]->setModulation(settings.m_streams[istream].m_modulation); + + if (settings.m_streams[istream].m_modulation == TestMIStreamSettings::ModulationPattern0) { + m_testSourceThreads[istream]->setPattern0(); + } else if (settings.m_streams[istream].m_modulation == TestMIStreamSettings::ModulationPattern1) { + m_testSourceThreads[istream]->setPattern1(); + } else if (settings.m_streams[istream].m_modulation == TestMIStreamSettings::ModulationPattern2) { + m_testSourceThreads[istream]->setPattern2(); + } + } + } + + if ((m_settings.m_streams[istream].m_amModulation != settings.m_streams[istream].m_amModulation) || force) + { + reverseAPIKeys.append("amModulation"); + + if ((istream < m_testSourceThreads.size()) && (m_testSourceThreads[istream])) { + m_testSourceThreads[istream]->setAMModulation(settings.m_streams[istream].m_amModulation / 100.0f); + } + } + + if ((m_settings.m_streams[istream].m_fmDeviation != settings.m_streams[istream].m_fmDeviation) || force) + { + reverseAPIKeys.append("fmDeviation"); + + if ((istream < m_testSourceThreads.size()) && (m_testSourceThreads[istream])) { + m_testSourceThreads[istream]->setFMDeviation(settings.m_streams[istream].m_fmDeviation * 100.0f); + } + } + } // for each stream index if (settings.m_useReverseAPI) { @@ -449,7 +476,7 @@ bool TestMI::applySettings(const TestMISettings& settings, bool force) (m_settings.m_reverseAPIAddress != settings.m_reverseAPIAddress) || (m_settings.m_reverseAPIPort != settings.m_reverseAPIPort) || (m_settings.m_reverseAPIDeviceIndex != settings.m_reverseAPIDeviceIndex); - webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force); + webapiReverseSendSettings(deviceSettingsKeys, settings, fullUpdate || force); } m_settings = settings; @@ -504,62 +531,75 @@ int TestMI::webapiSettingsPutPatch( (void) errorMessage; TestMISettings settings = m_settings; - if (deviceSettingsKeys.contains("centerFrequency")) { - settings.m_centerFrequency = response.getTestMiSettings()->getCenterFrequency(); + if (deviceSettingsKeys.contains("streams")) + { + QList *streamsSettings = response.getTestMiSettings()->getStreams(); + QList::const_iterator it = streamsSettings->begin(); + + for (; it != streamsSettings->end(); ++it) + { + int istream = (*it)->getStreamIndex(); + + if (deviceSettingsKeys.contains(tr("streams[%1].centerFrequency").arg(istream))) { + settings.m_streams[istream].m_centerFrequency = (*it)->getCenterFrequency(); + } + if (deviceSettingsKeys.contains(tr("streams[%1].frequencyShift").arg(istream))) { + settings.m_streams[istream].m_frequencyShift = (*it)->getFrequencyShift(); + } + if (deviceSettingsKeys.contains(tr("streams[%1].sampleRate").arg(istream))) { + settings.m_streams[istream].m_sampleRate = (*it)->getSampleRate(); + } + if (deviceSettingsKeys.contains(tr("streams[%1].log2Decim").arg(istream))) { + settings.m_streams[istream].m_log2Decim = (*it)->getLog2Decim(); + } + if (deviceSettingsKeys.contains(tr("streams[%1].fcPos").arg(istream))) { + int fcPos = (*it)->getFcPos(); + fcPos = fcPos < 0 ? 0 : fcPos > 2 ? 2 : fcPos; + settings.m_streams[istream].m_fcPos = (TestMIStreamSettings::fcPos_t) fcPos; + } + if (deviceSettingsKeys.contains(tr("streams[%1].sampleSizeIndex").arg(istream))) { + int sampleSizeIndex = (*it)->getSampleSizeIndex(); + sampleSizeIndex = sampleSizeIndex < 0 ? 0 : sampleSizeIndex > 1 ? 2 : sampleSizeIndex; + settings.m_streams[istream].m_sampleSizeIndex = sampleSizeIndex; + } + if (deviceSettingsKeys.contains(tr("streams[%1].amplitudeBits").arg(istream))) { + settings.m_streams[istream].m_amplitudeBits = (*it)->getAmplitudeBits(); + } + if (deviceSettingsKeys.contains(tr("streams[%1].autoCorrOptions").arg(istream))) { + int autoCorrOptions = (*it)->getAutoCorrOptions(); + autoCorrOptions = autoCorrOptions < 0 ? 0 : autoCorrOptions >= TestMIStreamSettings::AutoCorrLast ? TestMIStreamSettings::AutoCorrLast-1 : autoCorrOptions; + settings.m_streams[istream].m_sampleSizeIndex = (TestMIStreamSettings::AutoCorrOptions) autoCorrOptions; + } + if (deviceSettingsKeys.contains(tr("streams[%1].modulation").arg(istream))) { + int modulation = (*it)->getModulation(); + modulation = modulation < 0 ? 0 : modulation >= TestMIStreamSettings::ModulationLast ? TestMIStreamSettings::ModulationLast-1 : modulation; + settings.m_streams[istream].m_modulation = (TestMIStreamSettings::Modulation) modulation; + } + if (deviceSettingsKeys.contains(tr("streams[%1].modulationTone").arg(istream))) { + settings.m_streams[istream].m_modulationTone = (*it)->getModulationTone(); + } + if (deviceSettingsKeys.contains(tr("streams[%1].amModulation").arg(istream))) { + settings.m_streams[istream].m_amModulation = (*it)->getAmModulation(); + }; + if (deviceSettingsKeys.contains(tr("streams[%1].fmDeviation").arg(istream))) { + settings.m_streams[istream].m_fmDeviation = (*it)->getFmDeviation(); + }; + if (deviceSettingsKeys.contains(tr("streams[%1].dcFactor").arg(istream))) { + settings.m_streams[istream].m_dcFactor = (*it)->getDcFactor(); + }; + if (deviceSettingsKeys.contains(tr("streams[%1].iFactor").arg(istream))) { + settings.m_streams[istream].m_iFactor = (*it)->getIFactor(); + }; + if (deviceSettingsKeys.contains(tr("streams[%1].qFactor").arg(istream))) { + settings.m_streams[istream].m_qFactor = (*it)->getQFactor(); + }; + if (deviceSettingsKeys.contains(tr("streams[%1].phaseImbalance").arg(istream))) { + settings.m_streams[istream].m_phaseImbalance = (*it)->getPhaseImbalance(); + }; + } + } - if (deviceSettingsKeys.contains("frequencyShift")) { - settings.m_frequencyShift = response.getTestMiSettings()->getFrequencyShift(); - } - if (deviceSettingsKeys.contains("sampleRate")) { - settings.m_sampleRate = response.getTestMiSettings()->getSampleRate(); - } - if (deviceSettingsKeys.contains("log2Decim")) { - settings.m_log2Decim = response.getTestMiSettings()->getLog2Decim(); - } - if (deviceSettingsKeys.contains("fcPos")) { - int fcPos = response.getTestMiSettings()->getFcPos(); - fcPos = fcPos < 0 ? 0 : fcPos > 2 ? 2 : fcPos; - settings.m_fcPos = (TestMISettings::fcPos_t) fcPos; - } - if (deviceSettingsKeys.contains("sampleSizeIndex")) { - int sampleSizeIndex = response.getTestMiSettings()->getSampleSizeIndex(); - sampleSizeIndex = sampleSizeIndex < 0 ? 0 : sampleSizeIndex > 1 ? 2 : sampleSizeIndex; - settings.m_sampleSizeIndex = sampleSizeIndex; - } - if (deviceSettingsKeys.contains("amplitudeBits")) { - settings.m_amplitudeBits = response.getTestMiSettings()->getAmplitudeBits(); - } - if (deviceSettingsKeys.contains("autoCorrOptions")) { - int autoCorrOptions = response.getTestMiSettings()->getAutoCorrOptions(); - autoCorrOptions = autoCorrOptions < 0 ? 0 : autoCorrOptions >= TestMISettings::AutoCorrLast ? TestMISettings::AutoCorrLast-1 : autoCorrOptions; - settings.m_sampleSizeIndex = (TestMISettings::AutoCorrOptions) autoCorrOptions; - } - if (deviceSettingsKeys.contains("modulation")) { - int modulation = response.getTestMiSettings()->getModulation(); - modulation = modulation < 0 ? 0 : modulation >= TestMISettings::ModulationLast ? TestMISettings::ModulationLast-1 : modulation; - settings.m_modulation = (TestMISettings::Modulation) modulation; - } - if (deviceSettingsKeys.contains("modulationTone")) { - settings.m_modulationTone = response.getTestMiSettings()->getModulationTone(); - } - if (deviceSettingsKeys.contains("amModulation")) { - settings.m_amModulation = response.getTestMiSettings()->getAmModulation(); - }; - if (deviceSettingsKeys.contains("fmDeviation")) { - settings.m_fmDeviation = response.getTestMiSettings()->getFmDeviation(); - }; - if (deviceSettingsKeys.contains("dcFactor")) { - settings.m_dcFactor = response.getTestMiSettings()->getDcFactor(); - }; - if (deviceSettingsKeys.contains("iFactor")) { - settings.m_iFactor = response.getTestMiSettings()->getIFactor(); - }; - if (deviceSettingsKeys.contains("qFactor")) { - settings.m_qFactor = response.getTestMiSettings()->getQFactor(); - }; - if (deviceSettingsKeys.contains("phaseImbalance")) { - settings.m_phaseImbalance = response.getTestMiSettings()->getPhaseImbalance(); - }; + if (deviceSettingsKeys.contains("fileRecordName")) { settings.m_fileRecordName = *response.getTestMiSettings()->getFileRecordName(); } @@ -591,22 +631,32 @@ int TestMI::webapiSettingsPutPatch( void TestMI::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const TestMISettings& settings) { - response.getTestMiSettings()->setCenterFrequency(settings.m_centerFrequency); - response.getTestMiSettings()->setFrequencyShift(settings.m_frequencyShift); - response.getTestMiSettings()->setSampleRate(settings.m_sampleRate); - response.getTestMiSettings()->setLog2Decim(settings.m_log2Decim); - response.getTestMiSettings()->setFcPos((int) settings.m_fcPos); - response.getTestMiSettings()->setSampleSizeIndex((int) settings.m_sampleSizeIndex); - response.getTestMiSettings()->setAmplitudeBits(settings.m_amplitudeBits); - response.getTestMiSettings()->setAutoCorrOptions((int) settings.m_autoCorrOptions); - response.getTestMiSettings()->setModulation((int) settings.m_modulation); - response.getTestMiSettings()->setModulationTone(settings.m_modulationTone); - response.getTestMiSettings()->setAmModulation(settings.m_amModulation); - response.getTestMiSettings()->setFmDeviation(settings.m_fmDeviation); - response.getTestMiSettings()->setDcFactor(settings.m_dcFactor); - response.getTestMiSettings()->setIFactor(settings.m_iFactor); - response.getTestMiSettings()->setQFactor(settings.m_qFactor); - response.getTestMiSettings()->setPhaseImbalance(settings.m_phaseImbalance); + std::vector::const_iterator it = settings.m_streams.begin(); + int istream = 0; + + for (; it != settings.m_streams.end(); ++it, istream++) + { + QList *streams = response.getTestMiSettings()->getStreams(); + streams->append(new SWGSDRangel::SWGTestMiStreamSettings); + streams->back()->init(); + streams->back()->setStreamIndex(istream); + streams->back()->setCenterFrequency(it->m_centerFrequency); + streams->back()->setFrequencyShift(it->m_frequencyShift); + streams->back()->setSampleRate(it->m_sampleRate); + streams->back()->setLog2Decim(it->m_log2Decim); + streams->back()->setFcPos((int) it->m_fcPos); + streams->back()->setSampleSizeIndex((int) it->m_sampleSizeIndex); + streams->back()->setAmplitudeBits(it->m_amplitudeBits); + streams->back()->setAutoCorrOptions((int) it->m_autoCorrOptions); + streams->back()->setModulation((int) it->m_modulation); + streams->back()->setModulationTone(it->m_modulationTone); + streams->back()->setAmModulation(it->m_amModulation); + streams->back()->setFmDeviation(it->m_fmDeviation); + streams->back()->setDcFactor(it->m_dcFactor); + streams->back()->setIFactor(it->m_iFactor); + streams->back()->setQFactor(it->m_qFactor); + streams->back()->setPhaseImbalance(it->m_phaseImbalance); + } if (response.getTestMiSettings()->getFileRecordName()) { *response.getTestMiSettings()->getFileRecordName() = settings.m_fileRecordName; @@ -626,7 +676,7 @@ void TestMI::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response response.getTestMiSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex); } -void TestMI::webapiReverseSendSettings(QList& deviceSettingsKeys, const TestMISettings& settings, bool force) +void TestMI::webapiReverseSendSettings(const DeviceSettingsKeys& deviceSettingsKeys, const TestMISettings& settings, bool force) { SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings(); swgDeviceSettings->setDirection(0); // single Rx @@ -637,55 +687,71 @@ void TestMI::webapiReverseSendSettings(QList& deviceSettingsKeys, const // transfer data that has been modified. When force is on transfer all data except reverse API data - if (deviceSettingsKeys.contains("centerFrequency") || force) { - swgTestMISettings->setCenterFrequency(settings.m_centerFrequency); + QList>::const_iterator it = deviceSettingsKeys.m_streamsSettingsKeys.begin(); + int istream = 0; + + for (; it != deviceSettingsKeys.m_streamsSettingsKeys.end(); ++it, istream++) + { + if ((it->size() > 0) || force) + { + QList *streams = swgTestMISettings->getStreams(); + streams->append(new SWGSDRangel::SWGTestMiStreamSettings); + streams->back()->init(); + streams->back()->setStreamIndex(istream); + const QList& streamSettingsKeys = *it; + + if (streamSettingsKeys.contains("centerFrequency") || force) { + streams->back()->setCenterFrequency(settings.m_streams[istream].m_centerFrequency); + } + if (streamSettingsKeys.contains("frequencyShift") || force) { + streams->back()->setFrequencyShift(settings.m_streams[istream].m_frequencyShift); + } + if (streamSettingsKeys.contains("sampleRate") || force) { + streams->back()->setSampleRate(settings.m_streams[istream].m_sampleRate); + } + if (streamSettingsKeys.contains("log2Decim") || force) { + streams->back()->setLog2Decim(settings.m_streams[istream].m_log2Decim); + } + if (streamSettingsKeys.contains("fcPos") || force) { + streams->back()->setFcPos((int) settings.m_streams[istream].m_fcPos); + } + if (streamSettingsKeys.contains("sampleSizeIndex") || force) { + streams->back()->setSampleSizeIndex(settings.m_streams[istream].m_sampleSizeIndex); + } + if (streamSettingsKeys.contains("amplitudeBits") || force) { + streams->back()->setAmplitudeBits(settings.m_streams[istream].m_amplitudeBits); + } + if (streamSettingsKeys.contains("autoCorrOptions") || force) { + streams->back()->setAutoCorrOptions((int) settings.m_streams[istream].m_sampleSizeIndex); + } + if (streamSettingsKeys.contains("modulation") || force) { + streams->back()->setModulation((int) settings.m_streams[istream].m_modulation); + } + if (streamSettingsKeys.contains("modulationTone")) { + streams->back()->setModulationTone(settings.m_streams[istream].m_modulationTone); + } + if (streamSettingsKeys.contains("amModulation") || force) { + streams->back()->setAmModulation(settings.m_streams[istream].m_amModulation); + }; + if (streamSettingsKeys.contains("fmDeviation") || force) { + streams->back()->setFmDeviation(settings.m_streams[istream].m_fmDeviation); + }; + if (streamSettingsKeys.contains("dcFactor") || force) { + streams->back()->setDcFactor(settings.m_streams[istream].m_dcFactor); + }; + if (streamSettingsKeys.contains("iFactor") || force) { + streams->back()->setIFactor(settings.m_streams[istream].m_iFactor); + }; + if (streamSettingsKeys.contains("qFactor") || force) { + streams->back()->setQFactor(settings.m_streams[istream].m_qFactor); + }; + if (streamSettingsKeys.contains("phaseImbalance") || force) { + streams->back()->setPhaseImbalance(settings.m_streams[istream].m_phaseImbalance); + }; + } } - if (deviceSettingsKeys.contains("frequencyShift") || force) { - swgTestMISettings->setFrequencyShift(settings.m_frequencyShift); - } - if (deviceSettingsKeys.contains("sampleRate") || force) { - swgTestMISettings->setSampleRate(settings.m_sampleRate); - } - if (deviceSettingsKeys.contains("log2Decim") || force) { - swgTestMISettings->setLog2Decim(settings.m_log2Decim); - } - if (deviceSettingsKeys.contains("fcPos") || force) { - swgTestMISettings->setFcPos((int) settings.m_fcPos); - } - if (deviceSettingsKeys.contains("sampleSizeIndex") || force) { - swgTestMISettings->setSampleSizeIndex(settings.m_sampleSizeIndex); - } - if (deviceSettingsKeys.contains("amplitudeBits") || force) { - swgTestMISettings->setAmplitudeBits(settings.m_amplitudeBits); - } - if (deviceSettingsKeys.contains("autoCorrOptions") || force) { - swgTestMISettings->setAutoCorrOptions((int) settings.m_sampleSizeIndex); - } - if (deviceSettingsKeys.contains("modulation") || force) { - swgTestMISettings->setModulation((int) settings.m_modulation); - } - if (deviceSettingsKeys.contains("modulationTone")) { - swgTestMISettings->setModulationTone(settings.m_modulationTone); - } - if (deviceSettingsKeys.contains("amModulation") || force) { - swgTestMISettings->setAmModulation(settings.m_amModulation); - }; - if (deviceSettingsKeys.contains("fmDeviation") || force) { - swgTestMISettings->setFmDeviation(settings.m_fmDeviation); - }; - if (deviceSettingsKeys.contains("dcFactor") || force) { - swgTestMISettings->setDcFactor(settings.m_dcFactor); - }; - if (deviceSettingsKeys.contains("iFactor") || force) { - swgTestMISettings->setIFactor(settings.m_iFactor); - }; - if (deviceSettingsKeys.contains("qFactor") || force) { - swgTestMISettings->setQFactor(settings.m_qFactor); - }; - if (deviceSettingsKeys.contains("phaseImbalance") || force) { - swgTestMISettings->setPhaseImbalance(settings.m_phaseImbalance); - }; - if (deviceSettingsKeys.contains("fileRecordName") || force) { + + if (deviceSettingsKeys.m_commonSettingsKeys.contains("fileRecordName") || force) { swgTestMISettings->setFileRecordName(new QString(settings.m_fileRecordName)); } @@ -700,8 +766,6 @@ void TestMI::webapiReverseSendSettings(QList& deviceSettingsKeys, const buffer->open((QBuffer::ReadWrite)); buffer->write(swgDeviceSettings->asJson().toUtf8()); buffer->seek(0); -// qDebug("TestMI::webapiReverseSendSettings: %s", channelSettingsURL.toStdString().c_str()); -// qDebug("TestMI::webapiReverseSendSettings: query:\n%s", swgDeviceSettings->asJson().toStdString().c_str()); // Always use PATCH to avoid passing reverse API settings m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer); diff --git a/plugins/samplemimo/testmi/testmi.h b/plugins/samplemimo/testmi/testmi.h index be13a535b..2e5be0c7c 100644 --- a/plugins/samplemimo/testmi/testmi.h +++ b/plugins/samplemimo/testmi/testmi.h @@ -142,11 +142,17 @@ public: QString& errorMessage); private: + struct DeviceSettingsKeys + { + QList m_commonSettingsKeys; + QList> m_streamsSettingsKeys; + }; + DeviceAPI *m_deviceAPI; FileRecord *m_fileSink; //!< File sink to record device I/Q output QMutex m_mutex; TestMISettings m_settings; - TestMIThread* m_testSourceThread; + std::vector m_testSourceThreads; QString m_deviceDescription; bool m_running; const QTimer& m_masterTimer; @@ -155,7 +161,7 @@ private: bool applySettings(const TestMISettings& settings, bool force); void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const TestMISettings& settings); - void webapiReverseSendSettings(QList& deviceSettingsKeys, const TestMISettings& settings, bool force); + void webapiReverseSendSettings(const DeviceSettingsKeys& deviceSettingsKeys, const TestMISettings& settings, bool force); void webapiReverseSendStartStop(bool start); private slots: diff --git a/plugins/samplemimo/testmi/testmigui.cpp b/plugins/samplemimo/testmi/testmigui.cpp index fe9ece930..68d715b5b 100644 --- a/plugins/samplemimo/testmi/testmigui.cpp +++ b/plugins/samplemimo/testmi/testmigui.cpp @@ -52,6 +52,7 @@ TestMIGui::TestMIGui(DeviceUISet *deviceUISet, QWidget* parent) : { qDebug("TestMIGui::TestMIGui"); m_sampleMIMO = m_deviceUISet->m_deviceAPI->getSampleMIMO(); + m_streamIndex = 0; ui->setupUi(this); ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); @@ -104,12 +105,12 @@ void TestMIGui::resetToDefaults() qint64 TestMIGui::getCenterFrequency() const { - return m_settings.m_centerFrequency; + return m_settings.m_streams[m_streamIndex].m_centerFrequency; } void TestMIGui::setCenterFrequency(qint64 centerFrequency) { - m_settings.m_centerFrequency = centerFrequency; + m_settings.m_streams[m_streamIndex].m_centerFrequency = centerFrequency; displaySettings(); sendSettings(); } @@ -141,25 +142,31 @@ void TestMIGui::on_startStop_toggled(bool checked) } } +void TestMIGui::on_streamIndex_currentIndexChanged(int index) +{ + m_streamIndex = index; + displaySettings(); +} + void TestMIGui::on_centerFrequency_changed(quint64 value) { - m_settings.m_centerFrequency = value * 1000; + m_settings.m_streams[m_streamIndex].m_centerFrequency = value * 1000; sendSettings(); } void TestMIGui::on_autoCorr_currentIndexChanged(int index) { - if ((index < 0) || (index > TestMISettings::AutoCorrLast)) { + if ((index < 0) || (index > TestMIStreamSettings::AutoCorrLast)) { return; } - m_settings.m_autoCorrOptions = (TestMISettings::AutoCorrOptions) index; + m_settings.m_streams[m_streamIndex].m_autoCorrOptions = (TestMIStreamSettings::AutoCorrOptions) index; sendSettings(); } void TestMIGui::on_frequencyShift_changed(qint64 value) { - m_settings.m_frequencyShift = value; + m_settings.m_streams[m_streamIndex].m_frequencyShift = value; sendSettings(); } @@ -169,7 +176,7 @@ void TestMIGui::on_decimation_currentIndexChanged(int index) return; } - m_settings.m_log2Decim = index; + m_settings.m_streams[m_streamIndex].m_log2Decim = index; sendSettings(); } @@ -179,15 +186,15 @@ void TestMIGui::on_fcPos_currentIndexChanged(int index) return; } - m_settings.m_fcPos = (TestMISettings::fcPos_t) index; + m_settings.m_streams[m_streamIndex].m_fcPos = (TestMIStreamSettings::fcPos_t) index; sendSettings(); } void TestMIGui::on_sampleRate_changed(quint64 value) { updateFrequencyShiftLimit(); - m_settings.m_frequencyShift = ui->frequencyShift->getValueNew(); - m_settings.m_sampleRate = value; + m_settings.m_streams[m_streamIndex].m_frequencyShift = ui->frequencyShift->getValueNew(); + m_settings.m_streams[m_streamIndex].m_sampleRate = value; sendSettings(); } @@ -200,8 +207,8 @@ void TestMIGui::on_sampleSize_currentIndexChanged(int index) updateAmpCoarseLimit(); updateAmpFineLimit(); displayAmplitude(); - m_settings.m_amplitudeBits = ui->amplitudeCoarse->value() * 100 + ui->amplitudeFine->value(); - m_settings.m_sampleSizeIndex = index; + m_settings.m_streams[m_streamIndex].m_amplitudeBits = ui->amplitudeCoarse->value() * 100 + ui->amplitudeFine->value(); + m_settings.m_streams[m_streamIndex].m_sampleSizeIndex = index; sendSettings(); } @@ -210,7 +217,7 @@ void TestMIGui::on_amplitudeCoarse_valueChanged(int value) (void) value; updateAmpFineLimit(); displayAmplitude(); - m_settings.m_amplitudeBits = ui->amplitudeCoarse->value() * 100 + ui->amplitudeFine->value(); + m_settings.m_streams[m_streamIndex].m_amplitudeBits = ui->amplitudeCoarse->value() * 100 + ui->amplitudeFine->value(); sendSettings(); } @@ -218,66 +225,66 @@ void TestMIGui::on_amplitudeFine_valueChanged(int value) { (void) value; displayAmplitude(); - m_settings.m_amplitudeBits = ui->amplitudeCoarse->value() * 100 + ui->amplitudeFine->value(); + m_settings.m_streams[m_streamIndex].m_amplitudeBits = ui->amplitudeCoarse->value() * 100 + ui->amplitudeFine->value(); sendSettings(); } void TestMIGui::on_modulation_currentIndexChanged(int index) { - if ((index < 0) || (index > TestMISettings::ModulationLast)) { + if ((index < 0) || (index > TestMIStreamSettings::ModulationLast)) { return; } - m_settings.m_modulation = (TestMISettings::Modulation) index; + m_settings.m_streams[m_streamIndex].m_modulation = (TestMIStreamSettings::Modulation) index; sendSettings(); } void TestMIGui::on_modulationFrequency_valueChanged(int value) { - m_settings.m_modulationTone = value; - ui->modulationFrequencyText->setText(QString("%1").arg(m_settings.m_modulationTone / 100.0, 0, 'f', 2)); + m_settings.m_streams[m_streamIndex].m_modulationTone = value; + ui->modulationFrequencyText->setText(QString("%1").arg(m_settings.m_streams[m_streamIndex].m_modulationTone / 100.0, 0, 'f', 2)); sendSettings(); } void TestMIGui::on_amModulation_valueChanged(int value) { - m_settings.m_amModulation = value; - ui->amModulationText->setText(QString("%1").arg(m_settings.m_amModulation)); + m_settings.m_streams[m_streamIndex].m_amModulation = value; + ui->amModulationText->setText(QString("%1").arg(m_settings.m_streams[m_streamIndex].m_amModulation)); sendSettings(); } void TestMIGui::on_fmDeviation_valueChanged(int value) { - m_settings.m_fmDeviation = value; - ui->fmDeviationText->setText(QString("%1").arg(m_settings.m_fmDeviation / 10.0, 0, 'f', 1)); + m_settings.m_streams[m_streamIndex].m_fmDeviation = value; + ui->fmDeviationText->setText(QString("%1").arg(m_settings.m_streams[m_streamIndex].m_fmDeviation / 10.0, 0, 'f', 1)); sendSettings(); } void TestMIGui::on_dcBias_valueChanged(int value) { ui->dcBiasText->setText(QString(tr("%1 %").arg(value))); - m_settings.m_dcFactor = value / 100.0f; + m_settings.m_streams[m_streamIndex].m_dcFactor = value / 100.0f; sendSettings(); } void TestMIGui::on_iBias_valueChanged(int value) { ui->iBiasText->setText(QString(tr("%1 %").arg(value))); - m_settings.m_iFactor = value / 100.0f; + m_settings.m_streams[m_streamIndex].m_iFactor = value / 100.0f; sendSettings(); } void TestMIGui::on_qBias_valueChanged(int value) { ui->qBiasText->setText(QString(tr("%1 %").arg(value))); - m_settings.m_qFactor = value / 100.0f; + m_settings.m_streams[m_streamIndex].m_qFactor = value / 100.0f; sendSettings(); } void TestMIGui::on_phaseImbalance_valueChanged(int value) { ui->phaseImbalanceText->setText(QString(tr("%1 %").arg(value))); - m_settings.m_phaseImbalance = value / 100.0f; + m_settings.m_streams[m_streamIndex].m_phaseImbalance = value / 100.0f; sendSettings(); } @@ -374,40 +381,41 @@ void TestMIGui::displaySettings() blockApplySettings(true); ui->sampleSize->blockSignals(true); - ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000); - ui->decimation->setCurrentIndex(m_settings.m_log2Decim); - ui->fcPos->setCurrentIndex((int) m_settings.m_fcPos); - ui->sampleRate->setValue(m_settings.m_sampleRate); + ui->streamIndex->setCurrentIndex(m_streamIndex); + ui->centerFrequency->setValue(m_settings.m_streams[m_streamIndex].m_centerFrequency / 1000); + ui->decimation->setCurrentIndex(m_settings.m_streams[m_streamIndex].m_log2Decim); + ui->fcPos->setCurrentIndex((int) m_settings.m_streams[m_streamIndex].m_fcPos); + ui->sampleRate->setValue(m_settings.m_streams[m_streamIndex].m_sampleRate); updateFrequencyShiftLimit(); - ui->frequencyShift->setValue(m_settings.m_frequencyShift); - ui->sampleSize->setCurrentIndex(m_settings.m_sampleSizeIndex); + ui->frequencyShift->setValue(m_settings.m_streams[m_streamIndex].m_frequencyShift); + ui->sampleSize->setCurrentIndex(m_settings.m_streams[m_streamIndex].m_sampleSizeIndex); updateAmpCoarseLimit(); - int amplitudeBits = m_settings.m_amplitudeBits; + int amplitudeBits = m_settings.m_streams[m_streamIndex].m_amplitudeBits; ui->amplitudeCoarse->setValue(amplitudeBits/100); updateAmpFineLimit(); ui->amplitudeFine->setValue(amplitudeBits%100); displayAmplitude(); - int dcBiasPercent = roundf(m_settings.m_dcFactor * 100.0f); + int dcBiasPercent = roundf(m_settings.m_streams[m_streamIndex].m_dcFactor * 100.0f); ui->dcBias->setValue((int) dcBiasPercent); ui->dcBiasText->setText(QString(tr("%1 %").arg(dcBiasPercent))); - int iBiasPercent = roundf(m_settings.m_iFactor * 100.0f); + int iBiasPercent = roundf(m_settings.m_streams[m_streamIndex].m_iFactor * 100.0f); ui->iBias->setValue((int) iBiasPercent); ui->iBiasText->setText(QString(tr("%1 %").arg(iBiasPercent))); - int qBiasPercent = roundf(m_settings.m_qFactor * 100.0f); + int qBiasPercent = roundf(m_settings.m_streams[m_streamIndex].m_qFactor * 100.0f); ui->qBias->setValue((int) qBiasPercent); ui->qBiasText->setText(QString(tr("%1 %").arg(qBiasPercent))); - int phaseImbalancePercent = roundf(m_settings.m_phaseImbalance * 100.0f); + int phaseImbalancePercent = roundf(m_settings.m_streams[m_streamIndex].m_phaseImbalance * 100.0f); ui->phaseImbalance->setValue((int) phaseImbalancePercent); ui->phaseImbalanceText->setText(QString(tr("%1 %").arg(phaseImbalancePercent))); - ui->autoCorr->setCurrentIndex(m_settings.m_autoCorrOptions); + ui->autoCorr->setCurrentIndex(m_settings.m_streams[m_streamIndex].m_autoCorrOptions); ui->sampleSize->blockSignals(false); - ui->modulation->setCurrentIndex((int) m_settings.m_modulation); - ui->modulationFrequency->setValue(m_settings.m_modulationTone); - ui->modulationFrequencyText->setText(QString("%1").arg(m_settings.m_modulationTone / 100.0, 0, 'f', 2)); - ui->amModulation->setValue(m_settings.m_amModulation); - ui->amModulationText->setText(QString("%1").arg(m_settings.m_amModulation)); - ui->fmDeviation->setValue(m_settings.m_fmDeviation); - ui->fmDeviationText->setText(QString("%1").arg(m_settings.m_fmDeviation / 10.0, 0, 'f', 1)); + ui->modulation->setCurrentIndex((int) m_settings.m_streams[m_streamIndex].m_modulation); + ui->modulationFrequency->setValue(m_settings.m_streams[m_streamIndex].m_modulationTone); + ui->modulationFrequencyText->setText(QString("%1").arg(m_settings.m_streams[m_streamIndex].m_modulationTone / 100.0, 0, 'f', 2)); + ui->amModulation->setValue(m_settings.m_streams[m_streamIndex].m_amModulation); + ui->amModulationText->setText(QString("%1").arg(m_settings.m_streams[m_streamIndex].m_amModulation)); + ui->fmDeviation->setValue(m_settings.m_streams[m_streamIndex].m_fmDeviation); + ui->fmDeviationText->setText(QString("%1").arg(m_settings.m_streams[m_streamIndex].m_fmDeviation / 10.0, 0, 'f', 1)); blockApplySettings(false); } diff --git a/plugins/samplemimo/testmi/testmigui.h b/plugins/samplemimo/testmi/testmigui.h index 95d6b8a64..d50184047 100644 --- a/plugins/samplemimo/testmi/testmigui.h +++ b/plugins/samplemimo/testmi/testmigui.h @@ -57,6 +57,7 @@ private: DeviceUISet* m_deviceUISet; TestMISettings m_settings; + int m_streamIndex; //!< Current stream index being dealt with QTimer m_updateTimer; QTimer m_statusTimer; bool m_doApplySettings; @@ -80,6 +81,7 @@ private: private slots: void handleInputMessages(); void on_startStop_toggled(bool checked); + void on_streamIndex_currentIndexChanged(int index); void on_centerFrequency_changed(quint64 value); void on_autoCorr_currentIndexChanged(int index); void on_frequencyShift_changed(qint64 value); diff --git a/plugins/samplemimo/testmi/testmigui.ui b/plugins/samplemimo/testmi/testmigui.ui index d03340371..a6ce09b13 100644 --- a/plugins/samplemimo/testmi/testmigui.ui +++ b/plugins/samplemimo/testmi/testmigui.ui @@ -1,7 +1,7 @@ TestMIGui - + 0 @@ -188,6 +188,107 @@ + + + + + + Stream + + + + + + + + 40 + 16777215 + + + + Stream index + + + + 0 + + + + + 1 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 16 + 0 + + + + SR + + + + + + + + 0 + 0 + + + + + 32 + 16 + + + + + Liberation Mono + 12 + + + + PointingHandCursor + + + Generator sample rate (S/s) + + + + + + + S/s + + + + + @@ -380,60 +481,6 @@ 2 - - - - - 0 - 0 - - - - - 16 - 0 - - - - SR - - - - - - - - 0 - 0 - - - - - 32 - 16 - - - - - Liberation Mono - 12 - - - - PointingHandCursor - - - Generator sample rate (S/s) - - - - - - - S/s - - - diff --git a/plugins/samplemimo/testmi/testmisettings.cpp b/plugins/samplemimo/testmi/testmisettings.cpp index d36a858c2..2b580af24 100644 --- a/plugins/samplemimo/testmi/testmisettings.cpp +++ b/plugins/samplemimo/testmi/testmisettings.cpp @@ -19,12 +19,12 @@ #include "util/simpleserializer.h" #include "testmisettings.h" -TestMISettings::TestMISettings() +TestMIStreamSettings::TestMIStreamSettings() { resetToDefaults(); } -void TestMISettings::resetToDefaults() +void TestMIStreamSettings::resetToDefaults() { m_centerFrequency = 435000*1000; m_frequencyShift = 0; @@ -42,36 +42,64 @@ void TestMISettings::resetToDefaults() m_iFactor = 0.0f; m_qFactor = 0.0f; m_phaseImbalance = 0.0f; +} + +TestMISettings::TestMISettings() +{ m_fileRecordName = ""; m_useReverseAPI = false; m_reverseAPIAddress = "127.0.0.1"; m_reverseAPIPort = 8888; m_reverseAPIDeviceIndex = 0; + m_streams.push_back(TestMIStreamSettings()); + m_streams.push_back(TestMIStreamSettings()); +} + +TestMISettings::TestMISettings(const TestMISettings& other) : + m_streams(other.m_streams) +{ + m_fileRecordName = other.m_fileRecordName; + m_useReverseAPI = other.m_useReverseAPI; + m_reverseAPIAddress = other.m_reverseAPIAddress; + m_reverseAPIPort = other.m_reverseAPIPort; + m_reverseAPIDeviceIndex = other.m_reverseAPIDeviceIndex; +} + +void TestMISettings::resetToDefaults() +{ + for (unsigned int i = 0; i < m_streams.size(); i++) { + m_streams[i].resetToDefaults(); + } } QByteArray TestMISettings::serialize() const { SimpleSerializer s(1); - s.writeS32(2, m_frequencyShift); - s.writeU32(3, m_sampleRate); - s.writeU32(4, m_log2Decim); - s.writeS32(5, (int) m_fcPos); - s.writeU32(6, m_sampleSizeIndex); - s.writeS32(7, m_amplitudeBits); - s.writeS32(8, (int) m_autoCorrOptions); - s.writeFloat(10, m_dcFactor); - s.writeFloat(11, m_iFactor); - s.writeFloat(12, m_qFactor); - s.writeFloat(13, m_phaseImbalance); - s.writeS32(14, (int) m_modulation); - s.writeS32(15, m_modulationTone); - s.writeS32(16, m_amModulation); - s.writeS32(17, m_fmDeviation); - s.writeBool(18, m_useReverseAPI); - s.writeString(19, m_reverseAPIAddress); - s.writeU32(20, m_reverseAPIPort); - s.writeU32(21, m_reverseAPIDeviceIndex); + s.writeBool(1, m_useReverseAPI); + s.writeString(2, m_reverseAPIAddress); + s.writeU32(3, m_reverseAPIPort); + s.writeU32(4, m_reverseAPIDeviceIndex); + + for (unsigned int i = 0; i < m_streams.size(); i++) + { + s.writeS32(10 + 30*i, m_streams[i].m_frequencyShift); + s.writeU32(11 + 30*i, m_streams[i].m_sampleRate); + s.writeU32(12 + 30*i, m_streams[i].m_log2Decim); + s.writeS32(13 + 30*i, (int) m_streams[i].m_fcPos); + s.writeU32(14 + 30*i, m_streams[i].m_sampleSizeIndex); + s.writeS32(15 + 30*i, m_streams[i].m_amplitudeBits); + s.writeS32(16 + 30*i, (int) m_streams[i].m_autoCorrOptions); + s.writeFloat(17 + 30*i, m_streams[i].m_dcFactor); + s.writeFloat(18 + 30*i, m_streams[i].m_iFactor); + s.writeFloat(19 + 30*i, m_streams[i].m_qFactor); + s.writeFloat(20 + 30*i, m_streams[i].m_phaseImbalance); + s.writeS32(21 + 30*i, (int) m_streams[i].m_modulation); + s.writeS32(22 + 30*i, m_streams[i].m_modulationTone); + s.writeS32(23 + 30*i, m_streams[i].m_amModulation); + s.writeS32(24 + 30*i, m_streams[i].m_fmDeviation); + } + return s.final(); } @@ -90,40 +118,9 @@ bool TestMISettings::deserialize(const QByteArray& data) int intval; uint32_t utmp; - d.readS32(2, &m_frequencyShift, 0); - d.readU32(3, &m_sampleRate, 768*1000); - d.readU32(4, &m_log2Decim, 4); - d.readS32(5, &intval, 0); - m_fcPos = (fcPos_t) intval; - d.readU32(6, &m_sampleSizeIndex, 0); - d.readS32(7, &m_amplitudeBits, 128); - d.readS32(8, &intval, 0); - - if (intval < 0 || intval > (int) AutoCorrLast) { - m_autoCorrOptions = AutoCorrNone; - } else { - m_autoCorrOptions = (AutoCorrOptions) intval; - } - - d.readFloat(10, &m_dcFactor, 0.0f); - d.readFloat(11, &m_iFactor, 0.0f); - d.readFloat(12, &m_qFactor, 0.0f); - d.readFloat(13, &m_phaseImbalance, 0.0f); - d.readS32(14, &intval, 0); - - if (intval < 0 || intval > (int) ModulationLast) { - m_modulation = ModulationNone; - } else { - m_modulation = (Modulation) intval; - } - - d.readS32(15, &m_modulationTone, 44); - d.readS32(16, &m_amModulation, 50); - d.readS32(17, &m_fmDeviation, 50); - - d.readBool(18, &m_useReverseAPI, false); - d.readString(19, &m_reverseAPIAddress, "127.0.0.1"); - d.readU32(20, &utmp, 0); + d.readBool(1, &m_useReverseAPI, false); + d.readString(2, &m_reverseAPIAddress, "127.0.0.1"); + d.readU32(3, &utmp, 0); if ((utmp > 1023) && (utmp < 65535)) { m_reverseAPIPort = utmp; @@ -131,9 +128,43 @@ bool TestMISettings::deserialize(const QByteArray& data) m_reverseAPIPort = 8888; } - d.readU32(21, &utmp, 0); + d.readU32(4, &utmp, 0); m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp; + for (unsigned int i = 0; i < m_streams.size(); i++) + { + d.readS32(10 + 30*i, &m_streams[i].m_frequencyShift, 0); + d.readU32(11 + 30*i, &m_streams[i].m_sampleRate, 768*1000); + d.readU32(12 + 30*i, &m_streams[i].m_log2Decim, 4); + d.readS32(13 + 30*i, &intval, 0); + m_streams[i].m_fcPos = (TestMIStreamSettings::fcPos_t) intval; + d.readU32(14 + 30*i, &m_streams[i].m_sampleSizeIndex, 0); + d.readS32(15 + 30*i, &m_streams[i].m_amplitudeBits, 128); + d.readS32(16 + 30*i, &intval, 0); + + if (intval < 0 || intval > (int) TestMIStreamSettings::AutoCorrLast) { + m_streams[i].m_autoCorrOptions = TestMIStreamSettings::AutoCorrNone; + } else { + m_streams[i].m_autoCorrOptions = (TestMIStreamSettings::AutoCorrOptions) intval; + } + + d.readFloat(17 + 30*i, &m_streams[i].m_dcFactor, 0.0f); + d.readFloat(18 + 30*i, &m_streams[i].m_iFactor, 0.0f); + d.readFloat(19 + 30*i, &m_streams[i].m_qFactor, 0.0f); + d.readFloat(20 + 30*i, &m_streams[i].m_phaseImbalance, 0.0f); + d.readS32(21 + 30*i, &intval, 0); + + if (intval < 0 || intval > (int) TestMIStreamSettings::ModulationLast) { + m_streams[i].m_modulation = TestMIStreamSettings::ModulationNone; + } else { + m_streams[i].m_modulation = (TestMIStreamSettings::Modulation) intval; + } + + d.readS32(22 + 30*i, &m_streams[i].m_modulationTone, 44); + d.readS32(23 + 30*i, &m_streams[i].m_amModulation, 50); + d.readS32(24 + 30*i, &m_streams[i].m_fmDeviation, 50); + } + return true; } else diff --git a/plugins/samplemimo/testmi/testmisettings.h b/plugins/samplemimo/testmi/testmisettings.h index 9a5daa8be..bf7da4265 100644 --- a/plugins/samplemimo/testmi/testmisettings.h +++ b/plugins/samplemimo/testmi/testmisettings.h @@ -20,7 +20,7 @@ #include -struct TestMISettings { +struct TestMIStreamSettings { typedef enum { FC_POS_INFRA = 0, FC_POS_SUPRA, @@ -60,20 +60,25 @@ struct TestMISettings { float m_iFactor; //!< -1.0 < x < 1.0 float m_qFactor; //!< -1.0 < x < 1.0 float m_phaseImbalance; //!< -1.0 < x < 1.0 + + TestMIStreamSettings(); + void resetToDefaults(); +}; + +struct TestMISettings { QString m_fileRecordName; bool m_useReverseAPI; QString m_reverseAPIAddress; uint16_t m_reverseAPIPort; uint16_t m_reverseAPIDeviceIndex; + std::vector m_streams; TestMISettings(); + TestMISettings(const TestMISettings& other); void resetToDefaults(); QByteArray serialize() const; bool deserialize(const QByteArray& data); }; - - - #endif /* _TESTMI_TESTMISETTINGS_H_ */ diff --git a/plugins/samplemimo/testmi/testmithread.cpp b/plugins/samplemimo/testmi/testmithread.cpp index 02aea93ce..bb06a9085 100644 --- a/plugins/samplemimo/testmi/testmithread.cpp +++ b/plugins/samplemimo/testmi/testmithread.cpp @@ -38,7 +38,7 @@ TestMIThread::TestMIThread(SampleSinkFifo* sampleFifo, QObject* parent) : m_sampleFifo(sampleFifo), m_frequencyShift(0), m_toneFrequency(440), - m_modulation(TestMISettings::ModulationNone), + m_modulation(TestMIStreamSettings::ModulationNone), m_amModulation(0.5f), m_fmDeviationUnit(0.0f), m_fmPhasor(0.0f), @@ -176,7 +176,7 @@ void TestMIThread::setToneFrequency(int toneFrequency) m_toneNco.setFreq(toneFrequency, m_samplerate); } -void TestMIThread::setModulation(TestMISettings::Modulation modulation) +void TestMIThread::setModulation(TestMIStreamSettings::Modulation modulation) { m_modulation = modulation; } @@ -247,7 +247,7 @@ void TestMIThread::generate(quint32 chunksize) { switch (m_modulation) { - case TestMISettings::ModulationAM: + case TestMIStreamSettings::ModulationAM: { Complex c = m_nco.nextIQ(); Real t, re, im; @@ -259,7 +259,7 @@ void TestMIThread::generate(quint32 chunksize) m_buf[i++] = (int16_t) (im * (float) m_amplitudeBitsQ); } break; - case TestMISettings::ModulationFM: + case TestMIStreamSettings::ModulationFM: { Complex c = m_nco.nextIQ(); Real t, re, im; @@ -272,7 +272,7 @@ void TestMIThread::generate(quint32 chunksize) m_buf[i++] = (int16_t) (im * (float) m_amplitudeBitsQ); } break; - case TestMISettings::ModulationPattern0: // binary pattern + case TestMIStreamSettings::ModulationPattern0: // binary pattern { if (m_pulseSampleCount < m_pulseWidth) // sync pattern: 0 { @@ -314,7 +314,7 @@ void TestMIThread::generate(quint32 chunksize) } } break; - case TestMISettings::ModulationPattern1: // sawtooth pattern + case TestMIStreamSettings::ModulationPattern1: // sawtooth pattern { Real re, im; re = (float) (m_pulseWidth - m_pulseSampleCount) / (float) m_pulseWidth; @@ -329,7 +329,7 @@ void TestMIThread::generate(quint32 chunksize) } } break; - case TestMISettings::ModulationPattern2: // 50% duty cycle square pattern + case TestMIStreamSettings::ModulationPattern2: // 50% duty cycle square pattern { if (m_pulseSampleCount < m_pulseWidth) // 1 { @@ -347,7 +347,7 @@ void TestMIThread::generate(quint32 chunksize) } } break; - case TestMISettings::ModulationNone: + case TestMIStreamSettings::ModulationNone: default: { Complex c = m_nco.nextIQ(m_phaseImbalance); diff --git a/plugins/samplemimo/testmi/testmithread.h b/plugins/samplemimo/testmi/testmithread.h index 27f094c83..2df410ae1 100644 --- a/plugins/samplemimo/testmi/testmithread.h +++ b/plugins/samplemimo/testmi/testmithread.h @@ -73,7 +73,7 @@ public: void setPhaseImbalance(float phaseImbalance); void setFrequencyShift(int shift); void setToneFrequency(int toneFrequency); - void setModulation(TestMISettings::Modulation modulation); + void setModulation(TestMIStreamSettings::Modulation modulation); void setAMModulation(float amModulation); void setFMDeviation(float deviation); void setPattern0(); @@ -94,7 +94,7 @@ private: NCOF m_toneNco; int m_frequencyShift; int m_toneFrequency; - TestMISettings::Modulation m_modulation; + TestMIStreamSettings::Modulation m_modulation; float m_amModulation; float m_fmDeviationUnit; float m_fmPhasor; diff --git a/sdrbase/resources/webapi/doc/html2/index.html b/sdrbase/resources/webapi/doc/html2/index.html index b840b4e26..369d948b9 100644 --- a/sdrbase/resources/webapi/doc/html2/index.html +++ b/sdrbase/resources/webapi/doc/html2/index.html @@ -5216,6 +5216,38 @@ margin-bottom: 20px; }; defs.TestMISettings = { "properties" : { + "fileRecordName" : { + "type" : "string" + }, + "useReverseAPI" : { + "type" : "integer", + "description" : "Synchronize with reverse API (1 for yes, 0 for no)" + }, + "reverseAPIAddress" : { + "type" : "string" + }, + "reverseAPIPort" : { + "type" : "integer" + }, + "reverseAPIDeviceIndex" : { + "type" : "integer" + }, + "streams" : { + "type" : "array", + "description" : "Settings for each of the streams", + "items" : { + "$ref" : "#/definitions/TestMiStreamSettings" + } + } + }, + "description" : "TestMISettings" +}; + defs.TestMiStreamSettings = { + "properties" : { + "streamIndex" : { + "type" : "integer", + "description" : "Index of the stream to which the settings apply" + }, "centerFrequency" : { "type" : "integer", "format" : "uint64" @@ -5268,25 +5300,9 @@ margin-bottom: 20px; "phaseImbalance" : { "type" : "number", "format" : "float" - }, - "fileRecordName" : { - "type" : "string" - }, - "useReverseAPI" : { - "type" : "integer", - "description" : "Synchronize with reverse API (1 for yes, 0 for no)" - }, - "reverseAPIAddress" : { - "type" : "string" - }, - "reverseAPIPort" : { - "type" : "integer" - }, - "reverseAPIDeviceIndex" : { - "type" : "integer" } }, - "description" : "TestSourceMI" + "description" : "TestMiStreamSettings" }; defs.TestSourceSettings = { "properties" : { @@ -25084,7 +25100,7 @@ except ApiException as e:
- Generated 2019-05-20T16:12:41.467+02:00 + Generated 2019-05-25T21:27:31.978+02:00
diff --git a/sdrbase/resources/webapi/doc/swagger/include/TestMI.yaml b/sdrbase/resources/webapi/doc/swagger/include/TestMI.yaml index 16008a5e8..0c8c3a481 100644 --- a/sdrbase/resources/webapi/doc/swagger/include/TestMI.yaml +++ b/sdrbase/resources/webapi/doc/swagger/include/TestMI.yaml @@ -1,43 +1,6 @@ TestMISettings: - description: TestSourceMI + description: TestMISettings properties: - centerFrequency: - type: integer - format: uint64 - frequencyShift: - type: integer - sampleRate: - type: integer - log2Decim: - type: integer - fcPos: - type: integer - sampleSizeIndex: - type: integer - amplitudeBits: - type: integer - autoCorrOptions: - type: integer - modulation: - type: integer - modulationTone: - type: integer - amModulation: - type: integer - fmDeviation: - type: integer - dcFactor: - type: number - format: float - iFactor: - type: number - format: float - qFactor: - type: number - format: float - phaseImbalance: - type: number - format: float fileRecordName: type: string useReverseAPI: @@ -49,3 +12,53 @@ TestMISettings: type: integer reverseAPIDeviceIndex: type: integer + streams: + description: Settings for each of the streams + type: array + items: + $ref: "#/definitions/TestMiStreamSettings" + +definitions: + TestMiStreamSettings: + description: TestMiStreamSettings + properties: + streamIndex: + description: Index of the stream to which the settings apply + type: integer + centerFrequency: + type: integer + format: uint64 + frequencyShift: + type: integer + sampleRate: + type: integer + log2Decim: + type: integer + fcPos: + type: integer + sampleSizeIndex: + type: integer + amplitudeBits: + type: integer + autoCorrOptions: + type: integer + modulation: + type: integer + modulationTone: + type: integer + amModulation: + type: integer + fmDeviation: + type: integer + dcFactor: + type: number + format: float + iFactor: + type: number + format: float + qFactor: + type: number + format: float + phaseImbalance: + type: number + format: float diff --git a/sdrbase/webapi/webapirequestmapper.cpp b/sdrbase/webapi/webapirequestmapper.cpp index 3e9530e63..3aeeed1ae 100644 --- a/sdrbase/webapi/webapirequestmapper.cpp +++ b/sdrbase/webapi/webapirequestmapper.cpp @@ -2090,6 +2090,27 @@ bool WebAPIRequestMapper::validateDeviceSettings( return false; } } + else if ((*deviceHwType == "TestMI") && (deviceSettings.getDirection() == 2)) + { + if (jsonObject.contains("TestMISettings") && jsonObject["TestMISettings"].isObject()) + { + QJsonObject testMISettingsJsonObject = jsonObject["TestMISettings"].toObject(); + deviceSettingsKeys = testMISettingsJsonObject.keys(); + + if (deviceSettingsKeys.contains("streams") && testMISettingsJsonObject["streams"].isArray()) + { + appendSettingsArrayKeys(testMISettingsJsonObject, "streams", deviceSettingsKeys); + } + + deviceSettings.setTestMiSettings(new SWGSDRangel::SWGTestMISettings()); + deviceSettings.getTestMiSettings()->fromJsonObject(testMISettingsJsonObject); + return true; + } + else + { + return false; + } + } else if ((*deviceHwType == "XTRX") && (deviceSettings.getDirection() == 0)) { if (jsonObject.contains("xtrxInputSettings") && jsonObject["xtrxInputSettings"].isObject()) @@ -2595,6 +2616,30 @@ void WebAPIRequestMapper::appendSettingsSubKeys( } } +void WebAPIRequestMapper::appendSettingsArrayKeys( + const QJsonObject& parentSettingsJsonObject, + const QString& parentKey, + QStringList& keyList) +{ + QJsonArray streams = parentSettingsJsonObject[parentKey].toArray(); + + for (int istream = 0; istream < streams.count(); istream++) + { + QJsonValue v = streams.takeAt(istream); + + if (v.isObject()) + { + QJsonObject streamSettingsJsonObject = v.toObject(); + QStringList streamSettingsKeys = streamSettingsJsonObject.keys(); + + for (int i = 0; i < streamSettingsKeys.size(); i++) { + keyList.append(tr("streams[%1].%2").arg(istream).arg(streamSettingsKeys[i])); + } + } + } +} + + void WebAPIRequestMapper::resetDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings) { deviceSettings.cleanup(); diff --git a/sdrbase/webapi/webapirequestmapper.h b/sdrbase/webapi/webapirequestmapper.h index b506a75a7..3753b80aa 100644 --- a/sdrbase/webapi/webapirequestmapper.h +++ b/sdrbase/webapi/webapirequestmapper.h @@ -92,6 +92,11 @@ private: const QString& parentKey, QStringList& keyList); + void appendSettingsArrayKeys( + const QJsonObject& parentSettingsJsonObject, + const QString& parentKey, + QStringList& keyList); + bool parseJsonBody(QString& jsonStr, QJsonObject& jsonObject, qtwebapp::HttpResponse& response); void resetDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings); diff --git a/swagger/sdrangel/api/swagger/include/TestMI.yaml b/swagger/sdrangel/api/swagger/include/TestMI.yaml index 16008a5e8..0c8c3a481 100644 --- a/swagger/sdrangel/api/swagger/include/TestMI.yaml +++ b/swagger/sdrangel/api/swagger/include/TestMI.yaml @@ -1,43 +1,6 @@ TestMISettings: - description: TestSourceMI + description: TestMISettings properties: - centerFrequency: - type: integer - format: uint64 - frequencyShift: - type: integer - sampleRate: - type: integer - log2Decim: - type: integer - fcPos: - type: integer - sampleSizeIndex: - type: integer - amplitudeBits: - type: integer - autoCorrOptions: - type: integer - modulation: - type: integer - modulationTone: - type: integer - amModulation: - type: integer - fmDeviation: - type: integer - dcFactor: - type: number - format: float - iFactor: - type: number - format: float - qFactor: - type: number - format: float - phaseImbalance: - type: number - format: float fileRecordName: type: string useReverseAPI: @@ -49,3 +12,53 @@ TestMISettings: type: integer reverseAPIDeviceIndex: type: integer + streams: + description: Settings for each of the streams + type: array + items: + $ref: "#/definitions/TestMiStreamSettings" + +definitions: + TestMiStreamSettings: + description: TestMiStreamSettings + properties: + streamIndex: + description: Index of the stream to which the settings apply + type: integer + centerFrequency: + type: integer + format: uint64 + frequencyShift: + type: integer + sampleRate: + type: integer + log2Decim: + type: integer + fcPos: + type: integer + sampleSizeIndex: + type: integer + amplitudeBits: + type: integer + autoCorrOptions: + type: integer + modulation: + type: integer + modulationTone: + type: integer + amModulation: + type: integer + fmDeviation: + type: integer + dcFactor: + type: number + format: float + iFactor: + type: number + format: float + qFactor: + type: number + format: float + phaseImbalance: + type: number + format: float diff --git a/swagger/sdrangel/code/html2/index.html b/swagger/sdrangel/code/html2/index.html index b840b4e26..369d948b9 100644 --- a/swagger/sdrangel/code/html2/index.html +++ b/swagger/sdrangel/code/html2/index.html @@ -5216,6 +5216,38 @@ margin-bottom: 20px; }; defs.TestMISettings = { "properties" : { + "fileRecordName" : { + "type" : "string" + }, + "useReverseAPI" : { + "type" : "integer", + "description" : "Synchronize with reverse API (1 for yes, 0 for no)" + }, + "reverseAPIAddress" : { + "type" : "string" + }, + "reverseAPIPort" : { + "type" : "integer" + }, + "reverseAPIDeviceIndex" : { + "type" : "integer" + }, + "streams" : { + "type" : "array", + "description" : "Settings for each of the streams", + "items" : { + "$ref" : "#/definitions/TestMiStreamSettings" + } + } + }, + "description" : "TestMISettings" +}; + defs.TestMiStreamSettings = { + "properties" : { + "streamIndex" : { + "type" : "integer", + "description" : "Index of the stream to which the settings apply" + }, "centerFrequency" : { "type" : "integer", "format" : "uint64" @@ -5268,25 +5300,9 @@ margin-bottom: 20px; "phaseImbalance" : { "type" : "number", "format" : "float" - }, - "fileRecordName" : { - "type" : "string" - }, - "useReverseAPI" : { - "type" : "integer", - "description" : "Synchronize with reverse API (1 for yes, 0 for no)" - }, - "reverseAPIAddress" : { - "type" : "string" - }, - "reverseAPIPort" : { - "type" : "integer" - }, - "reverseAPIDeviceIndex" : { - "type" : "integer" } }, - "description" : "TestSourceMI" + "description" : "TestMiStreamSettings" }; defs.TestSourceSettings = { "properties" : { @@ -25084,7 +25100,7 @@ except ApiException as e:
- Generated 2019-05-20T16:12:41.467+02:00 + Generated 2019-05-25T21:27:31.978+02:00
diff --git a/swagger/sdrangel/code/qt5/client/SWGModelFactory.h b/swagger/sdrangel/code/qt5/client/SWGModelFactory.h index 45f07d9fc..b3f4afdd6 100644 --- a/swagger/sdrangel/code/qt5/client/SWGModelFactory.h +++ b/swagger/sdrangel/code/qt5/client/SWGModelFactory.h @@ -133,6 +133,7 @@ #include "SWGSoapySDRReport.h" #include "SWGSuccessResponse.h" #include "SWGTestMISettings.h" +#include "SWGTestMiStreamSettings.h" #include "SWGTestSourceSettings.h" #include "SWGUDPSinkReport.h" #include "SWGUDPSinkSettings.h" @@ -507,6 +508,9 @@ namespace SWGSDRangel { if(QString("SWGTestMISettings").compare(type) == 0) { return new SWGTestMISettings(); } + if(QString("SWGTestMiStreamSettings").compare(type) == 0) { + return new SWGTestMiStreamSettings(); + } if(QString("SWGTestSourceSettings").compare(type) == 0) { return new SWGTestSourceSettings(); } diff --git a/swagger/sdrangel/code/qt5/client/SWGTestMISettings.cpp b/swagger/sdrangel/code/qt5/client/SWGTestMISettings.cpp index b77b161ff..91bd8a91d 100644 --- a/swagger/sdrangel/code/qt5/client/SWGTestMISettings.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGTestMISettings.cpp @@ -28,38 +28,6 @@ SWGTestMISettings::SWGTestMISettings(QString* json) { } SWGTestMISettings::SWGTestMISettings() { - center_frequency = 0; - m_center_frequency_isSet = false; - frequency_shift = 0; - m_frequency_shift_isSet = false; - sample_rate = 0; - m_sample_rate_isSet = false; - log2_decim = 0; - m_log2_decim_isSet = false; - fc_pos = 0; - m_fc_pos_isSet = false; - sample_size_index = 0; - m_sample_size_index_isSet = false; - amplitude_bits = 0; - m_amplitude_bits_isSet = false; - auto_corr_options = 0; - m_auto_corr_options_isSet = false; - modulation = 0; - m_modulation_isSet = false; - modulation_tone = 0; - m_modulation_tone_isSet = false; - am_modulation = 0; - m_am_modulation_isSet = false; - fm_deviation = 0; - m_fm_deviation_isSet = false; - dc_factor = 0.0f; - m_dc_factor_isSet = false; - i_factor = 0.0f; - m_i_factor_isSet = false; - q_factor = 0.0f; - m_q_factor_isSet = false; - phase_imbalance = 0.0f; - m_phase_imbalance_isSet = false; file_record_name = nullptr; m_file_record_name_isSet = false; use_reverse_api = 0; @@ -70,6 +38,8 @@ SWGTestMISettings::SWGTestMISettings() { m_reverse_api_port_isSet = false; reverse_api_device_index = 0; m_reverse_api_device_index_isSet = false; + streams = nullptr; + m_streams_isSet = false; } SWGTestMISettings::~SWGTestMISettings() { @@ -78,38 +48,6 @@ SWGTestMISettings::~SWGTestMISettings() { void SWGTestMISettings::init() { - center_frequency = 0; - m_center_frequency_isSet = false; - frequency_shift = 0; - m_frequency_shift_isSet = false; - sample_rate = 0; - m_sample_rate_isSet = false; - log2_decim = 0; - m_log2_decim_isSet = false; - fc_pos = 0; - m_fc_pos_isSet = false; - sample_size_index = 0; - m_sample_size_index_isSet = false; - amplitude_bits = 0; - m_amplitude_bits_isSet = false; - auto_corr_options = 0; - m_auto_corr_options_isSet = false; - modulation = 0; - m_modulation_isSet = false; - modulation_tone = 0; - m_modulation_tone_isSet = false; - am_modulation = 0; - m_am_modulation_isSet = false; - fm_deviation = 0; - m_fm_deviation_isSet = false; - dc_factor = 0.0f; - m_dc_factor_isSet = false; - i_factor = 0.0f; - m_i_factor_isSet = false; - q_factor = 0.0f; - m_q_factor_isSet = false; - phase_imbalance = 0.0f; - m_phase_imbalance_isSet = false; file_record_name = new QString(""); m_file_record_name_isSet = false; use_reverse_api = 0; @@ -120,26 +58,12 @@ SWGTestMISettings::init() { m_reverse_api_port_isSet = false; reverse_api_device_index = 0; m_reverse_api_device_index_isSet = false; + streams = new QList(); + m_streams_isSet = false; } void SWGTestMISettings::cleanup() { - - - - - - - - - - - - - - - - if(file_record_name != nullptr) { delete file_record_name; } @@ -149,6 +73,13 @@ SWGTestMISettings::cleanup() { } + if(streams != nullptr) { + auto arr = streams; + for(auto o: *arr) { + delete o; + } + delete streams; + } } SWGTestMISettings* @@ -162,38 +93,6 @@ SWGTestMISettings::fromJson(QString &json) { void SWGTestMISettings::fromJsonObject(QJsonObject &pJson) { - ::SWGSDRangel::setValue(¢er_frequency, pJson["centerFrequency"], "qint32", ""); - - ::SWGSDRangel::setValue(&frequency_shift, pJson["frequencyShift"], "qint32", ""); - - ::SWGSDRangel::setValue(&sample_rate, pJson["sampleRate"], "qint32", ""); - - ::SWGSDRangel::setValue(&log2_decim, pJson["log2Decim"], "qint32", ""); - - ::SWGSDRangel::setValue(&fc_pos, pJson["fcPos"], "qint32", ""); - - ::SWGSDRangel::setValue(&sample_size_index, pJson["sampleSizeIndex"], "qint32", ""); - - ::SWGSDRangel::setValue(&litude_bits, pJson["amplitudeBits"], "qint32", ""); - - ::SWGSDRangel::setValue(&auto_corr_options, pJson["autoCorrOptions"], "qint32", ""); - - ::SWGSDRangel::setValue(&modulation, pJson["modulation"], "qint32", ""); - - ::SWGSDRangel::setValue(&modulation_tone, pJson["modulationTone"], "qint32", ""); - - ::SWGSDRangel::setValue(&am_modulation, pJson["amModulation"], "qint32", ""); - - ::SWGSDRangel::setValue(&fm_deviation, pJson["fmDeviation"], "qint32", ""); - - ::SWGSDRangel::setValue(&dc_factor, pJson["dcFactor"], "float", ""); - - ::SWGSDRangel::setValue(&i_factor, pJson["iFactor"], "float", ""); - - ::SWGSDRangel::setValue(&q_factor, pJson["qFactor"], "float", ""); - - ::SWGSDRangel::setValue(&phase_imbalance, pJson["phaseImbalance"], "float", ""); - ::SWGSDRangel::setValue(&file_record_name, pJson["fileRecordName"], "QString", "QString"); ::SWGSDRangel::setValue(&use_reverse_api, pJson["useReverseAPI"], "qint32", ""); @@ -204,6 +103,8 @@ SWGTestMISettings::fromJsonObject(QJsonObject &pJson) { ::SWGSDRangel::setValue(&reverse_api_device_index, pJson["reverseAPIDeviceIndex"], "qint32", ""); + + ::SWGSDRangel::setValue(&streams, pJson["streams"], "QList", "SWGTestMiStreamSettings"); } QString @@ -220,54 +121,6 @@ SWGTestMISettings::asJson () QJsonObject* SWGTestMISettings::asJsonObject() { QJsonObject* obj = new QJsonObject(); - if(m_center_frequency_isSet){ - obj->insert("centerFrequency", QJsonValue(center_frequency)); - } - if(m_frequency_shift_isSet){ - obj->insert("frequencyShift", QJsonValue(frequency_shift)); - } - if(m_sample_rate_isSet){ - obj->insert("sampleRate", QJsonValue(sample_rate)); - } - if(m_log2_decim_isSet){ - obj->insert("log2Decim", QJsonValue(log2_decim)); - } - if(m_fc_pos_isSet){ - obj->insert("fcPos", QJsonValue(fc_pos)); - } - if(m_sample_size_index_isSet){ - obj->insert("sampleSizeIndex", QJsonValue(sample_size_index)); - } - if(m_amplitude_bits_isSet){ - obj->insert("amplitudeBits", QJsonValue(amplitude_bits)); - } - if(m_auto_corr_options_isSet){ - obj->insert("autoCorrOptions", QJsonValue(auto_corr_options)); - } - if(m_modulation_isSet){ - obj->insert("modulation", QJsonValue(modulation)); - } - if(m_modulation_tone_isSet){ - obj->insert("modulationTone", QJsonValue(modulation_tone)); - } - if(m_am_modulation_isSet){ - obj->insert("amModulation", QJsonValue(am_modulation)); - } - if(m_fm_deviation_isSet){ - obj->insert("fmDeviation", QJsonValue(fm_deviation)); - } - if(m_dc_factor_isSet){ - obj->insert("dcFactor", QJsonValue(dc_factor)); - } - if(m_i_factor_isSet){ - obj->insert("iFactor", QJsonValue(i_factor)); - } - if(m_q_factor_isSet){ - obj->insert("qFactor", QJsonValue(q_factor)); - } - if(m_phase_imbalance_isSet){ - obj->insert("phaseImbalance", QJsonValue(phase_imbalance)); - } if(file_record_name != nullptr && *file_record_name != QString("")){ toJsonValue(QString("fileRecordName"), file_record_name, obj, QString("QString")); } @@ -283,170 +136,13 @@ SWGTestMISettings::asJsonObject() { if(m_reverse_api_device_index_isSet){ obj->insert("reverseAPIDeviceIndex", QJsonValue(reverse_api_device_index)); } + if(streams->size() > 0){ + toJsonArray((QList*)streams, obj, "streams", "SWGTestMiStreamSettings"); + } return obj; } -qint32 -SWGTestMISettings::getCenterFrequency() { - return center_frequency; -} -void -SWGTestMISettings::setCenterFrequency(qint32 center_frequency) { - this->center_frequency = center_frequency; - this->m_center_frequency_isSet = true; -} - -qint32 -SWGTestMISettings::getFrequencyShift() { - return frequency_shift; -} -void -SWGTestMISettings::setFrequencyShift(qint32 frequency_shift) { - this->frequency_shift = frequency_shift; - this->m_frequency_shift_isSet = true; -} - -qint32 -SWGTestMISettings::getSampleRate() { - return sample_rate; -} -void -SWGTestMISettings::setSampleRate(qint32 sample_rate) { - this->sample_rate = sample_rate; - this->m_sample_rate_isSet = true; -} - -qint32 -SWGTestMISettings::getLog2Decim() { - return log2_decim; -} -void -SWGTestMISettings::setLog2Decim(qint32 log2_decim) { - this->log2_decim = log2_decim; - this->m_log2_decim_isSet = true; -} - -qint32 -SWGTestMISettings::getFcPos() { - return fc_pos; -} -void -SWGTestMISettings::setFcPos(qint32 fc_pos) { - this->fc_pos = fc_pos; - this->m_fc_pos_isSet = true; -} - -qint32 -SWGTestMISettings::getSampleSizeIndex() { - return sample_size_index; -} -void -SWGTestMISettings::setSampleSizeIndex(qint32 sample_size_index) { - this->sample_size_index = sample_size_index; - this->m_sample_size_index_isSet = true; -} - -qint32 -SWGTestMISettings::getAmplitudeBits() { - return amplitude_bits; -} -void -SWGTestMISettings::setAmplitudeBits(qint32 amplitude_bits) { - this->amplitude_bits = amplitude_bits; - this->m_amplitude_bits_isSet = true; -} - -qint32 -SWGTestMISettings::getAutoCorrOptions() { - return auto_corr_options; -} -void -SWGTestMISettings::setAutoCorrOptions(qint32 auto_corr_options) { - this->auto_corr_options = auto_corr_options; - this->m_auto_corr_options_isSet = true; -} - -qint32 -SWGTestMISettings::getModulation() { - return modulation; -} -void -SWGTestMISettings::setModulation(qint32 modulation) { - this->modulation = modulation; - this->m_modulation_isSet = true; -} - -qint32 -SWGTestMISettings::getModulationTone() { - return modulation_tone; -} -void -SWGTestMISettings::setModulationTone(qint32 modulation_tone) { - this->modulation_tone = modulation_tone; - this->m_modulation_tone_isSet = true; -} - -qint32 -SWGTestMISettings::getAmModulation() { - return am_modulation; -} -void -SWGTestMISettings::setAmModulation(qint32 am_modulation) { - this->am_modulation = am_modulation; - this->m_am_modulation_isSet = true; -} - -qint32 -SWGTestMISettings::getFmDeviation() { - return fm_deviation; -} -void -SWGTestMISettings::setFmDeviation(qint32 fm_deviation) { - this->fm_deviation = fm_deviation; - this->m_fm_deviation_isSet = true; -} - -float -SWGTestMISettings::getDcFactor() { - return dc_factor; -} -void -SWGTestMISettings::setDcFactor(float dc_factor) { - this->dc_factor = dc_factor; - this->m_dc_factor_isSet = true; -} - -float -SWGTestMISettings::getIFactor() { - return i_factor; -} -void -SWGTestMISettings::setIFactor(float i_factor) { - this->i_factor = i_factor; - this->m_i_factor_isSet = true; -} - -float -SWGTestMISettings::getQFactor() { - return q_factor; -} -void -SWGTestMISettings::setQFactor(float q_factor) { - this->q_factor = q_factor; - this->m_q_factor_isSet = true; -} - -float -SWGTestMISettings::getPhaseImbalance() { - return phase_imbalance; -} -void -SWGTestMISettings::setPhaseImbalance(float phase_imbalance) { - this->phase_imbalance = phase_imbalance; - this->m_phase_imbalance_isSet = true; -} - QString* SWGTestMISettings::getFileRecordName() { return file_record_name; @@ -497,32 +193,27 @@ SWGTestMISettings::setReverseApiDeviceIndex(qint32 reverse_api_device_index) { this->m_reverse_api_device_index_isSet = true; } +QList* +SWGTestMISettings::getStreams() { + return streams; +} +void +SWGTestMISettings::setStreams(QList* streams) { + this->streams = streams; + this->m_streams_isSet = true; +} + bool SWGTestMISettings::isSet(){ bool isObjectUpdated = false; do{ - if(m_center_frequency_isSet){ isObjectUpdated = true; break;} - if(m_frequency_shift_isSet){ isObjectUpdated = true; break;} - if(m_sample_rate_isSet){ isObjectUpdated = true; break;} - if(m_log2_decim_isSet){ isObjectUpdated = true; break;} - if(m_fc_pos_isSet){ isObjectUpdated = true; break;} - if(m_sample_size_index_isSet){ isObjectUpdated = true; break;} - if(m_amplitude_bits_isSet){ isObjectUpdated = true; break;} - if(m_auto_corr_options_isSet){ isObjectUpdated = true; break;} - if(m_modulation_isSet){ isObjectUpdated = true; break;} - if(m_modulation_tone_isSet){ isObjectUpdated = true; break;} - if(m_am_modulation_isSet){ isObjectUpdated = true; break;} - if(m_fm_deviation_isSet){ isObjectUpdated = true; break;} - if(m_dc_factor_isSet){ isObjectUpdated = true; break;} - if(m_i_factor_isSet){ isObjectUpdated = true; break;} - if(m_q_factor_isSet){ isObjectUpdated = true; break;} - if(m_phase_imbalance_isSet){ isObjectUpdated = true; break;} if(file_record_name != nullptr && *file_record_name != QString("")){ isObjectUpdated = true; break;} if(m_use_reverse_api_isSet){ isObjectUpdated = true; break;} if(reverse_api_address != nullptr && *reverse_api_address != QString("")){ isObjectUpdated = true; break;} if(m_reverse_api_port_isSet){ isObjectUpdated = true; break;} if(m_reverse_api_device_index_isSet){ isObjectUpdated = true; break;} + if(streams->size() > 0){ isObjectUpdated = true; break;} }while(false); return isObjectUpdated; } diff --git a/swagger/sdrangel/code/qt5/client/SWGTestMISettings.h b/swagger/sdrangel/code/qt5/client/SWGTestMISettings.h index 43d67afa7..aad75639c 100644 --- a/swagger/sdrangel/code/qt5/client/SWGTestMISettings.h +++ b/swagger/sdrangel/code/qt5/client/SWGTestMISettings.h @@ -13,7 +13,7 @@ /* * SWGTestMISettings.h * - * TestSourceMI + * TestMISettings */ #ifndef SWGTestMISettings_H_ @@ -22,6 +22,8 @@ #include +#include "SWGTestMiStreamSettings.h" +#include #include #include "SWGObject.h" @@ -42,54 +44,6 @@ public: virtual void fromJsonObject(QJsonObject &json) override; virtual SWGTestMISettings* fromJson(QString &jsonString) override; - qint32 getCenterFrequency(); - void setCenterFrequency(qint32 center_frequency); - - qint32 getFrequencyShift(); - void setFrequencyShift(qint32 frequency_shift); - - qint32 getSampleRate(); - void setSampleRate(qint32 sample_rate); - - qint32 getLog2Decim(); - void setLog2Decim(qint32 log2_decim); - - qint32 getFcPos(); - void setFcPos(qint32 fc_pos); - - qint32 getSampleSizeIndex(); - void setSampleSizeIndex(qint32 sample_size_index); - - qint32 getAmplitudeBits(); - void setAmplitudeBits(qint32 amplitude_bits); - - qint32 getAutoCorrOptions(); - void setAutoCorrOptions(qint32 auto_corr_options); - - qint32 getModulation(); - void setModulation(qint32 modulation); - - qint32 getModulationTone(); - void setModulationTone(qint32 modulation_tone); - - qint32 getAmModulation(); - void setAmModulation(qint32 am_modulation); - - qint32 getFmDeviation(); - void setFmDeviation(qint32 fm_deviation); - - float getDcFactor(); - void setDcFactor(float dc_factor); - - float getIFactor(); - void setIFactor(float i_factor); - - float getQFactor(); - void setQFactor(float q_factor); - - float getPhaseImbalance(); - void setPhaseImbalance(float phase_imbalance); - QString* getFileRecordName(); void setFileRecordName(QString* file_record_name); @@ -105,58 +59,13 @@ public: qint32 getReverseApiDeviceIndex(); void setReverseApiDeviceIndex(qint32 reverse_api_device_index); + QList* getStreams(); + void setStreams(QList* streams); + virtual bool isSet() override; private: - qint32 center_frequency; - bool m_center_frequency_isSet; - - qint32 frequency_shift; - bool m_frequency_shift_isSet; - - qint32 sample_rate; - bool m_sample_rate_isSet; - - qint32 log2_decim; - bool m_log2_decim_isSet; - - qint32 fc_pos; - bool m_fc_pos_isSet; - - qint32 sample_size_index; - bool m_sample_size_index_isSet; - - qint32 amplitude_bits; - bool m_amplitude_bits_isSet; - - qint32 auto_corr_options; - bool m_auto_corr_options_isSet; - - qint32 modulation; - bool m_modulation_isSet; - - qint32 modulation_tone; - bool m_modulation_tone_isSet; - - qint32 am_modulation; - bool m_am_modulation_isSet; - - qint32 fm_deviation; - bool m_fm_deviation_isSet; - - float dc_factor; - bool m_dc_factor_isSet; - - float i_factor; - bool m_i_factor_isSet; - - float q_factor; - bool m_q_factor_isSet; - - float phase_imbalance; - bool m_phase_imbalance_isSet; - QString* file_record_name; bool m_file_record_name_isSet; @@ -172,6 +81,9 @@ private: qint32 reverse_api_device_index; bool m_reverse_api_device_index_isSet; + QList* streams; + bool m_streams_isSet; + }; } diff --git a/swagger/sdrangel/code/qt5/client/SWGTestMiStreamSettings.cpp b/swagger/sdrangel/code/qt5/client/SWGTestMiStreamSettings.cpp new file mode 100644 index 000000000..d341da560 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGTestMiStreamSettings.cpp @@ -0,0 +1,442 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time --- + * + * OpenAPI spec version: 4.8.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +#include "SWGTestMiStreamSettings.h" + +#include "SWGHelpers.h" + +#include +#include +#include +#include + +namespace SWGSDRangel { + +SWGTestMiStreamSettings::SWGTestMiStreamSettings(QString* json) { + init(); + this->fromJson(*json); +} + +SWGTestMiStreamSettings::SWGTestMiStreamSettings() { + stream_index = 0; + m_stream_index_isSet = false; + center_frequency = 0; + m_center_frequency_isSet = false; + frequency_shift = 0; + m_frequency_shift_isSet = false; + sample_rate = 0; + m_sample_rate_isSet = false; + log2_decim = 0; + m_log2_decim_isSet = false; + fc_pos = 0; + m_fc_pos_isSet = false; + sample_size_index = 0; + m_sample_size_index_isSet = false; + amplitude_bits = 0; + m_amplitude_bits_isSet = false; + auto_corr_options = 0; + m_auto_corr_options_isSet = false; + modulation = 0; + m_modulation_isSet = false; + modulation_tone = 0; + m_modulation_tone_isSet = false; + am_modulation = 0; + m_am_modulation_isSet = false; + fm_deviation = 0; + m_fm_deviation_isSet = false; + dc_factor = 0.0f; + m_dc_factor_isSet = false; + i_factor = 0.0f; + m_i_factor_isSet = false; + q_factor = 0.0f; + m_q_factor_isSet = false; + phase_imbalance = 0.0f; + m_phase_imbalance_isSet = false; +} + +SWGTestMiStreamSettings::~SWGTestMiStreamSettings() { + this->cleanup(); +} + +void +SWGTestMiStreamSettings::init() { + stream_index = 0; + m_stream_index_isSet = false; + center_frequency = 0; + m_center_frequency_isSet = false; + frequency_shift = 0; + m_frequency_shift_isSet = false; + sample_rate = 0; + m_sample_rate_isSet = false; + log2_decim = 0; + m_log2_decim_isSet = false; + fc_pos = 0; + m_fc_pos_isSet = false; + sample_size_index = 0; + m_sample_size_index_isSet = false; + amplitude_bits = 0; + m_amplitude_bits_isSet = false; + auto_corr_options = 0; + m_auto_corr_options_isSet = false; + modulation = 0; + m_modulation_isSet = false; + modulation_tone = 0; + m_modulation_tone_isSet = false; + am_modulation = 0; + m_am_modulation_isSet = false; + fm_deviation = 0; + m_fm_deviation_isSet = false; + dc_factor = 0.0f; + m_dc_factor_isSet = false; + i_factor = 0.0f; + m_i_factor_isSet = false; + q_factor = 0.0f; + m_q_factor_isSet = false; + phase_imbalance = 0.0f; + m_phase_imbalance_isSet = false; +} + +void +SWGTestMiStreamSettings::cleanup() { + + + + + + + + + + + + + + + + + +} + +SWGTestMiStreamSettings* +SWGTestMiStreamSettings::fromJson(QString &json) { + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); + return this; +} + +void +SWGTestMiStreamSettings::fromJsonObject(QJsonObject &pJson) { + ::SWGSDRangel::setValue(&stream_index, pJson["streamIndex"], "qint32", ""); + + ::SWGSDRangel::setValue(¢er_frequency, pJson["centerFrequency"], "qint32", ""); + + ::SWGSDRangel::setValue(&frequency_shift, pJson["frequencyShift"], "qint32", ""); + + ::SWGSDRangel::setValue(&sample_rate, pJson["sampleRate"], "qint32", ""); + + ::SWGSDRangel::setValue(&log2_decim, pJson["log2Decim"], "qint32", ""); + + ::SWGSDRangel::setValue(&fc_pos, pJson["fcPos"], "qint32", ""); + + ::SWGSDRangel::setValue(&sample_size_index, pJson["sampleSizeIndex"], "qint32", ""); + + ::SWGSDRangel::setValue(&litude_bits, pJson["amplitudeBits"], "qint32", ""); + + ::SWGSDRangel::setValue(&auto_corr_options, pJson["autoCorrOptions"], "qint32", ""); + + ::SWGSDRangel::setValue(&modulation, pJson["modulation"], "qint32", ""); + + ::SWGSDRangel::setValue(&modulation_tone, pJson["modulationTone"], "qint32", ""); + + ::SWGSDRangel::setValue(&am_modulation, pJson["amModulation"], "qint32", ""); + + ::SWGSDRangel::setValue(&fm_deviation, pJson["fmDeviation"], "qint32", ""); + + ::SWGSDRangel::setValue(&dc_factor, pJson["dcFactor"], "float", ""); + + ::SWGSDRangel::setValue(&i_factor, pJson["iFactor"], "float", ""); + + ::SWGSDRangel::setValue(&q_factor, pJson["qFactor"], "float", ""); + + ::SWGSDRangel::setValue(&phase_imbalance, pJson["phaseImbalance"], "float", ""); + +} + +QString +SWGTestMiStreamSettings::asJson () +{ + QJsonObject* obj = this->asJsonObject(); + + QJsonDocument doc(*obj); + QByteArray bytes = doc.toJson(); + delete obj; + return QString(bytes); +} + +QJsonObject* +SWGTestMiStreamSettings::asJsonObject() { + QJsonObject* obj = new QJsonObject(); + if(m_stream_index_isSet){ + obj->insert("streamIndex", QJsonValue(stream_index)); + } + if(m_center_frequency_isSet){ + obj->insert("centerFrequency", QJsonValue(center_frequency)); + } + if(m_frequency_shift_isSet){ + obj->insert("frequencyShift", QJsonValue(frequency_shift)); + } + if(m_sample_rate_isSet){ + obj->insert("sampleRate", QJsonValue(sample_rate)); + } + if(m_log2_decim_isSet){ + obj->insert("log2Decim", QJsonValue(log2_decim)); + } + if(m_fc_pos_isSet){ + obj->insert("fcPos", QJsonValue(fc_pos)); + } + if(m_sample_size_index_isSet){ + obj->insert("sampleSizeIndex", QJsonValue(sample_size_index)); + } + if(m_amplitude_bits_isSet){ + obj->insert("amplitudeBits", QJsonValue(amplitude_bits)); + } + if(m_auto_corr_options_isSet){ + obj->insert("autoCorrOptions", QJsonValue(auto_corr_options)); + } + if(m_modulation_isSet){ + obj->insert("modulation", QJsonValue(modulation)); + } + if(m_modulation_tone_isSet){ + obj->insert("modulationTone", QJsonValue(modulation_tone)); + } + if(m_am_modulation_isSet){ + obj->insert("amModulation", QJsonValue(am_modulation)); + } + if(m_fm_deviation_isSet){ + obj->insert("fmDeviation", QJsonValue(fm_deviation)); + } + if(m_dc_factor_isSet){ + obj->insert("dcFactor", QJsonValue(dc_factor)); + } + if(m_i_factor_isSet){ + obj->insert("iFactor", QJsonValue(i_factor)); + } + if(m_q_factor_isSet){ + obj->insert("qFactor", QJsonValue(q_factor)); + } + if(m_phase_imbalance_isSet){ + obj->insert("phaseImbalance", QJsonValue(phase_imbalance)); + } + + return obj; +} + +qint32 +SWGTestMiStreamSettings::getStreamIndex() { + return stream_index; +} +void +SWGTestMiStreamSettings::setStreamIndex(qint32 stream_index) { + this->stream_index = stream_index; + this->m_stream_index_isSet = true; +} + +qint32 +SWGTestMiStreamSettings::getCenterFrequency() { + return center_frequency; +} +void +SWGTestMiStreamSettings::setCenterFrequency(qint32 center_frequency) { + this->center_frequency = center_frequency; + this->m_center_frequency_isSet = true; +} + +qint32 +SWGTestMiStreamSettings::getFrequencyShift() { + return frequency_shift; +} +void +SWGTestMiStreamSettings::setFrequencyShift(qint32 frequency_shift) { + this->frequency_shift = frequency_shift; + this->m_frequency_shift_isSet = true; +} + +qint32 +SWGTestMiStreamSettings::getSampleRate() { + return sample_rate; +} +void +SWGTestMiStreamSettings::setSampleRate(qint32 sample_rate) { + this->sample_rate = sample_rate; + this->m_sample_rate_isSet = true; +} + +qint32 +SWGTestMiStreamSettings::getLog2Decim() { + return log2_decim; +} +void +SWGTestMiStreamSettings::setLog2Decim(qint32 log2_decim) { + this->log2_decim = log2_decim; + this->m_log2_decim_isSet = true; +} + +qint32 +SWGTestMiStreamSettings::getFcPos() { + return fc_pos; +} +void +SWGTestMiStreamSettings::setFcPos(qint32 fc_pos) { + this->fc_pos = fc_pos; + this->m_fc_pos_isSet = true; +} + +qint32 +SWGTestMiStreamSettings::getSampleSizeIndex() { + return sample_size_index; +} +void +SWGTestMiStreamSettings::setSampleSizeIndex(qint32 sample_size_index) { + this->sample_size_index = sample_size_index; + this->m_sample_size_index_isSet = true; +} + +qint32 +SWGTestMiStreamSettings::getAmplitudeBits() { + return amplitude_bits; +} +void +SWGTestMiStreamSettings::setAmplitudeBits(qint32 amplitude_bits) { + this->amplitude_bits = amplitude_bits; + this->m_amplitude_bits_isSet = true; +} + +qint32 +SWGTestMiStreamSettings::getAutoCorrOptions() { + return auto_corr_options; +} +void +SWGTestMiStreamSettings::setAutoCorrOptions(qint32 auto_corr_options) { + this->auto_corr_options = auto_corr_options; + this->m_auto_corr_options_isSet = true; +} + +qint32 +SWGTestMiStreamSettings::getModulation() { + return modulation; +} +void +SWGTestMiStreamSettings::setModulation(qint32 modulation) { + this->modulation = modulation; + this->m_modulation_isSet = true; +} + +qint32 +SWGTestMiStreamSettings::getModulationTone() { + return modulation_tone; +} +void +SWGTestMiStreamSettings::setModulationTone(qint32 modulation_tone) { + this->modulation_tone = modulation_tone; + this->m_modulation_tone_isSet = true; +} + +qint32 +SWGTestMiStreamSettings::getAmModulation() { + return am_modulation; +} +void +SWGTestMiStreamSettings::setAmModulation(qint32 am_modulation) { + this->am_modulation = am_modulation; + this->m_am_modulation_isSet = true; +} + +qint32 +SWGTestMiStreamSettings::getFmDeviation() { + return fm_deviation; +} +void +SWGTestMiStreamSettings::setFmDeviation(qint32 fm_deviation) { + this->fm_deviation = fm_deviation; + this->m_fm_deviation_isSet = true; +} + +float +SWGTestMiStreamSettings::getDcFactor() { + return dc_factor; +} +void +SWGTestMiStreamSettings::setDcFactor(float dc_factor) { + this->dc_factor = dc_factor; + this->m_dc_factor_isSet = true; +} + +float +SWGTestMiStreamSettings::getIFactor() { + return i_factor; +} +void +SWGTestMiStreamSettings::setIFactor(float i_factor) { + this->i_factor = i_factor; + this->m_i_factor_isSet = true; +} + +float +SWGTestMiStreamSettings::getQFactor() { + return q_factor; +} +void +SWGTestMiStreamSettings::setQFactor(float q_factor) { + this->q_factor = q_factor; + this->m_q_factor_isSet = true; +} + +float +SWGTestMiStreamSettings::getPhaseImbalance() { + return phase_imbalance; +} +void +SWGTestMiStreamSettings::setPhaseImbalance(float phase_imbalance) { + this->phase_imbalance = phase_imbalance; + this->m_phase_imbalance_isSet = true; +} + + +bool +SWGTestMiStreamSettings::isSet(){ + bool isObjectUpdated = false; + do{ + if(m_stream_index_isSet){ isObjectUpdated = true; break;} + if(m_center_frequency_isSet){ isObjectUpdated = true; break;} + if(m_frequency_shift_isSet){ isObjectUpdated = true; break;} + if(m_sample_rate_isSet){ isObjectUpdated = true; break;} + if(m_log2_decim_isSet){ isObjectUpdated = true; break;} + if(m_fc_pos_isSet){ isObjectUpdated = true; break;} + if(m_sample_size_index_isSet){ isObjectUpdated = true; break;} + if(m_amplitude_bits_isSet){ isObjectUpdated = true; break;} + if(m_auto_corr_options_isSet){ isObjectUpdated = true; break;} + if(m_modulation_isSet){ isObjectUpdated = true; break;} + if(m_modulation_tone_isSet){ isObjectUpdated = true; break;} + if(m_am_modulation_isSet){ isObjectUpdated = true; break;} + if(m_fm_deviation_isSet){ isObjectUpdated = true; break;} + if(m_dc_factor_isSet){ isObjectUpdated = true; break;} + if(m_i_factor_isSet){ isObjectUpdated = true; break;} + if(m_q_factor_isSet){ isObjectUpdated = true; break;} + if(m_phase_imbalance_isSet){ isObjectUpdated = true; break;} + }while(false); + return isObjectUpdated; +} +} + diff --git a/swagger/sdrangel/code/qt5/client/SWGTestMiStreamSettings.h b/swagger/sdrangel/code/qt5/client/SWGTestMiStreamSettings.h new file mode 100644 index 000000000..13b38b836 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGTestMiStreamSettings.h @@ -0,0 +1,154 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time --- + * + * OpenAPI spec version: 4.8.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +/* + * SWGTestMiStreamSettings.h + * + * TestMiStreamSettings + */ + +#ifndef SWGTestMiStreamSettings_H_ +#define SWGTestMiStreamSettings_H_ + +#include + + + +#include "SWGObject.h" +#include "export.h" + +namespace SWGSDRangel { + +class SWG_API SWGTestMiStreamSettings: public SWGObject { +public: + SWGTestMiStreamSettings(); + SWGTestMiStreamSettings(QString* json); + virtual ~SWGTestMiStreamSettings(); + void init(); + void cleanup(); + + virtual QString asJson () override; + virtual QJsonObject* asJsonObject() override; + virtual void fromJsonObject(QJsonObject &json) override; + virtual SWGTestMiStreamSettings* fromJson(QString &jsonString) override; + + qint32 getStreamIndex(); + void setStreamIndex(qint32 stream_index); + + qint32 getCenterFrequency(); + void setCenterFrequency(qint32 center_frequency); + + qint32 getFrequencyShift(); + void setFrequencyShift(qint32 frequency_shift); + + qint32 getSampleRate(); + void setSampleRate(qint32 sample_rate); + + qint32 getLog2Decim(); + void setLog2Decim(qint32 log2_decim); + + qint32 getFcPos(); + void setFcPos(qint32 fc_pos); + + qint32 getSampleSizeIndex(); + void setSampleSizeIndex(qint32 sample_size_index); + + qint32 getAmplitudeBits(); + void setAmplitudeBits(qint32 amplitude_bits); + + qint32 getAutoCorrOptions(); + void setAutoCorrOptions(qint32 auto_corr_options); + + qint32 getModulation(); + void setModulation(qint32 modulation); + + qint32 getModulationTone(); + void setModulationTone(qint32 modulation_tone); + + qint32 getAmModulation(); + void setAmModulation(qint32 am_modulation); + + qint32 getFmDeviation(); + void setFmDeviation(qint32 fm_deviation); + + float getDcFactor(); + void setDcFactor(float dc_factor); + + float getIFactor(); + void setIFactor(float i_factor); + + float getQFactor(); + void setQFactor(float q_factor); + + float getPhaseImbalance(); + void setPhaseImbalance(float phase_imbalance); + + + virtual bool isSet() override; + +private: + qint32 stream_index; + bool m_stream_index_isSet; + + qint32 center_frequency; + bool m_center_frequency_isSet; + + qint32 frequency_shift; + bool m_frequency_shift_isSet; + + qint32 sample_rate; + bool m_sample_rate_isSet; + + qint32 log2_decim; + bool m_log2_decim_isSet; + + qint32 fc_pos; + bool m_fc_pos_isSet; + + qint32 sample_size_index; + bool m_sample_size_index_isSet; + + qint32 amplitude_bits; + bool m_amplitude_bits_isSet; + + qint32 auto_corr_options; + bool m_auto_corr_options_isSet; + + qint32 modulation; + bool m_modulation_isSet; + + qint32 modulation_tone; + bool m_modulation_tone_isSet; + + qint32 am_modulation; + bool m_am_modulation_isSet; + + qint32 fm_deviation; + bool m_fm_deviation_isSet; + + float dc_factor; + bool m_dc_factor_isSet; + + float i_factor; + bool m_i_factor_isSet; + + float q_factor; + bool m_q_factor_isSet; + + float phase_imbalance; + bool m_phase_imbalance_isSet; + +}; + +} + +#endif /* SWGTestMiStreamSettings_H_ */ From f9a85237144f60b2c0888afe7a2e33bfb6adace2 Mon Sep 17 00:00:00 2001 From: f4exb Date: Mon, 27 May 2019 02:52:33 +0200 Subject: [PATCH 2/8] MIMO: add channel to testMI (2) --- plugins/channelrx/demodam/amdemod.cpp | 19 ++- plugins/channelrx/demodam/amdemodgui.cpp | 1 + plugins/samplemimo/testmi/testmi.cpp | 28 +++-- plugins/samplemimo/testmi/testmithread.cpp | 3 +- plugins/samplemimo/testmi/testmithread.h | 3 +- sdrbase/device/deviceapi.cpp | 14 ++- sdrbase/device/deviceapi.h | 4 +- sdrbase/dsp/dspdevicemimoengine.cpp | 129 +++++++++++++++++++-- sdrbase/dsp/dspdevicemimoengine.h | 17 ++- sdrgui/mainwindow.cpp | 2 +- 10 files changed, 182 insertions(+), 38 deletions(-) diff --git a/plugins/channelrx/demodam/amdemod.cpp b/plugins/channelrx/demodam/amdemod.cpp index 99eeb328e..7e4149e26 100644 --- a/plugins/channelrx/demodam/amdemod.cpp +++ b/plugins/channelrx/demodam/amdemod.cpp @@ -36,6 +36,7 @@ #include "dsp/dspengine.h" #include "dsp/threadedbasebandsamplesink.h" #include "dsp/dspcommands.h" +#include "dsp/devicesamplemimo.h" #include "dsp/fftfilt.h" #include "device/deviceapi.h" #include "util/db.h" @@ -374,7 +375,7 @@ bool AMDemod::handleMessage(const Message& cmd) void AMDemod::applyAudioSampleRate(int sampleRate) { - qDebug("AMDemod::applyAudioSampleRate: %d", sampleRate); + qDebug("AMDemod::applyAudioSampleRate: sampleRate: %d m_inputSampleRate: %d", sampleRate, m_inputSampleRate); MsgConfigureChannelizer* channelConfigMsg = MsgConfigureChannelizer::create( sampleRate, m_settings.m_inputFrequencyOffset); @@ -408,7 +409,8 @@ void AMDemod::applyChannelSettings(int inputSampleRate, int inputFrequencyOffset { qDebug() << "AMDemod::applyChannelSettings:" << " inputSampleRate: " << inputSampleRate - << " inputFrequencyOffset: " << inputFrequencyOffset; + << " inputFrequencyOffset: " << inputFrequencyOffset + << " m_audioSampleRate: " << m_audioSampleRate; if ((m_inputFrequencyOffset != inputFrequencyOffset) || (m_inputSampleRate != inputSampleRate) || force) @@ -526,7 +528,18 @@ void AMDemod::applySettings(const AMDemodSettings& settings, bool force) reverseAPIKeys.append("volume"); } - if ((m_settings.m_streamIndex != settings.m_streamIndex) || force) { + if (m_settings.m_streamIndex != settings.m_streamIndex) + { + if (m_deviceAPI->getSampleMIMO()) // change of stream is possible for MIMO devices only + { + m_deviceAPI->removeChannelSinkAPI(this, m_settings.m_streamIndex); + m_deviceAPI->removeChannelSink(m_threadedChannelizer, m_settings.m_streamIndex); + m_deviceAPI->addChannelSink(m_threadedChannelizer, settings.m_streamIndex); + m_deviceAPI->addChannelSinkAPI(this, settings.m_streamIndex); + // apply stream sample rate to itself + applyChannelSettings(m_deviceAPI->getSampleMIMO()->getSourceSampleRate(settings.m_streamIndex), m_inputFrequencyOffset); + } + reverseAPIKeys.append("streamIndex"); } diff --git a/plugins/channelrx/demodam/amdemodgui.cpp b/plugins/channelrx/demodam/amdemodgui.cpp index 8a4aabfc6..756a0a608 100644 --- a/plugins/channelrx/demodam/amdemodgui.cpp +++ b/plugins/channelrx/demodam/amdemodgui.cpp @@ -240,6 +240,7 @@ void AMDemodGUI::onMenuDialogCalled(const QPoint &p) dialog.exec(); m_settings.m_streamIndex = dialog.getSelectedStreamIndex(); + displayStreamIndex(); applySettings(); } diff --git a/plugins/samplemimo/testmi/testmi.cpp b/plugins/samplemimo/testmi/testmi.cpp index 8780743b4..d34039475 100644 --- a/plugins/samplemimo/testmi/testmi.cpp +++ b/plugins/samplemimo/testmi/testmi.cpp @@ -51,9 +51,9 @@ TestMI::TestMI(DeviceAPI *deviceAPI) : { m_fileSink = new FileRecord(QString("test_%1.sdriq").arg(m_deviceAPI->getDeviceUID())); m_deviceAPI->setNbSourceStreams(2); - m_deviceAPI->addSourceStream(); // Add a new source stream data set in the engine - m_deviceAPI->addSourceStream(); // Add a new source stream data set in the engine - m_deviceAPI->addAncillarySink(m_fileSink); + m_deviceAPI->addSourceStream(true); // Add a new source stream data set in the engine - asynchronous handling of FIFOs + m_deviceAPI->addSourceStream(true); // Add a new source stream data set in the engine - asynchronous handling of FIFOs + //m_deviceAPI->addAncillarySink(m_fileSink); TODO: implement when active m_sampleSinkFifos.push_back(SampleSinkFifo(96000 * 4)); m_sampleSinkFifos.push_back(SampleSinkFifo(96000 * 4)); m_networkManager = new QNetworkAccessManager(); @@ -87,15 +87,18 @@ void TestMI::init() bool TestMI::start() { + qDebug("TestMI::start"); QMutexLocker mutexLocker(&m_mutex); - if (m_running) stop(); + if (m_running) { + stop(); + } - m_testSourceThreads.push_back(new TestMIThread(&m_sampleSinkFifos[0])); + m_testSourceThreads.push_back(new TestMIThread(&m_sampleSinkFifos[0], 0)); m_testSourceThreads.back()->setSamplerate(m_settings.m_streams[0].m_sampleRate); m_testSourceThreads.back()->startStop(true); - m_testSourceThreads.push_back(new TestMIThread(&m_sampleSinkFifos[1])); + m_testSourceThreads.push_back(new TestMIThread(&m_sampleSinkFifos[1], 1)); m_testSourceThreads.back()->setSamplerate(m_settings.m_streams[1].m_sampleRate); m_testSourceThreads.back()->startStop(true); @@ -109,6 +112,7 @@ bool TestMI::start() void TestMI::stop() { + qDebug("TestMI::stop"); QMutexLocker mutexLocker(&m_mutex); std::vector::iterator it = m_testSourceThreads.begin(); @@ -263,12 +267,10 @@ bool TestMI::applySettings(const TestMISettings& settings, bool force) { DeviceSettingsKeys deviceSettingsKeys; - QList> streamReverseAPIKeys; // FIXME: one set of keys per streams - for (unsigned int istream = 0; istream < m_settings.m_streams.size(); istream++) { deviceSettingsKeys.m_streamsSettingsKeys.push_back(QList()); - QList& reverseAPIKeys = streamReverseAPIKeys.back(); + QList& reverseAPIKeys = deviceSettingsKeys.m_streamsSettingsKeys.back(); if ((m_settings.m_streams[istream].m_autoCorrOptions != settings.m_streams[istream].m_autoCorrOptions) || force) { @@ -296,7 +298,8 @@ bool TestMI::applySettings(const TestMISettings& settings, bool force) if ((istream < m_testSourceThreads.size()) && (m_testSourceThreads[istream])) { m_testSourceThreads[istream]->setSamplerate(settings.m_streams[istream].m_sampleRate); - qDebug("TestMI::applySettings: sample rate set to %d", settings.m_streams[istream].m_sampleRate); + qDebug("TestMI::applySettings: thread on stream: %u sample rate set to %d", + istream, settings.m_streams[istream].m_sampleRate); } } @@ -307,7 +310,8 @@ bool TestMI::applySettings(const TestMISettings& settings, bool force) if ((istream < m_testSourceThreads.size()) && (m_testSourceThreads[istream])) { m_testSourceThreads[istream]->setLog2Decimation(settings.m_streams[istream].m_log2Decim); - qDebug() << "TestMI::applySettings: set decimation to " << (1<setFcPos((int) settings.m_streams[istream].m_fcPos); m_testSourceThreads[istream]->setFrequencyShift(frequencyShift); qDebug() << "TestMI::applySettings:" - << " istream: " << istream + << " thread on istream: " << istream << " center freq: " << settings.m_streams[istream].m_centerFrequency << " Hz" << " device center freq: " << deviceCenterFrequency << " Hz" << " device sample rate: " << devSampleRate << "Hz" diff --git a/plugins/samplemimo/testmi/testmithread.cpp b/plugins/samplemimo/testmi/testmithread.cpp index bb06a9085..53457a7b4 100644 --- a/plugins/samplemimo/testmi/testmithread.cpp +++ b/plugins/samplemimo/testmi/testmithread.cpp @@ -28,7 +28,7 @@ MESSAGE_CLASS_DEFINITION(TestMIThread::MsgStartStop, Message) -TestMIThread::TestMIThread(SampleSinkFifo* sampleFifo, QObject* parent) : +TestMIThread::TestMIThread(SampleSinkFifo* sampleFifo, int streamIndex, QObject* parent) : QThread(parent), m_running(false), m_buf(0), @@ -36,6 +36,7 @@ TestMIThread::TestMIThread(SampleSinkFifo* sampleFifo, QObject* parent) : m_chunksize(0), m_convertBuffer(TESTMI_BLOCKSIZE), m_sampleFifo(sampleFifo), + m_streamIndex(streamIndex), m_frequencyShift(0), m_toneFrequency(440), m_modulation(TestMIStreamSettings::ModulationNone), diff --git a/plugins/samplemimo/testmi/testmithread.h b/plugins/samplemimo/testmi/testmithread.h index 2df410ae1..72e8bad97 100644 --- a/plugins/samplemimo/testmi/testmithread.h +++ b/plugins/samplemimo/testmi/testmithread.h @@ -58,7 +58,7 @@ public: { } }; - TestMIThread(SampleSinkFifo* sampleFifo, QObject* parent = 0); + TestMIThread(SampleSinkFifo* sampleFifo, int streamIndex, QObject* parent = 0); ~TestMIThread(); void startStop(bool start); @@ -90,6 +90,7 @@ private: quint32 m_chunksize; SampleVector m_convertBuffer; SampleSinkFifo* m_sampleFifo; + int m_streamIndex; NCOF m_nco; NCOF m_toneNco; int m_frequencyShift; diff --git a/sdrbase/device/deviceapi.cpp b/sdrbase/device/deviceapi.cpp index 3cf7fb95b..9992ecc09 100644 --- a/sdrbase/device/deviceapi.cpp +++ b/sdrbase/device/deviceapi.cpp @@ -58,10 +58,10 @@ DeviceAPI::~DeviceAPI() { } -void DeviceAPI::addSourceStream() +void DeviceAPI::addSourceStream(bool connect) { if (m_deviceMIMOEngine) { - m_deviceMIMOEngine->addSourceStream(); + m_deviceMIMOEngine->addSourceStream(connect); } } @@ -72,10 +72,10 @@ void DeviceAPI::removeLastSourceStream() } } -void DeviceAPI::addSinkStream() +void DeviceAPI::addSinkStream(bool connect) { if (m_deviceMIMOEngine) { - m_deviceMIMOEngine->addSinkStream(); + m_deviceMIMOEngine->addSinkStream(connect); } } @@ -92,7 +92,7 @@ void DeviceAPI::addAncillarySink(BasebandSampleSink *sink) m_deviceSourceEngine->addSink(sink); } else if (m_deviceSinkEngine) { m_deviceSinkEngine->addSpectrumSink(sink); - } + } // TODO: MIMO } void DeviceAPI::removeAncillarySink(BasebandSampleSink* sink) @@ -101,7 +101,7 @@ void DeviceAPI::removeAncillarySink(BasebandSampleSink* sink) m_deviceSourceEngine->removeSink(sink); } else if (m_deviceSinkEngine) { m_deviceSinkEngine->removeSpectrumSink(sink); - } + } // TODO: MIMO } void DeviceAPI::setSpectrumSinkInput(bool sourceElseSink, unsigned int index) @@ -126,6 +126,8 @@ void DeviceAPI::removeChannelSink(ThreadedBasebandSampleSink* sink, int streamIn if (m_deviceSourceEngine) { m_deviceSourceEngine->removeThreadedSink(sink); + } else if (m_deviceMIMOEngine) { + m_deviceMIMOEngine->removeChannelSink(sink, streamIndex); } } diff --git a/sdrbase/device/deviceapi.h b/sdrbase/device/deviceapi.h index 6d3547c1d..3aa63a0c1 100644 --- a/sdrbase/device/deviceapi.h +++ b/sdrbase/device/deviceapi.h @@ -67,9 +67,9 @@ public: ~DeviceAPI(); // MIMO Engine baseband / channel lists management - void addSourceStream(); + void addSourceStream(bool connect); void removeLastSourceStream(); - void addSinkStream(); + void addSinkStream(bool connect); void removeLastSinkStream(); void addAncillarySink(BasebandSampleSink* sink); //!< Adds a sink to receive full baseband and that is not a channel (e.g. spectrum) diff --git a/sdrbase/dsp/dspdevicemimoengine.cpp b/sdrbase/dsp/dspdevicemimoengine.cpp index 3f6390d31..cd318e10b 100644 --- a/sdrbase/dsp/dspdevicemimoengine.cpp +++ b/sdrbase/dsp/dspdevicemimoengine.cpp @@ -122,10 +122,10 @@ void DSPDeviceMIMOEngine::setMIMOSequence(int sequence) m_sampleMIMOSequence = sequence; } -void DSPDeviceMIMOEngine::addSourceStream() +void DSPDeviceMIMOEngine::addSourceStream(bool connect) { qDebug("DSPDeviceMIMOEngine::addSourceStream"); - AddSourceStream cmd; + AddSourceStream cmd(connect); m_syncMessenger.sendWait(cmd); } @@ -136,10 +136,10 @@ void DSPDeviceMIMOEngine::removeLastSourceStream() m_syncMessenger.sendWait(cmd); } -void DSPDeviceMIMOEngine::addSinkStream() +void DSPDeviceMIMOEngine::addSinkStream(bool connect) { qDebug("DSPDeviceMIMOEngine::addSinkStream"); - AddSinkStream cmd; + AddSinkStream cmd(connect); m_syncMessenger.sendWait(cmd); } @@ -335,6 +335,81 @@ void DSPDeviceMIMOEngine::work(int nbWriteSamples) // TODO: sinks } +void DSPDeviceMIMOEngine::workSampleSink(unsigned int sinkIndex) +{ + if (m_state != StRunning) { + return; + } + + SampleSinkFifo* sampleFifo = m_deviceSampleMIMO->getSampleSinkFifo(sinkIndex); + int samplesDone = 0; + bool positiveOnly = false; + + while ((sampleFifo->fill() > 0) && (m_inputMessageQueue.size() == 0) && (samplesDone < m_deviceSampleMIMO->getSourceSampleRate(sinkIndex))) + { + SampleVector::iterator part1begin; + SampleVector::iterator part1end; + SampleVector::iterator part2begin; + SampleVector::iterator part2end; + + std::size_t count = sampleFifo->readBegin(sampleFifo->fill(), &part1begin, &part1end, &part2begin, &part2end); + + // first part of FIFO data + if (part1begin != part1end) + { + // TODO: DC and IQ corrections + + // feed data to direct sinks + if (sinkIndex < m_basebandSampleSinks.size()) + { + for (BasebandSampleSinks::const_iterator it = m_basebandSampleSinks[sinkIndex].begin(); it != m_basebandSampleSinks[sinkIndex].end(); ++it) { + (*it)->feed(part1begin, part1end, positiveOnly); + } + } + + // possibly feed data to spectrum sink + if ((m_spectrumSink) && (m_spectrumInputSourceElseSink) && (sinkIndex == m_spectrumInputIndex)) { + m_spectrumSink->feed(part1begin, part1end, positiveOnly); + } + + // feed data to threaded sinks + for (ThreadedBasebandSampleSinks::const_iterator it = m_threadedBasebandSampleSinks[sinkIndex].begin(); it != m_threadedBasebandSampleSinks[sinkIndex].end(); ++it) + { + (*it)->feed(part1begin, part1end, positiveOnly); + } + } + + // second part of FIFO data (used when block wraps around) + if(part2begin != part2end) + { + // TODO: DC and IQ corrections + + // feed data to direct sinks + if (sinkIndex < m_basebandSampleSinks.size()) + { + for (BasebandSampleSinks::const_iterator it = m_basebandSampleSinks[sinkIndex].begin(); it != m_basebandSampleSinks[sinkIndex].end(); ++it) { + (*it)->feed(part2begin, part2end, positiveOnly); + } + } + + // possibly feed data to spectrum sink + if ((m_spectrumSink) && (m_spectrumInputSourceElseSink) && (sinkIndex == m_spectrumInputIndex)) { + m_spectrumSink->feed(part2begin, part2end, positiveOnly); + } + + // feed data to threaded sinks + for (ThreadedBasebandSampleSinks::const_iterator it = m_threadedBasebandSampleSinks[sinkIndex].begin(); it != m_threadedBasebandSampleSinks[sinkIndex].end(); ++it) + { + (*it)->feed(part2begin, part2end, positiveOnly); + } + } + + // adjust FIFO pointers + sampleFifo->readCommit((unsigned int) count); + samplesDone += count; + } +} + // notStarted -> idle -> init -> running -+ // ^ | // +-----------------------+ @@ -544,7 +619,7 @@ DSPDeviceMIMOEngine::State DSPDeviceMIMOEngine::gotoError(const QString& errorMe void DSPDeviceMIMOEngine::handleData() { - if(m_state == StRunning) + if (m_state == StRunning) { work(0); // TODO: implement Tx side } @@ -554,14 +629,38 @@ void DSPDeviceMIMOEngine::handleSetMIMO(DeviceSampleMIMO* mimo) { m_deviceSampleMIMO = mimo; - if (mimo && (mimo->getNbSinkFifos() > 0)) + if (mimo) { - // if there is at least one Rx then the first Rx drives the FIFOs - qDebug("DSPDeviceMIMOEngine::handleSetMIMO: set %s", qPrintable(mimo->getDeviceDescription())); - connect(m_deviceSampleMIMO->getSampleSinkFifo(0), SIGNAL(dataReady()), this, SLOT(handleData()), Qt::QueuedConnection); + if ((m_sampleSinkConnectionIndexes.size() == 1) && (m_sampleSourceConnectionIndexes.size() == 0)) // true MIMO (synchronous FIFOs) + { + qDebug("DSPDeviceMIMOEngine::handleSetMIMO: synchronous set %s", qPrintable(mimo->getDeviceDescription())); + // connect(m_deviceSampleMIMO->getSampleSinkFifo(m_sampleSinkConnectionIndexes[0]), SIGNAL(dataReady()), this, SLOT(handleData()), Qt::QueuedConnection); + QObject::connect( + m_deviceSampleMIMO->getSampleSinkFifo(m_sampleSinkConnectionIndexes[0]), + &SampleSinkFifo::dataReady, + this, + [=](){ this->handleData(); }, // lambda function is not strictly needed here + Qt::QueuedConnection + ); + } + else if (m_sampleSinkConnectionIndexes.size() != 0) // asynchronous FIFOs + { + for (unsigned int isink = 0; isink < m_sampleSinkConnectionIndexes.size(); isink++) + { + qDebug("DSPDeviceMIMOEngine::handleSetMIMO: asynchronous sources set %s channel %u", + qPrintable(mimo->getDeviceDescription()), isink); + QObject::connect( + m_deviceSampleMIMO->getSampleSinkFifo(m_sampleSinkConnectionIndexes[isink]), + &SampleSinkFifo::dataReady, + this, + [=](){ this->workSampleSink(isink); }, + Qt::QueuedConnection + ); + } + } } - // TODO: only Tx + // TODO: Tx } void DSPDeviceMIMOEngine::handleSynchronousMessages() @@ -601,8 +700,13 @@ void DSPDeviceMIMOEngine::handleSynchronousMessages() else if (AddSourceStream::match(*message)) { m_basebandSampleSinks.push_back(BasebandSampleSinks()); + int currentIndex = m_threadedBasebandSampleSinks.size(); m_threadedBasebandSampleSinks.push_back(ThreadedBasebandSampleSinks()); m_sourcesCorrections.push_back(SourceCorrection()); + + if (((AddSourceStream *) message)->getConnect()) { + m_sampleSinkConnectionIndexes.push_back(currentIndex); + } } else if (RemoveLastSourceStream::match(*message)) { @@ -611,7 +715,12 @@ void DSPDeviceMIMOEngine::handleSynchronousMessages() } else if (AddSinkStream::match(*message)) { + int currentIndex = m_threadedBasebandSampleSources.size(); m_threadedBasebandSampleSources.push_back(ThreadedBasebandSampleSources()); + + if (((AddSinkStream *) message)->getConnect()) { + m_sampleSourceConnectionIndexes.push_back(currentIndex); + } } else if (RemoveLastSinkStream::match(*message)) { diff --git a/sdrbase/dsp/dspdevicemimoengine.h b/sdrbase/dsp/dspdevicemimoengine.h index fd7f3a299..4276ae015 100644 --- a/sdrbase/dsp/dspdevicemimoengine.h +++ b/sdrbase/dsp/dspdevicemimoengine.h @@ -62,6 +62,11 @@ public: class AddSourceStream : public Message { MESSAGE_CLASS_DECLARATION + public: + AddSourceStream(bool connect) : Message(), m_connect(connect) { } + bool getConnect() const { return m_connect; } + private: + bool m_connect; }; class RemoveLastSourceStream : public Message { @@ -70,6 +75,11 @@ public: class AddSinkStream : public Message { MESSAGE_CLASS_DECLARATION + public: + AddSinkStream(bool connect) : Message(), m_connect(connect) { } + bool getConnect() const { return m_connect; } + private: + bool m_connect; }; class RemoveLastSinkStream : public Message { @@ -266,9 +276,9 @@ public: void setMIMOSequence(int sequence); //!< Set the sample MIMO sequence in type uint getUID() const { return m_uid; } - void addSourceStream(); + void addSourceStream(bool connect); void removeLastSourceStream(); - void addSinkStream(); + void addSinkStream(bool connect); void removeLastSinkStream(); void addChannelSource(ThreadedBasebandSampleSource* source, int index = 0); //!< Add a channel source that will run on its own thread @@ -358,9 +368,11 @@ private: typedef std::list ThreadedBasebandSampleSinks; std::vector m_threadedBasebandSampleSinks; //!< channel sample sinks on their own thread (per input stream) + std::vector m_sampleSinkConnectionIndexes; typedef std::list ThreadedBasebandSampleSources; std::vector m_threadedBasebandSampleSources; //!< channel sample sources on their own threads (per output stream) + std::vector m_sampleSourceConnectionIndexes; std::vector m_sourcesCorrections; @@ -380,6 +392,7 @@ private: private slots: void handleData(); //!< Handle data when samples have to be processed + void workSampleSink(unsigned int sinkIndex); void handleSynchronousMessages(); //!< Handle synchronous messages with the thread void handleInputMessages(); //!< Handle input message queue void handleForwardToSpectrumSink(int nbSamples); diff --git a/sdrgui/mainwindow.cpp b/sdrgui/mainwindow.cpp index 5ea432d3e..b62ce1e17 100644 --- a/sdrgui/mainwindow.cpp +++ b/sdrgui/mainwindow.cpp @@ -1837,7 +1837,7 @@ void MainWindow::sampleMIMOChanged() deviceUI->m_deviceAPI->setSamplingDevicePluginInterface( DeviceEnumerator::instance()->getMIMOPluginInterface(deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex())); - // constructs new GUI and output object + // constructs new GUI and MIMO object DeviceSampleMIMO *mimo = deviceUI->m_deviceAPI->getPluginInterface()->createSampleMIMOPluginInstance( deviceUI->m_deviceAPI->getSamplingDeviceId(), deviceUI->m_deviceAPI); deviceUI->m_deviceAPI->setSampleMIMO(mimo); From bb8366bfde04bed40b8bbbb056b607218e2d0462 Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 28 May 2019 08:56:36 +0200 Subject: [PATCH 3/8] MIMO: test MI source: implemented file record --- plugins/samplemimo/testmi/testmi.cpp | 38 +++++++++++++++++++------ plugins/samplemimo/testmi/testmi.h | 15 ++++++---- plugins/samplemimo/testmi/testmigui.cpp | 14 +++++++-- plugins/samplemimo/testmi/testmigui.h | 1 + sdrbase/device/deviceapi.cpp | 12 +++++--- sdrbase/device/deviceapi.h | 4 +-- sdrbase/dsp/filerecord.cpp | 8 ++++-- sdrbase/dsp/filerecord.h | 3 +- 8 files changed, 70 insertions(+), 25 deletions(-) diff --git a/plugins/samplemimo/testmi/testmi.cpp b/plugins/samplemimo/testmi/testmi.cpp index d34039475..9c061adc9 100644 --- a/plugins/samplemimo/testmi/testmi.cpp +++ b/plugins/samplemimo/testmi/testmi.cpp @@ -49,11 +49,9 @@ TestMI::TestMI(DeviceAPI *deviceAPI) : m_running(false), m_masterTimer(deviceAPI->getMasterTimer()) { - m_fileSink = new FileRecord(QString("test_%1.sdriq").arg(m_deviceAPI->getDeviceUID())); m_deviceAPI->setNbSourceStreams(2); m_deviceAPI->addSourceStream(true); // Add a new source stream data set in the engine - asynchronous handling of FIFOs m_deviceAPI->addSourceStream(true); // Add a new source stream data set in the engine - asynchronous handling of FIFOs - //m_deviceAPI->addAncillarySink(m_fileSink); TODO: implement when active m_sampleSinkFifos.push_back(SampleSinkFifo(96000 * 4)); m_sampleSinkFifos.push_back(SampleSinkFifo(96000 * 4)); m_networkManager = new QNetworkAccessManager(); @@ -69,10 +67,17 @@ TestMI::~TestMI() stop(); } - m_deviceAPI->removeAncillarySink(m_fileSink); + std::vector::iterator it = m_fileSinks.begin(); + int istream = 0; + + for (; it != m_fileSinks.end(); ++it, istream++) + { + m_deviceAPI->removeAncillarySink(*it, istream); + delete *it; + } + m_deviceAPI->removeLastSourceStream(); // Remove the last source stream data set in the engine m_deviceAPI->removeLastSourceStream(); // Remove the last source stream data set in the engine - delete m_fileSink; } void TestMI::destroy() @@ -82,6 +87,11 @@ void TestMI::destroy() void TestMI::init() { + m_fileSinks.push_back(new FileRecord(QString("test_0_%1.sdriq").arg(m_deviceAPI->getDeviceUID()))); + m_fileSinks.push_back(new FileRecord(QString("test_1_%1.sdriq").arg(m_deviceAPI->getDeviceUID()))); + m_deviceAPI->addAncillarySink(m_fileSinks[0], 0); + m_deviceAPI->addAncillarySink(m_fileSinks[1], 1); + applySettings(m_settings, true); } @@ -216,20 +226,21 @@ bool TestMI::handleMessage(const Message& message) { MsgFileRecord& conf = (MsgFileRecord&) message; qDebug() << "TestMI::handleMessage: MsgFileRecord: " << conf.getStartStop(); + int istream = conf.getStreamIndex(); if (conf.getStartStop()) { if (m_settings.m_fileRecordName.size() != 0) { - m_fileSink->setFileName(m_settings.m_fileRecordName); + m_fileSinks[istream]->setFileName(m_settings.m_fileRecordName + "_0.sdriq"); } else { - m_fileSink->genUniqueFileName(m_deviceAPI->getDeviceUID()); + m_fileSinks[istream]->genUniqueFileName(m_deviceAPI->getDeviceUID(), istream); } - m_fileSink->startRecording(); + m_fileSinks[istream]->startRecording(); } else { - m_fileSink->stopRecording(); + m_fileSinks[istream]->stopRecording(); } return true; @@ -421,7 +432,7 @@ bool TestMI::applySettings(const TestMISettings& settings, bool force) { int sampleRate = settings.m_streams[istream].m_sampleRate/(1<handleMessage(*notif); // forward to file sink + m_fileSinks[istream]->handleMessage(*notif); // forward to file sink DSPDeviceMIMOEngine::SignalNotification *engineNotif = new DSPDeviceMIMOEngine::SignalNotification( sampleRate, settings.m_streams[istream].m_centerFrequency, true, 0); m_deviceAPI->getDeviceEngineInputMessageQueue()->push(engineNotif); @@ -820,3 +831,12 @@ void TestMI::networkManagerFinished(QNetworkReply *reply) answer.chop(1); // remove last \n qDebug("TestMI::networkManagerFinished: reply:\n%s", answer.toStdString().c_str()); } + +bool TestMI::isRecording(unsigned int istream) const +{ + if (istream < m_fileSinks.size()) { + return m_fileSinks[istream]->isRecording(); + } else { + return false; + } +} \ No newline at end of file diff --git a/plugins/samplemimo/testmi/testmi.h b/plugins/samplemimo/testmi/testmi.h index 2e5be0c7c..33e3eed35 100644 --- a/plugins/samplemimo/testmi/testmi.h +++ b/plugins/samplemimo/testmi/testmi.h @@ -63,17 +63,20 @@ public: public: bool getStartStop() const { return m_startStop; } + int getStreamIndex() const { return m_streamIndex; } - static MsgFileRecord* create(bool startStop) { - return new MsgFileRecord(startStop); + static MsgFileRecord* create(bool startStop, int streamIndex) { + return new MsgFileRecord(startStop, streamIndex); } protected: bool m_startStop; + int m_streamIndex; - MsgFileRecord(bool startStop) : + MsgFileRecord(bool startStop, int streamIndex) : Message(), - m_startStop(startStop) + m_startStop(startStop), + m_streamIndex(streamIndex) { } }; @@ -141,6 +144,8 @@ public: SWGSDRangel::SWGDeviceState& response, QString& errorMessage); + bool isRecording(unsigned int istream) const; + private: struct DeviceSettingsKeys { @@ -149,7 +154,7 @@ private: }; DeviceAPI *m_deviceAPI; - FileRecord *m_fileSink; //!< File sink to record device I/Q output + std::vector m_fileSinks; //!< File sinks to record device I/Q output QMutex m_mutex; TestMISettings m_settings; std::vector m_testSourceThreads; diff --git a/plugins/samplemimo/testmi/testmigui.cpp b/plugins/samplemimo/testmi/testmigui.cpp index 68d715b5b..9d5a2b4de 100644 --- a/plugins/samplemimo/testmi/testmigui.cpp +++ b/plugins/samplemimo/testmi/testmigui.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2018 Edouard Griffiths, F4EXB // +// Copyright (C) 2019 Edouard Griffiths, F4EXB // // // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -145,6 +145,7 @@ void TestMIGui::on_startStop_toggled(bool checked) void TestMIGui::on_streamIndex_currentIndexChanged(int index) { m_streamIndex = index; + updateFileRecordStatus(); displaySettings(); } @@ -296,7 +297,7 @@ void TestMIGui::on_record_toggled(bool checked) ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); } - TestMI::MsgFileRecord* message = TestMI::MsgFileRecord::create(checked); + TestMI::MsgFileRecord* message = TestMI::MsgFileRecord::create(checked, m_streamIndex); m_sampleMIMO->getInputMessageQueue()->push(message); } @@ -376,6 +377,15 @@ void TestMIGui::updateFrequencyShiftLimit() ui->frequencyShift->setValueRange(false, 7, -sampleRate, sampleRate); } +void TestMIGui::updateFileRecordStatus() +{ + if (((TestMI*) m_sampleMIMO)->isRecording(m_streamIndex)) { + ui->record->setStyleSheet("QToolButton { background-color : red; }"); + } else { + ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); + } +} + void TestMIGui::displaySettings() { blockApplySettings(true); diff --git a/plugins/samplemimo/testmi/testmigui.h b/plugins/samplemimo/testmi/testmigui.h index d50184047..5113ac959 100644 --- a/plugins/samplemimo/testmi/testmigui.h +++ b/plugins/samplemimo/testmi/testmigui.h @@ -77,6 +77,7 @@ private: void updateAmpCoarseLimit(); void updateAmpFineLimit(); void updateFrequencyShiftLimit(); + void updateFileRecordStatus(); private slots: void handleInputMessages(); diff --git a/sdrbase/device/deviceapi.cpp b/sdrbase/device/deviceapi.cpp index 9992ecc09..f40e72bdb 100644 --- a/sdrbase/device/deviceapi.cpp +++ b/sdrbase/device/deviceapi.cpp @@ -86,22 +86,26 @@ void DeviceAPI::removeLastSinkStream() } } -void DeviceAPI::addAncillarySink(BasebandSampleSink *sink) +void DeviceAPI::addAncillarySink(BasebandSampleSink *sink, unsigned int index) { if (m_deviceSourceEngine) { m_deviceSourceEngine->addSink(sink); } else if (m_deviceSinkEngine) { m_deviceSinkEngine->addSpectrumSink(sink); - } // TODO: MIMO + } else if (m_deviceMIMOEngine) { + m_deviceMIMOEngine->addAncillarySink(sink, index); + } } -void DeviceAPI::removeAncillarySink(BasebandSampleSink* sink) +void DeviceAPI::removeAncillarySink(BasebandSampleSink* sink, unsigned int index) { if (m_deviceSourceEngine) { m_deviceSourceEngine->removeSink(sink); } else if (m_deviceSinkEngine) { m_deviceSinkEngine->removeSpectrumSink(sink); - } // TODO: MIMO + } else if (m_deviceMIMOEngine) { + m_deviceMIMOEngine->removeAncillarySink(sink, index); + } } void DeviceAPI::setSpectrumSinkInput(bool sourceElseSink, unsigned int index) diff --git a/sdrbase/device/deviceapi.h b/sdrbase/device/deviceapi.h index 3aa63a0c1..ebb4ada00 100644 --- a/sdrbase/device/deviceapi.h +++ b/sdrbase/device/deviceapi.h @@ -72,8 +72,8 @@ public: void addSinkStream(bool connect); void removeLastSinkStream(); - void addAncillarySink(BasebandSampleSink* sink); //!< Adds a sink to receive full baseband and that is not a channel (e.g. spectrum) - void removeAncillarySink(BasebandSampleSink* sink); //!< Removes it + void addAncillarySink(BasebandSampleSink* sink, unsigned int index = 0); //!< Adds a sink to receive full baseband and that is not a channel (e.g. spectrum) + void removeAncillarySink(BasebandSampleSink* sink, unsigned int index = 0); //!< Removes it void setSpectrumSinkInput(bool sourceElseSink = true, unsigned int index = 0); //!< Used in the MIMO case to select which stream is used as input to main spectrum void addChannelSink(ThreadedBasebandSampleSink* sink, int streamIndex = 0); //!< Add a channel sink (Rx) diff --git a/sdrbase/dsp/filerecord.cpp b/sdrbase/dsp/filerecord.cpp index 6b0459b6c..3d7543512 100644 --- a/sdrbase/dsp/filerecord.cpp +++ b/sdrbase/dsp/filerecord.cpp @@ -64,9 +64,13 @@ void FileRecord::setFileName(const QString& filename) } } -void FileRecord::genUniqueFileName(uint deviceUID) +void FileRecord::genUniqueFileName(uint deviceUID, int istream) { - setFileName(QString("rec%1_%2.sdriq").arg(deviceUID).arg(QDateTime::currentDateTimeUtc().toString("yyyy-MM-ddTHH_mm_ss_zzz"))); + if (istream < 0) { + setFileName(QString("rec%1_%2.sdriq").arg(deviceUID).arg(QDateTime::currentDateTimeUtc().toString("yyyy-MM-ddTHH_mm_ss_zzz"))); + } else { + setFileName(QString("rec%1_%2_%3.sdriq").arg(deviceUID).arg(istream).arg(QDateTime::currentDateTimeUtc().toString("yyyy-MM-ddTHH_mm_ss_zzz"))); + } } void FileRecord::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly) diff --git a/sdrbase/dsp/filerecord.h b/sdrbase/dsp/filerecord.h index 1463edcf6..d0a855c0e 100644 --- a/sdrbase/dsp/filerecord.h +++ b/sdrbase/dsp/filerecord.h @@ -50,7 +50,7 @@ public: quint64 getByteCount() const { return m_byteCount; } void setFileName(const QString& filename); - void genUniqueFileName(uint deviceUID); + void genUniqueFileName(uint deviceUID, int istream = -1); virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly); virtual void start(); @@ -58,6 +58,7 @@ public: virtual bool handleMessage(const Message& message); void startRecording(); void stopRecording(); + bool isRecording() const { return m_recordOn; } static bool readHeader(std::ifstream& samplefile, Header& header); //!< returns true if CRC checksum is correct else false static void writeHeader(std::ofstream& samplefile, Header& header); From a0f16a1db0ef17409e5fa0d5b42243205a02859d Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 28 May 2019 12:09:08 +0200 Subject: [PATCH 4/8] MIMO: test MI: select stream to be displayed on main sperctrum --- plugins/samplemimo/testmi/testmi.cpp | 2 +- plugins/samplemimo/testmi/testmigui.cpp | 30 ++- plugins/samplemimo/testmi/testmigui.h | 6 +- plugins/samplemimo/testmi/testmigui.ui | 236 +++++++++++++----------- sdrbase/dsp/dspdevicemimoengine.cpp | 3 +- 5 files changed, 159 insertions(+), 118 deletions(-) diff --git a/plugins/samplemimo/testmi/testmi.cpp b/plugins/samplemimo/testmi/testmi.cpp index 9c061adc9..1daa56b56 100644 --- a/plugins/samplemimo/testmi/testmi.cpp +++ b/plugins/samplemimo/testmi/testmi.cpp @@ -434,7 +434,7 @@ bool TestMI::applySettings(const TestMISettings& settings, bool force) DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, settings.m_streams[istream].m_centerFrequency); m_fileSinks[istream]->handleMessage(*notif); // forward to file sink DSPDeviceMIMOEngine::SignalNotification *engineNotif = new DSPDeviceMIMOEngine::SignalNotification( - sampleRate, settings.m_streams[istream].m_centerFrequency, true, 0); + sampleRate, settings.m_streams[istream].m_centerFrequency, true, istream); m_deviceAPI->getDeviceEngineInputMessageQueue()->push(engineNotif); } diff --git a/plugins/samplemimo/testmi/testmigui.cpp b/plugins/samplemimo/testmi/testmigui.cpp index 9d5a2b4de..e762588ff 100644 --- a/plugins/samplemimo/testmi/testmigui.cpp +++ b/plugins/samplemimo/testmi/testmigui.cpp @@ -53,8 +53,14 @@ TestMIGui::TestMIGui(DeviceUISet *deviceUISet, QWidget* parent) : qDebug("TestMIGui::TestMIGui"); m_sampleMIMO = m_deviceUISet->m_deviceAPI->getSampleMIMO(); m_streamIndex = 0; + m_deviceCenterFrequencies.push_back(m_settings.m_streams[0].m_centerFrequency); + m_deviceCenterFrequencies.push_back(m_settings.m_streams[1].m_centerFrequency); + m_deviceSampleRates.push_back(m_settings.m_streams[0].m_sampleRate / (1<setupUi(this); + ui->spectrumSource->addItem("0"); + ui->spectrumSource->addItem("1"); ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); ui->centerFrequency->setValueRange(7, 0, 9999999); ui->sampleRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow)); @@ -146,9 +152,17 @@ void TestMIGui::on_streamIndex_currentIndexChanged(int index) { m_streamIndex = index; updateFileRecordStatus(); + updateSampleRateAndFrequency(); displaySettings(); } +void TestMIGui::on_spectrumSource_currentIndexChanged(int index) +{ + m_spectrumStreamIndex = index; + m_deviceUISet->m_deviceAPI->setSpectrumSinkInput(true, m_spectrumStreamIndex); + updateSampleRateAndFrequency(); +} + void TestMIGui::on_centerFrequency_changed(quint64 value) { m_settings.m_streams[m_streamIndex].m_centerFrequency = value * 1000; @@ -511,10 +525,14 @@ void TestMIGui::handleInputMessages() if (DSPDeviceMIMOEngine::SignalNotification::match(*message)) { DSPDeviceMIMOEngine::SignalNotification* notif = (DSPDeviceMIMOEngine::SignalNotification*) message; - m_deviceSampleRate = notif->getSampleRate(); - m_deviceCenterFrequency = notif->getCenterFrequency(); + int istream = notif->getIndex(); + bool sourceOrSink = notif->getSourceOrSink(); + m_deviceSampleRates[istream] = notif->getSampleRate(); + m_deviceCenterFrequencies[istream] = notif->getCenterFrequency(); // Do not consider multiple sources at this time - qDebug("TestMIGui::handleInputMessages: DSPDeviceMIMOEngine::SignalNotification: SampleRate:%d, CenterFrequency:%llu", + qDebug("TestMIGui::handleInputMessages: DSPDeviceMIMOEngine::SignalNotification: %s stream: %d SampleRate:%d, CenterFrequency:%llu", + sourceOrSink ? "source" : "sink", + istream, notif->getSampleRate(), notif->getCenterFrequency()); updateSampleRateAndFrequency(); @@ -533,9 +551,9 @@ void TestMIGui::handleInputMessages() void TestMIGui::updateSampleRateAndFrequency() { - m_deviceUISet->getSpectrum()->setSampleRate(m_deviceSampleRate); - m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency); - ui->deviceRateText->setText(tr("%1k").arg((float)m_deviceSampleRate / 1000)); + m_deviceUISet->getSpectrum()->setSampleRate(m_deviceSampleRates[m_spectrumStreamIndex]); + m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequencies[m_spectrumStreamIndex]); + ui->deviceRateText->setText(tr("%1k").arg((float) m_deviceSampleRates[m_streamIndex] / 1000)); } void TestMIGui::openDeviceSettingsDialog(const QPoint& p) diff --git a/plugins/samplemimo/testmi/testmigui.h b/plugins/samplemimo/testmi/testmigui.h index 5113ac959..0585f2674 100644 --- a/plugins/samplemimo/testmi/testmigui.h +++ b/plugins/samplemimo/testmi/testmigui.h @@ -58,14 +58,15 @@ private: DeviceUISet* m_deviceUISet; TestMISettings m_settings; int m_streamIndex; //!< Current stream index being dealt with + int m_spectrumStreamIndex; //!< Index of the stream displayed on main spectrum QTimer m_updateTimer; QTimer m_statusTimer; bool m_doApplySettings; bool m_forceSettings; DeviceSampleMIMO* m_sampleMIMO; std::size_t m_tickCount; - int m_deviceSampleRate; - quint64 m_deviceCenterFrequency; //!< Center frequency in device + std::vector m_deviceSampleRates; + std::vector m_deviceCenterFrequencies; //!< Center frequency in device int m_lastEngineState; MessageQueue m_inputMessageQueue; @@ -83,6 +84,7 @@ private slots: void handleInputMessages(); void on_startStop_toggled(bool checked); void on_streamIndex_currentIndexChanged(int index); + void on_spectrumSource_currentIndexChanged(int index); void on_centerFrequency_changed(quint64 value); void on_autoCorr_currentIndexChanged(int index); void on_frequencyShift_changed(qint64 value); diff --git a/plugins/samplemimo/testmi/testmigui.ui b/plugins/samplemimo/testmi/testmigui.ui index a6ce09b13..ed074e225 100644 --- a/plugins/samplemimo/testmi/testmigui.ui +++ b/plugins/samplemimo/testmi/testmigui.ui @@ -50,6 +50,80 @@ 2 + + + + + + Stream + + + + + + + + 40 + 16777215 + + + + Stream index + + + + 0 + + + + + 1 + + + + + + + + Spectrum + + + + + + + + 60 + 16777215 + + + + Select stream for main spectrum source + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + @@ -181,114 +255,6 @@
- - - - Qt::Horizontal - - - - - - - - - Stream - - - - - - - - 40 - 16777215 - - - - Stream index - - - - 0 - - - - - 1 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 16 - 0 - - - - SR - - - - - - - - 0 - 0 - - - - - 32 - 16 - - - - - Liberation Mono - 12 - - - - PointingHandCursor - - - Generator sample rate (S/s) - - - - - - - S/s - - - - - @@ -481,6 +447,60 @@ 2 + + + + + 0 + 0 + + + + + 16 + 0 + + + + SR + + + + + + + + 0 + 0 + + + + + 32 + 16 + + + + + Liberation Mono + 12 + + + + PointingHandCursor + + + Generator sample rate (S/s) + + + + + + + S/s + + + diff --git a/sdrbase/dsp/dspdevicemimoengine.cpp b/sdrbase/dsp/dspdevicemimoengine.cpp index cd318e10b..65546e477 100644 --- a/sdrbase/dsp/dspdevicemimoengine.cpp +++ b/sdrbase/dsp/dspdevicemimoengine.cpp @@ -948,7 +948,6 @@ void DSPDeviceMIMOEngine::handleInputMessages() << " sampleRate: " << sampleRate << " centerFrequency: " << centerFrequency; - if (sourceElseSink) { if ((istream < m_deviceSampleMIMO->getNbSourceStreams())) @@ -984,6 +983,7 @@ void DSPDeviceMIMOEngine::handleInputMessages() guiMessageQueue->push(rep); } + // forward changes to spectrum sink if currently active if (m_spectrumSink && m_spectrumInputSourceElseSink && (m_spectrumInputIndex == istream)) { DSPSignalNotification spectrumNotif(sampleRate, centerFrequency); @@ -1016,6 +1016,7 @@ void DSPDeviceMIMOEngine::handleInputMessages() guiMessageQueue->push(rep); } + // forward changes to spectrum sink if currently active if (m_spectrumSink && !m_spectrumInputSourceElseSink && (m_spectrumInputIndex == istream)) { DSPSignalNotification spectrumNotif(sampleRate, centerFrequency); From f9328789d516890e0cf41813ef3a64ba3aecd6e0 Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 28 May 2019 16:31:44 +0200 Subject: [PATCH 5/8] MIMO: test MI: fixed updateFrequencyShiftLimit method zeroing frequency shift --- plugins/samplemimo/testmi/testmi.cpp | 27 ++++++++++++++++++++++++- plugins/samplemimo/testmi/testmigui.cpp | 4 +++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/plugins/samplemimo/testmi/testmi.cpp b/plugins/samplemimo/testmi/testmi.cpp index 1daa56b56..4a1ae5e8d 100644 --- a/plugins/samplemimo/testmi/testmi.cpp +++ b/plugins/samplemimo/testmi/testmi.cpp @@ -278,8 +278,33 @@ bool TestMI::applySettings(const TestMISettings& settings, bool force) { DeviceSettingsKeys deviceSettingsKeys; - for (unsigned int istream = 0; istream < m_settings.m_streams.size(); istream++) + qDebug() << "TestMI::applySettings: common: " + << " m_fileRecordName: " << settings.m_fileRecordName + << " m_useReverseAPI: " << settings.m_useReverseAPI + << " m_reverseAPIAddress: " << settings.m_reverseAPIAddress + << " m_reverseAPIPort: " << settings.m_reverseAPIPort + << " m_reverseAPIDeviceIndex: " << settings.m_reverseAPIDeviceIndex; + + for (unsigned int istream = 0; (istream < m_settings.m_streams.size()) && (istream < settings.m_streams.size()); istream++) { + qDebug() << "TestMI::applySettings: stream #" << istream << ": " + << " m_centerFrequency: " << settings.m_streams[istream].m_centerFrequency + << " m_frequencyShift: " << settings.m_streams[istream].m_frequencyShift + << " m_sampleRate: " << settings.m_streams[istream].m_sampleRate + << " m_log2Decim: " << settings.m_streams[istream].m_log2Decim + << " m_fcPos: " << settings.m_streams[istream].m_fcPos + << " m_amplitudeBits: " << settings.m_streams[istream].m_amplitudeBits + << " m_sampleSizeIndex: " << settings.m_streams[istream].m_sampleSizeIndex + << " m_autoCorrOptions: " << settings.m_streams[istream].m_autoCorrOptions + << " m_dcFactor: " << settings.m_streams[istream].m_dcFactor + << " m_iFactor: " << settings.m_streams[istream].m_iFactor + << " m_qFactor: " << settings.m_streams[istream].m_qFactor + << " m_phaseImbalance: " << settings.m_streams[istream].m_phaseImbalance + << " m_modulation: " << settings.m_streams[istream].m_modulation + << " m_amModulation: " << settings.m_streams[istream].m_amModulation + << " m_fmDeviation: " << settings.m_streams[istream].m_fmDeviation + << " m_modulationTone: " << settings.m_streams[istream].m_modulationTone; + deviceSettingsKeys.m_streamsSettingsKeys.push_back(QList()); QList& reverseAPIKeys = deviceSettingsKeys.m_streamsSettingsKeys.back(); diff --git a/plugins/samplemimo/testmi/testmigui.cpp b/plugins/samplemimo/testmi/testmigui.cpp index e762588ff..c8d8843dc 100644 --- a/plugins/samplemimo/testmi/testmigui.cpp +++ b/plugins/samplemimo/testmi/testmigui.cpp @@ -387,8 +387,10 @@ void TestMIGui::updateAmpFineLimit() void TestMIGui::updateFrequencyShiftLimit() { - int sampleRate = ui->sampleRate->getValueNew(); + qint64 sampleRate = ui->sampleRate->getValueNew(); + qint64 frequencyShift = ui->frequencyShift->getValueNew(); ui->frequencyShift->setValueRange(false, 7, -sampleRate, sampleRate); + ui->frequencyShift->setValue(frequencyShift); } void TestMIGui::updateFileRecordStatus() From e361afd29f9503130dbdfa09b99a33158f3ce66a Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 29 May 2019 22:09:19 +0200 Subject: [PATCH 6/8] MIMO: implement I/Q correction for sources --- plugins/samplemimo/testmi/testmigui.cpp | 3 +- sdrbase/dsp/dspdevicemimoengine.cpp | 99 ++++++++++++++++++++++++- sdrbase/dsp/dspdevicemimoengine.h | 1 + 3 files changed, 99 insertions(+), 4 deletions(-) diff --git a/plugins/samplemimo/testmi/testmigui.cpp b/plugins/samplemimo/testmi/testmigui.cpp index c8d8843dc..01c12b763 100644 --- a/plugins/samplemimo/testmi/testmigui.cpp +++ b/plugins/samplemimo/testmi/testmigui.cpp @@ -388,9 +388,8 @@ void TestMIGui::updateAmpFineLimit() void TestMIGui::updateFrequencyShiftLimit() { qint64 sampleRate = ui->sampleRate->getValueNew(); - qint64 frequencyShift = ui->frequencyShift->getValueNew(); ui->frequencyShift->setValueRange(false, 7, -sampleRate, sampleRate); - ui->frequencyShift->setValue(frequencyShift); + ui->frequencyShift->setValue(m_settings.m_streams[m_streamIndex].m_frequencyShift); } void TestMIGui::updateFileRecordStatus() diff --git a/sdrbase/dsp/dspdevicemimoengine.cpp b/sdrbase/dsp/dspdevicemimoengine.cpp index 65546e477..e209ab4ac 100644 --- a/sdrbase/dsp/dspdevicemimoengine.cpp +++ b/sdrbase/dsp/dspdevicemimoengine.cpp @@ -357,7 +357,10 @@ void DSPDeviceMIMOEngine::workSampleSink(unsigned int sinkIndex) // first part of FIFO data if (part1begin != part1end) { - // TODO: DC and IQ corrections + // DC and IQ corrections + if (m_sourcesCorrections[sinkIndex].m_dcOffsetCorrection) { + iqCorrections(part1begin, part1end, sinkIndex, m_sourcesCorrections[sinkIndex].m_iqImbalanceCorrection); + } // feed data to direct sinks if (sinkIndex < m_basebandSampleSinks.size()) @@ -382,7 +385,10 @@ void DSPDeviceMIMOEngine::workSampleSink(unsigned int sinkIndex) // second part of FIFO data (used when block wraps around) if(part2begin != part2end) { - // TODO: DC and IQ corrections + // DC and IQ corrections + if (m_sourcesCorrections[sinkIndex].m_dcOffsetCorrection) { + iqCorrections(part2begin, part2end, sinkIndex, m_sourcesCorrections[sinkIndex].m_iqImbalanceCorrection); + } // feed data to direct sinks if (sinkIndex < m_basebandSampleSinks.size()) @@ -1048,3 +1054,92 @@ void DSPDeviceMIMOEngine::handleForwardToSpectrumSink(int nbSamples) m_spectrumSink->feed(readUntil - nbSamples, readUntil, false); } } + +void DSPDeviceMIMOEngine::iqCorrections(SampleVector::iterator begin, SampleVector::iterator end, int isource, bool imbalanceCorrection) +{ + for(SampleVector::iterator it = begin; it < end; it++) + { + m_sourcesCorrections[isource].m_iBeta(it->real()); + m_sourcesCorrections[isource].m_qBeta(it->imag()); + + if (imbalanceCorrection) + { +#if IMBALANCE_INT + // acquisition + int64_t xi = (it->m_real - (int32_t) m_sourcesCorrections[isource].m_iBeta) << 5; + int64_t xq = (it->m_imag - (int32_t) m_sourcesCorrections[isource].m_qBeta) << 5; + + // phase imbalance + m_sourcesCorrections[isource].m_avgII((xi*xi)>>28); // + m_sourcesCorrections[isource].m_avgIQ((xi*xq)>>28); // + + if ((int64_t) m_sourcesCorrections[isource].m_avgII != 0) + { + int64_t phi = (((int64_t) m_sourcesCorrections[isource].m_avgIQ)<<28) / (int64_t) m_sourcesCorrections[isource].m_avgII; + m_sourcesCorrections[isource].m_avgPhi(phi); + } + + int64_t corrPhi = (((int64_t) m_sourcesCorrections[isource].m_avgPhi) * xq) >> 28; //(m_avgPhi.asDouble()/16777216.0) * ((double) xq); + + int64_t yi = xi - corrPhi; + int64_t yq = xq; + + // amplitude I/Q imbalance + m_sourcesCorrections[isource].m_avgII2((yi*yi)>>28); // + m_sourcesCorrections[isource].m_avgQQ2((yq*yq)>>28); // + + if ((int64_t) m_sourcesCorrections[isource].m_avgQQ2 != 0) + { + int64_t a = (((int64_t) m_sourcesCorrections[isource].m_avgII2)<<28) / (int64_t) m_sourcesCorrections[isource].m_avgQQ2; + Fixed fA(Fixed::internal(), a); + Fixed sqrtA = sqrt((Fixed) fA); + m_sourcesCorrections[isource].m_avgAmp(sqrtA.as_internal()); + } + + int64_t zq = (((int64_t) m_sourcesCorrections[isource].m_avgAmp) * yq) >> 28; + + it->m_real = yi >> 5; + it->m_imag = zq >> 5; + +#else + // DC correction and conversion + float xi = (it->m_real - (int32_t) m_sourcesCorrections[isource].m_iBeta) / SDR_RX_SCALEF; + float xq = (it->m_imag - (int32_t) m_sourcesCorrections[isource].m_qBeta) / SDR_RX_SCALEF; + + // phase imbalance + m_sourcesCorrections[isource].m_avgII(xi*xi); // + m_sourcesCorrections[isource].m_avgIQ(xi*xq); // + + + if (m_sourcesCorrections[isource].m_avgII.asDouble() != 0) { + m_sourcesCorrections[isource].m_avgPhi(m_sourcesCorrections[isource].m_avgIQ.asDouble()/m_sourcesCorrections[isource].m_avgII.asDouble()); + } + + float& yi = xi; // the in phase remains the reference + float yq = xq - m_sourcesCorrections[isource].m_avgPhi.asDouble()*xi; + + // amplitude I/Q imbalance + m_sourcesCorrections[isource].m_avgII2(yi*yi); // + m_sourcesCorrections[isource].m_avgQQ2(yq*yq); // + + if (m_sourcesCorrections[isource].m_avgQQ2.asDouble() != 0) { + m_sourcesCorrections[isource].m_avgAmp(sqrt(m_sourcesCorrections[isource].m_avgII2.asDouble() / m_sourcesCorrections[isource].m_avgQQ2.asDouble())); + } + + // final correction + float& zi = yi; // the in phase remains the reference + float zq = m_sourcesCorrections[isource].m_avgAmp.asDouble() * yq; + + // convert and store + it->m_real = zi * SDR_RX_SCALEF; + it->m_imag = zq * SDR_RX_SCALEF; +#endif + } + else + { + // DC correction only + it->m_real -= (int32_t) m_sourcesCorrections[isource].m_iBeta; + it->m_imag -= (int32_t) m_sourcesCorrections[isource].m_qBeta; + } + } +} diff --git a/sdrbase/dsp/dspdevicemimoengine.h b/sdrbase/dsp/dspdevicemimoengine.h index 4276ae015..6cd6f42cb 100644 --- a/sdrbase/dsp/dspdevicemimoengine.h +++ b/sdrbase/dsp/dspdevicemimoengine.h @@ -389,6 +389,7 @@ private: State gotoError(const QString& errorMsg); //!< Go to an error state void handleSetMIMO(DeviceSampleMIMO* mimo); //!< Manage MIMO device setting + void iqCorrections(SampleVector::iterator begin, SampleVector::iterator end, int isource, bool imbalanceCorrection); private slots: void handleData(); //!< Handle data when samples have to be processed From d0c829f14172d36460bcef1abf99c569de9524d6 Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 29 May 2019 23:53:33 +0200 Subject: [PATCH 7/8] Test MI: added option to lock stream selection to spectrum display --- plugins/samplemimo/testmi/testmigui.cpp | 26 +++++++++++++++++++++++++ plugins/samplemimo/testmi/testmigui.h | 1 + plugins/samplemimo/testmi/testmigui.ui | 18 +++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/plugins/samplemimo/testmi/testmigui.cpp b/plugins/samplemimo/testmi/testmigui.cpp index 01c12b763..745369ee5 100644 --- a/plugins/samplemimo/testmi/testmigui.cpp +++ b/plugins/samplemimo/testmi/testmigui.cpp @@ -150,6 +150,15 @@ void TestMIGui::on_startStop_toggled(bool checked) void TestMIGui::on_streamIndex_currentIndexChanged(int index) { + if (ui->streamLock->isChecked()) + { + m_spectrumStreamIndex = index; + m_deviceUISet->m_deviceAPI->setSpectrumSinkInput(true, m_spectrumStreamIndex); + ui->spectrumSource->blockSignals(true); + ui->spectrumSource->setCurrentIndex(index); + ui->spectrumSource->blockSignals(false); + } + m_streamIndex = index; updateFileRecordStatus(); updateSampleRateAndFrequency(); @@ -161,6 +170,23 @@ void TestMIGui::on_spectrumSource_currentIndexChanged(int index) m_spectrumStreamIndex = index; m_deviceUISet->m_deviceAPI->setSpectrumSinkInput(true, m_spectrumStreamIndex); updateSampleRateAndFrequency(); + + if (ui->streamLock->isChecked()) + { + ui->streamIndex->blockSignals(true); + ui->streamIndex->setCurrentIndex(index); + ui->streamIndex->blockSignals(false); + m_streamIndex = index; + updateFileRecordStatus(); + displaySettings(); + } +} + +void TestMIGui::on_streamLock_toggled(bool checked) +{ + if (checked && (ui->streamIndex->currentIndex() != ui->spectrumSource->currentIndex())) { + ui->spectrumSource->setCurrentIndex(ui->streamIndex->currentIndex()); + } } void TestMIGui::on_centerFrequency_changed(quint64 value) diff --git a/plugins/samplemimo/testmi/testmigui.h b/plugins/samplemimo/testmi/testmigui.h index 0585f2674..eaff0fb03 100644 --- a/plugins/samplemimo/testmi/testmigui.h +++ b/plugins/samplemimo/testmi/testmigui.h @@ -85,6 +85,7 @@ private slots: void on_startStop_toggled(bool checked); void on_streamIndex_currentIndexChanged(int index); void on_spectrumSource_currentIndexChanged(int index); + void on_streamLock_toggled(bool checked); void on_centerFrequency_changed(quint64 value); void on_autoCorr_currentIndexChanged(int index); void on_frequencyShift_changed(qint64 value); diff --git a/plugins/samplemimo/testmi/testmigui.ui b/plugins/samplemimo/testmi/testmigui.ui index ed074e225..e21fe1946 100644 --- a/plugins/samplemimo/testmi/testmigui.ui +++ b/plugins/samplemimo/testmi/testmigui.ui @@ -102,6 +102,24 @@
+ + + + Lock spectrum display to stream selection + + + + + + + :/unlocked.png + :/locked.png:/unlocked.png + + + true + + + From ecb4a0871852f8132804b351fd00838316dcb28e Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 30 May 2019 18:38:10 +0200 Subject: [PATCH 8/8] MIMO: channel marker affinity with the stream being displayed on the main spectrum. Implemented in demod AM --- plugins/channelrx/demodam/amdemodgui.cpp | 1 + .../channeltx/localsource/localsourcegui.cpp | 1 + plugins/channeltx/modam/ammodgui.cpp | 1 + plugins/channeltx/modatv/atvmodgui.cpp | 1 + plugins/channeltx/modfreedv/freedvmodgui.cpp | 1 + plugins/channeltx/modnfm/nfmmodgui.cpp | 1 + plugins/channeltx/modssb/ssbmodgui.cpp | 1 + plugins/channeltx/modwfm/wfmmodgui.cpp | 1 + .../remotesource/remotesourcegui.cpp | 1 + plugins/channeltx/udpsource/udpsourcegui.cpp | 1 + plugins/samplemimo/testmi/testmigui.cpp | 2 + sdrbase/dsp/channelmarker.cpp | 4 +- sdrbase/dsp/channelmarker.h | 7 ++++ sdrgui/gui/glspectrum.cpp | 41 ++++++++++++++++--- sdrgui/gui/glspectrum.h | 9 +++- sdrgui/mainwindow.cpp | 1 + 16 files changed, 66 insertions(+), 8 deletions(-) diff --git a/plugins/channelrx/demodam/amdemodgui.cpp b/plugins/channelrx/demodam/amdemodgui.cpp index 756a0a608..654a5cc65 100644 --- a/plugins/channelrx/demodam/amdemodgui.cpp +++ b/plugins/channelrx/demodam/amdemodgui.cpp @@ -240,6 +240,7 @@ void AMDemodGUI::onMenuDialogCalled(const QPoint &p) dialog.exec(); m_settings.m_streamIndex = dialog.getSelectedStreamIndex(); + m_channelMarker.setStreamIndex(m_settings.m_streamIndex); displayStreamIndex(); applySettings(); } diff --git a/plugins/channeltx/localsource/localsourcegui.cpp b/plugins/channeltx/localsource/localsourcegui.cpp index 2f495a644..31cf92009 100644 --- a/plugins/channeltx/localsource/localsourcegui.cpp +++ b/plugins/channeltx/localsource/localsourcegui.cpp @@ -125,6 +125,7 @@ LocalSourceGUI::LocalSourceGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, B m_channelMarker.setColor(m_settings.m_rgbColor); m_channelMarker.setCenterFrequency(0); m_channelMarker.setTitle("Local Source"); + m_channelMarker.setSourceOrSinkStream(false); m_channelMarker.blockSignals(false); m_channelMarker.setVisible(true); // activate signal on the last setting only diff --git a/plugins/channeltx/modam/ammodgui.cpp b/plugins/channeltx/modam/ammodgui.cpp index 83e96be0a..999c988b2 100644 --- a/plugins/channeltx/modam/ammodgui.cpp +++ b/plugins/channeltx/modam/ammodgui.cpp @@ -342,6 +342,7 @@ AMModGUI::AMModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampl m_channelMarker.setBandwidth(5000); m_channelMarker.setCenterFrequency(0); m_channelMarker.setTitle("AM Modulator"); + m_channelMarker.setSourceOrSinkStream(false); m_channelMarker.blockSignals(false); m_channelMarker.setVisible(true); // activate signal on the last setting only diff --git a/plugins/channeltx/modatv/atvmodgui.cpp b/plugins/channeltx/modatv/atvmodgui.cpp index 8c6a32863..04f1f9a0f 100644 --- a/plugins/channeltx/modatv/atvmodgui.cpp +++ b/plugins/channeltx/modatv/atvmodgui.cpp @@ -678,6 +678,7 @@ ATVModGUI::ATVModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam m_channelMarker.setBandwidth(5000); m_channelMarker.setCenterFrequency(0); m_channelMarker.setTitle("ATV Modulator"); + m_channelMarker.setSourceOrSinkStream(false); m_channelMarker.blockSignals(false); m_channelMarker.setVisible(true); // activate signal on the last setting only diff --git a/plugins/channeltx/modfreedv/freedvmodgui.cpp b/plugins/channeltx/modfreedv/freedvmodgui.cpp index d61571894..e35326859 100644 --- a/plugins/channeltx/modfreedv/freedvmodgui.cpp +++ b/plugins/channeltx/modfreedv/freedvmodgui.cpp @@ -375,6 +375,7 @@ FreeDVModGUI::FreeDVModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999); + m_channelMarker.setSourceOrSinkStream(false); m_channelMarker.setVisible(true); m_deviceUISet->registerTxChannelInstance(FreeDVMod::m_channelIdURI, this); diff --git a/plugins/channeltx/modnfm/nfmmodgui.cpp b/plugins/channeltx/modnfm/nfmmodgui.cpp index 403de44b8..9187414ad 100644 --- a/plugins/channeltx/modnfm/nfmmodgui.cpp +++ b/plugins/channeltx/modnfm/nfmmodgui.cpp @@ -370,6 +370,7 @@ NFMModGUI::NFMModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam m_channelMarker.setBandwidth(12500); m_channelMarker.setCenterFrequency(0); m_channelMarker.setTitle("NFM Modulator"); + m_channelMarker.setSourceOrSinkStream(false); m_channelMarker.blockSignals(false); m_channelMarker.setVisible(true); // activate signal on the last setting only diff --git a/plugins/channeltx/modssb/ssbmodgui.cpp b/plugins/channeltx/modssb/ssbmodgui.cpp index 316616ef2..a709b02e4 100644 --- a/plugins/channeltx/modssb/ssbmodgui.cpp +++ b/plugins/channeltx/modssb/ssbmodgui.cpp @@ -455,6 +455,7 @@ SSBModGUI::SSBModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam m_channelMarker.setSidebands(ChannelMarker::usb); m_channelMarker.setCenterFrequency(0); m_channelMarker.setTitle("SSB Modulator"); + m_channelMarker.setSourceOrSinkStream(false); m_channelMarker.blockSignals(false); m_channelMarker.setVisible(true); diff --git a/plugins/channeltx/modwfm/wfmmodgui.cpp b/plugins/channeltx/modwfm/wfmmodgui.cpp index 408c306bf..65e3e0466 100644 --- a/plugins/channeltx/modwfm/wfmmodgui.cpp +++ b/plugins/channeltx/modwfm/wfmmodgui.cpp @@ -360,6 +360,7 @@ WFMModGUI::WFMModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam m_channelMarker.setBandwidth(125000); m_channelMarker.setCenterFrequency(0); m_channelMarker.setTitle("WFM Modulator"); + m_channelMarker.setSourceOrSinkStream(false); m_channelMarker.blockSignals(false); m_channelMarker.setVisible(true); // activate signal on the last setting only diff --git a/plugins/channeltx/remotesource/remotesourcegui.cpp b/plugins/channeltx/remotesource/remotesourcegui.cpp index 1058e0ce4..26433ea69 100644 --- a/plugins/channeltx/remotesource/remotesourcegui.cpp +++ b/plugins/channeltx/remotesource/remotesourcegui.cpp @@ -184,6 +184,7 @@ RemoteSourceGUI::RemoteSourceGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, m_channelMarker.setColor(m_settings.m_rgbColor); m_channelMarker.setCenterFrequency(0); m_channelMarker.setTitle("Remote source"); + m_channelMarker.setSourceOrSinkStream(false); m_channelMarker.blockSignals(false); m_channelMarker.setVisible(true); // activate signal on the last setting only diff --git a/plugins/channeltx/udpsource/udpsourcegui.cpp b/plugins/channeltx/udpsource/udpsourcegui.cpp index eb7d220d2..c57aeed74 100644 --- a/plugins/channeltx/udpsource/udpsourcegui.cpp +++ b/plugins/channeltx/udpsource/udpsourcegui.cpp @@ -159,6 +159,7 @@ UDPSourceGUI::UDPSourceGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb m_channelMarker.setCenterFrequency(0); m_channelMarker.setColor(m_settings.m_rgbColor); m_channelMarker.setTitle("UDP Sample Sink"); + m_channelMarker.setSourceOrSinkStream(false); m_channelMarker.blockSignals(false); m_channelMarker.setVisible(true); // activate signal on the last setting only diff --git a/plugins/samplemimo/testmi/testmigui.cpp b/plugins/samplemimo/testmi/testmigui.cpp index 745369ee5..6433621bb 100644 --- a/plugins/samplemimo/testmi/testmigui.cpp +++ b/plugins/samplemimo/testmi/testmigui.cpp @@ -153,6 +153,7 @@ void TestMIGui::on_streamIndex_currentIndexChanged(int index) if (ui->streamLock->isChecked()) { m_spectrumStreamIndex = index; + m_deviceUISet->m_spectrum->setDisplayedStream(true, index); m_deviceUISet->m_deviceAPI->setSpectrumSinkInput(true, m_spectrumStreamIndex); ui->spectrumSource->blockSignals(true); ui->spectrumSource->setCurrentIndex(index); @@ -168,6 +169,7 @@ void TestMIGui::on_streamIndex_currentIndexChanged(int index) void TestMIGui::on_spectrumSource_currentIndexChanged(int index) { m_spectrumStreamIndex = index; + m_deviceUISet->m_spectrum->setDisplayedStream(true, index); m_deviceUISet->m_deviceAPI->setSpectrumSinkInput(true, m_spectrumStreamIndex); updateSampleRateAndFrequency(); diff --git a/sdrbase/dsp/channelmarker.cpp b/sdrbase/dsp/channelmarker.cpp index 1b242caf2..b106471b5 100644 --- a/sdrbase/dsp/channelmarker.cpp +++ b/sdrbase/dsp/channelmarker.cpp @@ -37,7 +37,9 @@ ChannelMarker::ChannelMarker(QObject* parent) : m_highlighted(false), m_color(m_colorTable[m_nextColor]), m_movable(true), - m_fScaleDisplayType(FScaleDisplay_freq) + m_fScaleDisplayType(FScaleDisplay_freq), + m_sourceOrSinkStream(true), + m_streamIndex(0) { ++m_nextColor; if(m_colorTable[m_nextColor] == 0) diff --git a/sdrbase/dsp/channelmarker.h b/sdrbase/dsp/channelmarker.h index 125a4cf58..4e93d720b 100644 --- a/sdrbase/dsp/channelmarker.h +++ b/sdrbase/dsp/channelmarker.h @@ -72,6 +72,11 @@ public: const QString& getDisplayAddressSend() const { return m_displayAddressSend; } const QString& getDisplayAddressReceive() const { return m_displayAddressReceive; } + void setSourceOrSinkStream(bool sourceOrSinkStream) { m_sourceOrSinkStream = sourceOrSinkStream; } + bool getSourceOrSinkStream() const { return m_sourceOrSinkStream; } + void setStreamIndex(int streamIndex) { m_streamIndex = streamIndex; } + int getStreamIndex() const { return m_streamIndex; } + virtual QByteArray serialize() const; virtual bool deserialize(const QByteArray& data); @@ -92,6 +97,8 @@ protected: QColor m_color; bool m_movable; frequencyScaleDisplay_t m_fScaleDisplayType; + bool m_sourceOrSinkStream; + int m_streamIndex; void resetToDefaults(); diff --git a/sdrgui/gui/glspectrum.cpp b/sdrgui/gui/glspectrum.cpp index 94e686129..9638ab13f 100644 --- a/sdrgui/gui/glspectrum.cpp +++ b/sdrgui/gui/glspectrum.cpp @@ -64,6 +64,8 @@ GLSpectrum::GLSpectrum(QWidget* parent) : m_histogram(0), m_displayHistogram(true), m_displayChanged(false), + m_displaySourceOrSink(true), + m_displayStreamIndex(0), m_matrixLoc(0), m_colorLoc(0), m_messageQueueToGUI(0) @@ -605,7 +607,10 @@ void GLSpectrum::paintGL() for (int i = 0; i < m_channelMarkerStates.size(); ++i) { ChannelMarkerState* dv = m_channelMarkerStates[i]; - if (dv->m_channelMarker->getVisible()) + + if (dv->m_channelMarker->getVisible() + && (dv->m_channelMarker->getSourceOrSinkStream() == m_displaySourceOrSink) + && (dv->m_channelMarker->getStreamIndex() == m_displayStreamIndex)) { { GLfloat q3[] { @@ -693,7 +698,10 @@ void GLSpectrum::paintGL() for(int i = 0; i < m_channelMarkerStates.size(); ++i) { ChannelMarkerState* dv = m_channelMarkerStates[i]; - if(dv->m_channelMarker->getVisible()) + + if (dv->m_channelMarker->getVisible() + && (dv->m_channelMarker->getSourceOrSinkStream() == m_displaySourceOrSink) + && (dv->m_channelMarker->getStreamIndex() == m_displayStreamIndex)) { { GLfloat q3[] { @@ -784,7 +792,9 @@ void GLSpectrum::paintGL() ChannelMarkerState* dv = m_channelMarkerStates[i]; // frequency scale channel overlay - if(dv->m_channelMarker->getVisible()) + if (dv->m_channelMarker->getVisible() + && (dv->m_channelMarker->getSourceOrSinkStream() == m_displaySourceOrSink) + && (dv->m_channelMarker->getStreamIndex() == m_displayStreamIndex)) { { GLfloat q3[] { @@ -1506,7 +1516,10 @@ void GLSpectrum::applyChanges() // Frequency overlay on highlighted marker for(int i = 0; i < m_channelMarkerStates.size(); ++i) { ChannelMarkerState* dv = m_channelMarkerStates[i]; - if (dv->m_channelMarker->getHighlighted()) + + if (dv->m_channelMarker->getVisible() + && (dv->m_channelMarker->getSourceOrSinkStream() == m_displaySourceOrSink) + && (dv->m_channelMarker->getStreamIndex() == m_displayStreamIndex)) { qreal xc; int shift; @@ -1651,7 +1664,9 @@ void GLSpectrum::mouseMoveEvent(QMouseEvent* event) { Real freq = m_frequencyScale.getValueFromPos(event->x() - m_leftMarginPixmap.width() - 1) - m_centerFrequency; - if (m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getMovable()) + if (m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getMovable() + && (m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getSourceOrSinkStream() == m_displaySourceOrSink) + && (m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getStreamIndex() == m_displayStreamIndex)) { m_channelMarkerStates[m_cursorChannel]->m_channelMarker->setCenterFrequencyByCursor(freq); channelMarkerChanged(); @@ -1662,6 +1677,12 @@ void GLSpectrum::mouseMoveEvent(QMouseEvent* event) { for (int i = 0; i < m_channelMarkerStates.size(); ++i) { + if ((m_channelMarkerStates[i]->m_channelMarker->getSourceOrSinkStream() != m_displaySourceOrSink) + || (m_channelMarkerStates[i]->m_channelMarker->getStreamIndex() != m_displayStreamIndex)) + { + continue; + } + if (m_channelMarkerStates[i]->m_rect.contains(event->pos())) { if (m_cursorState == CSNormal) @@ -1721,7 +1742,9 @@ void GLSpectrum::mousePressEvent(QMouseEvent* event) m_cursorChannel = 0; Real freq = m_frequencyScale.getValueFromPos(event->x() - m_leftMarginPixmap.width() - 1) - m_centerFrequency; - if(m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getMovable()) + if (m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getMovable() + && (m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getSourceOrSinkStream() == m_displaySourceOrSink) + && (m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getStreamIndex() == m_displayStreamIndex)) { m_channelMarkerStates[m_cursorChannel]->m_channelMarker->setCenterFrequencyByCursor(freq); channelMarkerChanged(); @@ -1756,6 +1779,12 @@ void GLSpectrum::wheelEvent(QWheelEvent *event) for (int i = 0; i < m_channelMarkerStates.size(); ++i) { + if ((m_channelMarkerStates[i]->m_channelMarker->getSourceOrSinkStream() != m_displaySourceOrSink) + || (m_channelMarkerStates[i]->m_channelMarker->getStreamIndex() != m_displayStreamIndex)) + { + continue; + } + if (m_channelMarkerStates[i]->m_rect.contains(event->pos())) { int freq = m_channelMarkerStates[i]->m_channelMarker->getCenterFrequency(); diff --git a/sdrgui/gui/glspectrum.h b/sdrgui/gui/glspectrum.h index 053a173e4..75940813e 100644 --- a/sdrgui/gui/glspectrum.h +++ b/sdrgui/gui/glspectrum.h @@ -96,6 +96,12 @@ public: void setWaterfallShare(Real waterfallShare); void connectTimer(const QTimer& timer); + void setDisplayedStream(bool sourceOrSink, int streamIndex) + { + m_displaySourceOrSink = sourceOrSink; + m_displayStreamIndex = streamIndex; + } + private: struct ChannelMarkerState { ChannelMarker* m_channelMarker; @@ -180,8 +186,9 @@ private: QMatrix4x4 m_glHistogramSpectrumMatrix; QMatrix4x4 m_glHistogramBoxMatrix; bool m_displayHistogram; - bool m_displayChanged; + bool m_displaySourceOrSink; + int m_displayStreamIndex; GLShaderSimple m_glShaderSimple; GLShaderTextured m_glShaderLeftScale; diff --git a/sdrgui/mainwindow.cpp b/sdrgui/mainwindow.cpp index b62ce1e17..5e359105c 100644 --- a/sdrgui/mainwindow.cpp +++ b/sdrgui/mainwindow.cpp @@ -362,6 +362,7 @@ void MainWindow::addSinkDevice() connect(m_deviceUIs.back()->m_samplingDeviceControl->getAddChannelButton(), SIGNAL(clicked(bool)), this, SLOT(channelAddClicked(bool))); dspDeviceSinkEngine->addSpectrumSink(m_deviceUIs.back()->m_spectrumVis); + m_deviceUIs.back()->m_spectrum->setDisplayedStream(false, 0); ui->tabSpectra->addTab(m_deviceUIs.back()->m_spectrum, tabNameCStr); ui->tabSpectraGUI->addTab(m_deviceUIs.back()->m_spectrumGUI, tabNameCStr); ui->tabChannels->addTab(m_deviceUIs.back()->m_channelWindow, tabNameCStr);