ngscopeclient 0.1-dev+51fbda87c
ConstellationFilter.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopeprotocols *
4* *
5* Copyright (c) 2012-2024 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 ConstellationFilter_h
37#define ConstellationFilter_h
38
39#include "../scopehal/ConstellationWaveform.h"
40#include "../scopehal/ActionProvider.h"
41
43{
44public:
45 ConstellationPoint(int64_t x, float y, float xn, float yn)
46 : m_xval(x)
47 , m_yval(y)
48 , m_xnorm(xn)
49 , m_ynorm(yn)
50 {}
51
53 int64_t m_xval;
54
56 float m_yval;
57
59 float m_xnorm;
60
62 float m_ynorm;
63};
64
66 : public Filter
67 , public ActionProvider
68{
69public:
70 ConstellationFilter(const std::string& color);
71
72 virtual void Refresh(vk::raii::CommandBuffer& cmdBuf, std::shared_ptr<QueueHandle> queue) override;
73
74 static std::string GetProtocolName();
75
76 virtual bool ValidateChannel(size_t i, StreamDescriptor stream) override;
77
78 virtual float GetVoltageRange(size_t stream) override;
79 virtual float GetOffset(size_t stream) override;
80
81 virtual void ClearSweeps() override;
82
83 virtual std::vector<std::string> EnumActions() override;
84 virtual bool PerformAction(const std::string& id) override;
85
86 ConstellationWaveform* ReallocateWaveform();
87
88 void SetWidth(size_t width)
89 {
90 if(m_width != width)
91 {
92 SetData(NULL, 0);
93 m_width = width;
94 }
95 }
96
97 void SetHeight(size_t height)
98 {
99 if(m_height != height)
100 {
101 SetData(NULL, 0);
102 m_height = height;
103 }
104 }
105
106 int64_t GetXOffset()
107 { return 0; }
108
109 float GetXScale()
110 { return m_xscale; }
111
112 size_t GetWidth() const
113 { return m_width; }
114
115 size_t GetHeight() const
116 { return m_height; }
117
118 PROTOCOL_DECODER_INITPROC(ConstellationFilter)
119
120 enum modulation_t
121 {
122 MOD_NONE,
123 MOD_QAM4,
124 MOD_QAM9,
125 MOD_QAM16,
126 MOD_QAM32,
127 MOD_QAM64,
128 MOD_PSK8
129 };
130
131 const std::vector<ConstellationPoint>& GetNominalPoints()
132 { return m_points; }
133
134protected:
135 void RecomputeNominalPoints();
136 void GetMinMaxSymbols(
137 std::vector<size_t>& hist,
138 float vmin,
139 float& vmin_out,
140 float& vmax_out,
141 float binsize,
142 size_t order,
143 ssize_t nbins);
144
145 size_t m_height;
146 size_t m_width;
147
148 float m_xscale;
149
150 std::string m_modulation;
151 std::string m_nomci;
152 std::string m_nomcq;
153 std::string m_nomr;
154
155 double m_evmSum;
156 int64_t m_evmCount;
157
159 std::vector<ConstellationPoint> m_points;
160};
161
162#endif
Abstract base for objects (usually filters) which provide a series of actions a user can perform.
Definition: ActionProvider.h:48
Definition: ConstellationFilter.h:68
virtual bool PerformAction(const std::string &id) override
Perform a specific action.
Definition: ConstellationFilter.cpp:353
virtual void ClearSweeps() override
Clears any integrated data from past triggers (e.g. eye patterns).
Definition: ConstellationFilter.cpp:121
std::vector< ConstellationPoint > m_points
Nominal locations of each constellation point.
Definition: ConstellationFilter.h:159
virtual std::vector< std::string > EnumActions() override
Return a list of all actions which may be performed on the object.
Definition: ConstellationFilter.cpp:346
Definition: ConstellationFilter.h:43
int64_t m_xval
Nominal X coordinate.
Definition: ConstellationFilter.h:53
float m_ynorm
Normalized Y coordinate.
Definition: ConstellationFilter.h:62
float m_xnorm
Normalized X coordinate.
Definition: ConstellationFilter.h:59
float m_yval
Nominal Y coordinate.
Definition: ConstellationFilter.h:56
A constellation diagram.
Definition: ConstellationWaveform.h:47
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
Descriptor for a single stream coming off a channel.
Definition: StreamDescriptor.h:46