ngscopeclient v0.2
Loading...
Searching...
No Matches
MockPowerSupply.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopehal *
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
37#ifndef MockPowerSupply_h
38#define MockPowerSupply_h
39
46{
47public:
49 const std::string& name,
50 const std::string& vendor,
51 const std::string& serial,
52 const std::string& transport,
53 const std::string& driver,
54 const std::string& args
55 );
56 virtual ~MockPowerSupply();
57
58 //Device capabilities
59 bool SupportsSoftStart() override;
61 bool SupportsMasterOutputSwitching() override;
62 bool SupportsOvercurrentShutdown() override;
63
64 //Read sensors
65 double GetPowerVoltageActual(int chan) override; //actual voltage after current limiting
66 double GetPowerVoltageNominal(int chan) override; //set point
67 double GetPowerCurrentActual(int chan) override; //actual current drawn by the load
68 double GetPowerCurrentNominal(int chan) override; //current limit
69 bool GetPowerChannelActive(int chan) override;
70
71 //Configuration
72 bool GetPowerOvercurrentShutdownEnabled(int chan) override; //shut channel off entirely on overload,
73 //rather than current limiting
74 void SetPowerOvercurrentShutdownEnabled(int chan, bool enable) override;
75 bool GetPowerOvercurrentShutdownTripped(int chan) override;
76 void SetPowerVoltage(int chan, double volts) override;
77 void SetPowerCurrent(int chan, double amps) override;
78 void SetPowerChannelActive(int chan, bool on) override;
79 bool IsPowerConstantCurrent(int chan) override;
80
81 bool GetMasterPowerEnable() override;
82 void SetMasterPowerEnable(bool enable) override;
83
84 // Serialization
85 //This is intentionally not virtual since it's called by Instrument::m_preloaders
86 //cppcheck-suppress duplInheritedMember
87 void DoPreLoadConfiguration(int version, const YAML::Node& node, IDTable& idmap, ConfigWarningList& warnings);
88
89 // SCPI
90 virtual void BackgroundProcessing() override {}
91 virtual uint32_t GetInstrumentTypesForChannel(size_t i) const override;
92
93
94protected:
95
96 bool m_masterEnabled;
97 bool m_hasSoftStart;
98 bool m_hasIndividualOutputSwitching;
99 bool m_hasMasterOutputSwitching;
100 bool m_hasOvercurrentShutdown;
101 std::map<size_t, bool> m_enabled;
102 std::map<size_t, bool> m_constantCurrent;
103 std::map<size_t, bool> m_overcurrentShutdown;
104 std::map<size_t, bool> m_overcurrentTripped;
105 std::map<size_t, double> m_voltagesActual;
106 std::map<size_t, double> m_currentsActual;
107 std::map<size_t, double> m_voltagesNominal;
108 std::map<size_t, double> m_currentsNominal;
109 std::map<size_t, double> m_voltageSetPoints;
110 std::map<size_t, double> m_currentSetPoints;
111
112};
113
114#endif
Definition AcceleratorBuffer.h:204
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
Base class for simulated instruments.
Definition MockInstrument.h:44
A simulated power supply for demonstration.
Definition MockPowerSupply.h:46
virtual void BackgroundProcessing() override
Run various background processing typically done by a second thread (e.g. InstrumentThread)
Definition MockPowerSupply.h:90
virtual uint32_t GetInstrumentTypesForChannel(size_t i) const override
Returns a bitfield describing the set of instrument types that a given channel supports.
Definition MockPowerSupply.cpp:139
bool SupportsOvercurrentShutdown() override
Determines if the power supply supports shutdown rather than constant-current mode on overcurrent.
Definition MockPowerSupply.cpp:134
bool SupportsSoftStart() override
Determines if the power supply supports soft start.
Definition MockPowerSupply.cpp:119
bool SupportsIndividualOutputSwitching() override
Determines if the power supply supports switching individual output channels.
Definition MockPowerSupply.cpp:124
bool SupportsMasterOutputSwitching() override
Determines if the power supply supports ganged master switching of all outputs.
Definition MockPowerSupply.cpp:129
An SCPI-based power supply.
Definition SCPIPowerSupply.h:38