ngscopeclient 0.1-dev+51fbda87c
PowerSupply.h
1/***********************************************************************************************************************
2* *
3* libscopehal *
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
30#ifndef PowerSupply_h
31#define PowerSupply_h
32
36class PowerSupply : public virtual Instrument
37{
38public:
40 virtual ~PowerSupply();
41
42 virtual unsigned int GetInstrumentTypes() const override;
43
44 //Device capabilities
51 virtual bool SupportsSoftStart();
52
60
67 virtual bool SupportsMasterOutputSwitching();
68
75 virtual bool SupportsOvercurrentShutdown();
76
83 virtual bool SupportsVoltageCurrentControl(int chan);
84
85 virtual bool AcquireData() override;
86
87 //Read sensors
88 virtual double GetPowerVoltageActual(int chan) =0; //actual voltage after current limiting
89 virtual double GetPowerVoltageNominal(int chan) =0; //set point
90 virtual double GetPowerCurrentActual(int chan) =0; //actual current drawn by the load
91 virtual double GetPowerCurrentNominal(int chan) =0; //current limit
92 virtual bool GetPowerChannelActive(int chan);
93
94 //Configuration
95 virtual bool GetPowerOvercurrentShutdownEnabled(int chan); //shut channel off entirely on overload,
96 //rather than current limiting
97 virtual void SetPowerOvercurrentShutdownEnabled(int chan, bool enable);
98 virtual bool GetPowerOvercurrentShutdownTripped(int chan);
99 virtual void SetPowerVoltage(int chan, double volts) =0;
100 virtual void SetPowerCurrent(int chan, double amps) =0;
101 virtual void SetPowerChannelActive(int chan, bool on);
102
103 virtual bool IsPowerConstantCurrent(int chan) =0; //true = CC, false = CV
104
105 virtual bool GetMasterPowerEnable();
106 virtual void SetMasterPowerEnable(bool enable);
107
108 //Soft start
109 virtual bool IsSoftStartEnabled(int chan);
110 virtual void SetSoftStartEnabled(int chan, bool enable);
111
119 virtual int64_t GetSoftStartRampTime(int chan);
120
127 virtual void SetSoftStartRampTime(int chan, int64_t time);
128
130 // Serialization
131
132protected:
136 void DoSerializeConfiguration(YAML::Node& node, IDTable& table);
137
141 void DoLoadConfiguration(int version, const YAML::Node& node, IDTable& idmap);
142
146 void DoPreLoadConfiguration(int version, const YAML::Node& node, IDTable& idmap, ConfigWarningList& list);
147};
148
149#endif
All warnings generated by a configuration we're in the process of loading.
Definition: ConfigWarningList.h:90
Bidirectional table mapping integer IDs in scopesession files to object pointers.
Definition: IDTable.h:49
An arbitrary lab instrument. Oscilloscope, LA, PSU, DMM, etc.
Definition: Instrument.h:58
A generic power supply.
Definition: PowerSupply.h:37
virtual int64_t GetSoftStartRampTime(int chan)
Gets the ramp time for use with soft-start mode.
Definition: PowerSupply.cpp:120
virtual bool SupportsIndividualOutputSwitching()
Determines if the power supply supports switching individual output channels.
Definition: PowerSupply.cpp:57
void DoSerializeConfiguration(YAML::Node &node, IDTable &table)
Serializes this oscilloscope's configuration to a YAML node.
Definition: PowerSupply.cpp:153
virtual bool SupportsVoltageCurrentControl(int chan)
Determines if the power supply supports voltage/current control for the given channel.
Definition: PowerSupply.cpp:72
virtual void SetSoftStartRampTime(int chan, int64_t time)
Sets the ramp time for use with soft-start mode.
Definition: PowerSupply.cpp:125
virtual bool AcquireData() override
Pulls data from hardware and updates our measurements.
Definition: PowerSupply.cpp:133
virtual bool SupportsOvercurrentShutdown()
Determines if the power supply supports shutdown rather than constant-current mode on overcurrent.
Definition: PowerSupply.cpp:67
void DoLoadConfiguration(int version, const YAML::Node &node, IDTable &idmap)
Load instrument and channel configuration from a save file.
Definition: PowerSupply.cpp:297
void DoPreLoadConfiguration(int version, const YAML::Node &node, IDTable &idmap, ConfigWarningList &list)
Validate instrument and channel configuration from a save file.
Definition: PowerSupply.cpp:208
virtual bool SupportsMasterOutputSwitching()
Determines if the power supply supports ganged master switching of all outputs.
Definition: PowerSupply.cpp:62
virtual unsigned int GetInstrumentTypes() const override
Returns a bitfield describing the set of instrument types that this instrument supports.
Definition: PowerSupply.cpp:47
virtual bool SupportsSoftStart()
Determines if the power supply supports soft start.
Definition: PowerSupply.cpp:52