ngscopeclient 0.1-dev+51fbda87c
Load.h
Go to the documentation of this file.
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
37#ifndef Load_h
38#define Load_h
39
44class Load : public virtual Instrument
45{
46public:
47 Load();
48 virtual ~Load();
49
50 virtual unsigned int GetInstrumentTypes() const override;
51
52 virtual bool AcquireData() override;
53
54 //New object model does not have explicit query methods for channel properties.
55 //Instead, call AcquireData() then read scalar channel state
56
58 // Operating modes
59
62 {
65
68
71
74 };
75
81 virtual LoadMode GetLoadMode(size_t channel) =0;
82
89 virtual void SetLoadMode(size_t channel, LoadMode mode) =0;
90
91 static std::string GetNameOfLoadMode(LoadMode mode);
92 static LoadMode GetLoadModeOfName(const std::string& name);
93
95 // Range selection
96
104 virtual std::vector<float> GetLoadCurrentRanges(size_t channel) =0;
105
111 virtual size_t GetLoadCurrentRange(size_t channel) =0;
112
121 virtual std::vector<float> GetLoadVoltageRanges(size_t channel) =0;
122
128 virtual size_t GetLoadVoltageRange(size_t channel) =0;
129
136 virtual void SetLoadVoltageRange(size_t channel, size_t rangeIndex) =0;
137
144 virtual void SetLoadCurrentRange(size_t channel, size_t rangeIndex) =0;
145
147 // Channel control
148
154 virtual bool GetLoadActive(size_t channel) =0;
155
162 virtual void SetLoadActive(size_t channel, bool active) =0;
163
171 virtual float GetLoadSetPoint(size_t channel) =0;
172
181 virtual void SetLoadSetPoint(size_t channel, float target) =0;
182
184 // Readback
185 // Typically called by AcquireData() and cached in the channel object, not used directly by applications
186
187protected:
188
194 virtual float GetLoadVoltageActual(size_t channel) =0;
195
201 virtual float GetLoadCurrentActual(size_t channel) =0;
202
204 // Configuration storage
205
206protected:
207 void DoSerializeConfiguration(YAML::Node& node, IDTable& table);
208 void DoLoadConfiguration(int version, const YAML::Node& node, IDTable& idmap);
209 void DoPreLoadConfiguration(int version, const YAML::Node& node, IDTable& idmap, ConfigWarningList& list);
210};
211
212#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
Base class for all electronic load drivers.
Definition: Load.h:45
virtual size_t GetLoadCurrentRange(size_t channel)=0
Returns the index of the load's selected current range, as returned by GetLoadCurrentRanges()
LoadMode
Operating modes for the load.
Definition: Load.h:62
@ MODE_CONSTANT_VOLTAGE
Draw as much current as needed for the input voltage to drop to the specified level.
Definition: Load.h:67
@ MODE_CONSTANT_CURRENT
Draw a constant current regardless of supplied voltage.
Definition: Load.h:64
@ MODE_CONSTANT_POWER
Draw a constant power regardless of supplied voltage.
Definition: Load.h:73
@ MODE_CONSTANT_RESISTANCE
Emulate a fixed resistance.
Definition: Load.h:70
virtual float GetLoadSetPoint(size_t channel)=0
Gets the set point for the channel.
virtual void SetLoadMode(size_t channel, LoadMode mode)=0
Sets the operating mode of the load.
virtual void SetLoadActive(size_t channel, bool active)=0
Turns the load on or off.
virtual void SetLoadCurrentRange(size_t channel, size_t rangeIndex)=0
Select the current range to use.
static std::string GetNameOfLoadMode(LoadMode mode)
Convert a LoadMode to a printable string.
Definition: Load.cpp:87
virtual unsigned int GetInstrumentTypes() const override
Returns a bitfield describing the set of instrument types that this instrument supports.
Definition: Load.cpp:54
virtual std::vector< float > GetLoadCurrentRanges(size_t channel)=0
Returns a sorted list of operating ranges for the load's current scale, in amps.
virtual std::vector< float > GetLoadVoltageRanges(size_t channel)=0
Returns a sorted list of operating ranges for the load's voltage scale, in volts.
virtual size_t GetLoadVoltageRange(size_t channel)=0
Returns the index of the load's selected voltage range, as returned by GetLoadVoltageRanges()
virtual float GetLoadCurrentActual(size_t channel)=0
Get the measured current of the load (uncached instantaneous measurement)
virtual LoadMode GetLoadMode(size_t channel)=0
Returns the operating mode of the load.
void DoSerializeConfiguration(YAML::Node &node, IDTable &table)
Serializes this multimeter's configuration to a YAML node.
Definition: Load.cpp:135
void DoLoadConfiguration(int version, const YAML::Node &node, IDTable &idmap)
Load instrument and channel configuration from a save file.
Definition: Load.cpp:185
static LoadMode GetLoadModeOfName(const std::string &name)
Convert a printable string to a LoadMode.
Definition: Load.cpp:116
virtual void SetLoadVoltageRange(size_t channel, size_t rangeIndex)=0
Select the voltage range to use.
virtual bool GetLoadActive(size_t channel)=0
Returns true if the load is enabled (sinking power) and false if disabled (no load)
void DoPreLoadConfiguration(int version, const YAML::Node &node, IDTable &idmap, ConfigWarningList &list)
Validate instrument and channel configuration from a save file.
Definition: Load.cpp:209
virtual bool AcquireData() override
Pulls data from hardware and updates our measurements.
Definition: Load.cpp:62
virtual void SetLoadSetPoint(size_t channel, float target)=0
Sets the set point for the channel.
virtual float GetLoadVoltageActual(size_t channel)=0
Get the measured voltage of the load (uncached instantaneous measurement)