ngscopeclient 0.1-dev+51fbda87c
FunctionGenerator.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 FunctionGenerator_h
38#define FunctionGenerator_h
39
45class FunctionGenerator : public virtual Instrument
46{
47public:
49 virtual ~FunctionGenerator();
50
51 virtual bool AcquireData() override;
52
55 {
56 SHAPE_SINE,
57 SHAPE_SQUARE,
58 SHAPE_TRIANGLE,
59 SHAPE_PULSE,
60 SHAPE_DC,
61 SHAPE_NOISE,
62 SHAPE_SAWTOOTH_UP,
63 SHAPE_SAWTOOTH_DOWN,
64 SHAPE_SINC,
65 SHAPE_GAUSSIAN,
66 SHAPE_LORENTZ,
67 SHAPE_HALF_SINE,
68 SHAPE_PRBS_NONSTANDARD,
69 SHAPE_EXPONENTIAL_RISE,
70 SHAPE_EXPONENTIAL_DECAY,
71 SHAPE_HAVERSINE,
72 SHAPE_CARDIAC,
73
74 SHAPE_STAIRCASE_UP,
75 SHAPE_STAIRCASE_DOWN,
76 SHAPE_STAIRCASE_UP_DOWN,
77 SHAPE_NEGATIVE_PULSE,
78 SHAPE_LOG_RISE,
79 SHAPE_LOG_DECAY,
80 SHAPE_SQUARE_ROOT,
81 SHAPE_CUBE_ROOT,
82 SHAPE_QUADRATIC,
83 SHAPE_CUBIC,
84 SHAPE_DLORENTZ,
85 SHAPE_GAUSSIAN_PULSE,
86 SHAPE_HAMMING,
87 SHAPE_HANNING,
88 SHAPE_KAISER,
89 SHAPE_BLACKMAN,
90 SHAPE_GAUSSIAN_WINDOW,
91 SHAPE_HARRIS,
92 SHAPE_BARTLETT,
93 SHAPE_TAN,
94 SHAPE_COT,
95 SHAPE_SEC,
96 SHAPE_CSC,
97 SHAPE_ASIN,
98 SHAPE_ACOS,
99 SHAPE_ATAN,
100 SHAPE_ACOT,
101
102 SHAPE_ARB
103 };
104
105 static std::string GetNameOfShape(WaveShape shape);
106 static WaveShape GetShapeOfName(const std::string& name);
107
113 virtual bool GetFunctionChannelActive(int chan) =0;
114
121 virtual void SetFunctionChannelActive(int chan, bool on) =0;
122
132 virtual bool HasFunctionDutyCycleControls(int chan);
133
140 virtual float GetFunctionChannelDutyCycle(int chan);
141
148 virtual void SetFunctionChannelDutyCycle(int chan, float duty);
149
156 virtual float GetFunctionChannelAmplitude(int chan) =0;
157
164 virtual void SetFunctionChannelAmplitude(int chan, float amplitude) =0;
165
172 virtual float GetFunctionChannelOffset(int chan) =0;
173
180 virtual void SetFunctionChannelOffset(int chan, float offset) =0;
181
188 virtual float GetFunctionChannelFrequency(int chan) =0;
189
196 virtual void SetFunctionChannelFrequency(int chan, float hz) =0;
197
204 virtual WaveShape GetFunctionChannelShape(int chan) =0;
205
212 virtual void SetFunctionChannelShape(int chan, WaveShape shape) =0;
213
220 virtual float GetFunctionChannelRiseTime(int chan);
221
228 virtual void SetFunctionChannelRiseTime(int chan, float fs);
229
236 virtual float GetFunctionChannelFallTime(int chan);
237
244 virtual void SetFunctionChannelFallTime(int chan, float fs);
245
255 virtual bool HasFunctionRiseFallTimeControls(int chan) =0;
256
259 {
262
265 };
266
267 static std::string GetNameOfImpedance(OutputImpedance imp);
268 static OutputImpedance GetImpedanceOfName(const std::string& name);
269
276 virtual bool HasFunctionImpedanceControls(int chan);
277
285
292 virtual void SetFunctionChannelOutputImpedance(int chan, OutputImpedance z);
293
301 virtual std::vector<WaveShape> GetAvailableWaveformShapes(int chan) =0;
302
304 // Serialization
305
306protected:
307
308 void DoSerializeConfiguration(YAML::Node& node, IDTable& table);
309
310 void DoLoadConfiguration(int version, const YAML::Node& node, IDTable& idmap);
311
312 void DoPreLoadConfiguration(int version, const YAML::Node& node, IDTable& idmap, ConfigWarningList& list);
313};
314
315#endif
All warnings generated by a configuration we're in the process of loading.
Definition: ConfigWarningList.h:90
A baseband waveform generator.
Definition: FunctionGenerator.h:46
virtual void SetFunctionChannelFrequency(int chan, float hz)=0
Sets the frequency for a function generator output.
virtual float GetFunctionChannelDutyCycle(int chan)
Gets the duty cycle for a function generator output.
Definition: FunctionGenerator.cpp:340
virtual void SetFunctionChannelOutputImpedance(int chan, OutputImpedance z)
Sets the currently selected output impedance for a function generator output (if supported)
Definition: FunctionGenerator.cpp:359
virtual bool HasFunctionRiseFallTimeControls(int chan)=0
Determines if the function generator allows control over rise/fall times.
static WaveShape GetShapeOfName(const std::string &name)
Converts a human readable name to a WaveShape.
Definition: FunctionGenerator.cpp:218
virtual void SetFunctionChannelActive(int chan, bool on)=0
Turns a function generator channel on or off.
WaveShape
Predefined waveform shapes.
Definition: FunctionGenerator.h:55
virtual std::vector< WaveShape > GetAvailableWaveformShapes(int chan)=0
Query the set of available pre-defined waveforms for this generator.
void DoSerializeConfiguration(YAML::Node &node, IDTable &table)
Serializes this instrument's configuration to a YAML node.
Definition: FunctionGenerator.cpp:419
virtual bool GetFunctionChannelActive(int chan)=0
Returns true if the function generator channel's output is enabled.
virtual bool HasFunctionDutyCycleControls(int chan)
Determines if the function generator allows control over duty cycles.
Definition: FunctionGenerator.cpp:335
virtual void SetFunctionChannelAmplitude(int chan, float amplitude)=0
Sets the amplitude for a function generator output.
virtual OutputImpedance GetFunctionChannelOutputImpedance(int chan)
Gets the currently selected output impedance for a function generator output (if supported)
Definition: FunctionGenerator.cpp:354
virtual void SetFunctionChannelShape(int chan, WaveShape shape)=0
Sets the waveform shape for a function generator output.
virtual float GetFunctionChannelFrequency(int chan)=0
Gets the frequency for a function generator output.
virtual WaveShape GetFunctionChannelShape(int chan)=0
Gets the waveform shape for a function generator output.
virtual float GetFunctionChannelOffset(int chan)=0
Gets the DC offset for a function generator output.
virtual void SetFunctionChannelDutyCycle(int chan, float duty)
Sets the duty cycle for a function generator output.
Definition: FunctionGenerator.cpp:345
virtual bool HasFunctionImpedanceControls(int chan)
Determines if the function generator allows control over rise/fall times.
Definition: FunctionGenerator.cpp:349
void DoPreLoadConfiguration(int version, const YAML::Node &node, IDTable &idmap, ConfigWarningList &list)
Validate instrument and channel configuration from a save file.
Definition: FunctionGenerator.cpp:471
virtual float GetFunctionChannelFallTime(int chan)
Gets the fall time for a function generator output (if supported)
Definition: FunctionGenerator.cpp:326
void DoLoadConfiguration(int version, const YAML::Node &node, IDTable &idmap)
Load instrument and channel configuration from a save file.
Definition: FunctionGenerator.cpp:551
static std::string GetNameOfImpedance(OutputImpedance imp)
Converts an OutputImpedance enum to a human readable name.
Definition: FunctionGenerator.cpp:379
virtual bool AcquireData() override
Pull data from the instrument.
Definition: FunctionGenerator.cpp:363
OutputImpedance
Nominal output impedance for a function generator channel.
Definition: FunctionGenerator.h:259
@ IMPEDANCE_HIGH_Z
Channel expects to drive a high-impedance load.
Definition: FunctionGenerator.h:261
@ IMPEDANCE_50_OHM
Channel expects to drive a 50-ohm load.
Definition: FunctionGenerator.h:264
virtual float GetFunctionChannelRiseTime(int chan)
Gets the rise time for a function generator output (if supported)
Definition: FunctionGenerator.cpp:317
static std::string GetNameOfShape(WaveShape shape)
Converts a WaveShape enum to a human readable name.
Definition: FunctionGenerator.cpp:66
virtual float GetFunctionChannelAmplitude(int chan)=0
Gets the amplitude for a function generator output.
static OutputImpedance GetImpedanceOfName(const std::string &name)
Converts a human readable name to an OutputImpedance.
Definition: FunctionGenerator.cpp:401
virtual void SetFunctionChannelOffset(int chan, float offset)=0
Sets the DC offset for a function generator output.
virtual void SetFunctionChannelFallTime(int chan, float fs)
Sets the fall time for a function generator output (if supported)
Definition: FunctionGenerator.cpp:331
virtual void SetFunctionChannelRiseTime(int chan, float fs)
Sets the rise time for a function generator output (if supported)
Definition: FunctionGenerator.cpp:322
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