ngscopeclient v0.2
Loading...
Searching...
No Matches
OscilloscopeChannel.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 OscilloscopeChannel_h
37#define OscilloscopeChannel_h
38
39class Oscilloscope;
40
41#include "InstrumentChannel.h"
42
49{
50public:
51
52 //Some drivers have to be able to call AddStream() for now (this will be refactored out eventually)
53 friend class Oscilloscope;
54 friend class MockOscilloscope;
55
58 const std::string& hwname,
59 const std::string& color,
60 Unit xunit = Unit(Unit::UNIT_FS),
61 size_t index = 0);
62
65 const std::string& hwname,
66 const std::string& color,
67 Unit xunit = Unit(Unit::UNIT_FS),
68 Unit yunit = Unit(Unit::UNIT_VOLTS),
69 Stream::StreamType stype = Stream::STREAM_TYPE_ANALOG,
70 size_t index = 0);
71 virtual ~OscilloscopeChannel();
72
73 //implemented in Oscilloscope.h
74 Oscilloscope* GetScope();
75
76 size_t GetRefCount()
77 { return m_refcount; }
78
79 virtual void SetDisplayName(std::string name) override;
80 virtual std::string GetDisplayName() override;
81
82 //Hardware configuration
83public:
84 bool IsEnabled();
85
86 //Warning: these functions FORCE the channel to be on or off. May break other code that assumes it's on.
87 void Enable();
88 void Disable();
89
90 //These functions are preferred in GUI or other environments with multiple consumers of waveform data.
91 //The channel is reference counted and only turned off when all consumers have released it.
92 virtual void AddRef();
93 virtual void Release();
94
95 enum CouplingType
96 {
97 COUPLE_DC_1M, //1M ohm, DC coupled
98 COUPLE_AC_1M, //1M ohm, AC coupled
99 COUPLE_DC_50, //50 ohm, DC coupled
100 COUPLE_AC_50, //50 ohm, AC coupled
101 COUPLE_GND, //tie to ground
102 COUPLE_SYNTHETIC //channel is math, digital, or otherwise not a direct voltage measurement
103 };
104
105 virtual CouplingType GetCoupling();
106 virtual void SetCoupling(CouplingType type);
107
108 virtual std::vector<OscilloscopeChannel::CouplingType> GetAvailableCouplings();
109
110 virtual double GetAttenuation();
111 virtual void SetAttenuation(double atten);
112
113 virtual int GetBandwidthLimit();
114 virtual void SetBandwidthLimit(int mhz);
115
116 virtual void SetDeskew(int64_t skew);
117 virtual int64_t GetDeskew();
118
119 bool IsPhysicalChannel()
120 { return (m_instrument != nullptr); }
121
122 virtual bool IsInverted(size_t stream);
123
124 virtual float GetVoltageRange(size_t stream);
125 virtual void SetVoltageRange(float range, size_t stream);
126
127 virtual float GetOffset(size_t stream);
128 virtual void SetOffset(float offset, size_t stream);
129 virtual bool IsHighRateOffsetCapable();
130
131 void SetDigitalHysteresis(float level);
132 void SetDigitalThreshold(float level);
133
134 void SetCenterFrequency(int64_t freq);
135
136 bool CanAutoZero();
137 void AutoZero();
138 bool CanDegauss();
139 void Degauss();
140 std::string GetProbeName();
141
142 virtual bool CanInvert();
143 virtual void Invert(bool invert);
144 virtual bool IsInverted();
145
146 virtual bool HasInputMux();
147 virtual size_t GetInputMuxSetting();
148 virtual void SetInputMux(size_t select);
149
151
152 virtual DownloadState GetDownloadState() override;
153 virtual float GetDownloadProgress() override;
154 virtual double GetDownloadStartTime() override;
155
156private:
157 // to be accessed by Oscilloscope to update download status
158 DownloadState m_downloadState;
159 float m_downloadProgress;
160 double m_downloadStartTime;
161
162protected:
163 void SharedCtorInit(Unit unit);
164
167};
168
169#endif
Declaration of InstrumentChannel.
Definition AcceleratorBuffer.h:204
A single channel of an instrument.
Definition InstrumentChannel.h:63
DownloadState
Enum values to be mapped to GetDownloadState() int result value for specific channel download states.
Definition InstrumentChannel.h:283
Instrument * m_instrument
The instrument we're part of (may be null in the case of filters etc)
Definition InstrumentChannel.h:313
Fake oscilloscope driver used for offline waveform analysis.
Definition MockOscilloscope.h:45
A single channel on an oscilloscope.
Definition OscilloscopeChannel.h:49
void SetDefaultDisplayName()
Gives a channel a default display name if there's not one already.
Definition OscilloscopeChannel.cpp:79
virtual DownloadState GetDownloadState() override
Returns the current download state of this channel.
Definition OscilloscopeChannel.cpp:359
virtual bool IsHighRateOffsetCapable()
Check if this channel is able to handle high rate (e.g. every mouse movement) offset changes.
Definition OscilloscopeChannel.cpp:379
virtual double GetDownloadStartTime() override
returns the start time of a download, if we are DOWNLOAD_IN_PROGRESS; undefined, otherwise
Definition OscilloscopeChannel.cpp:369
size_t m_refcount
Number of references (channel is disabled when last ref is released)
Definition OscilloscopeChannel.h:166
virtual void SetDisplayName(std::string name) override
Sets the human-readable nickname for this channel, as displayed in the GUI.
Definition OscilloscopeChannel.cpp:254
virtual float GetDownloadProgress() override
returns the current completion of the download (on the range [0, 1]), if not DOWNLOAD_UNKNOWN
Definition OscilloscopeChannel.cpp:364
virtual std::string GetDisplayName() override
Gets the human-readable nickname for this channel, as displayed in the GUI.
Definition OscilloscopeChannel.cpp:261
Generic representation of an oscilloscope, logic analyzer, or spectrum analyzer.
Definition Oscilloscope.h:51
StreamType
General data type stored in a stream.
Definition Stream.h:57
A unit of measurement, plus conversion to pretty-printed output.
Definition Unit.h:59