ngscopeclient 0.1-dev+51fbda87c
DigilentOscilloscope.h
Go to the documentation of this file.
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
37#ifndef DigilentOscilloscope_h
38#define DigilentOscilloscope_h
39
40#include "RemoteBridgeOscilloscope.h"
41
48{
49public:
51 virtual ~DigilentOscilloscope();
52
53 //not copyable or assignable
55 DigilentOscilloscope& operator=(const DigilentOscilloscope& 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 std::vector<OscilloscopeChannel::CouplingType> GetAvailableCouplings(size_t i) override;
67 virtual double GetChannelAttenuation(size_t i) override;
68 virtual void SetChannelAttenuation(size_t i, double atten) override;
69 virtual unsigned int GetChannelBandwidthLimit(size_t i) override;
70 virtual void SetChannelBandwidthLimit(size_t i, unsigned int limit_mhz) override;
71 virtual OscilloscopeChannel* GetExternalTrigger() override;
72 virtual bool CanEnableChannel(size_t i) override;
73
74 //Triggering
75 virtual Oscilloscope::TriggerMode PollTrigger() override;
76 virtual bool AcquireData() override;
77 virtual void PushTrigger() override;
78
79 //Timebase
80 virtual std::vector<uint64_t> GetSampleRatesNonInterleaved() override;
81 virtual std::vector<uint64_t> GetSampleRatesInterleaved() override;
82 virtual std::set<InterleaveConflict> GetInterleaveConflicts() override;
83 virtual std::vector<uint64_t> GetSampleDepthsNonInterleaved() override;
84 virtual std::vector<uint64_t> GetSampleDepthsInterleaved() override;
85 virtual bool IsInterleaving() override;
86 virtual bool SetInterleaving(bool combine) override;
87
88 //ADC configuration
89 virtual std::vector<AnalogBank> GetAnalogBanks() override;
90 virtual AnalogBank GetAnalogBank(size_t channel) override;
91 virtual bool IsADCModeConfigurable() override;
92 virtual std::vector<std::string> GetADCModeNames(size_t channel) override;
93 virtual size_t GetADCMode(size_t channel) override;
94 virtual void SetADCMode(size_t channel, size_t mode) override;
95
97 // Logic analyzer configuration
98
99 virtual std::vector<DigitalBank> GetDigitalBanks() override;
100 virtual DigitalBank GetDigitalBank(size_t channel) override;
101 virtual bool IsDigitalHysteresisConfigurable() override;
102 virtual bool IsDigitalThresholdConfigurable() override;
103 virtual float GetDigitalHysteresis(size_t channel) override;
104 virtual float GetDigitalThreshold(size_t channel) override;
105 virtual void SetDigitalHysteresis(size_t channel, float level) override;
106 virtual void SetDigitalThreshold(size_t channel, float level) override;
107
108 enum Series
109 {
110 SERIES_ANALOG_DISCOVERY,
111 SERIES_ANALOG_DISCOVERY_2,
112 SERIES_DIGITAL_DISCOVERY,
113 SERIES_ANALOG_DISCOVERY_PRO,
114
115 SERIES_UNKNOWN
116 };
117
118protected:
119 void IdentifyHardware();
120
121 std::string GetChannelColor(size_t i);
122
123 //hardware analog channel count, independent of LA option etc
124 size_t m_analogChannelCount;
125 size_t m_digitalChannelBase;
126 size_t m_digitalChannelCount;
127
128 //OscilloscopeChannel* m_extTrigChannel;
129
130 //Most SCPI API calls are write only, so we have to maintain all state clientside.
131 //This isn't strictly a cache anymore since it's never flushed!
132 std::map<size_t, double> m_channelAttenuations;
133
134 Series m_series;
135
136public:
137
138 static std::string GetDriverNameInternal();
139 OSCILLOSCOPE_INITPROC(DigilentOscilloscope)
140};
141
142#endif
DigilentOscilloscope - driver for talking to the scopehal-waveforms-bridge daemon (wfmserver)
Definition: DigilentOscilloscope.h:48
virtual float GetDigitalThreshold(size_t channel) override
Gets the threshold for a digital input.
Definition: DigilentOscilloscope.cpp:625
virtual void FlushConfigCache() override
Instruments are allowed to cache configuration settings to reduce round trip queries to the device.
Definition: DigilentOscilloscope.cpp:217
virtual unsigned int GetInstrumentTypes() const override
Returns a bitfield describing the set of instrument types that this instrument supports.
Definition: DigilentOscilloscope.cpp:198
virtual std::vector< DigitalBank > GetDigitalBanks() override
Gets the digital channel banks for this instrument.
Definition: DigilentOscilloscope.cpp:598
virtual double GetChannelAttenuation(size_t i) override
Gets the probe attenuation for an input channel.
Definition: DigilentOscilloscope.cpp:234
virtual bool CanEnableChannel(size_t i) override
Determines if a channel can be enabled.
Definition: DigilentOscilloscope.cpp:589
virtual Oscilloscope::TriggerMode PollTrigger() override
Checks the curent trigger status.
Definition: DigilentOscilloscope.cpp:269
virtual void PushTrigger() override
Pushes changes made to m_trigger to the instrument.
Definition: DigilentOscilloscope.cpp:543
virtual bool IsDigitalHysteresisConfigurable() override
Checks if digital input hysteresis is configurable or fixed.
Definition: DigilentOscilloscope.cpp:610
virtual bool IsDigitalThresholdConfigurable() override
Checks if digital input threshold is configurable or fixed.
Definition: DigilentOscilloscope.cpp:615
virtual float GetDigitalHysteresis(size_t channel) override
Gets the hysteresis for a digital input.
Definition: DigilentOscilloscope.cpp:620
virtual void SetDigitalHysteresis(size_t channel, float level) override
Sets the hysteresis for a digital input.
Definition: DigilentOscilloscope.cpp:630
virtual bool IsInterleaving() override
Checks if the scope is currently combining channels.
Definition: DigilentOscilloscope.cpp:531
virtual std::vector< uint64_t > GetSampleRatesInterleaved() override
Get the legal sampling rates (in Hz) for this scope in combined-channels mode.
Definition: DigilentOscilloscope.cpp:482
DigilentOscilloscope(SCPITransport *transport)
Initialize the driver.
Definition: DigilentOscilloscope.cpp:56
virtual bool SetInterleaving(bool combine) override
Configures the scope to combine channels.
Definition: DigilentOscilloscope.cpp:537
virtual std::vector< uint64_t > GetSampleDepthsInterleaved() override
Get the legal memory depths for this scope in combined-channels mode.
Definition: DigilentOscilloscope.cpp:524
virtual std::vector< uint64_t > GetSampleDepthsNonInterleaved() override
Get the legal memory depths for this scope in all-channels mode.
Definition: DigilentOscilloscope.cpp:496
virtual size_t GetADCMode(size_t channel) override
Gets the ADC mode for a channel.
Definition: DigilentOscilloscope.cpp:579
virtual std::vector< AnalogBank > GetAnalogBanks() override
Gets the analog banks for this instrument.
Definition: DigilentOscilloscope.cpp:555
virtual void SetADCMode(size_t channel, size_t mode) override
Sets the ADC mode for a channel.
Definition: DigilentOscilloscope.cpp:584
virtual AnalogBank GetAnalogBank(size_t channel) override
Gets the bank containing a given channel.
Definition: DigilentOscilloscope.cpp:562
virtual unsigned int GetChannelBandwidthLimit(size_t i) override
Gets the bandwidth limit for an input channel.
Definition: DigilentOscilloscope.cpp:254
virtual void SetDigitalThreshold(size_t channel, float level) override
Gets the threshold for a digital input.
Definition: DigilentOscilloscope.cpp:635
virtual void SetChannelAttenuation(size_t i, double atten) override
Sets the probe attenuation used for an input channel.
Definition: DigilentOscilloscope.cpp:240
virtual bool AcquireData() override
Pull data from the instrument.
Definition: DigilentOscilloscope.cpp:276
virtual std::vector< std::string > GetADCModeNames(size_t channel) override
Gets the names of the ADC modes for the bank a given channel is located in.
Definition: DigilentOscilloscope.cpp:573
virtual std::vector< OscilloscopeChannel::CouplingType > GetAvailableCouplings(size_t i) override
Gets the set of legal coupling values for an input channel.
Definition: DigilentOscilloscope.cpp:222
virtual std::vector< uint64_t > GetSampleRatesNonInterleaved() override
Get the legal sampling rates (in Hz) for this scope in all-channels mode.
Definition: DigilentOscilloscope.cpp:451
std::string GetChannelColor(size_t i)
Color the channels based on Digilent's standard color sequence (yellow-cyan-magenta-green)
Definition: DigilentOscilloscope.cpp:147
virtual void SetChannelBandwidthLimit(size_t i, unsigned int limit_mhz) override
Sets the bandwidth limit for an input channel.
Definition: DigilentOscilloscope.cpp:259
virtual uint32_t GetInstrumentTypesForChannel(size_t i) const override
Returns a bitfield describing the set of instrument types that a given channel supports.
Definition: DigilentOscilloscope.cpp:203
virtual bool IsADCModeConfigurable() override
Returns true if the ADC is configurable, false if it can only run in one mode.
Definition: DigilentOscilloscope.cpp:568
void IdentifyHardware()
Parse model name text to figure out what the scope is.
Definition: DigilentOscilloscope.cpp:169
static std::string GetDriverNameInternal()
Return the constant driver name "digilent".
Definition: DigilentOscilloscope.cpp:212
virtual DigitalBank GetDigitalBank(size_t channel) override
Gets the bank containing a given channel.
Definition: DigilentOscilloscope.cpp:604
virtual OscilloscopeChannel * GetExternalTrigger() override
Returns the external trigger input channel, if we have one.
Definition: DigilentOscilloscope.cpp:263
A single channel on an oscilloscope.
Definition: OscilloscopeChannel.h:49
TriggerMode
Definition: Oscilloscope.h:411
An oscilloscope connected over a SDK-to-SCPI bridge that follows our pattern (i.e....
Definition: RemoteBridgeOscilloscope.h:40
Abstraction of a transport layer for moving SCPI data between endpoints.
Definition: SCPITransport.h:47