ngscopeclient 0.1-dev+51fbda87c
RigolOscilloscope.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 RigolOscilloscope_h
31#define RigolOscilloscope_h
32
33class EdgeTrigger;
34
35class RigolOscilloscope : public virtual SCPIOscilloscope
36{
37public:
39 virtual ~RigolOscilloscope();
40
41 //not copyable or assignable
42 RigolOscilloscope(const RigolOscilloscope& rhs) = delete;
43 RigolOscilloscope& operator=(const RigolOscilloscope& rhs) = delete;
44
45public:
46 //Device information
47 virtual unsigned int GetInstrumentTypes() const override;
48 virtual uint32_t GetInstrumentTypesForChannel(size_t i) const override;
49
50 virtual void FlushConfigCache() override;
51
52 //Channel configuration
53 virtual bool IsChannelEnabled(size_t i) override;
54 virtual void EnableChannel(size_t i) override;
55 virtual void DisableChannel(size_t i) override;
56 virtual OscilloscopeChannel::CouplingType GetChannelCoupling(size_t i) override;
57 virtual void SetChannelCoupling(size_t i, OscilloscopeChannel::CouplingType type) override;
58 virtual std::vector<OscilloscopeChannel::CouplingType> GetAvailableCouplings(size_t i) override;
59 virtual double GetChannelAttenuation(size_t i) override;
60 virtual void SetChannelAttenuation(size_t i, double atten) override;
61 virtual std::vector<unsigned int> GetChannelBandwidthLimiters(size_t i) override;
62 virtual unsigned int GetChannelBandwidthLimit(size_t i) override;
63 virtual void SetChannelBandwidthLimit(size_t i, unsigned int limit_mhz) override;
64 virtual float GetChannelVoltageRange(size_t i, size_t stream) override;
65 virtual void SetChannelVoltageRange(size_t i, size_t stream, float range) override;
66 virtual OscilloscopeChannel* GetExternalTrigger() override;
67 virtual float GetChannelOffset(size_t i, size_t stream) override;
68 virtual void SetChannelOffset(size_t i, size_t stream, float offset) override;
69
70 //Triggering
71 virtual Oscilloscope::TriggerMode PollTrigger() override;
72 virtual bool AcquireData() override;
73 virtual void Start() override;
74 virtual void StartSingleTrigger() override;
75 virtual void Stop() override;
76 virtual void ForceTrigger() override;
77 virtual bool IsTriggerArmed() override;
78 virtual void PushTrigger() override;
79 virtual void PullTrigger() override;
80
81 //Timebase
82 virtual std::vector<uint64_t> GetSampleRatesNonInterleaved() override;
83 virtual std::vector<uint64_t> GetSampleRatesInterleaved() override;
84 virtual std::set<InterleaveConflict> GetInterleaveConflicts() override;
85 virtual std::vector<uint64_t> GetSampleDepthsNonInterleaved() override;
86 virtual std::vector<uint64_t> GetSampleDepthsInterleaved() override;
87 virtual uint64_t GetSampleRate() override;
88 virtual uint64_t GetSampleDepth() override;
89 virtual void SetSampleDepth(uint64_t depth) override;
90 virtual void SetSampleRate(uint64_t rate) override;
91 virtual void SetTriggerOffset(int64_t offset) override;
92 virtual int64_t GetTriggerOffset() override;
93 virtual bool IsInterleaving() override;
94 virtual bool SetInterleaving(bool combine) override;
95
96 void ForceHDMode(bool mode);
97
98protected:
99 enum protocol_version
100 {
101 MSO5, //MSO5000 series
102 DS,
103 DS_OLD,
104 DHO, //DHO800, DHO900, DHO1000 and DHO4000 series
105 };
106
107 OscilloscopeChannel* m_extTrigChannel;
108
109 //hardware analog channel count, independent of LA option etc
110 unsigned int m_analogChannelCount;
111
112 //config cache
113 std::map<size_t, double> m_channelAttenuations;
114 std::map<size_t, OscilloscopeChannel::CouplingType> m_channelCouplings;
115 std::map<size_t, float> m_channelOffsets;
116 std::map<size_t, float> m_channelVoltageRanges;
117 std::map<size_t, unsigned int> m_channelBandwidthLimits;
118 std::map<int, bool> m_channelsEnabled;
119 bool m_srateValid;
120 uint64_t m_srate;
121 bool m_mdepthValid;
122 uint64_t m_mdepth;
123 int64_t m_triggerOffset;
124 bool m_triggerOffsetValid;
125
126 bool m_triggerArmed;
127 bool m_triggerWasLive;
128 bool m_triggerOneShot;
129
130 bool m_liveMode;
131
132 int m_modelNumber;
133 unsigned int m_bandwidth;
134 bool m_opt200M;
135 uint64_t m_maxMdepth; /* Maximum Memory depth for DHO model s*/
136 uint64_t m_maxSrate; /* Maximum Sample rate for DHO models */
137 bool m_lowSrate; /* True for DHO low sample rate models (DHO800/900) */
138 protocol_version m_protocol;
139
140 //True if we have >8 bit capture depth
141 bool m_highDefinition;
142
143 void PushEdgeTrigger(EdgeTrigger* trig);
144 void PullEdgeTrigger();
145
146 void PrepareStart();
147
148public:
149 static std::string GetDriverNameInternal();
150 OSCILLOSCOPE_INITPROC(RigolOscilloscope)
151};
152
153#endif
Simple edge trigger.
Definition: EdgeTrigger.h:44
A single channel on an oscilloscope.
Definition: OscilloscopeChannel.h:49
TriggerMode
Definition: Oscilloscope.h:411
Definition: RigolOscilloscope.h:36
virtual OscilloscopeChannel * GetExternalTrigger() override
Returns the external trigger input channel, if we have one.
Definition: RigolOscilloscope.cpp:689
virtual void SetSampleDepth(uint64_t depth) override
Sets the sample depth of the scope.
Definition: RigolOscilloscope.cpp:1346
virtual std::vector< unsigned int > GetChannelBandwidthLimiters(size_t i) override
Gets the set of available bandwidth limiters for an input channel.
Definition: RigolOscilloscope.cpp:527
virtual void SetTriggerOffset(int64_t offset) override
Sets the trigger offset.
Definition: RigolOscilloscope.cpp:1466
virtual uint64_t GetSampleDepth() override
Gets the current sample depth of this scope.
Definition: RigolOscilloscope.cpp:1332
virtual std::vector< uint64_t > GetSampleDepthsInterleaved() override
Get the legal memory depths for this scope in combined-channels mode.
Definition: RigolOscilloscope.cpp:1303
virtual bool IsChannelEnabled(size_t i) override
Checks if a channel is enabled in hardware.
Definition: RigolOscilloscope.cpp:304
virtual bool SetInterleaving(bool combine) override
Configures the scope to combine channels.
Definition: RigolOscilloscope.cpp:1510
virtual std::vector< uint64_t > GetSampleDepthsNonInterleaved() override
Get the legal memory depths for this scope in all-channels mode.
Definition: RigolOscilloscope.cpp:1271
void PullEdgeTrigger()
Reads settings for an edge trigger from the instrument.
Definition: RigolOscilloscope.cpp:1535
virtual Oscilloscope::TriggerMode PollTrigger() override
Checks the curent trigger status.
Definition: RigolOscilloscope.cpp:722
virtual void ForceTrigger() override
Forces a single acquisition as soon as possible.
Definition: RigolOscilloscope.cpp:1113
virtual void FlushConfigCache() override
Instruments are allowed to cache configuration settings to reduce round trip queries to the device.
Definition: RigolOscilloscope.cpp:285
virtual void StartSingleTrigger() override
Arms the trigger for a single acquistion.
Definition: RigolOscilloscope.cpp:1086
virtual uint64_t GetSampleRate() override
Gets the current sampling rate (in Hz) of this scope.
Definition: RigolOscilloscope.cpp:1318
virtual void Start() override
Starts the instrument in continuous trigger mode.
Definition: RigolOscilloscope.cpp:1052
virtual void SetSampleRate(uint64_t rate) override
Sets the sample rate of the scope, in Hz.
Definition: RigolOscilloscope.cpp:1444
virtual void EnableChannel(size_t i) override
Turn a channel on, given the index.
Definition: RigolOscilloscope.cpp:335
virtual void SetChannelBandwidthLimit(size_t i, unsigned int limit_mhz) override
Sets the bandwidth limit for an input channel.
Definition: RigolOscilloscope.cpp:580
virtual void SetChannelVoltageRange(size_t i, size_t stream, float range) override
Sets the range of the current channel configuration.
Definition: RigolOscilloscope.cpp:676
virtual std::vector< uint64_t > GetSampleRatesInterleaved() override
Get the legal sampling rates (in Hz) for this scope in combined-channels mode.
Definition: RigolOscilloscope.cpp:1236
virtual bool IsTriggerArmed() override
Checks if the trigger is currently armed.
Definition: RigolOscilloscope.cpp:1124
void ForceHDMode(bool mode)
Forces 16-bit transfer mode on/off when for HD models.
Definition: RigolOscilloscope.cpp:1615
virtual float GetChannelVoltageRange(size_t i, size_t stream) override
Gets the range of the current channel configuration.
Definition: RigolOscilloscope.cpp:650
virtual float GetChannelOffset(size_t i, size_t stream) override
Gets the offset, in volts, for a given channel.
Definition: RigolOscilloscope.cpp:695
virtual void PullTrigger() override
Updates m_trigger with any changes made from the instrument side.
Definition: RigolOscilloscope.cpp:1515
virtual double GetChannelAttenuation(size_t i) override
Gets the probe attenuation for an input channel.
Definition: RigolOscilloscope.cpp:409
virtual int64_t GetTriggerOffset() override
Gets the trigger offset.
Definition: RigolOscilloscope.cpp:1476
virtual unsigned int GetChannelBandwidthLimit(size_t i) override
Gets the bandwidth limit for an input channel.
Definition: RigolOscilloscope.cpp:558
virtual bool IsInterleaving() override
Checks if the scope is currently combining channels.
Definition: RigolOscilloscope.cpp:1505
virtual bool AcquireData() override
Pull data from the instrument.
Definition: RigolOscilloscope.cpp:757
void PushEdgeTrigger(EdgeTrigger *trig)
Pushes settings for an edge trigger to the instrument.
Definition: RigolOscilloscope.cpp:1583
virtual uint32_t GetInstrumentTypesForChannel(size_t i) const override
Returns a bitfield describing the set of instrument types that a given channel supports.
Definition: RigolOscilloscope.cpp:272
virtual void PushTrigger() override
Pushes changes made to m_trigger to the instrument.
Definition: RigolOscilloscope.cpp:1570
virtual std::vector< OscilloscopeChannel::CouplingType > GetAvailableCouplings(size_t i) override
Gets the set of legal coupling values for an input channel.
Definition: RigolOscilloscope.cpp:349
virtual OscilloscopeChannel::CouplingType GetChannelCoupling(size_t i) override
Gets the coupling used for an input channel.
Definition: RigolOscilloscope.cpp:360
virtual void SetChannelOffset(size_t i, size_t stream, float offset) override
Sets the offset for a given channel.
Definition: RigolOscilloscope.cpp:714
virtual void Stop() override
Stops triggering.
Definition: RigolOscilloscope.cpp:1105
virtual void SetChannelAttenuation(size_t i, double atten) override
Sets the probe attenuation used for an input channel.
Definition: RigolOscilloscope.cpp:427
virtual unsigned int GetInstrumentTypes() const override
Returns a bitfield describing the set of instrument types that this instrument supports.
Definition: RigolOscilloscope.cpp:267
virtual void SetChannelCoupling(size_t i, OscilloscopeChannel::CouplingType type) override
Sets the coupling used for an input channel.
Definition: RigolOscilloscope.cpp:380
virtual std::vector< uint64_t > GetSampleRatesNonInterleaved() override
Get the legal sampling rates (in Hz) for this scope in all-channels mode.
Definition: RigolOscilloscope.cpp:1185
virtual void DisableChannel(size_t i) override
Turn a channel off, given the index.
Definition: RigolOscilloscope.cpp:342
An SCPI-based oscilloscope.
Definition: SCPIOscilloscope.h:38
Abstraction of a transport layer for moving SCPI data between endpoints.
Definition: SCPITransport.h:47