ngscopeclient v0.1
Oscilloscope.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
36#ifndef Oscilloscope_h
37#define Oscilloscope_h
38
39class Instrument;
40
41#include "SCPITransport.h"
42#include "WaveformPool.h"
43
49class Oscilloscope : public virtual Instrument
50{
51public:
53 // Construction / destruction
54
56 virtual ~Oscilloscope();
57
64 virtual std::string IDPing() =0;
65
72 virtual bool IsOffline();
73
75 // Channel information
76
83 { return dynamic_cast<OscilloscopeChannel*>(GetChannel(i)); }
84
88 virtual bool IsChannelEnabled(size_t i) =0;
89
95 virtual void EnableChannel(size_t i) =0;
96
109 virtual bool CanEnableChannel(size_t i);
110
118 virtual void DisableChannel(size_t i) =0;
119
126
131 { return dynamic_cast<OscilloscopeChannel*>(GetChannelByHwName(name)); }
132
138 virtual OscilloscopeChannel::CouplingType GetChannelCoupling(size_t i) =0;
139
145 virtual void SetChannelCoupling(size_t i, OscilloscopeChannel::CouplingType type) =0;
146
152 virtual std::vector<OscilloscopeChannel::CouplingType> GetAvailableCouplings(size_t i) =0;
153
162 virtual double GetChannelAttenuation(size_t i) =0;
163
170 virtual void SetChannelAttenuation(size_t i, double atten) =0;
171
177 virtual std::vector<unsigned int> GetChannelBandwidthLimiters(size_t i);
178
186 virtual unsigned int GetChannelBandwidthLimit(size_t i) =0;
187
194 virtual void SetChannelBandwidthLimit(size_t i, unsigned int limit_mhz) =0;
195
203
216 virtual float GetChannelVoltageRange(size_t i, size_t stream) =0;
217
231 virtual void SetChannelVoltageRange(size_t i, size_t stream, float range) =0;
232
240 virtual bool CanAutoZero(size_t i);
241
247 virtual void AutoZero(size_t i);
248
256 virtual bool CanDegauss(size_t i);
257
263 virtual bool ShouldDegauss(size_t i);
264
270 virtual void Degauss(size_t i);
271
277 virtual bool CanAverage(size_t i);
278
284 virtual size_t GetNumAverages(size_t i);
285
292 virtual void SetNumAverages(size_t i, size_t navg);
293
302 virtual std::string GetProbeName(size_t i);
303
309 virtual bool HasInputMux(size_t i);
310
316 virtual size_t GetInputMuxSetting(size_t i);
317
323 virtual std::vector<std::string> GetInputMuxNames(size_t i);
324
331 virtual void SetInputMux(size_t i, size_t select);
332
339 virtual float GetChannelOffset(size_t i, size_t stream) =0;
340
348 virtual void SetChannelOffset(size_t i, size_t stream, float offset) =0;
349
355 virtual bool CanInvert(size_t i);
356
363 virtual void Invert(size_t i, bool invert);
364
370 virtual bool IsInverted(size_t i);
371
372protected:
373
376
388 void ChannelsDownloadStatusUpdate(size_t ch, InstrumentChannel::DownloadState state, float progress);
389
392
393public:
394 //Triggering
396 {
399
402
405
408
411
414 };
415
420
432 virtual bool PeekTriggerArmed();
433
444 bool WaitForTrigger(int timeout);
445
453 void SetTrigger(Trigger* trigger)
454 {
455 Trigger* old_trig = m_trigger;
456
457 //Set the new trigger and sync to hardware
458 m_trigger = trigger;
459 PushTrigger();
460
461 //Delete old trigger *after* pushing the new one.
462 //This prevents possible race conditions where we disable the current trigger channel before the new
463 //trigger is set.
464 if(old_trig != trigger)
465 delete old_trig;
466 }
467
471 virtual void PushTrigger() =0;
472
479 Trigger* GetTrigger(bool sync = false)
480 {
481 if(sync || (m_trigger == NULL) )
482 PullTrigger();
483 return m_trigger;
484 }
485
489 virtual std::vector<std::string> GetTriggerTypes();
490
494 virtual void PullTrigger() =0;
495
502 virtual void Start() =0;
503
507 virtual void StartSingleTrigger() =0;
508
512 virtual void Stop() =0;
513
519 virtual void ForceTrigger() =0;
520
524 virtual bool IsTriggerArmed() =0;
525
532 virtual void EnableTriggerOutput();
533
534public:
536 // Memory depth / sample rate control.
537
541 virtual std::vector<uint64_t> GetSampleRatesNonInterleaved() =0;
542
546 virtual std::vector<uint64_t> GetSampleRatesInterleaved() =0;
547
551 virtual uint64_t GetSampleRate() =0;
552
556 virtual bool IsInterleaving() =0;
557
565 virtual bool SetInterleaving(bool combine) =0;
566
570 virtual bool CanInterleave();
571
577 typedef std::pair<OscilloscopeChannel*, OscilloscopeChannel* > InterleaveConflict;
578 virtual std::set< InterleaveConflict > GetInterleaveConflicts() =0;
579
583 virtual std::vector<uint64_t> GetSampleDepthsNonInterleaved() =0;
584
588 virtual std::vector<uint64_t> GetSampleDepthsInterleaved() =0;
589
593 virtual uint64_t GetSampleDepth() =0;
594
598 virtual void SetSampleDepth(uint64_t depth) =0;
599
603 virtual void SetSampleRate(uint64_t rate) =0;
604
605 enum SamplingMode
606 {
607 REAL_TIME,
608 EQUIVALENT_TIME
609 };
610
616 virtual bool IsSamplingModeAvailable(SamplingMode mode);
617
623 virtual SamplingMode GetSamplingMode();
624
630 virtual void SetSamplingMode(SamplingMode mode);
631
641 virtual void SetUseExternalRefclk(bool external);
642
650 virtual void SetTriggerOffset(int64_t offset) =0;
651
655 virtual int64_t GetTriggerOffset() =0;
656
667 virtual void SetDeskewForChannel(size_t channel, int64_t skew);
668
674 virtual int64_t GetDeskewForChannel(size_t channel);
675
677 // Sequenced triggering
678
680 // ADC bit depth configuration
681
682 typedef std::vector<OscilloscopeChannel*> AnalogBank;
683
689 virtual std::vector<AnalogBank> GetAnalogBanks();
690
694 virtual AnalogBank GetAnalogBank(size_t channel);
695
699 virtual bool IsADCModeConfigurable();
700
709 virtual std::vector<std::string> GetADCModeNames(size_t channel);
710
714 virtual size_t GetADCMode(size_t channel);
715
719 virtual void SetADCMode(size_t channel, size_t mode);
720
722 // Logic analyzer configuration
723
724 typedef std::vector<OscilloscopeChannel*> DigitalBank;
725
731 virtual std::vector<DigitalBank> GetDigitalBanks();
732
736 virtual DigitalBank GetDigitalBank(size_t channel);
737
743 virtual bool IsDigitalHysteresisConfigurable();
744
750 virtual bool IsDigitalThresholdConfigurable();
751
755 virtual float GetDigitalHysteresis(size_t channel);
756
760 virtual float GetDigitalThreshold(size_t channel);
761
765 virtual void SetDigitalHysteresis(size_t channel, float level);
766
770 virtual void SetDigitalThreshold(size_t channel, float level);
771
773 // Frequency domain channel configuration
774
780 virtual void SetSpan(int64_t span);
781
785 virtual int64_t GetSpan();
786
793 virtual void SetCenterFrequency(size_t channel, int64_t freq);
794
800 virtual int64_t GetCenterFrequency(size_t channel);
801
805 virtual void SetResolutionBandwidth(int64_t rbw);
806
810 virtual int64_t GetResolutionBandwidth();
811
815 virtual bool HasFrequencyControls();
816
824 virtual bool HasResolutionBandwidth();
825
829 virtual bool HasTimebaseControls();
830
831 //TODO: window controls
832
834 // Configuration storage
835
836protected:
840 void DoSerializeConfiguration(YAML::Node& node, IDTable& table);
841
845 void DoLoadConfiguration(int version, const YAML::Node& node, IDTable& idmap);
846
850 void DoPreLoadConfiguration(int version, const YAML::Node& node, IDTable& idmap, ConfigWarningList& list);
851
853 // Sample format conversion
854public:
855 static void Convert8BitSamples(float* pout, const int8_t* pin, float gain, float offset, size_t count);
856 static void Convert8BitSamplesGeneric(float* pout, const int8_t* pin, float gain, float offset, size_t count);
857#ifdef __x86_64__
858 static void Convert8BitSamplesAVX2(float* pout, const int8_t* pin, float gain, float offset, size_t count);
859#endif
860
861 static void ConvertUnsigned8BitSamples(float* pout, const uint8_t* pin, float gain, float offset, size_t count);
862 static void ConvertUnsigned8BitSamplesGeneric(float* pout, const uint8_t* pin, float gain, float offset, size_t count);
863#ifdef __x86_64__
864 static void ConvertUnsigned8BitSamplesAVX2(float* pout, const uint8_t* pin, float gain, float offset, size_t count);
865#endif
866
867 static void Convert16BitSamples(float* pout, const int16_t* pin, float gain, float offset, size_t count);
868 static void Convert16BitSamplesGeneric(float* pout, const int16_t* pin, float gain, float offset, size_t count);
869#ifdef __x86_64__
870 static void Convert16BitSamplesAVX2(float* pout, const int16_t* pin, float gain, float offset, size_t count);
871 static void Convert16BitSamplesFMA(float* pout, const int16_t* pin, float gain, float offset, size_t count);
872 static void Convert16BitSamplesAVX512F(float* pout, const int16_t* pin, float gain, float offset, size_t count);
873#endif
874
875public:
877 // Waveform Access
878
879 bool HasPendingWaveforms();
881 size_t GetPendingWaveformCount();
882 virtual bool PopPendingWaveform();
883 virtual bool IsAppendingToWaveform();
884
885protected:
886 typedef std::map<StreamDescriptor, WaveformBase*> SequenceSet;
887 std::list<SequenceSet> m_pendingWaveforms;
888 std::mutex m_pendingWaveformsMutex;
889 std::recursive_mutex m_mutex;
890
892 // Diagnostics Access
893protected:
894 std::deque<std::string> m_diagnosticLogMessages;
895 std::map<std::string, FilterParameter*> m_diagnosticValues;
896 // Pointers are expected to be to members of this class; not dynamically allocated
897
898 void AddDiagnosticLog(std::string message)
899 {
900 m_diagnosticLogMessages.push_back(message);
901 }
902
903public:
904 bool HasPendingDiagnosticLogMessages()
905 {
906 return !m_diagnosticLogMessages.empty();
907 }
908
909 std::string PopPendingDiagnosticLogMessage()
910 {
911 std::string message = m_diagnosticLogMessages.front();
912 m_diagnosticLogMessages.pop_front();
913 return message;
914 }
915
916 std::map<std::string, FilterParameter*>& GetDiagnosticsValues()
917 {
918 // TODO: Should really be readonly, but need to mutate to add change listeners...
919 return m_diagnosticValues;
920 }
921
922protected:
923
924 //The trigger
925 Trigger* m_trigger;
926
927 //Pool for reusing memory allocations
928 WaveformPool m_analogWaveformPool;
929
930 WaveformPool m_digitalWaveformPool;
931
932 UniformAnalogWaveform* AllocateAnalogWaveform(const std::string& name)
933 {
934 auto p = m_analogWaveformPool.Get();
935 auto ret = dynamic_cast<UniformAnalogWaveform*>(p);
936 if(ret)
937 {
938 ret->Rename(name);
939 return ret;
940 }
941
942 //Delete garbage if somebody pushed the wrong type of waveform
943 if(p)
944 delete p;
945
946 //Pool was empty, allocate a new waveform
947 return new UniformAnalogWaveform(name);
948 }
949
950 SparseDigitalWaveform* AllocateDigitalWaveform(const std::string& name)
951 {
952 auto p = m_digitalWaveformPool.Get();
953 auto ret = dynamic_cast<SparseDigitalWaveform*>(p);
954 if(ret)
955 {
956 ret->Rename(name);
957 return ret;
958 }
959
960 //Delete garbage if somebody pushed the wrong type of waveform
961 if(p)
962 delete p;
963
964 //Pool was empty, allocate a new waveform
965 return new SparseDigitalWaveform(name);
966 }
967
968public:
969
976 { return m_analogWaveformPool.clear() || m_digitalWaveformPool.clear(); }
977
978 void AddWaveformToAnalogPool(WaveformBase* w)
979 { m_analogWaveformPool.Add(w); }
980
981 void AddWaveformToDigitalPool(WaveformBase* w)
982 { m_digitalWaveformPool.Add(w); }
983
984public:
985 typedef std::shared_ptr<Oscilloscope> (*CreateProcType)(SCPITransport*);
986 static void DoAddDriverClass(std::string name, CreateProcType proc);
987
988 static void EnumDrivers(std::vector<std::string>& names);
989 static std::shared_ptr<Oscilloscope> CreateOscilloscope(std::string driver, SCPITransport* transport);
990
991protected:
992 //Class enumeration
993 typedef std::map< std::string, CreateProcType > CreateMapType;
994 static CreateMapType m_createprocs;
995};
996
997//must be declared here after Oscilloscope is defined
998inline Oscilloscope* OscilloscopeChannel::GetScope()
999{ return dynamic_cast<Oscilloscope*>(m_instrument); }
1000
1001#ifndef STRINGIFY
1002#define STRINGIFY(T) #T
1003#endif
1004
1005#define OSCILLOSCOPE_INITPROC(T) \
1006 static std::shared_ptr<Oscilloscope> CreateInstance(SCPITransport* transport) \
1007 { return std::make_shared<T>(transport); } \
1008 virtual std::string GetDriverName() const override \
1009 { return GetDriverNameInternal(); }
1010
1011#define AddDriverClass(T) Oscilloscope::DoAddDriverClass(T::GetDriverNameInternal(), T::CreateInstance)
1012
1013#endif
Declaration of SCPITransport.
Declaration of WaveformPool.
All warnings generated by a configuration we're in the process of loading.
Definition: ConfigWarningList.h:90
Bidirectional table mapping integer IDs in scopesession files to object pointers.
Definition: IDTable.h:51
DownloadState
Enum values to be mapped to GetDownloadState() int result value for specific channel download states.
Definition: InstrumentChannel.h:246
Instrument * m_instrument
The instrument we're part of (may be null in the case of filters etc)
Definition: InstrumentChannel.h:274
An arbitrary lab instrument. Oscilloscope, LA, PSU, DMM, etc.
Definition: Instrument.h:62
InstrumentChannel * GetChannelByHwName(const std::string &name)
Gets a channel given the hardware name.
Definition: Instrument.cpp:79
InstrumentChannel * GetChannel(size_t i) const
Gets a given channel on the instrument.
Definition: Instrument.h:162
A single channel on an oscilloscope.
Definition: OscilloscopeChannel.h:49
Generic representation of an oscilloscope, logic analyzer, or spectrum analyzer.
Definition: Oscilloscope.h:50
virtual int64_t GetCenterFrequency(size_t channel)
Gets the center frequency for a frequency-domain channel.
Definition: Oscilloscope.cpp:921
virtual bool IsChannelEnabled(size_t i)=0
Checks if a channel is enabled in hardware.
virtual std::vector< uint64_t > GetSampleRatesInterleaved()=0
Get the legal sampling rates (in Hz) for this scope in combined-channels mode.
virtual bool IsInverted(size_t i)
Checks if hardware polarity inversion is enabled for a channel.
Definition: Oscilloscope.cpp:849
virtual bool HasInputMux(size_t i)
Checks if a channel has an input multiplexer.
Definition: Oscilloscope.cpp:774
void DoLoadConfiguration(int version, const YAML::Node &node, IDTable &idmap)
Load instrument and channel configuration from a save file.
Definition: Oscilloscope.cpp:381
virtual float GetChannelOffset(size_t i, size_t stream)=0
Gets the offset, in volts, for a given channel.
virtual bool HasFrequencyControls()
Returns true if the instrument has at least one frequency-domain channel.
Definition: Oscilloscope.cpp:935
virtual void SetChannelAttenuation(size_t i, double atten)=0
Sets the probe attenuation used for an input channel.
virtual int64_t GetResolutionBandwidth()
Gets the resolution bandwidth for frequency-domain channels.
Definition: Oscilloscope.cpp:930
std::pair< OscilloscopeChannel *, OscilloscopeChannel * > InterleaveConflict
Get the set of conflicting channels.
Definition: Oscilloscope.h:577
virtual void SetDigitalThreshold(size_t channel, float level)
Gets the threshold for a digital input.
Definition: Oscilloscope.cpp:742
virtual unsigned int GetChannelBandwidthLimit(size_t i)=0
Gets the bandwidth limit for an input channel.
virtual bool IsSamplingModeAvailable(SamplingMode mode)
Returns true if the requested sampling mode is available with the current instrument configuration.
Definition: Oscilloscope.cpp:651
virtual void SetDigitalHysteresis(size_t channel, float level)
Sets the hysteresis for a digital input.
Definition: Oscilloscope.cpp:738
virtual bool IsADCModeConfigurable()
Returns true if the ADC is configurable, false if it can only run in one mode.
Definition: Oscilloscope.cpp:818
bool FreeWaveformPools()
Free all waveforms in our pool to reclaim memory.
Definition: Oscilloscope.h:975
virtual int64_t GetDeskewForChannel(size_t channel)
Gets the deskew setting for a channel.
Definition: Oscilloscope.cpp:678
virtual bool PopPendingWaveform()
Pops the queue of pending waveforms and updates each channel with a new waveform.
Definition: Oscilloscope.cpp:177
virtual std::vector< uint64_t > GetSampleDepthsNonInterleaved()=0
Get the legal memory depths for this scope in all-channels mode.
static void ConvertUnsigned8BitSamplesGeneric(float *pout, const uint8_t *pin, float gain, float offset, size_t count)
Generic backend for ConvertUnsigned8BitSamples()
Definition: Oscilloscope.cpp:1148
virtual bool ShouldDegauss(size_t i)
Determines if a channel requires a degauss cycle (if supported)
Definition: Oscilloscope.cpp:760
virtual uint64_t GetSampleDepth()=0
Gets the current sample depth of this scope.
virtual void SetADCMode(size_t channel, size_t mode)
Sets the ADC mode for a channel.
Definition: Oscilloscope.cpp:835
virtual bool HasResolutionBandwidth()
Returns true if the instrument has a resolution bandwidth setting.
Definition: Oscilloscope.cpp:940
static void Convert8BitSamples(float *pout, const int8_t *pin, float gain, float offset, size_t count)
Converts 8-bit ADC samples to floating point.
Definition: Oscilloscope.cpp:957
virtual void SetDeskewForChannel(size_t channel, int64_t skew)
Sets the deskew setting for a channel.
Definition: Oscilloscope.cpp:673
virtual bool IsDigitalThresholdConfigurable()
Checks if digital input threshold is configurable or fixed.
Definition: Oscilloscope.cpp:723
virtual std::vector< uint64_t > GetSampleRatesNonInterleaved()=0
Get the legal sampling rates (in Hz) for this scope in all-channels mode.
virtual double GetChannelAttenuation(size_t i)=0
Gets the probe attenuation for an input channel.
virtual float GetChannelVoltageRange(size_t i, size_t stream)=0
Gets the range of the current channel configuration.
virtual size_t GetNumAverages(size_t i)
Returns the number of averages the channel is configured for.
Definition: Oscilloscope.cpp:207
virtual bool CanEnableChannel(size_t i)
Determines if a channel can be enabled.
Definition: Oscilloscope.cpp:112
int GetEnabledChannelCount()
Returns the number of enabled channels for this oscilloscope.
Definition: Oscilloscope.cpp:117
virtual void SetChannelBandwidthLimit(size_t i, unsigned int limit_mhz)=0
Sets the bandwidth limit for an input channel.
virtual std::string IDPing()=0
Returns the instrument's identification string.
void ChannelsDownloadStatusUpdate(size_t ch, InstrumentChannel::DownloadState state, float progress)
Helper method called by drivers to set one channel's download status and update its download progress...
Definition: Oscilloscope.cpp:868
virtual void StartSingleTrigger()=0
Arms the trigger for a single acquistion.
virtual void DisableChannel(size_t i)=0
Turn a channel off, given the index.
void DoPreLoadConfiguration(int version, const YAML::Node &node, IDTable &idmap, ConfigWarningList &list)
Validate instrument and channel configuration from a save file.
Definition: Oscilloscope.cpp:586
virtual void Start()=0
Starts the instrument in continuous trigger mode.
virtual void SetSampleDepth(uint64_t depth)=0
Sets the sample depth of the scope.
virtual void SetSampleRate(uint64_t rate)=0
Sets the sample rate of the scope, in Hz.
void ChannelsDownloadFinished()
Helper method called by drivers when waveform download is finished to reset all channels to "no downl...
Definition: Oscilloscope.cpp:878
virtual bool PeekTriggerArmed()
Checks if the trigger is armed directly on the instrument, without altering internal state or touchin...
Definition: Oscilloscope.cpp:900
virtual std::vector< AnalogBank > GetAnalogBanks()
Gets the analog banks for this instrument.
Definition: Oscilloscope.cpp:797
virtual bool CanDegauss(size_t i)
Determines if a channel has a probe connected which supports the "degauss" feature.
Definition: Oscilloscope.cpp:755
virtual void SetChannelOffset(size_t i, size_t stream, float offset)=0
Sets the offset for a given channel.
static void Convert8BitSamplesGeneric(float *pout, const int8_t *pin, float gain, float offset, size_t count)
Generic backend for Convert8BitSamples()
Definition: Oscilloscope.cpp:1016
virtual void SetChannelVoltageRange(size_t i, size_t stream, float range)=0
Sets the range of the current channel configuration.
virtual void SetSpan(int64_t span)
Sets the span for frequency-domain channels.
Definition: Oscilloscope.cpp:908
virtual void SetInputMux(size_t i, size_t select)
Sets the input mux for a channel.
Definition: Oscilloscope.cpp:790
virtual bool IsInterleaving()=0
Checks if the scope is currently combining channels.
virtual bool IsTriggerArmed()=0
Checks if the trigger is currently armed.
virtual bool CanAutoZero(size_t i)
Determines if a channel has a probe connected which supports the "auto zero" feature.
Definition: Oscilloscope.cpp:746
virtual std::vector< std::string > GetInputMuxNames(size_t i)
Gets names for the input mux ports of a channel.
Definition: Oscilloscope.cpp:784
void ClearPendingWaveforms()
Discard any pending waveforms that haven't yet been processed.
Definition: Oscilloscope.cpp:162
virtual size_t GetInputMuxSetting(size_t i)
Gets the setting for a channel's input mux (if it has one)
Definition: Oscilloscope.cpp:779
OscilloscopeChannel * GetOscilloscopeChannelByHwName(const std::string &name)
Gets a channel given the hardware name.
Definition: Oscilloscope.h:130
virtual size_t GetADCMode(size_t channel)
Gets the ADC mode for a channel.
Definition: Oscilloscope.cpp:830
virtual std::vector< std::string > GetADCModeNames(size_t channel)
Gets the names of the ADC modes for the bank a given channel is located in.
Definition: Oscilloscope.cpp:823
OscilloscopeChannel * GetOscilloscopeChannel(size_t i)
Gets a channel by index.
Definition: Oscilloscope.h:82
void SetTrigger(Trigger *trigger)
Sets a new trigger on the instrument and pushes changes.
Definition: Oscilloscope.h:453
virtual std::string GetProbeName(size_t i)
Returns the name of the probe connected to the scope, if possible.
Definition: Oscilloscope.cpp:769
virtual void Invert(size_t i, bool invert)
Enables hardware polarity inversion for a channel, if supported.
Definition: Oscilloscope.cpp:845
virtual std::vector< unsigned int > GetChannelBandwidthLimiters(size_t i)
Gets the set of available bandwidth limiters for an input channel.
Definition: Oscilloscope.cpp:697
virtual bool CanInvert(size_t i)
Checks if a channel is capable of hardware polarity inversion.
Definition: Oscilloscope.cpp:840
virtual void SetChannelCoupling(size_t i, OscilloscopeChannel::CouplingType type)=0
Sets the coupling used for an input channel.
virtual bool IsAppendingToWaveform()
Checks if we are appending to the existing waveform or creating a new one.
Definition: Oscilloscope.cpp:194
bool WaitForTrigger(int timeout)
Block until a trigger happens or a timeout elapses.
Definition: Oscilloscope.cpp:132
virtual void Stop()=0
Stops triggering.
virtual OscilloscopeChannel::CouplingType GetChannelCoupling(size_t i)=0
Gets the coupling used for an input channel.
virtual float GetDigitalHysteresis(size_t channel)
Gets the hysteresis for a digital input.
Definition: Oscilloscope.cpp:728
virtual std::vector< uint64_t > GetSampleDepthsInterleaved()=0
Get the legal memory depths for this scope in combined-channels mode.
virtual bool CanInterleave()
Returns true if we have no interleave conflicts, false if we have conflicts.
Definition: Oscilloscope.cpp:684
virtual void SetResolutionBandwidth(int64_t rbw)
Gets the resolution bandwidth for frequency-domain channels.
Definition: Oscilloscope.cpp:926
virtual void SetSamplingMode(SamplingMode mode)
Sets the current sampling mode of the instrument.
Definition: Oscilloscope.cpp:661
virtual DigitalBank GetDigitalBank(size_t channel)
Gets the bank containing a given channel.
Definition: Oscilloscope.cpp:713
static void Convert16BitSamples(float *pout, const int16_t *pin, float gain, float offset, size_t count)
Converts 16-bit ADC samples to floating point.
Definition: Oscilloscope.cpp:1224
Trigger * GetTrigger(bool sync=false)
Gets the current trigger.
Definition: Oscilloscope.h:479
virtual bool SetInterleaving(bool combine)=0
Configures the scope to combine channels.
virtual void ForceTrigger()=0
Forces a single acquisition as soon as possible.
virtual SamplingMode GetSamplingMode()
Gets the current sampling mode of the instrument.
Definition: Oscilloscope.cpp:656
virtual void PushTrigger()=0
Pushes changes made to m_trigger to the instrument.
virtual int64_t GetTriggerOffset()=0
Gets the trigger offset.
virtual void PullTrigger()=0
Updates m_trigger with any changes made from the instrument side.
void ChannelsDownloadStarted()
Helper method called by drivers to reset all channels to "waiting to download" state.
Definition: Oscilloscope.cpp:854
virtual bool IsDigitalHysteresisConfigurable()
Checks if digital input hysteresis is configurable or fixed.
Definition: Oscilloscope.cpp:718
virtual float GetDigitalThreshold(size_t channel)
Gets the threshold for a digital input.
Definition: Oscilloscope.cpp:733
virtual int64_t GetSpan()
Gets the span for frequency-domain channels.
Definition: Oscilloscope.cpp:912
virtual void AutoZero(size_t i)
Performs an "auto zero" cycle on the attached active probe, if supported by the hardware.
Definition: Oscilloscope.cpp:751
virtual void EnableChannel(size_t i)=0
Turn a channel on, given the index.
virtual void SetUseExternalRefclk(bool external)
Configures the instrument's clock source.
Definition: Oscilloscope.cpp:666
virtual void EnableTriggerOutput()
Enables the trigger output, configuring a shared auxiliary port for this purpose if needed.
Definition: Oscilloscope.cpp:646
static void ConvertUnsigned8BitSamples(float *pout, const uint8_t *pin, float gain, float offset, size_t count)
Converts Unsigned 8-bit ADC samples to floating point.
Definition: Oscilloscope.cpp:1089
TriggerMode
Definition: Oscilloscope.h:396
@ TRIGGER_MODE_AUTO
Auto trigger - waiting for auto-trigger.
Definition: Oscilloscope.h:410
@ TRIGGER_MODE_COUNT
Placeholder.
Definition: Oscilloscope.h:413
@ TRIGGER_MODE_WAIT
WAIT - not yet fully armed.
Definition: Oscilloscope.h:407
@ TRIGGER_MODE_TRIGGERED
Just got triggered, data is ready to read.
Definition: Oscilloscope.h:404
@ TRIGGER_MODE_RUN
Active, waiting for a trigger event.
Definition: Oscilloscope.h:398
@ TRIGGER_MODE_STOP
Triggered once, but not recently.
Definition: Oscilloscope.h:401
virtual std::vector< DigitalBank > GetDigitalBanks()
Gets the digital channel banks for this instrument.
Definition: Oscilloscope.cpp:707
virtual void SetCenterFrequency(size_t channel, int64_t freq)
Sets the center frequency for frequency-domain channels.
Definition: Oscilloscope.cpp:917
virtual void SetNumAverages(size_t i, size_t navg)
Sets the number of hardware averages to use.
Definition: Oscilloscope.cpp:212
virtual bool IsOffline()
Checks if the instrument is currently online.
Definition: Oscilloscope.cpp:107
virtual OscilloscopeChannel * GetExternalTrigger()=0
Returns the external trigger input channel, if we have one.
virtual bool HasTimebaseControls()
Returns true if the instrument has at least one time-domain channel.
Definition: Oscilloscope.cpp:946
virtual Oscilloscope::TriggerMode PollTrigger()=0
Checks the curent trigger status.
virtual std::vector< OscilloscopeChannel::CouplingType > GetAvailableCouplings(size_t i)=0
Gets the set of legal coupling values for an input channel.
virtual void Degauss(size_t i)
Performs an "degauss" cycle on the attached active probe, if supported by the hardware.
Definition: Oscilloscope.cpp:765
virtual std::vector< std::string > GetTriggerTypes()
Gets a list of triggers this instrument supports.
Definition: Oscilloscope.cpp:893
virtual AnalogBank GetAnalogBank(size_t channel)
Gets the bank containing a given channel.
Definition: Oscilloscope.cpp:804
static void Convert16BitSamplesGeneric(float *pout, const int16_t *pin, float gain, float offset, size_t count)
Converts raw ADC samples to floating point.
Definition: Oscilloscope.cpp:1309
virtual void SetTriggerOffset(int64_t offset)=0
Sets the trigger offset.
void DoSerializeConfiguration(YAML::Node &node, IDTable &table)
Serializes this oscilloscope's configuration to a YAML node.
Definition: Oscilloscope.cpp:221
virtual bool CanAverage(size_t i)
Determines if the channel supports hardware averaging.
Definition: Oscilloscope.cpp:202
virtual uint64_t GetSampleRate()=0
Gets the current sampling rate (in Hz) of this scope.
Abstraction of a transport layer for moving SCPI data between endpoints.
Definition: SCPITransport.h:47
A waveform sampled at irregular intervals.
Definition: Waveform.h:481
virtual void Rename(const std::string &name="") override
Assings a human readable name to the waveform for debug purposes.
Definition: Waveform.h:499
Abstract base class for oscilloscope / logic analyzer trigger inputs.
Definition: Trigger.h:46
A waveform sampled at uniform intervals.
Definition: Waveform.h:383
virtual void Rename(const std::string &name="") override
Assings a human readable name to the waveform for debug purposes.
Definition: Waveform.h:401
Base class for all Waveform specializations.
Definition: Waveform.h:59
Thread safe memory pool for reusing Waveform objects.
Definition: WaveformPool.h:47
bool clear()
Free all waveforms in the pool to reclaim memory.
Definition: WaveformPool.h:109
WaveformBase * Get()
Attempts to get a waveform from the pool.
Definition: WaveformPool.h:89
void Add(WaveformBase *w)
Adds a new waveform to the pool if there's sufficient free slots in the pool.
Definition: WaveformPool.h:73