ngscopeclient 0.1-dev+51fbda87c
RFSignalGenerator.h
1/***********************************************************************************************************************
2* *
3* libscopehal v0.1 *
4* *
5* Copyright (c) 2012-2023 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 RFSignalGenerator_h
31#define RFSignalGenerator_h
32
36class RFSignalGenerator : public virtual Instrument
37{
38public:
40 virtual ~RFSignalGenerator();
41
43 // General
44
52 virtual bool GetChannelOutputEnable(int chan) =0;
53
60 virtual void SetChannelOutputEnable(int chan, bool on) =0;
61
69 virtual float GetChannelOutputPower(int chan) =0;
70
77 virtual void SetChannelOutputPower(int chan, float power) =0;
78
86 virtual double GetChannelCenterFrequency(int chan) =0;
87
94 virtual void SetChannelCenterFrequency(int chan, double freq) =0;
95
97 // Analog modulation
98
104 virtual bool IsAnalogModulationAvailable(int chan) =0;
105
109 virtual void SetAnalogModulationEnable(int chan, bool on) =0;
110
114 virtual bool GetAnalogModulationEnable(int chan) =0;
115
119 virtual void SetAnalogFMEnable(int chan, bool on) =0;
120
124 virtual bool GetAnalogFMEnable(int chan) =0;
125
129 virtual std::vector<FunctionGenerator::WaveShape> GetAnalogFMWaveShapes() =0;
130
135
139 virtual void SetAnalogFMWaveShape(int chan, FunctionGenerator::WaveShape shape) =0;
140
144 virtual void SetAnalogFMDeviation(int chan, int64_t deviation) =0;
145
149 virtual int64_t GetAnalogFMDeviation(int chan) =0;
150
154 virtual void SetAnalogFMFrequency(int chan, int64_t frequency) =0;
155
159 virtual int64_t GetAnalogFMFrequency(int chan) =0;
160
162 // Vector modulation
163
169 virtual bool IsVectorModulationAvailable(int chan) =0;
170
172 // Sweeps
173
177 virtual bool IsSweepAvailable(int chan) =0;
178
179 enum SweepType
180 {
181 SWEEP_TYPE_NONE,
182 SWEEP_TYPE_FREQ,
183 SWEEP_TYPE_LEVEL,
184 SWEEP_TYPE_FREQ_LEVEL
185 };
186
190 static std::string GetNameOfSweepType(SweepType type);
191
195 static SweepType GetSweepTypeOfName(const std::string& name);
196
202 virtual SweepType GetSweepType(int chan);
203
210 virtual void SetSweepType(int chan, SweepType type);
211
217 virtual float GetSweepStartFrequency(int chan);
218
224 virtual float GetSweepStopFrequency(int chan);
225
232 virtual void SetSweepStartFrequency(int chan, float freq);
233
240 virtual void SetSweepStopFrequency(int chan, float freq);
241
247 virtual float GetSweepStartLevel(int chan);
248
254 virtual float GetSweepStopLevel(int chan);
255
262 virtual void SetSweepStartLevel(int chan, float level);
263
270 virtual void SetSweepStopLevel(int chan, float level);
271
278 virtual void SetSweepDwellTime(int chan, float fs);
279
285 virtual float GetSweepDwellTime(int chan);
286
293 virtual void SetSweepPoints(int chan, int npoints);
294
300 virtual int GetSweepPoints(int chan);
301
302 enum SweepShape
303 {
304 //Ramp up and down
305 SWEEP_SHAPE_TRIANGLE,
306
307 //Ramp up, then jump down
308 SWEEP_SHAPE_SAWTOOTH
309 };
310
314 static std::string GetNameOfSweepShape(SweepShape shape);
315
319 static SweepShape GetSweepShapeOfName(const std::string& name);
320
326 virtual SweepShape GetSweepShape(int chan);
327
334 virtual void SetSweepShape(int chan, SweepShape shape);
335
336 enum SweepSpacing
337 {
338 SWEEP_SPACING_LINEAR,
339 SWEEP_SPACING_LOG
340 };
341
345 static std::string GetNameOfSweepSpacing(SweepSpacing spacing);
346
350 static SweepSpacing GetSweepSpacingOfName(const std::string& name);
351
357 virtual SweepSpacing GetSweepSpacing(int chan);
358
365 virtual void SetSweepSpacing(int chan, SweepSpacing shape);
366
367 enum SweepDirection
368 {
369 SWEEP_DIR_FWD,
370 SWEEP_DIR_REV
371 };
372
376 static std::string GetNameOfSweepDirection(SweepDirection dir);
377
381 static SweepDirection GetSweepDirectionOfName(const std::string& name);
382
388 virtual SweepDirection GetSweepDirection(int chan);
389
396 virtual void SetSweepDirection(int chan, SweepDirection dir);
397
398 virtual bool AcquireData() override;
399
401 // Serialization
402
403protected:
407 void DoSerializeConfiguration(YAML::Node& node, IDTable& table);
408
412 void DoLoadConfiguration(int version, const YAML::Node& node, IDTable& idmap);
413
417 void DoPreLoadConfiguration(int version, const YAML::Node& node, IDTable& idmap, ConfigWarningList& list);
418};
419
420#endif
All warnings generated by a configuration we're in the process of loading.
Definition: ConfigWarningList.h:90
WaveShape
Predefined waveform shapes.
Definition: FunctionGenerator.h:55
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
An RF waveform generator which creates a carrier and optionally modulates it.
Definition: RFSignalGenerator.h:37
virtual FunctionGenerator::WaveShape GetAnalogFMWaveShape(int chan)=0
Get the current waveform selected for analog FM.
virtual void SetSweepStartFrequency(int chan, float freq)
Sets the start of a frequency sweep.
Definition: RFSignalGenerator.cpp:61
virtual SweepShape GetSweepShape(int chan)
Gets the shape of a sweep.
Definition: RFSignalGenerator.cpp:110
virtual void SetAnalogFMFrequency(int chan, int64_t frequency)=0
Sets the analog FM frequency for a channel (in Hz)
virtual float GetSweepStartFrequency(int chan)
Gets the start of a frequency sweep, in Hz.
Definition: RFSignalGenerator.cpp:51
virtual bool IsAnalogModulationAvailable(int chan)=0
Checks if an instrument is analog modulation capable.
virtual void SetSweepDwellTime(int chan, float fs)
Sets the dwell time for each step in a sweep.
Definition: RFSignalGenerator.cpp:96
virtual SweepDirection GetSweepDirection(int chan)
Gets the direction of a sweep.
Definition: RFSignalGenerator.cpp:130
static SweepSpacing GetSweepSpacingOfName(const std::string &name)
Converts a human-readable name to a SweepSpacing.
Definition: RFSignalGenerator.cpp:246
virtual void SetSweepStopLevel(int chan, float level)
Sets the stop of a power sweep.
Definition: RFSignalGenerator.cpp:86
void DoSerializeConfiguration(YAML::Node &node, IDTable &table)
Serializes this oscilloscope's configuration to a YAML node.
Definition: RFSignalGenerator.cpp:285
virtual float GetSweepStopFrequency(int chan)
Gets the end of a frequency sweep, in Hz.
Definition: RFSignalGenerator.cpp:56
static std::string GetNameOfSweepSpacing(SweepSpacing spacing)
Converts a SweepSpacing to a human-readable name.
Definition: RFSignalGenerator.cpp:231
virtual void SetAnalogModulationEnable(int chan, bool on)=0
Enable or disable analog modulation.
virtual void SetAnalogFMEnable(int chan, bool on)=0
Enable or disable analog frequency modulation (also requires modulation to be turned on)
static std::string GetNameOfSweepDirection(SweepDirection dir)
Converts a SweepDirection to a human-readable name.
Definition: RFSignalGenerator.cpp:258
static SweepShape GetSweepShapeOfName(const std::string &name)
Converts a human-readable name to a SweepShape.
Definition: RFSignalGenerator.cpp:219
virtual void SetChannelOutputEnable(int chan, bool on)=0
Enable or disable a channel output.
virtual int64_t GetAnalogFMFrequency(int chan)=0
Gets the analog FM frequency for a channel.
void DoLoadConfiguration(int version, const YAML::Node &node, IDTable &idmap)
Load instrument and channel configuration from a save file.
Definition: RFSignalGenerator.cpp:447
virtual bool AcquireData() override
Pull data from the instrument.
Definition: RFSignalGenerator.cpp:150
virtual void SetSweepShape(int chan, SweepShape shape)
Sets the shape of a sweep.
Definition: RFSignalGenerator.cpp:115
virtual void SetChannelOutputPower(int chan, float power)=0
Sets the power level of a channel.
virtual float GetSweepDwellTime(int chan)
Gets the dwell time for each step in a sweep, in femtoseconds.
Definition: RFSignalGenerator.cpp:91
virtual void SetSweepDirection(int chan, SweepDirection dir)
Sets the direction of a sweep.
Definition: RFSignalGenerator.cpp:135
virtual bool IsVectorModulationAvailable(int chan)=0
Checks if an instrument is vector modulation capable.
virtual int GetSweepPoints(int chan)
Gets the number of frequency points in a sweep.
Definition: RFSignalGenerator.cpp:105
virtual double GetChannelCenterFrequency(int chan)=0
Gets the center frequency of a channel.
virtual bool GetChannelOutputEnable(int chan)=0
Check if a channel is currently enabled.
virtual void SetSweepStartLevel(int chan, float level)
Sets the start of a power sweep.
Definition: RFSignalGenerator.cpp:81
virtual void SetSweepPoints(int chan, int npoints)
Sets the number of frequency points in a sweep.
Definition: RFSignalGenerator.cpp:101
virtual void SetSweepStopFrequency(int chan, float freq)
Sets the stop of a frequency sweep.
Definition: RFSignalGenerator.cpp:66
virtual float GetSweepStopLevel(int chan)
Gets the end of a power sweep, in dBm.
Definition: RFSignalGenerator.cpp:76
virtual void SetSweepSpacing(int chan, SweepSpacing shape)
Sets the spacing of a sweep (log or linear)
Definition: RFSignalGenerator.cpp:125
virtual int64_t GetAnalogFMDeviation(int chan)=0
Gets the analog FM deviation for a channel.
virtual SweepType GetSweepType(int chan)
Gets the type of a sweep.
Definition: RFSignalGenerator.cpp:140
void DoPreLoadConfiguration(int version, const YAML::Node &node, IDTable &idmap, ConfigWarningList &list)
Validate instrument and channel configuration from a save file.
Definition: RFSignalGenerator.cpp:361
virtual std::vector< FunctionGenerator::WaveShape > GetAnalogFMWaveShapes()=0
Get the set of waveforms available for analog FM.
virtual void SetAnalogFMDeviation(int chan, int64_t deviation)=0
Sets the analog FM deviation for a channel (in Hz)
virtual SweepSpacing GetSweepSpacing(int chan)
Gets the spacing of a sweep (log or linear)
Definition: RFSignalGenerator.cpp:120
static std::string GetNameOfSweepShape(SweepShape shape)
Converts a SweepShape to a human-readable name.
Definition: RFSignalGenerator.cpp:204
virtual bool GetAnalogModulationEnable(int chan)=0
Enable or disable analog modulation.
virtual void SetChannelCenterFrequency(int chan, double freq)=0
Sets the power level of a channel.
static SweepDirection GetSweepDirectionOfName(const std::string &name)
Converts a human-readable name to a SweepDirection.
Definition: RFSignalGenerator.cpp:273
virtual float GetSweepStartLevel(int chan)
Gets the start of a power sweep, in dBm.
Definition: RFSignalGenerator.cpp:71
static SweepType GetSweepTypeOfName(const std::string &name)
Converts a human-readable name to a SweepType.
Definition: RFSignalGenerator.cpp:189
static std::string GetNameOfSweepType(SweepType type)
Converts a SweepType to a human-readable name.
Definition: RFSignalGenerator.cpp:168
virtual bool GetAnalogFMEnable(int chan)=0
Enable or disable analog frequency modulation.
virtual float GetChannelOutputPower(int chan)=0
Gets the power level of a channel.
virtual void SetAnalogFMWaveShape(int chan, FunctionGenerator::WaveShape shape)=0
Sets the analog FM modulation shape for a channel.
virtual bool IsSweepAvailable(int chan)=0
Checks if an instrument supports sweeping the center frequency.
virtual void SetSweepType(int chan, SweepType type)
Sets the type of a sweep.
Definition: RFSignalGenerator.cpp:145