diff --git a/lib b/lib index 9eb82a0cb..ba3e7e0d8 160000 --- a/lib +++ b/lib @@ -1 +1 @@ -Subproject commit 9eb82a0cb35cb0e6362d1b6ae555be1df299aa60 +Subproject commit ba3e7e0d883dc944dcc60dd7e806e1dcd2adddd3 diff --git a/src/ngscopeclient/MainWindow.cpp b/src/ngscopeclient/MainWindow.cpp index f1b480a6c..04abeeebd 100644 --- a/src/ngscopeclient/MainWindow.cpp +++ b/src/ngscopeclient/MainWindow.cpp @@ -65,6 +65,7 @@ #include "MetricsDialog.h" #include "MultimeterDialog.h" #include "PersistenceSettingsDialog.h" +#include "PowerSupplyDialog.h" #include "PreferenceDialog.h" #include "ProtocolAnalyzerDialog.h" #include "RFGeneratorDialog.h" @@ -202,6 +203,7 @@ void MainWindow::CloseSession() m_fileBrowser = nullptr; m_measurementsDialog = nullptr; m_meterDialogs.clear(); + m_psuDialogs.clear(); m_channelPropertiesDialogs.clear(); m_generatorDialogs.clear(); m_rfgeneratorDialogs.clear(); @@ -880,6 +882,10 @@ void MainWindow::OnDialogClosed(const std::shared_ptr& dlg) if(meterDlg) m_meterDialogs.erase(meterDlg->GetMeter()); + auto psuDlg = dynamic_pointer_cast(dlg); + if(psuDlg) + m_psuDialogs.erase(psuDlg->GetPSU()); + auto genDlg = dynamic_pointer_cast(dlg); if(genDlg) m_generatorDialogs.erase(genDlg->GetGenerator()); @@ -1940,6 +1946,14 @@ bool MainWindow::LoadSessionFromYaml(const YAML::Node& node, const string& dataD return false; } + //Update all of our instrument dialogs as needed + for(auto it : m_psuDialogs) + { + auto dlg = dynamic_pointer_cast(it.second); + if(dlg) + dlg->RefreshFromHardware(); + } + //Load ImGui configuration LogTrace("Loading ImGui configuration\n"); string ipath = dataDir + "/imgui.ini"; @@ -2482,6 +2496,7 @@ YAML::Node MainWindow::SerializeDialogs() node["meters"] = mnode; } + //TODO: psu dialogs //TODO: generator dialogs //TODO: rf generator dialogs //TODO: SCPI console diff --git a/src/ngscopeclient/MainWindow.h b/src/ngscopeclient/MainWindow.h index 0748b967e..83c86f26b 100644 --- a/src/ngscopeclient/MainWindow.h +++ b/src/ngscopeclient/MainWindow.h @@ -279,6 +279,9 @@ class MainWindow : public VulkanWindow ///@brief Map of multimeters to meter control dialogs std::map > m_meterDialogs; + ///@brief Map of PSUs to power supply control dialogs + std::map > m_psuDialogs; + ///@brief Map of generators to generator control dialogs std::map > m_generatorDialogs; diff --git a/src/ngscopeclient/MainWindow_Menus.cpp b/src/ngscopeclient/MainWindow_Menus.cpp index be98b2703..e5b6c0e91 100644 --- a/src/ngscopeclient/MainWindow_Menus.cpp +++ b/src/ngscopeclient/MainWindow_Menus.cpp @@ -57,6 +57,7 @@ #include "MetricsDialog.h" #include "MultimeterDialog.h" #include "PersistenceSettingsDialog.h" +#include "PowerSupplyDialog.h" #include "PreferenceDialog.h" #include "ProtocolAnalyzerDialog.h" #include "RFGeneratorDialog.h" @@ -75,6 +76,10 @@ void MainWindow::AddDialog(shared_ptr dlg) if(mdlg != nullptr) m_meterDialogs[mdlg->GetMeter()] = dlg; + auto pdlg = dynamic_cast(dlg.get()); + if(pdlg != nullptr) + m_psuDialogs[pdlg->GetPSU()] = dlg; + auto fdlg = dynamic_cast(dlg.get()); if(fdlg != nullptr) m_generatorDialogs[fdlg->GetGenerator()] = dlg; diff --git a/src/ngscopeclient/PowerSupplyDialog.cpp b/src/ngscopeclient/PowerSupplyDialog.cpp index fa935f3c2..59e34dfd1 100644 --- a/src/ngscopeclient/PowerSupplyDialog.cpp +++ b/src/ngscopeclient/PowerSupplyDialog.cpp @@ -53,10 +53,32 @@ PowerSupplyDialog::PowerSupplyDialog(SCPIPowerSupply* psu, shared_ptrRemovePowerSupply(m_psu); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Rendering + +void PowerSupplyDialog::RefreshFromHardware() +{ + //pull settings again + AsyncLoadState(); +} + +void PowerSupplyDialog::AsyncLoadState() +{ + //Clear existing state (if any) and allocate space for new state + m_channelUIState.clear(); m_channelUIState.resize(m_psu->GetChannelCount()); - //Asynchronously load rest of the state + //Do the async load + m_futureUIState.clear(); + SCPIPowerSupply* psu = m_psu; for(size_t i=0; iGetChannelCount(); i++) { //Add placeholders for non-power channels @@ -70,14 +92,6 @@ PowerSupplyDialog::PowerSupplyDialog(SCPIPowerSupply* psu, shared_ptrRemovePowerSupply(m_psu); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Rendering - bool PowerSupplyDialog::DoRender() { //Device information diff --git a/src/ngscopeclient/PowerSupplyDialog.h b/src/ngscopeclient/PowerSupplyDialog.h index c1bdae22f..c3768a51f 100644 --- a/src/ngscopeclient/PowerSupplyDialog.h +++ b/src/ngscopeclient/PowerSupplyDialog.h @@ -89,8 +89,14 @@ class PowerSupplyDialog : public Dialog virtual bool DoRender(); + void RefreshFromHardware(); + + SCPIPowerSupply* GetPSU() + { return m_psu; } + protected: void ChannelSettings(int i, float v, float a, float etime); + void AsyncLoadState(); ///@brief Session handle so we can remove the PSU when closed Session* m_session; diff --git a/src/ngscopeclient/Session.cpp b/src/ngscopeclient/Session.cpp index df4c821ca..96f80dde8 100644 --- a/src/ngscopeclient/Session.cpp +++ b/src/ngscopeclient/Session.cpp @@ -713,8 +713,11 @@ bool Session::LoadInstruments(int version, const YAML::Node& node, bool /*online auto nick = inst["nick"].as(); LogTrace("Loading instrument \"%s\"\n", nick.c_str()); - reinterpret_cast(m_idtable[inst["id"].as()])->LoadConfiguration( - version, inst, m_idtable); + auto pinst = reinterpret_cast(m_idtable[inst["id"].as()]); + if(!pinst) + continue; + + pinst->LoadConfiguration(version, inst, m_idtable); } return true;