ngscopeclient 0.1-dev+51fbda87c
StreamDescriptor_inlines.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopehal v0.1 *
4* *
5* Copyright (c) 2012-2023 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
35#ifndef StreamDescriptor_inlines_h
36#define StreamDescriptor_inlines_h
37
38inline Unit StreamDescriptor::GetXAxisUnits()
39{
40 return m_channel->GetXAxisUnits();
41}
42
43inline Unit StreamDescriptor::GetYAxisUnits()
44{
45 if(m_channel == nullptr)
46 return Unit(Unit::UNIT_VOLTS);
47 else
48 return m_channel->GetYAxisUnits(m_stream);
49}
50
51inline WaveformBase* StreamDescriptor::GetData() const
52{
53 if(m_channel == nullptr)
54 return nullptr;
55 else
56 return m_channel->GetData(m_stream);
57}
58
59inline bool StreamDescriptor::operator==(const StreamDescriptor& rhs) const
60{
61 return (m_channel == rhs.m_channel) && (m_stream == rhs.m_stream);
62}
63
64inline bool StreamDescriptor::operator!=(const StreamDescriptor& rhs) const
65{
66 return (m_channel != rhs.m_channel) || (m_stream != rhs.m_stream);
67}
68
69inline bool StreamDescriptor::operator<(const StreamDescriptor& rhs) const
70{
71 if(m_channel < rhs.m_channel)
72 return true;
73 if( (m_channel == rhs.m_channel) && (m_stream < rhs.m_stream) )
74 return true;
75
76 return false;
77}
78
79inline uint8_t StreamDescriptor::GetFlags() const
80{
81 if(m_channel == NULL)
82 return 0;
83 else
84 return m_channel->GetStreamFlags(m_stream);
85}
86
87inline float StreamDescriptor::GetVoltageRange()
88{
89 auto schan = dynamic_cast<OscilloscopeChannel*>(m_channel);
90 if(schan == NULL)
91 return 1;
92 else
93 return schan->GetVoltageRange(m_stream);
94}
95
96inline float StreamDescriptor::GetOffset()
97{
98 auto schan = dynamic_cast<OscilloscopeChannel*>(m_channel);
99 if(schan == NULL)
100 return 0;
101 else
102 return schan->GetOffset(m_stream);
103}
104
105inline void StreamDescriptor::SetVoltageRange(float v)
106{
107 auto schan = dynamic_cast<OscilloscopeChannel*>(m_channel);
108 if(schan)
109 schan->SetVoltageRange(v, m_stream);
110}
111
112inline void StreamDescriptor::SetOffset(float v)
113{
114 auto schan = dynamic_cast<OscilloscopeChannel*>(m_channel);
115 if(schan)
116 schan->SetOffset(v, m_stream);
117}
118
119inline float StreamDescriptor::GetScalarValue()
120{
121 if(m_channel == nullptr)
122 return 0;
123 else
124 return m_channel->GetScalarValue(m_stream);
125}
126
127#endif
WaveformBase * GetData(size_t stream)
Get the contents of a data stream.
Definition: InstrumentChannel.h:184
virtual Unit GetYAxisUnits(size_t stream)
Returns the Y axis unit for a specified stream.
Definition: InstrumentChannel.h:140
float GetScalarValue(size_t stream)
Gets the value of a scalar data stream.
Definition: InstrumentChannel.h:200
virtual Unit GetXAxisUnits()
Returns the X axis unit for this channel.
Definition: InstrumentChannel.h:134
uint8_t GetStreamFlags(size_t stream)
Get the flags of a data stream.
Definition: InstrumentChannel.h:192
A single channel on an oscilloscope.
Definition: OscilloscopeChannel.h:49
Descriptor for a single stream coming off a channel.
Definition: StreamDescriptor.h:46
A unit of measurement, plus conversion to pretty-printed output.
Definition: Unit.h:57
Base class for all Waveform specializations.
Definition: Waveform.h:59