ngscopeclient v0.2.1
Loading...
Searching...
No Matches
ThunderScopeOscilloscope.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
37#ifndef ThunderScopeOscilloscope_h
38#define ThunderScopeOscilloscope_h
39
40#include "RemoteBridgeOscilloscope.h"
41#include "../xptools/HzClock.h"
42
49{
50public:
53
54 //not copyable or assignable
56 ThunderScopeOscilloscope& operator=(const ThunderScopeOscilloscope& rhs) =delete;
57
58public:
59
60 //Device information
61 virtual unsigned int GetInstrumentTypes() const override;
62 virtual void FlushConfigCache() override;
63
64 //Channel configuration
65 virtual std::vector<OscilloscopeChannel::CouplingType> GetAvailableCouplings(size_t i) override;
66 virtual double GetChannelAttenuation(size_t i) override;
67 virtual void SetChannelAttenuation(size_t i, double atten) override;
68 virtual unsigned int GetChannelBandwidthLimit(size_t i) override;
69 virtual void SetChannelBandwidthLimit(size_t i, unsigned int limit_mhz) override;
70 virtual std::vector<unsigned int> GetChannelBandwidthLimiters(size_t i) override;
71 virtual OscilloscopeChannel* GetExternalTrigger() override;
72 virtual bool CanEnableChannel(size_t i) override;
73 virtual uint32_t GetInstrumentTypesForChannel(size_t i) const override;
74 virtual void SetChannelCoupling(size_t i, OscilloscopeChannel::CouplingType type) override;
75 virtual void EnableChannel(size_t i) override;
76 virtual bool IsHighRateOffsetCapable(size_t i) override;
77
78 //Triggering
79 virtual void BackgroundProcessing() override;
80 virtual Oscilloscope::TriggerMode PollTrigger() override;
81 virtual bool AcquireData() override;
82 virtual void PushEdgeTrigger(EdgeTrigger* trig) override;
83
84 // Captures
85 virtual void Start() override;
86 virtual void StartSingleTrigger() override;
87 virtual void Stop() override;
88 virtual void ForceTrigger() override;
89
90 //Timebase
91 virtual std::vector<uint64_t> GetSampleRatesNonInterleaved() override;
92 virtual std::vector<uint64_t> GetSampleRatesInterleaved() override;
93 virtual std::set<InterleaveConflict> GetInterleaveConflicts() override;
94 virtual std::vector<uint64_t> GetSampleDepthsNonInterleaved() override;
95 virtual std::vector<uint64_t> GetSampleDepthsInterleaved() override;
96 virtual bool IsInterleaving() override;
97 virtual bool SetInterleaving(bool combine) override;
98 virtual bool CanInterleave() override;
99 virtual bool HasInterleavingControls() override;
100 void SetSampleDepth(uint64_t depth) override;
101 void SetSampleRate(uint64_t rate) override;
102
103 //ADC modes
104 virtual bool IsADCModeConfigurable() override;
105 virtual std::vector<std::string> GetADCModeNames(size_t channel) override;
106 virtual size_t GetADCMode(size_t channel) override;
107 virtual void SetADCMode(size_t channel, size_t mode) override;
108
109protected:
111 void RefreshSampleRate();
112 bool DoAcquireData(bool keep);
113
115
120 {
121 while(!m_wipWaveforms.empty())
123 }
124
125 std::string GetChannelColor(size_t i);
126
129
131 std::map<size_t, double> m_channelAttenuations;
132
135
138
141
144
147
150
152 std::vector<std::unique_ptr<AcceleratorBuffer<int16_t> > > m_analogRawWaveformBuffers;
153
156
158 std::unique_ptr<ComputePipeline> m_conversion8BitPipeline;
159
161 std::unique_ptr<ComputePipeline> m_conversion16BitPipeline;
162
165
167 std::vector<unsigned int> m_bandwidthLimits;
168
171 {
172 MODE_8BIT,
173 MODE_12BIT
174 } m_adcMode;
175
178
181
183 std::recursive_mutex m_wipWaveformMutex;
184
186 SequenceSet m_wipWaveforms;
187
188public:
189
190 //This is intentionally not virtual since it's a static method used by enumeration
191 //cppcheck-suppress duplInheritedMember
192 static std::vector<SCPIInstrumentModel> GetDriverSupportedModels()
193 {
194 return
195 {
196 {"TS0xxx", {{ SCPITransportType::TRANSPORT_TWINLAN, "localhost:5025:5026" }}}
197 };
198 }
199
200 static std::string GetDriverNameInternal();
201 OSCILLOSCOPE_INITPROC(ThunderScopeOscilloscope);
202};
203
204#endif
Definition AcceleratorBuffer.h:204
Simple edge trigger.
Definition EdgeTrigger.h:44
A parameter to a filter.
Definition FilterParameter.h:86
Clock that measures rate at which it is called; windowed average.
Definition HzClock.h:52
A single channel on an oscilloscope.
Definition OscilloscopeChannel.h:49
TriggerMode
Definition Oscilloscope.h:398
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:53
Driver for talking to the TS.NET server controlling a ThunderScope.
Definition ThunderScopeOscilloscope.h:49
virtual std::vector< uint64_t > GetSampleDepthsInterleaved() override
Get the legal memory depths for this scope in combined-channels mode.
Definition ThunderScopeOscilloscope.cpp:778
virtual double GetChannelAttenuation(size_t i) override
Gets the probe attenuation for an input channel.
Definition ThunderScopeOscilloscope.cpp:249
virtual bool HasInterleavingControls() override
Returns true if the scope has a user controllable interleaving feature, false if not.
Definition ThunderScopeOscilloscope.cpp:753
size_t m_analogChannelCount
Number of analog channels (always 4 at the moment)
Definition ThunderScopeOscilloscope.h:128
virtual void FlushConfigCache() override
Instruments are allowed to cache configuration settings to reduce round trip queries to the device.
Definition ThunderScopeOscilloscope.cpp:231
virtual size_t GetADCMode(size_t channel) override
Gets the ADC mode for a channel.
Definition ThunderScopeOscilloscope.cpp:866
virtual void SetADCMode(size_t channel, size_t mode) override
Sets the ADC mode for a channel.
Definition ThunderScopeOscilloscope.cpp:871
std::unique_ptr< ComputePipeline > m_conversion8BitPipeline
Compute pipeline for converting raw ADC codes to float32 samples.
Definition ThunderScopeOscilloscope.h:158
HzClock m_receiveClock
Counter of average trigger rate.
Definition ThunderScopeOscilloscope.h:149
uint32_t m_lastSeq
Most recently received sequence number.
Definition ThunderScopeOscilloscope.h:177
virtual OscilloscopeChannel * GetExternalTrigger() override
Returns the external trigger input channel, if we have one.
Definition ThunderScopeOscilloscope.cpp:304
virtual bool IsInterleaving() override
Checks if the scope is currently combining channels.
Definition ThunderScopeOscilloscope.cpp:785
virtual void SetChannelAttenuation(size_t i, double atten) override
Sets the probe attenuation used for an input channel.
Definition ThunderScopeOscilloscope.cpp:255
virtual bool IsADCModeConfigurable() override
Returns true if the ADC is configurable, false if it can only run in one mode.
Definition ThunderScopeOscilloscope.cpp:853
SequenceSet m_wipWaveforms
Waveforms actively being downloaded and processed but not ready to push to the filter graph yet.
Definition ThunderScopeOscilloscope.h:186
virtual void StartSingleTrigger() override
Arms the trigger for a single acquistion.
Definition ThunderScopeOscilloscope.cpp:663
virtual std::vector< unsigned int > GetChannelBandwidthLimiters(size_t i) override
Gets the set of available bandwidth limiters for an input channel.
Definition ThunderScopeOscilloscope.cpp:286
FilterParameter m_diag_hardwareWFMHz
Number of WFM/s acquired by hardware.
Definition ThunderScopeOscilloscope.h:134
virtual bool CanInterleave() override
Returns true if we have no interleave conflicts, false if we have conflicts.
Definition ThunderScopeOscilloscope.cpp:748
std::unique_ptr< ComputePipeline > m_conversion16BitPipeline
Compute pipeline for converting raw ADC codes to float32 samples.
Definition ThunderScopeOscilloscope.h:161
void ResetPerCaptureDiagnostics()
Reset performance counters at the start of a capture.
Definition ThunderScopeOscilloscope.cpp:172
virtual std::vector< uint64_t > GetSampleDepthsNonInterleaved() override
Get the legal memory depths for this scope in all-channels mode.
Definition ThunderScopeOscilloscope.cpp:765
virtual std::vector< uint64_t > GetSampleRatesNonInterleaved() override
Get the legal sampling rates (in Hz) for this scope in all-channels mode.
Definition ThunderScopeOscilloscope.cpp:727
FilterParameter m_diag_receivedWFMHz
Number of WFM/s recieved by the driver.
Definition ThunderScopeOscilloscope.h:137
unsigned int m_nextWaveformWriteBuffer
Index of next buffer from m_analogRawWaveformBuffers to use.
Definition ThunderScopeOscilloscope.h:155
virtual void PushEdgeTrigger(EdgeTrigger *trig) override
Pushes settings for an edge trigger to the instrument.
Definition ThunderScopeOscilloscope.cpp:680
static std::string GetDriverNameInternal()
Return the driver name "thunderscope".
Definition ThunderScopeOscilloscope.cpp:226
ADCMode
ADC modes.
Definition ThunderScopeOscilloscope.h:171
virtual void Start() override
Starts the instrument in continuous trigger mode.
Definition ThunderScopeOscilloscope.cpp:633
virtual uint32_t GetInstrumentTypesForChannel(size_t i) const override
Returns a bitfield describing the set of instrument types that a given channel supports.
Definition ThunderScopeOscilloscope.cpp:217
virtual std::vector< uint64_t > GetSampleRatesInterleaved() override
Get the legal sampling rates (in Hz) for this scope in combined-channels mode.
Definition ThunderScopeOscilloscope.cpp:740
void PushPendingWaveformsIfReady()
Wait up to 1ms for waveform conversion to finish, then push it to the pending waveforms buffer.
Definition ThunderScopeOscilloscope.cpp:586
std::string GetChannelColor(size_t i)
Color the channels based on our standard color sequence (blue-red-green-yellow)
Definition ThunderScopeOscilloscope.cpp:185
uint32_t m_dropUntilSeq
Sequence number to drop until (if we get stale data after stopping the trigger)
Definition ThunderScopeOscilloscope.h:180
virtual bool AcquireData() override
Pull data from the instrument.
Definition ThunderScopeOscilloscope.cpp:350
virtual unsigned int GetInstrumentTypes() const override
Returns a bitfield describing the set of instrument types that this instrument supports.
Definition ThunderScopeOscilloscope.cpp:212
virtual void SetChannelCoupling(size_t i, OscilloscopeChannel::CouplingType type) override
Sets the coupling used for an input channel.
Definition ThunderScopeOscilloscope.cpp:807
void SetSampleRate(uint64_t rate) override
Sets the sample rate of the scope, in Hz.
Definition ThunderScopeOscilloscope.cpp:721
virtual void ForceTrigger() override
Forces a single acquisition as soon as possible.
Definition ThunderScopeOscilloscope.cpp:669
void SetSampleDepth(uint64_t depth) override
Sets the sample depth of the scope.
Definition ThunderScopeOscilloscope.cpp:715
virtual void BackgroundProcessing() override
Run various background processing typically done by a second thread (e.g. InstrumentThread)
Definition ThunderScopeOscilloscope.cpp:310
std::recursive_mutex m_wipWaveformMutex
Mutex for m_wipWaveforms.
Definition ThunderScopeOscilloscope.h:183
virtual bool SetInterleaving(bool combine) override
Configures the scope to combine channels.
Definition ThunderScopeOscilloscope.cpp:791
virtual void SetChannelBandwidthLimit(size_t i, unsigned int limit_mhz) override
Sets the bandwidth limit for an input channel.
Definition ThunderScopeOscilloscope.cpp:273
FilterParameter m_diag_droppedPercent
Percentage of waveforms which were dropped.
Definition ThunderScopeOscilloscope.h:146
virtual std::vector< OscilloscopeChannel::CouplingType > GetAvailableCouplings(size_t i) override
Gets the set of legal coupling values for an input channel.
Definition ThunderScopeOscilloscope.cpp:797
virtual void Stop() override
Stops triggering.
Definition ThunderScopeOscilloscope.cpp:646
virtual bool IsHighRateOffsetCapable(size_t i) override
Checks if the channel supports high rate offset changes, or if the GUI should rate-limit.
Definition ThunderScopeOscilloscope.cpp:299
FilterParameter m_diag_droppedWFMs
Number of waveforms dropped because some part of the pipeline couldn't keep up.
Definition ThunderScopeOscilloscope.h:143
virtual Oscilloscope::TriggerMode PollTrigger() override
Checks the curent trigger status.
Definition ThunderScopeOscilloscope.cpp:320
FilterParameter m_diag_totalWFMs
Number of waveforms acquired during this session.
Definition ThunderScopeOscilloscope.h:140
virtual bool CanEnableChannel(size_t i) override
Determines if a channel can be enabled.
Definition ThunderScopeOscilloscope.cpp:895
std::vector< unsigned int > m_bandwidthLimits
Bandwidth limiters.
Definition ThunderScopeOscilloscope.h:167
virtual unsigned int GetChannelBandwidthLimit(size_t i) override
Gets the bandwidth limit for an input channel.
Definition ThunderScopeOscilloscope.cpp:267
std::map< size_t, double > m_channelAttenuations
Map of channel numbers to attenuation levels.
Definition ThunderScopeOscilloscope.h:131
virtual void EnableChannel(size_t i) override
Turn a channel on, given the index.
Definition ThunderScopeOscilloscope.cpp:243
AcceleratorBuffer< uint32_t > m_clippingBuffer
Buffer for storing channel clip state.
Definition ThunderScopeOscilloscope.h:164
void FlushAllPendingWaveforms()
Ensure all pending waveforms have been processed.
Definition ThunderScopeOscilloscope.h:119
std::vector< std::unique_ptr< AcceleratorBuffer< int16_t > > > m_analogRawWaveformBuffers
Buffers for storing raw ADC samples before converting to fp32.
Definition ThunderScopeOscilloscope.h:152
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 ThunderScopeOscilloscope.cpp:858