ngscopeclient 0.1-dev+51fbda87c
KeysightDCA.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 KeysightDCA_h
31#define KeysightDCA_h
32
33#include "DCAEdgeTrigger.h"
34
35class KeysightDCA : public virtual SCPIOscilloscope
36{
37public:
38 KeysightDCA(SCPITransport* transport);
39 virtual ~KeysightDCA();
40
41 //not copyable or assignable
42 KeysightDCA(const KeysightDCA& rhs) =delete;
43 KeysightDCA& operator=(const KeysightDCA& rhs) =delete;
44
45public:
46
47 //Device information
48 virtual unsigned int GetInstrumentTypes() const override;
49 virtual uint32_t GetInstrumentTypesForChannel(size_t i) const override;
50
51 virtual void FlushConfigCache() override;
52
53 //Channel configuration
54 virtual bool IsChannelEnabled(size_t i) override;
55 virtual void EnableChannel(size_t i) override;
56 virtual void DisableChannel(size_t i) override;
57 virtual OscilloscopeChannel::CouplingType GetChannelCoupling(size_t i) override;
58 virtual void SetChannelCoupling(size_t i, OscilloscopeChannel::CouplingType type) override;
59 virtual std::vector<OscilloscopeChannel::CouplingType> GetAvailableCouplings(size_t i) override;
60 virtual double GetChannelAttenuation(size_t i) override;
61 virtual void SetChannelAttenuation(size_t i, double atten) 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 virtual std::vector<std::string> GetTriggerTypes() override;
81
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
96protected:
97
98 unsigned int m_analogChannelCount;
99
100 //config cache
101 std::map<size_t, float> m_channelOffsets;
102 std::map<size_t, float> m_channelVoltageRanges;
103 std::map<size_t, OscilloscopeChannel::CouplingType> m_channelCouplings;
104 std::map<size_t, double> m_channelAttenuations;
105 std::map<size_t, int> m_channelBandwidthLimits;
106 std::map<int, bool> m_channelsEnabled;
107 uint64_t m_triggerOffset;
108 bool m_triggerOffsetValid = false;
109
110 bool m_sampleDepthValid;
111 uint64_t m_sampleDepth;
112 bool m_sampleRateValid;
113 uint64_t m_sampleRate;
114
115 bool m_triggerArmed;
116 bool m_triggerOneShot;
117
118 void PullEdgeTrigger();
119
120 void GetTriggerSlope(DCAEdgeTrigger* trig, std::string reply);
121
123 void PushFloat(std::string path, float f);
124 void PushSlope(std::string path, DCAEdgeTrigger::EdgeType slope);
125
126private:
127 static std::map<uint64_t, uint64_t> m_sampleRateToDuration;
128
129 struct WaveformPreamble {
130 unsigned int format;
131 unsigned int type;
132 size_t length;
133 unsigned int average_count;
134 double xincrement;
135 double xorigin;
136 double xreference;
137 double yincrement;
138 double yorigin;
139 double yreference;
140 };
141
142 void ConfigureWaveform(std::string channel);
143 void AddTriggerSource(std::string hwname, std::string displayname);
144 int GetLastError();
145 bool IsAnalogChannel(size_t i);
146 bool IsChannelPresent(std::string name);
147 bool IsModulePresent(std::string name);
148 std::vector<int8_t> GetWaveformData(std::string channel);
149 WaveformPreamble GetWaveformPreamble(std::string channel);
150 void SetSampleRateAndDepth(uint64_t rate, uint64_t depth);
151
152
153public:
154 static std::string GetDriverNameInternal();
155 OSCILLOSCOPE_INITPROC(KeysightDCA)
156};
157
158#endif
Declaration of DCAEdgeTrigger.
Simple edge trigger for Agilent DCA oscilloscopes.
Definition: DCAEdgeTrigger.h:45
EdgeType
Types of edges to trigger on.
Definition: DCAEdgeTrigger.h:52
Definition: KeysightDCA.h:36
virtual bool IsTriggerArmed() override
Checks if the trigger is currently armed.
Definition: KeysightDCA.cpp:574
virtual bool SetInterleaving(bool combine) override
Configures the scope to combine channels.
Definition: KeysightDCA.cpp:712
virtual std::vector< uint64_t > GetSampleRatesNonInterleaved() override
Get the legal sampling rates (in Hz) for this scope in all-channels mode.
Definition: KeysightDCA.cpp:579
virtual void PullTrigger() override
Updates m_trigger with any changes made from the instrument side.
Definition: KeysightDCA.cpp:717
virtual void SetChannelVoltageRange(size_t i, size_t stream, float range) override
Sets the range of the current channel configuration.
Definition: KeysightDCA.cpp:363
virtual void SetSampleRate(uint64_t rate) override
Sets the sample rate of the scope, in Hz.
Definition: KeysightDCA.cpp:671
virtual std::vector< uint64_t > GetSampleDepthsInterleaved() override
Get the legal memory depths for this scope in combined-channels mode.
Definition: KeysightDCA.cpp:622
void PushEdgeTrigger(DCAEdgeTrigger *trig)
Pushes settings for an edge trigger to the instrument.
Definition: KeysightDCA.cpp:786
virtual unsigned int GetInstrumentTypes() const override
Returns a bitfield describing the set of instrument types that this instrument supports.
Definition: KeysightDCA.cpp:124
void PullEdgeTrigger()
Reads settings for an edge trigger from the instrument.
Definition: KeysightDCA.cpp:726
virtual void DisableChannel(size_t i) override
Turn a channel off, given the index.
Definition: KeysightDCA.cpp:231
virtual bool IsChannelEnabled(size_t i) override
Checks if a channel is enabled in hardware.
Definition: KeysightDCA.cpp:189
virtual uint64_t GetSampleRate() override
Gets the current sampling rate (in Hz) of this scope.
Definition: KeysightDCA.cpp:627
virtual void ForceTrigger() override
Forces a single acquisition as soon as possible.
Definition: KeysightDCA.cpp:569
virtual void PushTrigger() override
Pushes changes made to m_trigger to the instrument.
Definition: KeysightDCA.cpp:773
virtual bool AcquireData() override
Pull data from the instrument.
Definition: KeysightDCA.cpp:475
virtual std::vector< uint64_t > GetSampleRatesInterleaved() override
Get the legal sampling rates (in Hz) for this scope in combined-channels mode.
Definition: KeysightDCA.cpp:596
virtual int64_t GetTriggerOffset() override
Gets the trigger offset.
Definition: KeysightDCA.cpp:688
virtual void SetTriggerOffset(int64_t offset) override
Sets the trigger offset.
Definition: KeysightDCA.cpp:679
virtual void Stop() override
Stops triggering.
Definition: KeysightDCA.cpp:559
virtual std::vector< OscilloscopeChannel::CouplingType > GetAvailableCouplings(size_t i) override
Gets the set of legal coupling values for an input channel.
Definition: KeysightDCA.cpp:243
virtual std::vector< uint64_t > GetSampleDepthsNonInterleaved() override
Get the legal memory depths for this scope in all-channels mode.
Definition: KeysightDCA.cpp:606
virtual bool IsInterleaving() override
Checks if the scope is currently combining channels.
Definition: KeysightDCA.cpp:707
virtual OscilloscopeChannel * GetExternalTrigger() override
Returns the external trigger input channel, if we have one.
Definition: KeysightDCA.cpp:372
virtual void EnableChannel(size_t i) override
Turn a channel on, given the index.
Definition: KeysightDCA.cpp:220
virtual OscilloscopeChannel::CouplingType GetChannelCoupling(size_t i) override
Gets the coupling used for an input channel.
Definition: KeysightDCA.cpp:250
virtual uint64_t GetSampleDepth() override
Gets the current sample depth of this scope.
Definition: KeysightDCA.cpp:640
virtual void FlushConfigCache() override
Instruments are allowed to cache configuration settings to reduce round trip queries to the device.
Definition: KeysightDCA.cpp:145
virtual void SetChannelCoupling(size_t i, OscilloscopeChannel::CouplingType type) override
Sets the coupling used for an input channel.
Definition: KeysightDCA.cpp:258
virtual double GetChannelAttenuation(size_t i) override
Gets the probe attenuation for an input channel.
Definition: KeysightDCA.cpp:263
virtual float GetChannelVoltageRange(size_t i, size_t stream) override
Gets the range of the current channel configuration.
Definition: KeysightDCA.cpp:337
virtual float GetChannelOffset(size_t i, size_t stream) override
Gets the offset, in volts, for a given channel.
Definition: KeysightDCA.cpp:378
virtual void SetChannelBandwidthLimit(size_t i, unsigned int limit_mhz) override
Sets the bandwidth limit for an input channel.
Definition: KeysightDCA.cpp:332
virtual void SetSampleDepth(uint64_t depth) override
Sets the sample depth of the scope.
Definition: KeysightDCA.cpp:663
virtual std::vector< std::string > GetTriggerTypes() override
Gets a list of triggers this instrument supports.
Definition: KeysightDCA.cpp:825
virtual void StartSingleTrigger() override
Arms the trigger for a single acquistion.
Definition: KeysightDCA.cpp:551
virtual uint32_t GetInstrumentTypesForChannel(size_t i) const override
Returns a bitfield describing the set of instrument types that a given channel supports.
Definition: KeysightDCA.cpp:129
virtual void SetChannelAttenuation(size_t i, double atten) override
Sets the probe attenuation used for an input channel.
Definition: KeysightDCA.cpp:287
virtual unsigned int GetChannelBandwidthLimit(size_t i) override
Gets the bandwidth limit for an input channel.
Definition: KeysightDCA.cpp:301
void GetTriggerSlope(DCAEdgeTrigger *trig, std::string reply)
Processes the slope for an edge or edge-derived trigger.
Definition: KeysightDCA.cpp:763
virtual void Start() override
Starts the instrument in continuous trigger mode.
Definition: KeysightDCA.cpp:543
virtual Oscilloscope::TriggerMode PollTrigger() override
Checks the curent trigger status.
Definition: KeysightDCA.cpp:414
virtual void SetChannelOffset(size_t i, size_t stream, float offset) override
Sets the offset for a given channel.
Definition: KeysightDCA.cpp:405
A single channel on an oscilloscope.
Definition: OscilloscopeChannel.h:49
TriggerMode
Definition: Oscilloscope.h:411
An SCPI-based oscilloscope.
Definition: SCPIOscilloscope.h:38
Abstraction of a transport layer for moving SCPI data between endpoints.
Definition: SCPITransport.h:47