ngscopeclient v0.2.2
Loading...
Searching...
No Matches
StreamDescriptor.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 StreamDescriptor_h
38#define StreamDescriptor_h
39
41class InputConstraint;
42
47{
48public:
50 : m_channel(NULL)
51 , m_stream(0)
52 {}
53
55 : m_channel(channel)
56 , m_stream(stream)
57 {}
58
61 {
62 if(m_channel == nullptr)
63 return true;
64 return (m_stream >= m_channel->GetStreamCount());
65 }
66
67 operator bool() const
68 { return (m_channel != nullptr); }
69
70 void AddSink(FlowGraphNode* node);
71 void RemoveSink(FlowGraphNode* node);
72 const std::set<FlowGraphNode*>& GetSinks();
73
74 std::string GetName() const;
75
76 InstrumentChannel* m_channel;
77 size_t m_stream;
78
79 //None of these functions can be inlined here, because OscilloscopeChannel isn't fully declared yet.
80 //See StreamDescriptor_inlines.h for implementations
81 Unit GetXAxisUnits();
82 Unit GetYAxisUnits();
83 WaveformBase* GetData() const;
84 bool operator==(const StreamDescriptor& rhs) const;
85 bool operator!=(const StreamDescriptor& rhs) const;
86 bool operator<(const StreamDescriptor& rhs) const;
87 uint8_t GetFlags() const;
88 float GetVoltageRange();
89 float GetOffset();
90 bool IsHighRateOffsetCapable();
91 void SetVoltageRange(float v);
92 void SetOffset(float v);
94 float GetScalarValue();
95 uint64_t GetDigitalScalarValue();
96 size_t GetDigitalWidth();
97 std::string PrettyPrintDigitalScalarHex();
98 std::string PrettyPrintDigitalScalarBinary();
99 std::string PrettyPrintDigitalScalarDecimal();
100 bool IsInverted();
101};
102
110{
111public:
112 InputDescriptor(const std::string& name = "", const StreamDescriptor source = nullptr)
113 : m_name(name)
115 {}
116
117 virtual ~InputDescriptor()
118 {}
119
120 //not copyable or assignable
121 InputDescriptor(const InputDescriptor& rhs) =delete;
122 InputDescriptor& operator=(const InputDescriptor& rhs) =delete;
123
124 //Porting helpers and trivial accessors
125 Unit GetYAxisUnits()
126 { return m_sourceStream.GetYAxisUnits(); }
127
128 Unit GetXAxisUnits()
129 { return m_sourceStream.GetXAxisUnits(); }
130
131 WaveformBase* GetData() const
132 { return m_sourceStream.GetData(); }
133
134 float GetVoltageRange()
135 { return m_sourceStream.GetVoltageRange(); }
136
142 std::string m_name;
143
146
148 std::shared_ptr<InputConstraint> m_constraints;
149};
150
151
152#endif
Definition AcceleratorBuffer.h:204
Abstract base class for a node in the signal flow graph.
Definition FlowGraphNode.h:81
Base class for constraints on inputs.
Definition InputConstraint.h:51
Base class for filter graph inputs.
Definition StreamDescriptor.h:110
std::shared_ptr< InputConstraint > m_constraints
Constraints that apply to this input.
Definition StreamDescriptor.h:148
StreamDescriptor m_sourceStream
The stream, if any, connected to this input port.
Definition StreamDescriptor.h:145
std::string m_name
Name of the input port displayed in the graph editor.
Definition StreamDescriptor.h:142
A single channel of an instrument.
Definition InstrumentChannel.h:63
size_t GetStreamCount()
Get the number of data streams.
Definition InstrumentChannel.h:176
Descriptor for a single stream coming off a channel.
Definition StreamDescriptor.h:47
Stream::StreamType GetType()
Get the type of stream (if connected). Returns STREAM_TYPE_ANALOG if null.
Definition FlowGraphNode_inlines.h:62
bool IsOutOfRange()
Definition StreamDescriptor.h:60
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
Base class for all Waveform specializations.
Definition Waveform.h:59