ngscopeclient 0.1-dev+51fbda87c
Multimeter.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
36#ifndef Multimeter_h
37#define Multimeter_h
38
47class Multimeter : public virtual Instrument
48{
49public:
50 Multimeter();
51 virtual ~Multimeter();
52
53 enum MeasurementTypes
54 {
55 NONE = 0x000,
56
57 DC_VOLTAGE = 0x001,
58 DC_RMS_AMPLITUDE = 0x002,
59 AC_RMS_AMPLITUDE = 0x004,
60 FREQUENCY = 0x008,
61 DC_CURRENT = 0x010,
62 AC_CURRENT = 0x020,
63 TEMPERATURE = 0x040,
64 RESISTANCE = 0x080,
65 CAPACITANCE = 0x100,
66 CONTINUITY = 0x200,
67 DIODE = 0x400
68
69
70 //TODO: other types
71 };
72
73 virtual unsigned int GetMeasurementTypes() =0;
74 virtual unsigned int GetSecondaryMeasurementTypes();
75
76 //Channel info
77 virtual int GetCurrentMeterChannel() =0;
78 virtual void SetCurrentMeterChannel(int chan) =0;
79
80 //Meter operating mode
81 virtual MeasurementTypes GetMeterMode() =0;
82 virtual MeasurementTypes GetSecondaryMeterMode();
83 virtual std::string ModeToText(MeasurementTypes type);
84 MeasurementTypes TextToMode(const std::string& mode);
85 virtual void SetMeterMode(MeasurementTypes type) =0;
86 virtual void SetSecondaryMeterMode(MeasurementTypes type);
87
88 //Control
89 virtual void SetMeterAutoRange(bool enable) =0;
90 virtual bool GetMeterAutoRange() =0;
91 virtual void StartMeter() =0;
92 virtual void StopMeter() =0;
93
97 virtual Unit GetMeterUnit();
98
102 virtual Unit GetSecondaryMeterUnit();
103
107 virtual double GetMeterValue() =0;
108
112 virtual double GetSecondaryMeterValue();
113
119 virtual int GetMeterDigits() =0;
120
121 virtual bool AcquireData() override;
122
124 // Configuration storage
125
126protected:
130 void DoSerializeConfiguration(YAML::Node& node, IDTable& table);
131
135 void DoLoadConfiguration(int version, const YAML::Node& node, IDTable& idmap);
136
140 void DoPreLoadConfiguration(int version, const YAML::Node& node, IDTable& idmap, ConfigWarningList& list);
141};
142
143#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 multimeter.
Definition: Multimeter.h:48
virtual double GetSecondaryMeterValue()
Get the value of the secondary measurement.
Definition: Multimeter.cpp:208
virtual std::string ModeToText(MeasurementTypes type)
Converts a meter mode to human readable text.
Definition: Multimeter.cpp:116
void DoLoadConfiguration(int version, const YAML::Node &node, IDTable &idmap)
Load instrument and channel configuration from a save file.
Definition: Multimeter.cpp:266
void DoSerializeConfiguration(YAML::Node &node, IDTable &table)
Serializes this multimeter's configuration to a YAML node.
Definition: Multimeter.cpp:228
void DoPreLoadConfiguration(int version, const YAML::Node &node, IDTable &idmap, ConfigWarningList &list)
Validate instrument and channel configuration from a save file.
Definition: Multimeter.cpp:286
virtual int GetMeterDigits()=0
Returns the digit resolution of the meter.
virtual Unit GetSecondaryMeterUnit()
Get the current secondary measurement unit.
Definition: Multimeter.cpp:83
virtual bool AcquireData() override
Pull meter readings from hardware.
Definition: Multimeter.cpp:216
virtual unsigned int GetSecondaryMeasurementTypes()
Gets a bitmask of secondary measurement types currently available.
Definition: Multimeter.cpp:185
virtual MeasurementTypes GetSecondaryMeterMode()
Gets the active secondary mode.
Definition: Multimeter.cpp:194
virtual double GetMeterValue()=0
Get the value of the primary measurement.
virtual void SetSecondaryMeterMode(MeasurementTypes type)
Sets the active secondary mode.
Definition: Multimeter.cpp:203
virtual Unit GetMeterUnit()
Get the current primary measurement unit.
Definition: Multimeter.cpp:53
MeasurementTypes TextToMode(const std::string &mode)
Converts a textual meter mode to a mode ID.
Definition: Multimeter.cpp:151
A unit of measurement, plus conversion to pretty-printed output.
Definition: Unit.h:57