mode: remove mode handler dependency in child modes
This commit is contained in:
parent
2fbe6e84be
commit
6bd80c5944
@ -1,5 +1,4 @@
|
|||||||
#include "generator.h"
|
#include "generator.h"
|
||||||
#include "modehandler.h"
|
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
@ -56,7 +55,7 @@ void Generator::fromJSON(nlohmann::json j)
|
|||||||
|
|
||||||
void Generator::updateDevice()
|
void Generator::updateDevice()
|
||||||
{
|
{
|
||||||
if(!window->getDevice() || window->getModeHandler()->getActiveMode() != this) {
|
if(!window->getDevice() || isActive != true) {
|
||||||
// can't update if not connected
|
// can't update if not connected
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#include "Device/firmwareupdatedialog.h"
|
#include "Device/firmwareupdatedialog.h"
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
#include "Generator/signalgenwidget.h"
|
#include "Generator/signalgenwidget.h"
|
||||||
#include "modehandler.h"
|
|
||||||
|
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
@ -434,7 +433,7 @@ using namespace std;
|
|||||||
|
|
||||||
void SpectrumAnalyzer::NewDatapoint(Protocol::SpectrumAnalyzerResult d)
|
void SpectrumAnalyzer::NewDatapoint(Protocol::SpectrumAnalyzerResult d)
|
||||||
{
|
{
|
||||||
if(window->getModeHandler()->getActiveMode() != this) {
|
if(isActive != true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -571,7 +570,7 @@ void SpectrumAnalyzer::SettingsChanged()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(window->getDevice() && window->getModeHandler()->getActiveMode() == this) {
|
if(window->getDevice() && isActive) {
|
||||||
window->getDevice()->Configure(settings, [=](Device::TransmissionResult res){
|
window->getDevice()->Configure(settings, [=](Device::TransmissionResult res){
|
||||||
// device received command
|
// device received command
|
||||||
changingSettings = false;
|
changingSettings = false;
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#include "Calibration/manualcalibrationdialog.h"
|
#include "Calibration/manualcalibrationdialog.h"
|
||||||
#include "Util/util.h"
|
#include "Util/util.h"
|
||||||
#include "Tools/parameters.h"
|
#include "Tools/parameters.h"
|
||||||
#include "modehandler.h"
|
|
||||||
|
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
@ -802,7 +801,7 @@ using namespace std;
|
|||||||
|
|
||||||
void VNA::NewDatapoint(Protocol::Datapoint d)
|
void VNA::NewDatapoint(Protocol::Datapoint d)
|
||||||
{
|
{
|
||||||
if(window->getModeHandler()->getActiveMode() != this) {
|
if(isActive != true) {
|
||||||
// ignore
|
// ignore
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -973,7 +972,7 @@ void VNA::SettingsChanged(bool resetTraces, std::function<void (Device::Transmis
|
|||||||
s.cdbm_excitation_stop = stop * 100;
|
s.cdbm_excitation_stop = stop * 100;
|
||||||
s.logSweep = false;
|
s.logSweep = false;
|
||||||
}
|
}
|
||||||
if(window->getDevice() && window->getModeHandler()->getActiveMode() == this) {
|
if(window->getDevice() && isActive) {
|
||||||
if(s.excitePort1 == 0 && s.excitePort2 == 0) {
|
if(s.excitePort1 == 0 && s.excitePort2 == 0) {
|
||||||
// no signal at either port, just set the device to idle
|
// no signal at either port, just set the device to idle
|
||||||
window->getDevice()->SetIdle();
|
window->getDevice()->SetIdle();
|
||||||
@ -1487,7 +1486,7 @@ void VNA::SetupSCPI()
|
|||||||
return ret;
|
return ret;
|
||||||
}));
|
}));
|
||||||
scpi_cal->add(new SCPICommand("MEASure", [=](QStringList params) -> QString {
|
scpi_cal->add(new SCPICommand("MEASure", [=](QStringList params) -> QString {
|
||||||
if(params.size() != 1 || CalibrationMeasurementActive() || !window->getDevice() || window->getModeHandler()->getActiveMode() != this) {
|
if(params.size() != 1 || CalibrationMeasurementActive() || !window->getDevice() || isActive != true) {
|
||||||
// no measurement specified, still busy or invalid mode
|
// no measurement specified, still busy or invalid mode
|
||||||
return SCPI::getResultName(SCPI::Result::Error);
|
return SCPI::getResultName(SCPI::Result::Error);
|
||||||
} else {
|
} else {
|
||||||
|
@ -19,6 +19,7 @@ Mode::Mode(AppWindow *window, QString name, QString SCPIname)
|
|||||||
: QObject(window),
|
: QObject(window),
|
||||||
SCPINode(SCPIname),
|
SCPINode(SCPIname),
|
||||||
window(window),
|
window(window),
|
||||||
|
isActive(false),
|
||||||
name(name),
|
name(name),
|
||||||
central(nullptr)
|
central(nullptr)
|
||||||
{
|
{
|
||||||
@ -40,6 +41,7 @@ Mode::~Mode()
|
|||||||
|
|
||||||
void Mode::activate()
|
void Mode::activate()
|
||||||
{
|
{
|
||||||
|
isActive = true;
|
||||||
qDebug() << "Activating mode" << name;
|
qDebug() << "Activating mode" << name;
|
||||||
// show all mode specific GUI elements
|
// show all mode specific GUI elements
|
||||||
for(auto t : toolbars) {
|
for(auto t : toolbars) {
|
||||||
@ -86,6 +88,7 @@ void Mode::activate()
|
|||||||
|
|
||||||
void Mode::deactivate()
|
void Mode::deactivate()
|
||||||
{
|
{
|
||||||
|
isActive = false;
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
// save dock/toolbar visibility
|
// save dock/toolbar visibility
|
||||||
for(auto d : docks) {
|
for(auto d : docks) {
|
||||||
@ -110,6 +113,7 @@ void Mode::deactivate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Deactivated mode" << name;
|
qDebug() << "Deactivated mode" << name;
|
||||||
|
|
||||||
if(window->getDevice()) {
|
if(window->getDevice()) {
|
||||||
window->getDevice()->SetIdle();
|
window->getDevice()->SetIdle();
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ protected:
|
|||||||
|
|
||||||
virtual void activate(); // derived classes must call Mode::activate before doing anything
|
virtual void activate(); // derived classes must call Mode::activate before doing anything
|
||||||
virtual void deactivate(); // derived classes must call Mode::deactivate before returning
|
virtual void deactivate(); // derived classes must call Mode::deactivate before returning
|
||||||
|
bool isActive;
|
||||||
|
|
||||||
void setStatusbarMessage(QString msg);
|
void setStatusbarMessage(QString msg);
|
||||||
// call once the derived class is fully initialized
|
// call once the derived class is fully initialized
|
||||||
|
Loading…
Reference in New Issue
Block a user