From ae88a7e5842ca022ae0e93c7463ba51c12f079e3 Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Wed, 9 Jun 2021 17:23:37 +0100 Subject: [PATCH] Report to GUI if failed to open VISA device --- plugins/channelrx/noisefigure/noisefigure.cpp | 17 ++++++++++++++--- plugins/channelrx/noisefigure/noisefigure.h | 6 +----- .../noisefigure/noisefigurecontroldialog.cpp | 6 +++--- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/plugins/channelrx/noisefigure/noisefigure.cpp b/plugins/channelrx/noisefigure/noisefigure.cpp index b98b0df24..138b97527 100644 --- a/plugins/channelrx/noisefigure/noisefigure.cpp +++ b/plugins/channelrx/noisefigure/noisefigure.cpp @@ -120,10 +120,11 @@ void NoiseFigure::stop() m_thread.wait(); } -void NoiseFigure::openVISADevice() +bool NoiseFigure::openVISADevice() { m_visa.openDefault(); m_session = m_visa.open(m_settings.m_visaDevice); + return m_session != 0; } void NoiseFigure::closeVISADevice() @@ -406,8 +407,18 @@ bool NoiseFigure::handleMessage(const Message& cmd) { if (m_state == IDLE) { - openVISADevice(); - QTimer::singleShot(0, this, SLOT(nextState())); + if (!m_settings.m_visaDevice.isEmpty()) + { + if (openVISADevice()) { + QTimer::singleShot(0, this, SLOT(nextState())); + } else if (getMessageQueueToGUI()) { + getMessageQueueToGUI()->push(MsgFinished::create(QString("Failed to open VISA device %1").arg(m_settings.m_visaDevice))); + } + } + else + { + QTimer::singleShot(0, this, SLOT(nextState())); + } } else { diff --git a/plugins/channelrx/noisefigure/noisefigure.h b/plugins/channelrx/noisefigure/noisefigure.h index e0a1d753a..b174bf526 100644 --- a/plugins/channelrx/noisefigure/noisefigure.h +++ b/plugins/channelrx/noisefigure/noisefigure.h @@ -219,12 +219,8 @@ public: void getMagSqLevels(double& avg, double& peak, int& nbSamples) { m_basebandSink->getMagSqLevels(avg, peak, nbSamples); } -/* void setMessageQueueToGUI(MessageQueue* queue) override { - ChannelAPI::setMessageQueueToGUI(queue); - m_basebandSink->setMessageQueueToGUI(queue); - }*/ - void openVISADevice(); + bool openVISADevice(); void closeVISADevice(); void processVISA(QStringList commands); void powerOn(); diff --git a/plugins/channelrx/noisefigure/noisefigurecontroldialog.cpp b/plugins/channelrx/noisefigure/noisefigurecontroldialog.cpp index f9f6ce922..dcf1ddfbd 100644 --- a/plugins/channelrx/noisefigure/noisefigurecontroldialog.cpp +++ b/plugins/channelrx/noisefigure/noisefigurecontroldialog.cpp @@ -49,9 +49,9 @@ NoiseFigureControlDialog::~NoiseFigureControlDialog() void NoiseFigureControlDialog::accept() { - m_settings->m_powerOnCommand = ui->powerOnCommand->text(); - m_settings->m_powerOffCommand = ui->powerOffCommand->text(); - m_settings->m_visaDevice = ui->device->text(); + m_settings->m_powerOnCommand = ui->powerOnCommand->text().trimmed(); + m_settings->m_powerOffCommand = ui->powerOffCommand->text().trimmed(); + m_settings->m_visaDevice = ui->device->text().trimmed(); m_settings->m_powerOnSCPI = ui->powerOnSCPI->toPlainText(); m_settings->m_powerOffSCPI = ui->powerOffSCPI->toPlainText(); m_settings->m_powerDelay = ui->delay->value();