ngscopeclient v0.2.1
Loading...
Searching...
No Matches
AgilentOscilloscope.h
Go to the documentation of this file.
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
36#ifndef AgilentOscilloscope_h
37#define AgilentOscilloscope_h
38
39#include "EdgeTrigger.h"
40#include "PulseWidthTrigger.h"
41#include "NthEdgeBurstTrigger.h"
42
48{
49public:
51 virtual ~AgilentOscilloscope();
52
53 //not copyable or assignable
54 AgilentOscilloscope(const AgilentOscilloscope& rhs) =delete;
55 AgilentOscilloscope& operator=(const AgilentOscilloscope& rhs) =delete;
56
57public:
58
59 //Device information
60 virtual unsigned int GetInstrumentTypes() const override;
61 virtual uint32_t GetInstrumentTypesForChannel(size_t i) const override;
62
63 virtual void FlushConfigCache() override;
64
65 //Channel configuration
66 virtual bool IsChannelEnabled(size_t i) override;
67 virtual void EnableChannel(size_t i) override;
68 virtual void DisableChannel(size_t i) override;
69 virtual OscilloscopeChannel::CouplingType GetChannelCoupling(size_t i) override;
70 virtual void SetChannelCoupling(size_t i, OscilloscopeChannel::CouplingType type) override;
71 virtual std::vector<OscilloscopeChannel::CouplingType> GetAvailableCouplings(size_t i) override;
72 virtual double GetChannelAttenuation(size_t i) override;
73 virtual void SetChannelAttenuation(size_t i, double atten) override;
74 virtual unsigned int GetChannelBandwidthLimit(size_t i) override;
75 virtual void SetChannelBandwidthLimit(size_t i, unsigned int limit_mhz) override;
76 virtual float GetChannelVoltageRange(size_t i, size_t stream) override;
77 virtual void SetChannelVoltageRange(size_t i, size_t stream, float range) override;
78 virtual OscilloscopeChannel* GetExternalTrigger() override;
79 virtual float GetChannelOffset(size_t i, size_t stream) override;
80 virtual void SetChannelOffset(size_t i, size_t stream, float offset) override;
81
82 //Triggering
83 virtual Oscilloscope::TriggerMode PollTrigger() override;
84 virtual bool AcquireData() override;
85 virtual void Start() override;
86 virtual void StartSingleTrigger() override;
87 virtual void Stop() override;
88 virtual void ForceTrigger() override;
89 virtual bool IsTriggerArmed() override;
90 virtual void PushTrigger() override;
91 virtual void PullTrigger() override;
92 virtual std::vector<std::string> GetTriggerTypes() override;
93
94 virtual std::vector<uint64_t> GetSampleRatesNonInterleaved() override;
95 virtual std::vector<uint64_t> GetSampleRatesInterleaved() override;
96 virtual std::set<InterleaveConflict> GetInterleaveConflicts() override;
97 virtual std::vector<uint64_t> GetSampleDepthsNonInterleaved() override;
98 virtual std::vector<uint64_t> GetSampleDepthsInterleaved() override;
99 virtual uint64_t GetSampleRate() override;
100 virtual uint64_t GetSampleDepth() override;
101 virtual void SetSampleDepth(uint64_t depth) override;
102 virtual void SetSampleRate(uint64_t rate) override;
103 virtual void SetTriggerOffset(int64_t offset) override;
104 virtual int64_t GetTriggerOffset() override;
105 virtual bool IsInterleaving() override;
106 virtual bool SetInterleaving(bool combine) override;
107
108protected:
109
112
115
118
121
124 {
127
130
133 };
134
136 std::map<size_t, float> m_channelOffsets;
137
139 std::map<size_t, float> m_channelVoltageRanges;
140
142 std::map<size_t, OscilloscopeChannel::CouplingType> m_channelCouplings;
143
145 std::map<size_t, double> m_channelAttenuations;
146
148 std::map<size_t, int> m_channelBandwidthLimits;
149
151 std::map<int, bool> m_channelsEnabled;
152
154 std::map<size_t, ProbeType> m_probeTypes;
155
158
161
164
166 uint64_t m_sampleRate;
167
168 void PullEdgeTrigger();
171
172 void GetTriggerSlope(EdgeTrigger* trig, const std::string& reply);
173 void GetTriggerSlope(NthEdgeBurstTrigger* trig, const std::string& reply);
174 Trigger::Condition GetCondition(const std::string& reply);
175 void GetProbeType(size_t i);
176
177 void PushEdgeTrigger(EdgeTrigger* trig);
180 void PushCondition(const std::string& path, Trigger::Condition cond);
181 void PushFloat(const std::string& path, float f);
182 void PushSlope(const std::string& path, EdgeTrigger::EdgeType slope);
183 void PushSlope(const std::string& path, NthEdgeBurstTrigger::EdgeType slope);
184
185private:
186
188 static std::map<uint64_t, uint64_t> m_sampleRateToDuration;
189
191 struct WaveformPreamble
192 {
193 unsigned int format;
194 unsigned int type;
195 size_t length;
196 unsigned int average_count;
197 double xincrement;
198 double xorigin;
199 double xreference;
200 double yincrement;
201 double yorigin;
202 double yreference;
203 };
204
205 void ConfigureWaveform(const std::string& channel);
206 bool IsAnalogChannel(size_t i);
207 size_t GetDigitalPodIndex(size_t i);
208 std::string GetDigitalPodName(size_t i);
209 std::vector<uint8_t> GetWaveformData(const std::string& channel);
210 WaveformPreamble GetWaveformPreamble(const std::string& channel);
211 void ProcessDigitalWaveforms(
212 std::map<int, std::vector<WaveformBase*>> &pending_waveforms,
213 std::vector<uint8_t> &data, WaveformPreamble &preamble,
214 size_t chan_start);
215 void SetSampleRateAndDepth(uint64_t rate, uint64_t depth);
216
217public:
218 static std::string GetDriverNameInternal();
219 OSCILLOSCOPE_INITPROC(AgilentOscilloscope)
220};
221
222#endif
Declaration of EdgeTrigger.
Declaration of NthEdgeBurstTrigger.
Declaration of PulseWidthTrigger.
Driver for Agilent (and some Keysight) oscilloscopes.
Definition AgilentOscilloscope.h:48
virtual bool IsTriggerArmed() override
Checks if the trigger is currently armed.
Definition AgilentOscilloscope.cpp:871
uint64_t m_sampleDepth
Acquisition memory depth.
Definition AgilentOscilloscope.h:160
virtual std::vector< uint64_t > GetSampleDepthsInterleaved() override
Get the legal memory depths for this scope in combined-channels mode.
Definition AgilentOscilloscope.cpp:943
virtual uint64_t GetSampleRate() override
Gets the current sampling rate (in Hz) of this scope.
Definition AgilentOscilloscope.cpp:950
virtual void DisableChannel(size_t i) override
Turn a channel off, given the index.
Definition AgilentOscilloscope.cpp:332
virtual void ForceTrigger() override
Forces a single acquisition as soon as possible.
Definition AgilentOscilloscope.cpp:862
virtual void SetChannelAttenuation(size_t i, double atten) override
Sets the probe attenuation used for an input channel.
Definition AgilentOscilloscope.cpp:449
virtual void SetSampleDepth(uint64_t depth) override
Sets the sample depth of the scope.
Definition AgilentOscilloscope.cpp:1013
virtual float GetChannelVoltageRange(size_t i, size_t stream) override
Gets the range of the current channel configuration.
Definition AgilentOscilloscope.cpp:500
virtual uint64_t GetSampleDepth() override
Gets the current sample depth of this scope.
Definition AgilentOscilloscope.cpp:963
virtual void Stop() override
Stops triggering.
Definition AgilentOscilloscope.cpp:854
virtual std::vector< OscilloscopeChannel::CouplingType > GetAvailableCouplings(size_t i) override
Gets the set of legal coupling values for an input channel.
Definition AgilentOscilloscope.cpp:344
std::map< size_t, int > m_channelBandwidthLimits
Map of channel ID to bandwidth limit.
Definition AgilentOscilloscope.h:148
bool m_sampleDepthValid
True if m_sampleDepth is valid, false if not.
Definition AgilentOscilloscope.h:157
virtual void SetChannelVoltageRange(size_t i, size_t stream, float range) override
Sets the range of the current channel configuration.
Definition AgilentOscilloscope.cpp:526
ProbeType
Type of probe connected to a channel.
Definition AgilentOscilloscope.h:124
@ AutoProbe
Passive probe with ID resistor for detecting attenuation.
Definition AgilentOscilloscope.h:129
@ SmartProbe
Active probe.
Definition AgilentOscilloscope.h:132
@ None
No probe, or no ID ring present.
Definition AgilentOscilloscope.h:126
std::map< size_t, float > m_channelOffsets
Map of channel ID to offset.
Definition AgilentOscilloscope.h:136
uint64_t m_sampleRate
Acquisition sample rate.
Definition AgilentOscilloscope.h:166
virtual bool AcquireData() override
Pull data from the instrument.
Definition AgilentOscilloscope.cpp:744
void GetProbeType(size_t i)
Figures out what kind of probe is connected to a channel.
Definition AgilentOscilloscope.cpp:1286
virtual void PullTrigger() override
Updates m_trigger with any changes made from the instrument side.
Definition AgilentOscilloscope.cpp:1050
bool m_sampleRateValid
True if m_sampleRate is valid, false if not.
Definition AgilentOscilloscope.h:163
virtual std::vector< uint64_t > GetSampleRatesInterleaved() override
Get the legal sampling rates (in Hz) for this scope in combined-channels mode.
Definition AgilentOscilloscope.cpp:907
virtual void SetTriggerOffset(int64_t offset) override
Sets the trigger offset.
Definition AgilentOscilloscope.cpp:1029
virtual void PushTrigger() override
Pushes changes made to m_trigger to the instrument.
Definition AgilentOscilloscope.cpp:1310
void PushPulseWidthTrigger(PulseWidthTrigger *trig)
Pushes settings for a pulse width trigger to the instrument.
Definition AgilentOscilloscope.cpp:1372
Trigger::Condition GetCondition(const std::string &reply)
Converts a trigger condition from a string to a Trigger::Condition.
Definition AgilentOscilloscope.cpp:1266
unsigned int m_analogChannelCount
Hardware analog channel count, independent of LA option etc.
Definition AgilentOscilloscope.h:114
virtual void FlushConfigCache() override
Instruments are allowed to cache configuration settings to reduce round trip queries to the device.
Definition AgilentOscilloscope.cpp:229
virtual void StartSingleTrigger() override
Arms the trigger for a single acquistion.
Definition AgilentOscilloscope.cpp:846
virtual void EnableChannel(size_t i) override
Turn a channel on, given the index.
Definition AgilentOscilloscope.cpp:316
virtual void Start() override
Starts the instrument in continuous trigger mode.
Definition AgilentOscilloscope.cpp:838
void PullPulseWidthTrigger()
Reads settings for a pulse width trigger from the instrument.
Definition AgilentOscilloscope.cpp:1157
void PushNthEdgeBurstTrigger(NthEdgeBurstTrigger *trig)
Pushes settings for a Nth edge burst trigger to the instrument.
Definition AgilentOscilloscope.cpp:1354
virtual void SetChannelCoupling(size_t i, OscilloscopeChannel::CouplingType type) override
Sets the coupling used for an input channel.
Definition AgilentOscilloscope.cpp:390
void PullEdgeTrigger()
Reads settings for an edge trigger from the instrument.
Definition AgilentOscilloscope.cpp:1076
std::map< size_t, float > m_channelVoltageRanges
Map of channel ID to voltage range.
Definition AgilentOscilloscope.h:139
void PushEdgeTrigger(EdgeTrigger *trig)
Pushes settings for an edge trigger to the instrument.
Definition AgilentOscilloscope.cpp:1332
void PullNthEdgeBurstTrigger()
Reads settings for an Nth-edge-burst trigger from the instrument.
Definition AgilentOscilloscope.cpp:1113
std::map< size_t, ProbeType > m_probeTypes
Map of channel ID to probe type.
Definition AgilentOscilloscope.h:154
virtual void SetChannelBandwidthLimit(size_t i, unsigned int limit_mhz) override
Sets the bandwidth limit for an input channel.
Definition AgilentOscilloscope.cpp:495
virtual float GetChannelOffset(size_t i, size_t stream) override
Gets the offset, in volts, for a given channel.
Definition AgilentOscilloscope.cpp:545
virtual bool IsChannelEnabled(size_t i) override
Checks if a channel is enabled in hardware.
Definition AgilentOscilloscope.cpp:284
virtual void SetSampleRate(uint64_t rate) override
Sets the sample rate of the scope, in Hz.
Definition AgilentOscilloscope.cpp:1021
virtual Oscilloscope::TriggerMode PollTrigger() override
Checks the curent trigger status.
Definition AgilentOscilloscope.cpp:585
virtual OscilloscopeChannel * GetExternalTrigger() override
Returns the external trigger input channel, if we have one.
Definition AgilentOscilloscope.cpp:539
static std::string GetDriverNameInternal()
Return the constant driver name "agilent".
Definition AgilentOscilloscope.cpp:211
virtual unsigned int GetChannelBandwidthLimit(size_t i) override
Gets the bandwidth limit for an input channel.
Definition AgilentOscilloscope.cpp:465
virtual int64_t GetTriggerOffset() override
Gets the trigger offset.
Definition AgilentOscilloscope.cpp:1034
std::map< size_t, OscilloscopeChannel::CouplingType > m_channelCouplings
Map of channel ID to voltage range.
Definition AgilentOscilloscope.h:142
virtual unsigned int GetInstrumentTypes() const override
Returns a bitfield describing the set of instrument types that this instrument supports.
Definition AgilentOscilloscope.cpp:216
unsigned int m_digitalChannelCount
Number of digital channels supported.
Definition AgilentOscilloscope.h:117
virtual bool IsInterleaving() override
Checks if the scope is currently combining channels.
Definition AgilentOscilloscope.cpp:1040
OscilloscopeChannel * m_extTrigChannel
External trigger.
Definition AgilentOscilloscope.h:111
std::map< int, bool > m_channelsEnabled
Map of channel ID to enable flag.
Definition AgilentOscilloscope.h:151
virtual bool SetInterleaving(bool combine) override
Configures the scope to combine channels.
Definition AgilentOscilloscope.cpp:1045
virtual OscilloscopeChannel::CouplingType GetChannelCoupling(size_t i) override
Gets the coupling used for an input channel.
Definition AgilentOscilloscope.cpp:354
std::map< size_t, double > m_channelAttenuations
Map of channel ID to attenuation.
Definition AgilentOscilloscope.h:145
virtual std::vector< uint64_t > GetSampleRatesNonInterleaved() override
Get the legal sampling rates (in Hz) for this scope in all-channels mode.
Definition AgilentOscilloscope.cpp:898
unsigned int m_digitalChannelBase
Index of the first digital channel (if any)
Definition AgilentOscilloscope.h:120
virtual std::vector< uint64_t > GetSampleDepthsNonInterleaved() override
Get the legal memory depths for this scope in all-channels mode.
Definition AgilentOscilloscope.cpp:921
virtual double GetChannelAttenuation(size_t i) override
Gets the probe attenuation for an input channel.
Definition AgilentOscilloscope.cpp:425
virtual std::vector< std::string > GetTriggerTypes() override
Gets a list of triggers this instrument supports.
Definition AgilentOscilloscope.cpp:1485
void PushFloat(const std::string &path, float f)
Send a floating-point value to the instrument.
Definition AgilentOscilloscope.cpp:1428
void PushCondition(const std::string &path, Trigger::Condition cond)
Send a trigger condition to the instrument.
Definition AgilentOscilloscope.cpp:1402
virtual uint32_t GetInstrumentTypesForChannel(size_t i) const override
Returns a bitfield describing the set of instrument types that a given channel supports.
Definition AgilentOscilloscope.cpp:221
virtual void SetChannelOffset(size_t i, size_t stream, float offset) override
Sets the offset for a given channel.
Definition AgilentOscilloscope.cpp:572
Simple edge trigger.
Definition EdgeTrigger.h:44
EdgeType
Types of edges to trigger on.
Definition EdgeTrigger.h:51
Nth Edge Burst Trigger: triggers on a specific edge within a burst.
Definition NthEdgeBurstTrigger.h:44
EdgeType
Types of edges to trigger on.
Definition NthEdgeBurstTrigger.h:51
A single channel on an oscilloscope.
Definition OscilloscopeChannel.h:49
TriggerMode
Definition Oscilloscope.h:398
Trigger on a pulse meeting certain width criteria.
Definition PulseWidthTrigger.h:44
An SCPI-based oscilloscope.
Definition SCPIOscilloscope.h:38
Abstraction of a transport layer for moving SCPI data between endpoints.
Definition SCPITransport.h:53
Condition
Conditions for triggers that perform logical comparisons of values.
Definition Trigger.h:85