ngscopeclient 0.1-dev+51fbda87c
RSRTO6Oscilloscope.h
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
30#ifndef RSRTO6Oscilloscope_h
31#define RSRTO6Oscilloscope_h
32
33class EdgeTrigger;
34
36 : public virtual SCPIOscilloscope
37 , public virtual SCPIFunctionGenerator
38{
39public:
41 virtual ~RSRTO6Oscilloscope();
42
43 //not copyable or assignable
44 RSRTO6Oscilloscope(const RSRTO6Oscilloscope& rhs) =delete;
45 RSRTO6Oscilloscope& operator=(const RSRTO6Oscilloscope& rhs) =delete;
46
47public:
48 //Device information
49 virtual unsigned int GetInstrumentTypes() const override;
50
51 virtual void FlushConfigCache() override;
52 virtual OscilloscopeChannel* GetExternalTrigger() override;
53
54 //Channel configuration
55 virtual uint32_t GetInstrumentTypesForChannel(size_t i) const override;
56 virtual bool IsChannelEnabled(size_t i) override;
57 virtual void EnableChannel(size_t i) override;
58 virtual void DisableChannel(size_t i) override;
59 virtual OscilloscopeChannel::CouplingType GetChannelCoupling(size_t i) override;
60 virtual void SetChannelCoupling(size_t i, OscilloscopeChannel::CouplingType type) override;
61 virtual std::vector<OscilloscopeChannel::CouplingType> GetAvailableCouplings(size_t i) override;
62 virtual double GetChannelAttenuation(size_t i) override;
63 virtual void SetChannelAttenuation(size_t i, double atten) override;
64 virtual unsigned int GetChannelBandwidthLimit(size_t i) override;
65 virtual void SetChannelBandwidthLimit(size_t i, unsigned int limit_mhz) override;
66 virtual std::vector<unsigned int> GetChannelBandwidthLimiters(size_t i) override;
67 virtual float GetChannelVoltageRange(size_t i, size_t stream) override;
68 virtual void SetChannelVoltageRange(size_t i, size_t stream, float range) override;
69 virtual float GetChannelOffset(size_t i, size_t stream) override;
70 virtual void SetChannelOffset(size_t i, size_t stream, float offset) override;
71 virtual std::string GetProbeName(size_t i) override;
72
73 //Digital channel configuration
74 virtual std::vector<DigitalBank> GetDigitalBanks() override;
75 virtual DigitalBank GetDigitalBank(size_t channel) override;
76 virtual bool IsDigitalHysteresisConfigurable() override;
77 virtual bool IsDigitalThresholdConfigurable() override;
78 // virtual float GetDigitalHysteresis(size_t channel) override;
79 virtual float GetDigitalThreshold(size_t channel) override;
80 // virtual void SetDigitalHysteresis(size_t channel, float level) override;
81 virtual void SetDigitalThreshold(size_t channel, float level) override;
82
83 //Triggering
84 virtual Oscilloscope::TriggerMode PollTrigger() override;
85 virtual bool AcquireData() override;
86 virtual void Start() override;
87 virtual void StartSingleTrigger() override;
88 virtual void Stop() override;
89 virtual void ForceTrigger() override;
90 virtual bool IsTriggerArmed() override;
91 virtual void PushTrigger() override;
92 virtual void PullTrigger() override;
93
94 //Timebase
95 virtual std::vector<uint64_t> GetSampleRatesNonInterleaved() override;
96 virtual std::vector<uint64_t> GetSampleRatesInterleaved() override;
97 virtual std::set<InterleaveConflict> GetInterleaveConflicts() override;
98 virtual std::vector<uint64_t> GetSampleDepthsNonInterleaved() override;
99 virtual std::vector<uint64_t> GetSampleDepthsInterleaved() override;
100 virtual uint64_t GetSampleRate() override;
101 virtual uint64_t GetSampleDepth() override;
102 virtual void SetSampleDepth(uint64_t depth) override;
103 virtual void SetSampleRate(uint64_t rate) override;
104 virtual void SetTriggerOffset(int64_t offset) override;
105 virtual int64_t GetTriggerOffset() override;
106 virtual bool IsInterleaving() override;
107 virtual bool SetInterleaving(bool combine) override;
108
110 // Function generator
111
112 //Channel info
113 virtual std::vector<WaveShape> GetAvailableWaveformShapes(int chan) override;
114
115 //Configuration
116 virtual bool GetFunctionChannelActive(int chan) override;
117 virtual void SetFunctionChannelActive(int chan, bool on) override;
118
119 virtual bool HasFunctionDutyCycleControls(int chan) override;
120 virtual float GetFunctionChannelDutyCycle(int chan) override;
121 virtual void SetFunctionChannelDutyCycle(int chan, float duty) override;
122
123 virtual float GetFunctionChannelAmplitude(int chan) override;
124 virtual void SetFunctionChannelAmplitude(int chan, float amplitude) override;
125
126 virtual float GetFunctionChannelOffset(int chan) override;
127 virtual void SetFunctionChannelOffset(int chan, float offset) override;
128
129 virtual float GetFunctionChannelFrequency(int chan) override;
130 virtual void SetFunctionChannelFrequency(int chan, float hz) override;
131
132 virtual WaveShape GetFunctionChannelShape(int chan) override;
133 virtual void SetFunctionChannelShape(int chan, WaveShape shape) override;
134
135 virtual bool HasFunctionRiseFallTimeControls(int chan) override;
136
137 virtual OutputImpedance GetFunctionChannelOutputImpedance(int chan) override;
138 virtual void SetFunctionChannelOutputImpedance(int chan, OutputImpedance z) override;
139
140protected:
141 OscilloscopeChannel* m_extTrigChannel;
142
143 //hardware analog channel count, independent of LA option etc
144 unsigned int m_analogChannelCount;
145 unsigned int m_digitalChannelBase;
146 unsigned int m_digitalChannelCount;
147 bool m_hasAFG;
148 unsigned int m_firstAFGIndex;
149
150 const static std::map<const std::string, const WaveShape> m_waveShapeNames;
151
152 bool IsAnalog(size_t index)
153 { return index < m_analogChannelCount; }
154
155 int HWDigitalNumber(size_t index)
156 { return index - m_digitalChannelBase; }
157
158 template <typename T> size_t AcquireHeader(T* cap, std::string chname);
159
160 //config cache
161 std::map<size_t, float> m_channelOffsets;
162 std::map<size_t, float> m_channelVoltageRanges;
163 std::map<int, bool> m_channelsEnabled;
164 std::map<size_t, float> m_channelDigitalThresholds;
165 std::map<size_t, OscilloscopeChannel::CouplingType> m_channelCouplings;
166 std::map<size_t, int> m_channelBandwidthLimits;
167 std::map<size_t, double> m_channelAttenuations;
168
169 bool m_triggerArmed;
170 bool m_triggerOneShot;
171
172 bool m_sampleRateValid;
173 uint64_t m_sampleRate;
174 bool m_sampleDepthValid;
175 uint64_t m_sampleDepth;
176 bool m_triggerOffsetValid;
177 uint64_t m_triggerOffset;
178
179 void PullEdgeTrigger();
180 void PushEdgeTrigger(EdgeTrigger* trig);
181
182public:
183 static std::string GetDriverNameInternal();
184 OSCILLOSCOPE_INITPROC(RSRTO6Oscilloscope)
185};
186
187#endif
Simple edge trigger.
Definition: EdgeTrigger.h:44
WaveShape
Predefined waveform shapes.
Definition: FunctionGenerator.h:55
OutputImpedance
Nominal output impedance for a function generator channel.
Definition: FunctionGenerator.h:259
A single channel on an oscilloscope.
Definition: OscilloscopeChannel.h:49
TriggerMode
Definition: Oscilloscope.h:411
Definition: RSRTO6Oscilloscope.h:38
virtual double GetChannelAttenuation(size_t i) override
Gets the probe attenuation for an input channel.
Definition: RSRTO6Oscilloscope.cpp:400
virtual bool IsInterleaving() override
Checks if the scope is currently combining channels.
Definition: RSRTO6Oscilloscope.cpp:1255
virtual bool AcquireData() override
Pull data from the instrument.
Definition: RSRTO6Oscilloscope.cpp:761
virtual float GetDigitalThreshold(size_t channel) override
Gets the threshold for a digital input.
Definition: RSRTO6Oscilloscope.cpp:658
virtual std::vector< uint64_t > GetSampleRatesNonInterleaved() override
Get the legal sampling rates (in Hz) for this scope in all-channels mode.
Definition: RSRTO6Oscilloscope.cpp:1044
virtual void DisableChannel(size_t i) override
Turn a channel off, given the index.
Definition: RSRTO6Oscilloscope.cpp:307
virtual void SetSampleRate(uint64_t rate) override
Sets the sample rate of the scope, in Hz.
Definition: RSRTO6Oscilloscope.cpp:1211
virtual uint64_t GetSampleDepth() override
Gets the current sample depth of this scope.
Definition: RSRTO6Oscilloscope.cpp:1177
virtual float GetChannelVoltageRange(size_t i, size_t stream) override
Gets the range of the current channel configuration.
Definition: RSRTO6Oscilloscope.cpp:553
virtual void ForceTrigger() override
Forces a single acquisition as soon as possible.
Definition: RSRTO6Oscilloscope.cpp:1033
virtual std::vector< unsigned int > GetChannelBandwidthLimiters(size_t i) override
Gets the set of available bandwidth limiters for an input channel.
Definition: RSRTO6Oscilloscope.cpp:539
virtual void Stop() override
Stops triggering.
Definition: RSRTO6Oscilloscope.cpp:1023
virtual bool IsTriggerArmed() override
Checks if the trigger is currently armed.
Definition: RSRTO6Oscilloscope.cpp:1039
virtual bool SetInterleaving(bool combine) override
Configures the scope to combine channels.
Definition: RSRTO6Oscilloscope.cpp:1260
virtual OutputImpedance GetFunctionChannelOutputImpedance(int chan) override
Gets the currently selected output impedance for a function generator output (if supported)
Definition: RSRTO6Oscilloscope.cpp:1469
virtual uint32_t GetInstrumentTypesForChannel(size_t i) const override
Returns a bitfield describing the set of instrument types that a given channel supports.
Definition: RSRTO6Oscilloscope.cpp:228
virtual void SetFunctionChannelFrequency(int chan, float hz) override
Sets the frequency for a function generator output.
Definition: RSRTO6Oscilloscope.cpp:1432
virtual std::vector< OscilloscopeChannel::CouplingType > GetAvailableCouplings(size_t i) override
Gets the set of legal coupling values for an input channel.
Definition: RSRTO6Oscilloscope.cpp:323
virtual void PushTrigger() override
Pushes changes made to m_trigger to the instrument.
Definition: RSRTO6Oscilloscope.cpp:1326
virtual std::vector< uint64_t > GetSampleDepthsInterleaved() override
Get the legal memory depths for this scope in combined-channels mode.
Definition: RSRTO6Oscilloscope.cpp:1156
virtual unsigned int GetChannelBandwidthLimit(size_t i) override
Gets the bandwidth limit for an input channel.
Definition: RSRTO6Oscilloscope.cpp:466
virtual WaveShape GetFunctionChannelShape(int chan) override
Gets the waveform shape for a function generator output.
Definition: RSRTO6Oscilloscope.cpp:1437
virtual void SetChannelBandwidthLimit(size_t i, unsigned int limit_mhz) override
Sets the bandwidth limit for an input channel.
Definition: RSRTO6Oscilloscope.cpp:504
virtual void SetFunctionChannelShape(int chan, WaveShape shape) override
Sets the waveform shape for a function generator output.
Definition: RSRTO6Oscilloscope.cpp:1450
virtual void SetChannelAttenuation(size_t i, double atten) override
Sets the probe attenuation used for an input channel.
Definition: RSRTO6Oscilloscope.cpp:435
virtual void SetChannelVoltageRange(size_t i, size_t stream, float range) override
Sets the range of the current channel configuration.
Definition: RSRTO6Oscilloscope.cpp:572
virtual std::vector< DigitalBank > GetDigitalBanks() override
Gets the digital channel banks for this instrument.
Definition: RSRTO6Oscilloscope.cpp:626
virtual DigitalBank GetDigitalBank(size_t channel) override
Gets the bank containing a given channel.
Definition: RSRTO6Oscilloscope.cpp:641
virtual void FlushConfigCache() override
Instruments are allowed to cache configuration settings to reduce round trip queries to the device.
Definition: RSRTO6Oscilloscope.cpp:239
virtual bool IsDigitalThresholdConfigurable() override
Checks if digital input threshold is configurable or fixed.
Definition: RSRTO6Oscilloscope.cpp:653
virtual void PullTrigger() override
Updates m_trigger with any changes made from the instrument side.
Definition: RSRTO6Oscilloscope.cpp:1265
virtual void SetFunctionChannelOutputImpedance(int chan, OutputImpedance z) override
Sets the currently selected output impedance for a function generator output (if supported)
Definition: RSRTO6Oscilloscope.cpp:1475
virtual void SetSampleDepth(uint64_t depth) override
Sets the sample depth of the scope.
Definition: RSRTO6Oscilloscope.cpp:1195
virtual void SetDigitalThreshold(size_t channel, float level) override
Gets the threshold for a digital input.
Definition: RSRTO6Oscilloscope.cpp:677
virtual bool IsChannelEnabled(size_t i) override
Checks if a channel is enabled in hardware.
Definition: RSRTO6Oscilloscope.cpp:259
virtual void SetFunctionChannelOffset(int chan, float offset) override
Sets the DC offset for a function generator output.
Definition: RSRTO6Oscilloscope.cpp:1422
virtual void SetFunctionChannelActive(int chan, bool on) override
Turns a function generator channel on or off.
Definition: RSRTO6Oscilloscope.cpp:1387
virtual unsigned int GetInstrumentTypes() const override
Returns a bitfield describing the set of instrument types that this instrument supports.
Definition: RSRTO6Oscilloscope.cpp:218
virtual void EnableChannel(size_t i) override
Turn a channel on, given the index.
Definition: RSRTO6Oscilloscope.cpp:289
virtual Oscilloscope::TriggerMode PollTrigger() override
Checks the curent trigger status.
Definition: RSRTO6Oscilloscope.cpp:684
virtual void SetChannelCoupling(size_t i, OscilloscopeChannel::CouplingType type) override
Sets the coupling used for an input channel.
Definition: RSRTO6Oscilloscope.cpp:368
virtual float GetFunctionChannelFrequency(int chan) override
Gets the frequency for a function generator output.
Definition: RSRTO6Oscilloscope.cpp:1427
virtual bool GetFunctionChannelActive(int chan) override
Returns true if the function generator channel's output is enabled.
Definition: RSRTO6Oscilloscope.cpp:1382
virtual uint64_t GetSampleRate() override
Gets the current sampling rate (in Hz) of this scope.
Definition: RSRTO6Oscilloscope.cpp:1161
virtual std::vector< uint64_t > GetSampleDepthsNonInterleaved() override
Get the legal memory depths for this scope in all-channels mode.
Definition: RSRTO6Oscilloscope.cpp:1120
virtual void Start() override
Starts the instrument in continuous trigger mode.
Definition: RSRTO6Oscilloscope.cpp:1003
void PullEdgeTrigger()
Reads settings for an edge trigger from the instrument.
Definition: RSRTO6Oscilloscope.cpp:1293
virtual bool HasFunctionDutyCycleControls(int chan) override
Determines if the function generator allows control over duty cycles.
Definition: RSRTO6Oscilloscope.cpp:1392
virtual std::vector< WaveShape > GetAvailableWaveformShapes(int chan) override
Query the set of available pre-defined waveforms for this generator.
Definition: RSRTO6Oscilloscope.cpp:1370
virtual int64_t GetTriggerOffset() override
Gets the trigger offset.
Definition: RSRTO6Oscilloscope.cpp:1239
virtual bool HasFunctionRiseFallTimeControls(int chan) override
Determines if the function generator allows control over rise/fall times.
Definition: RSRTO6Oscilloscope.cpp:1464
virtual void SetFunctionChannelDutyCycle(int chan, float duty) override
Sets the duty cycle for a function generator output.
Definition: RSRTO6Oscilloscope.cpp:1402
virtual OscilloscopeChannel * GetExternalTrigger() override
Returns the external trigger input channel, if we have one.
Definition: RSRTO6Oscilloscope.cpp:254
virtual void SetFunctionChannelAmplitude(int chan, float amplitude) override
Sets the amplitude for a function generator output.
Definition: RSRTO6Oscilloscope.cpp:1412
virtual float GetFunctionChannelAmplitude(int chan) override
Gets the amplitude for a function generator output.
Definition: RSRTO6Oscilloscope.cpp:1407
virtual float GetChannelOffset(size_t i, size_t stream) override
Gets the offset, in volts, for a given channel.
Definition: RSRTO6Oscilloscope.cpp:586
virtual void SetChannelOffset(size_t i, size_t stream, float offset) override
Sets the offset for a given channel.
Definition: RSRTO6Oscilloscope.cpp:609
virtual std::vector< uint64_t > GetSampleRatesInterleaved() override
Get the legal sampling rates (in Hz) for this scope in combined-channels mode.
Definition: RSRTO6Oscilloscope.cpp:1106
virtual float GetFunctionChannelOffset(int chan) override
Gets the DC offset for a function generator output.
Definition: RSRTO6Oscilloscope.cpp:1417
void PushEdgeTrigger(EdgeTrigger *trig)
Pushes settings for an edge trigger to the instrument.
Definition: RSRTO6Oscilloscope.cpp:1338
virtual void SetTriggerOffset(int64_t offset) override
Sets the trigger offset.
Definition: RSRTO6Oscilloscope.cpp:1227
virtual float GetFunctionChannelDutyCycle(int chan) override
Gets the duty cycle for a function generator output.
Definition: RSRTO6Oscilloscope.cpp:1397
virtual bool IsDigitalHysteresisConfigurable() override
Checks if digital input hysteresis is configurable or fixed.
Definition: RSRTO6Oscilloscope.cpp:646
virtual OscilloscopeChannel::CouplingType GetChannelCoupling(size_t i) override
Gets the coupling used for an input channel.
Definition: RSRTO6Oscilloscope.cpp:337
virtual void StartSingleTrigger() override
Arms the trigger for a single acquistion.
Definition: RSRTO6Oscilloscope.cpp:1013
virtual std::string GetProbeName(size_t i) override
Returns the name of the probe connected to the scope, if possible.
Definition: RSRTO6Oscilloscope.cpp:457
An SCPI-based function generator.
Definition: SCPIFunctionGenerator.h:38
An SCPI-based oscilloscope.
Definition: SCPIOscilloscope.h:38
Abstraction of a transport layer for moving SCPI data between endpoints.
Definition: SCPITransport.h:47