ngscopeclient v0.3
Loading...
Searching...
No Matches
PowerSupplyDialog.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* ngscopeclient *
4* *
5* Copyright (c) 2012-2026 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_softStartEnabled(false)
67 , m_setVoltage("")
68 , m_setCurrent("")
69 , m_committedSetVoltage(0)
70 , m_committedSetCurrent(0)
71 , m_committedSSRamp(0)
72 {}
73
74 PowerSupplyChannelUIState(std::shared_ptr<SCPIPowerSupply> psu, int chan)
75 : m_outputEnabled(psu->GetPowerChannelActive(chan))
76 , m_overcurrentShutdownEnabled(psu->GetPowerOvercurrentShutdownEnabled(chan))
77 , m_softStartEnabled(psu->IsSoftStartEnabled(chan))
78 , m_committedSetVoltage(psu->GetPowerVoltageNominal(chan))
79 , m_committedSetCurrent(psu->GetPowerCurrentNominal(chan))
80 , m_committedSSRamp(psu->GetSoftStartRampTime(chan))
81 {
82 Unit volts(Unit::UNIT_VOLTS);
83 Unit amps(Unit::UNIT_AMPS);
84 Unit fs(Unit::UNIT_FS);
85 m_setVoltage = volts.PrettyPrint(m_committedSetVoltage);
86 m_setCurrent = amps.PrettyPrint(m_committedSetCurrent);
87 m_setSSRamp = fs.PrettyPrint(m_committedSSRamp);
88 }
89};
90
92{
93public:
94 PowerSupplyDialog(std::shared_ptr<SCPIPowerSupply> psu, std::shared_ptr<PowerSupplyState> state, Session* session);
95 virtual ~PowerSupplyDialog();
96
97 virtual bool DoRender();
98
99 void RefreshFromHardware();
100
101 std::shared_ptr<SCPIPowerSupply> GetPSU()
102 { return m_psu; }
103
104protected:
105 void ChannelSettings(int i, float v, float a, float etime);
106 void AsyncLoadState();
107
108 //@brief Global power enable (if we have one)
109 bool m_masterEnable;
110
112 double m_tstart;
113
115 std::shared_ptr<SCPIPowerSupply> m_psu;
116
118 std::shared_ptr<PowerSupplyState> m_state;
119
120 //Future channel state during loading
121 std::vector<std::future<PowerSupplyChannelUIState> > m_futureUIState;
122
124 std::vector<PowerSupplyChannelUIState> m_channelUIState;
125};
126
127#endif
Declaration of Dialog.
Declaration of Session.
Definition AcceleratorBuffer.h:204
Generic dialog box or other popup window.
Definition Dialog.h:46
UI state for a single power supply channel.
Definition PowerSupplyDialog.h:49
Definition PowerSupplyDialog.h:92
double m_tstart
Timestamp of when we opened the dialog.
Definition PowerSupplyDialog.h:112
std::vector< PowerSupplyChannelUIState > m_channelUIState
Channel state for the UI.
Definition PowerSupplyDialog.h:124
std::shared_ptr< SCPIPowerSupply > m_psu
The PSU we're controlling.
Definition PowerSupplyDialog.h:115
std::shared_ptr< PowerSupplyState > m_state
Current channel stats, live updated.
Definition PowerSupplyDialog.h:118
void ChannelSettings(int i, float v, float a, float etime)
A single channel's settings.
Definition PowerSupplyDialog.cpp:184
A Session stores all of the instrument configuration and other state the user has open.
Definition Session.h:126
A unit of measurement, plus conversion to pretty-printed output.
Definition Unit.h:59