ngscopeclient 0.1-dev+51fbda87c
ScopeDeskewWizard.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* ngscopeclient *
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
35#ifndef ScopeDeskewWizard_h
36#define ScopeDeskewWizard_h
37
38#include "Dialog.h"
39#include "Session.h"
40
42{
43public:
45
46 int64_t priTimescale;
47 int64_t secTimescale;
48
49 int64_t trigPhaseDelta;
50
51 int32_t startingDelta;
52 int32_t numDeltas;
53
54 int32_t priLen;
55 int32_t secLen;
56};
57
59{
60public:
62 std::shared_ptr<TriggerGroup> group,
63 std::shared_ptr<Oscilloscope> secondary,
64 MainWindow* parent,
65 Session& session);
66 virtual ~ScopeDeskewWizard();
67
68 virtual bool DoRender();
69
70protected:
71 void DoMainProcessingFlow();
72 void StartCorrelation();
73 void DoProcessWaveformUniformUnequalRate(UniformAnalogWaveform* ppri, UniformAnalogWaveform* psec);
74 void DoProcessWaveformUniform4xRateVulkan(UniformAnalogWaveform* ppri, UniformAnalogWaveform* psec);
75 void DoProcessWaveformUniformUnequalRateVulkan(UniformAnalogWaveform* ppri, UniformAnalogWaveform* psec);
76 void DoProcessWaveformUniformEqualRateVulkan(UniformAnalogWaveform* ppri, UniformAnalogWaveform* psec);
77 void PostprocessVulkanCorrelation();
78 void DoProcessWaveformSparse(SparseAnalogWaveform* ppri, SparseAnalogWaveform* psec);
79 void ChannelSelector(const char* name, std::shared_ptr<Oscilloscope> scope, StreamDescriptor& stream);
80
81 enum state_t
82 {
83 STATE_WELCOME_1,
84 STATE_WELCOME_2,
85 STATE_WELCOME_3,
86 STATE_WELCOME_4,
87 STATE_WELCOME_5,
88 STATE_ACQUIRE,
89 STATE_CORRELATE,
90 STATE_DONE,
91 STATE_CLOSE
92 } m_state;
93
94 std::shared_ptr<TriggerGroup> m_group;
95 std::shared_ptr<Oscilloscope> m_secondary;
96
97 MainWindow* m_parent;
98 Session& m_session;
99
100 bool m_useExtRefPrimary;
101 bool m_useExtRefSecondary;
102
103 int m_measureCycle;
104
105 time_t m_lastTriggerTimestamp;
106 int64_t m_lastTriggerFs;
107
108 StreamDescriptor m_primaryStream;
109 StreamDescriptor m_secondaryStream;
110
111 //Combined measurements from all waveforms to date
112 std::vector<float> m_correlations;
113 std::vector<int64_t> m_skews;
114
115 //Best results found from the current waveform
116 float m_bestCorrelation;
117 int64_t m_bestCorrelationOffset;
118
119 bool m_gpuCorrelationAvailable;
120
121 //Maximum number of samples offset to consider
122 int64_t m_maxSkewSamples;
123
126
127 //Vulkan processing queues etc
128 std::shared_ptr<QueueHandle> m_queue;
129 vk::raii::CommandPool m_pool;
130 vk::raii::CommandBuffer m_cmdBuf;
131
132 //Vulkan compute pipelines
133 std::shared_ptr<ComputePipeline> m_uniform4xRatePipeline;
134 std::shared_ptr<ComputePipeline> m_uniformUnequalRatePipeline;
135 std::shared_ptr<ComputePipeline> m_uniformEqualRatePipeline;
136
137 //Output correlation data
138 AcceleratorBuffer<float> m_corrOut;
139};
140
141#endif
Declaration of Dialog.
Declaration of Session.
Generic dialog box or other popup window.
Definition: Dialog.h:44
Top level application window.
Definition: MainWindow.h:115
Definition: ScopeDeskewWizard.h:59
int64_t m_medianSkew
Calculated total skew.
Definition: ScopeDeskewWizard.h:125
virtual bool DoRender()
Renders the dialog and handles UI events.
Definition: ScopeDeskewWizard.cpp:141
A Session stores all of the instrument configuration and other state the user has open.
Definition: Session.h:95
A waveform sampled at irregular intervals.
Definition: Waveform.h:460
Descriptor for a single stream coming off a channel.
Definition: StreamDescriptor.h:46
Definition: ScopeDeskewWizard.h:42
A waveform sampled at uniform intervals.
Definition: Waveform.h:365