ngscopeclient v0.2.1
Loading...
Searching...
No Matches
RigolOscilloscope.h
1/***********************************************************************************************************************
2* *
3* libscopehal *
4* *
5* Copyright (c) 2012-2026 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
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, DHO4000, MHO98 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_triggerWasLive;
127
128 bool m_liveMode;
129
130 int m_modelNumber;
131 unsigned int m_bandwidth;
132 bool m_opt200M;
133 uint64_t m_maxMdepth; /* Maximum Memory depth for DHO model s*/
134 uint64_t m_maxSrate; /* Maximum Sample rate for DHO models */
135 bool m_lowSrate; /* True for DHO low sample rate models (DHO800/900) */
136 protocol_version m_protocol;
137 bool m_has_125M_sample_depth;
138 bool m_has_200M_sample_depth;
139
140 //True if we have >8 bit capture depth
141 bool m_highDefinition;
142
144 void PullEdgeTrigger();
145
146 void PrepareStart();
147
148public:
149 static std::string GetDriverNameInternal();
150
151 //This is intentionally not virtual since it's a static method used by enumeration
152 //cppcheck-suppress duplInheritedMember
153 static std::vector<SCPIInstrumentModel> GetDriverSupportedModels()
154 {
155 return {
156 {"Rigol DHO800", {
157 { SCPITransportType::TRANSPORT_LAN, "<ip_address>:5555" },
158 { SCPITransportType::TRANSPORT_USBTMC, "/dev/usbtmc<x>" },
159 }},
160 {"Rigol DHO900", {
161 { SCPITransportType::TRANSPORT_LAN, "<ip_address>:5555" },
162 { SCPITransportType::TRANSPORT_USBTMC, "/dev/usbtmc<x>" },
163 }},
164 {"Rigol DHO1000", {
165 { SCPITransportType::TRANSPORT_LAN, "<ip_address>:5555" },
166 { SCPITransportType::TRANSPORT_USBTMC, "/dev/usbtmc<x>" },
167 }},
168 {"Rigol DHO4000", {
169 { SCPITransportType::TRANSPORT_LAN, "<ip_address>:5555" },
170 { SCPITransportType::TRANSPORT_USBTMC, "/dev/usbtmc<x>" },
171 }},
172 {"Rigol MHO900", {
173 { SCPITransportType::TRANSPORT_LAN, "<ip_address>:5555" },
174 { SCPITransportType::TRANSPORT_USBTMC, "/dev/usbtmc<x>" },
175 }},
176 {"Rigol DS1100D/E", {
177 { SCPITransportType::TRANSPORT_LAN, "<ip_address>:5555" },
178 { SCPITransportType::TRANSPORT_USBTMC, "/dev/usbtmc<x>" },
179 }},
180 {"Rigol DS1000Z", {
181 { SCPITransportType::TRANSPORT_LAN, "<ip_address>:5555" },
182 { SCPITransportType::TRANSPORT_USBTMC, "/dev/usbtmc<x>" },
183 }},
184 {"Rigol MSO5000", {
185 { SCPITransportType::TRANSPORT_LAN, "<ip_address>:5555" },
186 { SCPITransportType::TRANSPORT_USBTMC, "/dev/usbtmc<x>" },
187 }},
188 };
189 }
190
191 OSCILLOSCOPE_INITPROC(RigolOscilloscope)
192};
193
194#endif
Definition AcceleratorBuffer.h:204
Simple edge trigger.
Definition EdgeTrigger.h:44
A single channel on an oscilloscope.
Definition OscilloscopeChannel.h:49
TriggerMode
Definition Oscilloscope.h:398
Definition RigolOscilloscope.h:36
virtual OscilloscopeChannel * GetExternalTrigger() override
Returns the external trigger input channel, if we have one.
Definition RigolOscilloscope.cpp:739
virtual void SetSampleDepth(uint64_t depth) override
Sets the sample depth of the scope.
Definition RigolOscilloscope.cpp:1404
virtual std::vector< unsigned int > GetChannelBandwidthLimiters(size_t i) override
Gets the set of available bandwidth limiters for an input channel.
Definition RigolOscilloscope.cpp:575
virtual void SetTriggerOffset(int64_t offset) override
Sets the trigger offset.
Definition RigolOscilloscope.cpp:1524
virtual uint64_t GetSampleDepth() override
Gets the current sample depth of this scope.
Definition RigolOscilloscope.cpp:1390
virtual std::vector< uint64_t > GetSampleDepthsInterleaved() override
Get the legal memory depths for this scope in combined-channels mode.
Definition RigolOscilloscope.cpp:1361
virtual bool IsChannelEnabled(size_t i) override
Checks if a channel is enabled in hardware.
Definition RigolOscilloscope.cpp:352
virtual bool SetInterleaving(bool combine) override
Configures the scope to combine channels.
Definition RigolOscilloscope.cpp:1568
virtual std::vector< uint64_t > GetSampleDepthsNonInterleaved() override
Get the legal memory depths for this scope in all-channels mode.
Definition RigolOscilloscope.cpp:1323
void PullEdgeTrigger()
Reads settings for an edge trigger from the instrument.
Definition RigolOscilloscope.cpp:1593
virtual Oscilloscope::TriggerMode PollTrigger() override
Checks the curent trigger status.
Definition RigolOscilloscope.cpp:772
virtual void ForceTrigger() override
Forces a single acquisition as soon as possible.
Definition RigolOscilloscope.cpp:1163
virtual void FlushConfigCache() override
Instruments are allowed to cache configuration settings to reduce round trip queries to the device.
Definition RigolOscilloscope.cpp:333
virtual void StartSingleTrigger() override
Arms the trigger for a single acquistion.
Definition RigolOscilloscope.cpp:1136
virtual uint64_t GetSampleRate() override
Gets the current sampling rate (in Hz) of this scope.
Definition RigolOscilloscope.cpp:1376
virtual void Start() override
Starts the instrument in continuous trigger mode.
Definition RigolOscilloscope.cpp:1102
virtual void SetSampleRate(uint64_t rate) override
Sets the sample rate of the scope, in Hz.
Definition RigolOscilloscope.cpp:1502
virtual void EnableChannel(size_t i) override
Turn a channel on, given the index.
Definition RigolOscilloscope.cpp:383
virtual void SetChannelBandwidthLimit(size_t i, unsigned int limit_mhz) override
Sets the bandwidth limit for an input channel.
Definition RigolOscilloscope.cpp:628
virtual void SetChannelVoltageRange(size_t i, size_t stream, float range) override
Sets the range of the current channel configuration.
Definition RigolOscilloscope.cpp:726
virtual std::vector< uint64_t > GetSampleRatesInterleaved() override
Get the legal sampling rates (in Hz) for this scope in combined-channels mode.
Definition RigolOscilloscope.cpp:1286
virtual bool IsTriggerArmed() override
Checks if the trigger is currently armed.
Definition RigolOscilloscope.cpp:1174
void ForceHDMode(bool mode)
Forces 16-bit transfer mode on/off when for HD models.
Definition RigolOscilloscope.cpp:1673
virtual float GetChannelVoltageRange(size_t i, size_t stream) override
Gets the range of the current channel configuration.
Definition RigolOscilloscope.cpp:700
virtual float GetChannelOffset(size_t i, size_t stream) override
Gets the offset, in volts, for a given channel.
Definition RigolOscilloscope.cpp:745
virtual void PullTrigger() override
Updates m_trigger with any changes made from the instrument side.
Definition RigolOscilloscope.cpp:1573
virtual double GetChannelAttenuation(size_t i) override
Gets the probe attenuation for an input channel.
Definition RigolOscilloscope.cpp:457
virtual int64_t GetTriggerOffset() override
Gets the trigger offset.
Definition RigolOscilloscope.cpp:1534
virtual unsigned int GetChannelBandwidthLimit(size_t i) override
Gets the bandwidth limit for an input channel.
Definition RigolOscilloscope.cpp:606
virtual bool IsInterleaving() override
Checks if the scope is currently combining channels.
Definition RigolOscilloscope.cpp:1563
virtual bool AcquireData() override
Pull data from the instrument.
Definition RigolOscilloscope.cpp:807
void PushEdgeTrigger(EdgeTrigger *trig)
Pushes settings for an edge trigger to the instrument.
Definition RigolOscilloscope.cpp:1641
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:320
virtual void PushTrigger() override
Pushes changes made to m_trigger to the instrument.
Definition RigolOscilloscope.cpp:1628
virtual std::vector< OscilloscopeChannel::CouplingType > GetAvailableCouplings(size_t i) override
Gets the set of legal coupling values for an input channel.
Definition RigolOscilloscope.cpp:397
virtual OscilloscopeChannel::CouplingType GetChannelCoupling(size_t i) override
Gets the coupling used for an input channel.
Definition RigolOscilloscope.cpp:408
virtual void SetChannelOffset(size_t i, size_t stream, float offset) override
Sets the offset for a given channel.
Definition RigolOscilloscope.cpp:764
virtual void Stop() override
Stops triggering.
Definition RigolOscilloscope.cpp:1155
virtual void SetChannelAttenuation(size_t i, double atten) override
Sets the probe attenuation used for an input channel.
Definition RigolOscilloscope.cpp:475
virtual unsigned int GetInstrumentTypes() const override
Returns a bitfield describing the set of instrument types that this instrument supports.
Definition RigolOscilloscope.cpp:315
virtual void SetChannelCoupling(size_t i, OscilloscopeChannel::CouplingType type) override
Sets the coupling used for an input channel.
Definition RigolOscilloscope.cpp:428
virtual std::vector< uint64_t > GetSampleRatesNonInterleaved() override
Get the legal sampling rates (in Hz) for this scope in all-channels mode.
Definition RigolOscilloscope.cpp:1235
virtual void DisableChannel(size_t i) override
Turn a channel off, given the index.
Definition RigolOscilloscope.cpp:390
An SCPI-based oscilloscope.
Definition SCPIOscilloscope.h:38
Abstraction of a transport layer for moving SCPI data between endpoints.
Definition SCPITransport.h:53