ngscopeclient v0.2.1
Loading...
Searching...
No Matches
SCPISpectrometer.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
36#ifndef SCPISpectrometer_h
37#define SCPISpectrometer_h
38
42class SCPISpectrometer : public virtual SCPIOscilloscope
43{
44public:
46 virtual ~SCPISpectrometer();
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 //Timebase
68 virtual std::set<InterleaveConflict> GetInterleaveConflicts() override;
69 virtual std::vector<uint64_t> GetSampleRatesInterleaved() override;
70 virtual std::vector<uint64_t> GetSampleDepthsInterleaved() override;
71 virtual void SetTriggerOffset(int64_t offset) override;
72 virtual int64_t GetTriggerOffset() override;
73 virtual bool IsInterleaving() override;
74 virtual bool SetInterleaving(bool combine) override;
75 virtual std::vector<uint64_t> GetSampleRatesNonInterleaved() override;
76 virtual uint64_t GetSampleRate() override;
77 virtual void SetSampleRate(uint64_t rate) override;
78
79 virtual bool HasFrequencyControls() override;
80 virtual bool HasTimebaseControls() override;
81
82 //Detector controls
83 virtual int64_t GetIntegrationTime() =0;
84 virtual void SetIntegrationTime(int64_t t) =0;
85
86
88 // Configuration storage
89
90protected:
94 //This is called by Instrument::m_serializers and is not virtual
95 //cppcheck-suppress duplInheritedMember
96 void DoSerializeConfiguration(YAML::Node& node, IDTable& table);
97
101 //This is called by Instrument::m_loaders and is not virtual
102 //cppcheck-suppress duplInheritedMember
103 void DoLoadConfiguration(int version, const YAML::Node& node, IDTable& idmap);
104
108 //This is called by Instrument::m_preloaders and is not virtual
109 //cppcheck-suppress duplInheritedMember
110 void DoPreLoadConfiguration(int version, const YAML::Node& node, IDTable& idmap, ConfigWarningList& list);
111
112protected:
113 std::map<std::pair<size_t, size_t>, float> m_channelVoltageRange;
114 std::map<std::pair<size_t, size_t>, float> m_channelOffset;
115
117 // Dynamic creation
118public:
119 typedef std::shared_ptr<SCPISpectrometer> (*SpectrometerCreateProcType)(SCPITransport*);
120 static void DoAddDriverClass(const std::string& name, SpectrometerCreateProcType proc);
121
122 //This is intentionally not virtual since it's a static method used by enumeration
123 //cppcheck-suppress duplInheritedMember
124 static void EnumDrivers(std::vector<std::string>& names);
125 static std::shared_ptr<SCPISpectrometer> CreateSpectrometer(const std::string& driver, SCPITransport* transport);
126
127 //Class enumeration
128 typedef std::map< std::string, SpectrometerCreateProcType > SpectrometerCreateMapType;
129 static SpectrometerCreateMapType m_spectrometercreateprocs;
130};
131
132#define SPECTROMETER_INITPROC(T) \
133 static std::shared_ptr<SCPISpectrometer> CreateInstance(SCPITransport* transport) \
134 { return std::make_shared<T>(transport); } \
135 virtual std::string GetDriverName() const override \
136 { return GetDriverNameInternal(); }
137
138#define AddSpectrometerDriverClass(T) SCPISpectrometer::DoAddDriverClass(T::GetDriverNameInternal(), T::CreateInstance); SCPIInstrument::DoAddDriverClass(T::GetDriverNameInternal(), T::GetDriverSupportedModels)
139
140#endif
Definition AcceleratorBuffer.h:204
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:49
An SCPI-based oscilloscope.
Definition SCPIOscilloscope.h:38
Generic representation of an optical (UV-VIS-IR) spectrometer.
Definition SCPISpectrometer.h:43
virtual bool HasFrequencyControls() override
Returns true if the instrument has at least one frequency-domain channel.
Definition SCPISpectrometer.cpp:144
virtual uint64_t GetSampleRate() override
Gets the current sampling rate (in Hz) of this scope.
Definition SCPISpectrometer.cpp:195
virtual double GetChannelAttenuation(size_t i) override
Gets the probe attenuation for an input channel.
Definition SCPISpectrometer.cpp:113
virtual void SetChannelVoltageRange(size_t i, size_t stream, float range) override
Sets the range of the current channel configuration.
Definition SCPISpectrometer.cpp:217
virtual std::vector< uint64_t > GetSampleRatesNonInterleaved() override
Get the legal sampling rates (in Hz) for this scope in all-channels mode.
Definition SCPISpectrometer.cpp:184
void DoSerializeConfiguration(YAML::Node &node, IDTable &table)
Serializes this spectrometer's configuration to a YAML node.
Definition SCPISpectrometer.cpp:243
virtual float GetChannelVoltageRange(size_t i, size_t stream) override
Gets the range of the current channel configuration.
Definition SCPISpectrometer.cpp:210
virtual bool IsInterleaving() override
Checks if the scope is currently combining channels.
Definition SCPISpectrometer.cpp:133
virtual std::vector< uint64_t > GetSampleRatesInterleaved() override
Get the legal sampling rates (in Hz) for this scope in combined-channels mode.
Definition SCPISpectrometer.cpp:170
virtual void DisableChannel(size_t i) override
Turn a channel off, given the index.
Definition SCPISpectrometer.cpp:90
virtual void SetSampleRate(uint64_t rate) override
Sets the sample rate of the scope, in Hz.
Definition SCPISpectrometer.cpp:191
virtual void EnableChannel(size_t i) override
Turn a channel on, given the index.
Definition SCPISpectrometer.cpp:85
virtual void SetChannelCoupling(size_t i, OscilloscopeChannel::CouplingType type) override
Sets the coupling used for an input channel.
Definition SCPISpectrometer.cpp:101
virtual bool HasTimebaseControls() override
Returns true if the instrument has at least one time-domain channel.
Definition SCPISpectrometer.cpp:149
virtual void SetTriggerOffset(int64_t offset) override
Sets the trigger offset.
Definition SCPISpectrometer.cpp:154
virtual void SetChannelAttenuation(size_t i, double atten) override
Sets the probe attenuation used for an input channel.
Definition SCPISpectrometer.cpp:118
virtual uint32_t GetInstrumentTypesForChannel(size_t i) const override
Returns a bitfield describing the set of instrument types that a given channel supports.
Definition SCPISpectrometer.cpp:205
virtual float GetChannelOffset(size_t i, size_t stream) override
Gets the offset, in volts, for a given channel.
Definition SCPISpectrometer.cpp:224
void DoPreLoadConfiguration(int version, const YAML::Node &node, IDTable &idmap, ConfigWarningList &list)
Validate instrument and channel configuration from a save file.
Definition SCPISpectrometer.cpp:258
virtual void SetChannelOffset(size_t i, size_t stream, float offset) override
Sets the offset for a given channel.
Definition SCPISpectrometer.cpp:231
virtual void SetChannelBandwidthLimit(size_t i, unsigned int limit_mhz) override
Sets the bandwidth limit for an input channel.
Definition SCPISpectrometer.cpp:128
virtual unsigned int GetChannelBandwidthLimit(size_t i) override
Gets the bandwidth limit for an input channel.
Definition SCPISpectrometer.cpp:123
virtual unsigned int GetInstrumentTypes() const override
Returns a bitfield describing the set of instrument types that this instrument supports.
Definition SCPISpectrometer.cpp:200
virtual std::vector< OscilloscopeChannel::CouplingType > GetAvailableCouplings(size_t i) override
Gets the set of legal coupling values for an input channel.
Definition SCPISpectrometer.cpp:106
void DoLoadConfiguration(int version, const YAML::Node &node, IDTable &idmap)
Load instrument and channel configuration from a save file.
Definition SCPISpectrometer.cpp:250
virtual std::vector< uint64_t > GetSampleDepthsInterleaved() override
Get the legal memory depths for this scope in combined-channels mode.
Definition SCPISpectrometer.cpp:163
virtual bool SetInterleaving(bool combine) override
Configures the scope to combine channels.
Definition SCPISpectrometer.cpp:138
virtual int64_t GetTriggerOffset() override
Gets the trigger offset.
Definition SCPISpectrometer.cpp:158
virtual OscilloscopeChannel::CouplingType GetChannelCoupling(size_t i) override
Gets the coupling used for an input channel.
Definition SCPISpectrometer.cpp:95
virtual bool IsChannelEnabled(size_t i) override
Checks if a channel is enabled in hardware.
Definition SCPISpectrometer.cpp:80
Abstraction of a transport layer for moving SCPI data between endpoints.
Definition SCPITransport.h:53