ngscopeclient 0.1-dev+51fbda87c
PowerSupplyDialog.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* ngscopeclient *
4* *
5* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
6* All rights reserved. *
7* *
8* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
9* following conditions are met: *
10* *
11* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
12* following disclaimer. *
13* *
14* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
15* following disclaimer in the documentation and/or other materials provided with the distribution. *
16* *
17* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
18* derived from this software without specific prior written permission. *
19* *
20* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
21* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
22* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
24* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
26* POSSIBILITY OF SUCH DAMAGE. *
27* *
28***********************************************************************************************************************/
29
35#ifndef PowerSupplyDialog_h
36#define PowerSupplyDialog_h
37
38#include "Dialog.h"
39#include "Session.h"
40
41#include <future>
42
49{
50public:
51 bool m_outputEnabled;
52 bool m_overcurrentShutdownEnabled;
53 bool m_softStartEnabled;
54
55 std::string m_setVoltage;
56 std::string m_setCurrent;
57 std::string m_setSSRamp;
58
59 float m_committedSetVoltage;
60 float m_committedSetCurrent;
61 float m_committedSSRamp;
62
64 : m_outputEnabled(false)
65 , m_overcurrentShutdownEnabled(false)
66 , m_setVoltage("")
67 , m_setCurrent("")
68 , m_committedSetVoltage(0)
69 , m_committedSetCurrent(0)
70 , m_committedSSRamp(0)
71 {}
72
73 PowerSupplyChannelUIState(std::shared_ptr<SCPIPowerSupply> psu, int chan)
74 : m_outputEnabled(psu->GetPowerChannelActive(chan))
75 , m_overcurrentShutdownEnabled(psu->GetPowerOvercurrentShutdownEnabled(chan))
76 , m_softStartEnabled(psu->IsSoftStartEnabled(chan))
77 , m_committedSetVoltage(psu->GetPowerVoltageNominal(chan))
78 , m_committedSetCurrent(psu->GetPowerCurrentNominal(chan))
79 , m_committedSSRamp(psu->GetSoftStartRampTime(chan))
80 {
81 Unit volts(Unit::UNIT_VOLTS);
82 Unit amps(Unit::UNIT_AMPS);
83 Unit fs(Unit::UNIT_FS);
84 m_setVoltage = volts.PrettyPrint(m_committedSetVoltage);
85 m_setCurrent = amps.PrettyPrint(m_committedSetCurrent);
86 m_setSSRamp = fs.PrettyPrint(m_committedSSRamp);
87 }
88};
89
91{
92public:
93 PowerSupplyDialog(std::shared_ptr<SCPIPowerSupply> psu, std::shared_ptr<PowerSupplyState> state, Session* session);
94 virtual ~PowerSupplyDialog();
95
96 virtual bool DoRender();
97
98 void RefreshFromHardware();
99
100 std::shared_ptr<SCPIPowerSupply> GetPSU()
101 { return m_psu; }
102
103protected:
104 void ChannelSettings(int i, float v, float a, float etime);
105 void AsyncLoadState();
106
109
110 //@brief Global power enable (if we have one)
111 bool m_masterEnable;
112
114 double m_tstart;
115
117 std::shared_ptr<SCPIPowerSupply> m_psu;
118
120 std::shared_ptr<PowerSupplyState> m_state;
121
122 //Future channel state during loading
123 std::vector<std::future<PowerSupplyChannelUIState> > m_futureUIState;
124
126 std::vector<PowerSupplyChannelUIState> m_channelUIState;
127};
128
129#endif
Declaration of Dialog.
Declaration of Session.
Generic dialog box or other popup window.
Definition: Dialog.h:44
UI state for a single power supply channel.
Definition: PowerSupplyDialog.h:49
Definition: PowerSupplyDialog.h:91
double m_tstart
Timestamp of when we opened the dialog.
Definition: PowerSupplyDialog.h:114
std::vector< PowerSupplyChannelUIState > m_channelUIState
Channel state for the UI.
Definition: PowerSupplyDialog.h:126
std::shared_ptr< SCPIPowerSupply > m_psu
The PSU we're controlling.
Definition: PowerSupplyDialog.h:117
Session * m_session
Session handle so we can remove the PSU when closed.
Definition: PowerSupplyDialog.h:108
std::shared_ptr< PowerSupplyState > m_state
Current channel stats, live updated.
Definition: PowerSupplyDialog.h:120
void ChannelSettings(int i, float v, float a, float etime)
A single channel's settings.
Definition: PowerSupplyDialog.cpp:185
A Session stores all of the instrument configuration and other state the user has open.
Definition: Session.h:95
A unit of measurement, plus conversion to pretty-printed output.
Definition: Unit.h:57
std::string PrettyPrint(double value, int sigfigs=-1, bool useDisplayLocale=true) const
Prints a value with SI scaling factors.
Definition: Unit.cpp:587