ngscopeclient 0.1-dev+51fbda87c
SCPISA.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 SCPISA_h
37#define SCPISA_h
38
42class SCPISA : public virtual SCPIOscilloscope
43{
44public:
45 SCPISA();
46 virtual ~SCPISA();
47
48 virtual unsigned int GetInstrumentTypes() const override;
49 virtual uint32_t GetInstrumentTypesForChannel(size_t i) const override;
50
51 //Channel configuration
52 virtual bool IsChannelEnabled(size_t i) override;
53 virtual void EnableChannel(size_t i) override;
54 virtual void DisableChannel(size_t i) override;
55 virtual OscilloscopeChannel::CouplingType GetChannelCoupling(size_t i) override;
56 virtual void SetChannelCoupling(size_t i, OscilloscopeChannel::CouplingType type) override;
57 virtual std::vector<OscilloscopeChannel::CouplingType> GetAvailableCouplings(size_t i) override;
58 virtual double GetChannelAttenuation(size_t i) override;
59 virtual void SetChannelAttenuation(size_t i, double atten) override;
60 virtual unsigned int GetChannelBandwidthLimit(size_t i) override;
61 virtual void SetChannelBandwidthLimit(size_t i, unsigned int limit_mhz) override;
62 virtual float GetChannelVoltageRange(size_t i, size_t stream) override;
63 virtual void SetChannelVoltageRange(size_t i, size_t stream, float range) override;
64 virtual float GetChannelOffset(size_t i, size_t stream) override;
65 virtual void SetChannelOffset(size_t i, size_t stream, float offset) override;
66
67 //Triggering
68 virtual OscilloscopeChannel* GetExternalTrigger() override;
69 virtual Oscilloscope::TriggerMode PollTrigger() override;
70 virtual void Start() override;
71 virtual void StartSingleTrigger() override;
72 virtual void Stop() override;
73 virtual void ForceTrigger() override;
74 virtual bool IsTriggerArmed() override;
75 virtual void PushTrigger() override;
76 virtual void PullTrigger() override;
77
78 //Timebase
79 virtual std::set<InterleaveConflict> GetInterleaveConflicts() override;
80 virtual std::vector<uint64_t> GetSampleDepthsInterleaved() override;
81 virtual std::vector<uint64_t> GetSampleDepthsNonInterleaved() override;
82 virtual uint64_t GetSampleDepth() override;
83 virtual void SetSampleDepth(uint64_t depth) override;
84 virtual std::vector<uint64_t> GetSampleRatesInterleaved() override;
85 virtual std::vector<uint64_t> GetSampleRatesNonInterleaved() override;
86 virtual uint64_t GetSampleRate() override;
87 virtual void SetSampleRate(uint64_t rate) override;
88 virtual void SetTriggerOffset(int64_t offset) override;
89 virtual int64_t GetTriggerOffset() override;
90 virtual bool IsInterleaving() override;
91 virtual bool SetInterleaving(bool combine) override;
92
93 virtual bool HasFrequencyControls() override;
94 virtual bool HasTimebaseControls() override;
95
96 virtual void SetResolutionBandwidth(int64_t rbw) override;
97 virtual int64_t GetResolutionBandwidth() override;
98
99protected:
100 std::map<std::pair<size_t, size_t>, float> m_channelVoltageRange;
101 std::map<std::pair<size_t, size_t>, float> m_channelOffset;
102
103 bool m_triggerArmed = false;
104 bool m_triggerOneShot = false;
105
106 int64_t m_sampleDepth = 0;
107 int64_t m_rbw = 0;
108
109
111 // Dynamic creation
112public:
113 //typedef std::shared_ptr<SCPISA> (*SACreateProcType)(SCPITransport*);
114 //static void DoAddDriverClass(std::string name, SACreateProcType proc);
115
116 //static void EnumDrivers(std::vector<std::string>& names);
117 //static std::shared_ptr<SCPISA> CreateSA(std::string driver, SCPITransport* transport);
118
119 //Class enumeration
120 //typedef std::map< std::string, SACreateProcType > SACreateMapType;
121 //static SACreateMapType m_vnacreateprocs;
122};
123
124/*
125#define SA_INITPROC(T) \
126 static std::shared_ptr<SCPISA> CreateInstance(SCPITransport* transport) \
127 { return std::make_shared<T>(transport); } \
128 virtual std::string GetDriverName() const override \
129 { return GetDriverNameInternal(); }
130
131#define AddSADriverClass(T) SCPISA::DoAddDriverClass(T::GetDriverNameInternal(), T::CreateInstance)
132*/
133#endif
A single channel on an oscilloscope.
Definition: OscilloscopeChannel.h:49
TriggerMode
Definition: Oscilloscope.h:411
An SCPI-based oscilloscope.
Definition: SCPIOscilloscope.h:38
Generic representation of a Spectrum Analyzer.
Definition: SCPISA.h:43
virtual void SetTriggerOffset(int64_t offset) override
Sets the trigger offset.
Definition: SCPISA.cpp:149
virtual void SetChannelCoupling(size_t i, OscilloscopeChannel::CouplingType type) override
Sets the coupling used for an input channel.
Definition: SCPISA.cpp:96
virtual void PullTrigger() override
Updates m_trigger with any changes made from the instrument side.
Definition: SCPISA.cpp:273
virtual float GetChannelVoltageRange(size_t i, size_t stream) override
Gets the range of the current channel configuration.
Definition: SCPISA.cpp:205
virtual std::vector< OscilloscopeChannel::CouplingType > GetAvailableCouplings(size_t i) override
Gets the set of legal coupling values for an input channel.
Definition: SCPISA.cpp:101
virtual double GetChannelAttenuation(size_t i) override
Gets the probe attenuation for an input channel.
Definition: SCPISA.cpp:108
virtual void SetChannelAttenuation(size_t i, double atten) override
Sets the probe attenuation used for an input channel.
Definition: SCPISA.cpp:113
virtual void EnableChannel(size_t i) override
Turn a channel on, given the index.
Definition: SCPISA.cpp:80
virtual void DisableChannel(size_t i) override
Turn a channel off, given the index.
Definition: SCPISA.cpp:85
virtual int64_t GetResolutionBandwidth() override
Gets the resolution bandwidth for frequency-domain channels.
Definition: SCPISA.cpp:302
virtual void SetChannelOffset(size_t i, size_t stream, float offset) override
Sets the offset for a given channel.
Definition: SCPISA.cpp:226
virtual uint64_t GetSampleDepth() override
Gets the current sample depth of this scope.
Definition: SCPISA.cpp:291
virtual void ForceTrigger() override
Forces a single acquisition as soon as possible.
Definition: SCPISA.cpp:262
virtual void SetSampleRate(uint64_t rate) override
Sets the sample rate of the scope, in Hz.
Definition: SCPISA.cpp:186
virtual void Start() override
Starts the instrument in continuous trigger mode.
Definition: SCPISA.cpp:244
virtual bool SetInterleaving(bool combine) override
Configures the scope to combine channels.
Definition: SCPISA.cpp:133
virtual std::vector< uint64_t > GetSampleDepthsInterleaved() override
Get the legal memory depths for this scope in combined-channels mode.
Definition: SCPISA.cpp:158
virtual void PushTrigger() override
Pushes changes made to m_trigger to the instrument.
Definition: SCPISA.cpp:278
virtual void SetResolutionBandwidth(int64_t rbw) override
Gets the resolution bandwidth for frequency-domain channels.
Definition: SCPISA.cpp:307
virtual void Stop() override
Stops triggering.
Definition: SCPISA.cpp:256
virtual bool IsInterleaving() override
Checks if the scope is currently combining channels.
Definition: SCPISA.cpp:128
virtual bool IsTriggerArmed() override
Checks if the trigger is currently armed.
Definition: SCPISA.cpp:268
virtual unsigned int GetChannelBandwidthLimit(size_t i) override
Gets the bandwidth limit for an input channel.
Definition: SCPISA.cpp:118
virtual OscilloscopeChannel::CouplingType GetChannelCoupling(size_t i) override
Gets the coupling used for an input channel.
Definition: SCPISA.cpp:90
virtual std::vector< uint64_t > GetSampleDepthsNonInterleaved() override
Get the legal memory depths for this scope in all-channels mode.
Definition: SCPISA.cpp:285
virtual unsigned int GetInstrumentTypes() const override
Returns a bitfield describing the set of instrument types that this instrument supports.
Definition: SCPISA.cpp:195
virtual uint64_t GetSampleRate() override
Gets the current sampling rate (in Hz) of this scope.
Definition: SCPISA.cpp:190
virtual uint32_t GetInstrumentTypesForChannel(size_t i) const override
Returns a bitfield describing the set of instrument types that a given channel supports.
Definition: SCPISA.cpp:200
virtual bool HasTimebaseControls() override
Returns true if the instrument has at least one time-domain channel.
Definition: SCPISA.cpp:144
virtual Oscilloscope::TriggerMode PollTrigger() override
Checks the curent trigger status.
Definition: SCPISA.cpp:240
virtual bool HasFrequencyControls() override
Returns true if the instrument has at least one frequency-domain channel.
Definition: SCPISA.cpp:139
virtual std::vector< uint64_t > GetSampleRatesNonInterleaved() override
Get the legal sampling rates (in Hz) for this scope in all-channels mode.
Definition: SCPISA.cpp:179
virtual void SetChannelBandwidthLimit(size_t i, unsigned int limit_mhz) override
Sets the bandwidth limit for an input channel.
Definition: SCPISA.cpp:123
virtual void SetSampleDepth(uint64_t depth) override
Sets the sample depth of the scope.
Definition: SCPISA.cpp:296
virtual int64_t GetTriggerOffset() override
Gets the trigger offset.
Definition: SCPISA.cpp:153
virtual OscilloscopeChannel * GetExternalTrigger() override
Returns the external trigger input channel, if we have one.
Definition: SCPISA.cpp:235
virtual bool IsChannelEnabled(size_t i) override
Checks if a channel is enabled in hardware.
Definition: SCPISA.cpp:75
virtual void StartSingleTrigger() override
Arms the trigger for a single acquistion.
Definition: SCPISA.cpp:250
virtual std::vector< uint64_t > GetSampleRatesInterleaved() override
Get the legal sampling rates (in Hz) for this scope in combined-channels mode.
Definition: SCPISA.cpp:165
virtual float GetChannelOffset(size_t i, size_t stream) override
Gets the offset, in volts, for a given channel.
Definition: SCPISA.cpp:219
virtual void SetChannelVoltageRange(size_t i, size_t stream, float range) override
Sets the range of the current channel configuration.
Definition: SCPISA.cpp:212