ngscopeclient 0.1-dev+51fbda87c
EyePattern.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopeprotocols *
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
36#ifndef EyePattern_h
37#define EyePattern_h
38
39#include "EyeMask.h"
40#include "../scopehal/EyeWaveform.h"
41
42class EyePattern : public Filter
43{
44public:
45 EyePattern(const std::string& color);
46
47 virtual void Refresh(vk::raii::CommandBuffer& cmdBuf, std::shared_ptr<QueueHandle> queue) override;
48
49 static std::string GetProtocolName();
50
51 virtual bool ValidateChannel(size_t i, StreamDescriptor stream) override;
52
53 virtual float GetVoltageRange(size_t stream) override;
54 virtual float GetOffset(size_t stream) override;
55
56 virtual void ClearSweeps() override;
57
58 void RecalculateUIWidth();
59 EyeWaveform* ReallocateWaveform();
60
61 void SetWidth(size_t width)
62 {
63 if(m_width != width)
64 {
65 SetData(NULL, 0);
66 m_width = width;
67 }
68 }
69
70 void SetHeight(size_t height)
71 {
72 if(m_height != height)
73 {
74 SetData(NULL, 0);
75 m_height = height;
76 }
77 }
78
79 int64_t GetXOffset()
80 { return m_xoff; }
81
82 float GetXScale()
83 { return m_xscale; }
84
85 size_t GetWidth() const
86 { return m_width; }
87
88 size_t GetHeight() const
89 { return m_height; }
90
91 EyeMask& GetMask()
92 { return m_mask; }
93
94 enum ClockPolarity
95 {
96 CLOCK_RISING = 1,
97 CLOCK_FALLING = 2,
98 CLOCK_BOTH = 3 //CLOCK_RISING | CLOCK_FALLING
99 };
100
101 enum RangeMode
102 {
103 RANGE_AUTO = 0,
104 RANGE_FIXED = 1
105 };
106
107 enum ClockAlignment
108 {
109 ALIGN_CENTER,
110 ALIGN_EDGE
111 };
112
113 enum UIMode
114 {
115 MODE_AUTO,
116 MODE_FIXED
117 };
118
119 PROTOCOL_DECODER_INITPROC(EyePattern)
120
121protected:
122 void DoMaskTest(EyeWaveform* cap);
123
124 void SparsePackedInnerLoop(
125 SparseAnalogWaveform* waveform,
126 std::vector<int64_t>& clock_edges,
127 int64_t* data,
128 size_t wend,
129 size_t cend,
130 int32_t xmax,
131 int32_t ymax,
132 float xtimescale,
133 float yscale,
134 float yoff
135 );
136
137 void DensePackedInnerLoop(
138 UniformAnalogWaveform* waveform,
139 std::vector<int64_t>& clock_edges,
140 int64_t* data,
141 size_t wend,
142 size_t cend,
143 int32_t xmax,
144 int32_t ymax,
145 float xtimescale,
146 float yscale,
147 float yoff
148 );
149
150#ifdef __x86_64__
151 void DensePackedInnerLoopAVX2(
152 UniformAnalogWaveform* waveform,
153 std::vector<int64_t>& clock_edges,
154 int64_t* data,
155 size_t wend,
156 size_t cend,
157 int32_t xmax,
158 int32_t ymax,
159 float xtimescale,
160 float yscale,
161 float yoff
162 );
163#endif
164
165 size_t m_height;
166 size_t m_width;
167
168 int64_t m_xoff;
169 float m_xscale;
170 ClockAlignment m_lastClockAlign;
171
172 std::string m_saturationName;
173 std::string m_centerName;
174 std::string m_maskName;
175 std::string m_polarityName;
176 std::string m_vmodeName;
177 std::string m_rangeName;
178 std::string m_clockAlignName;
179 std::string m_rateModeName;
180 std::string m_rateName;
181
182 EyeMask m_mask;
183};
184
185#endif
Declaration of EyeMask, EyeMaskPoint, and EyeMaskPolygon.
A mask used for checking eye patterns.
Definition: EyeMask.h:98
Definition: EyePattern.h:43
void DoMaskTest(EyeWaveform *cap)
Checks the current capture against the eye mask.
Definition: EyePattern.cpp:694
virtual void ClearSweeps() override
Clears any integrated data from past triggers (e.g. eye patterns).
Definition: EyePattern.cpp:145
An eye-pattern waveform.
Definition: EyeWaveform.h:58
Abstract base class for all filter graph blocks which are not physical instrument channels.
Definition: Filter.h:95
virtual void Refresh() override
Evaluates a filter graph node.
Definition: Filter.cpp:816
void SetData(WaveformBase *pNew, size_t stream)
Sets the waveform data for a given stream, replacing any previous waveform.
Definition: InstrumentChannel.cpp:139
A waveform sampled at irregular intervals.
Definition: Waveform.h:460
Descriptor for a single stream coming off a channel.
Definition: StreamDescriptor.h:46
A waveform sampled at uniform intervals.
Definition: Waveform.h:365