ngscopeclient 0.1-dev+51fbda87c
WindowTrigger.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopehal *
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 WindowTrigger_h
37#define WindowTrigger_h
38
39#include "TwoLevelTrigger.h"
40
46{
47public:
49 virtual ~WindowTrigger();
50
51 virtual bool ValidateChannel(size_t i, StreamDescriptor stream) override;
52
57 {
60
63
66
69 };
70
75 {
78
81
84
87 };
88
92
95 { return (Crossing)m_crossingType.GetIntVal(); }
96
99 { m_windowType.SetIntVal(type); }
100
103 { return (WindowType)m_windowType.GetIntVal(); }
104
110 void SetWidth(int64_t ps)
111 { m_width.SetIntVal(ps); }
112
114 int64_t GetWidth()
115 { return m_width.GetIntVal(); }
116
117 static std::string GetTriggerName();
118 TRIGGER_INITPROC(WindowTrigger);
119
120protected:
121
124
127
130};
131
132#endif
Declaration of TwoLevelTrigger.
A parameter to a filter.
Definition: FilterParameter.h:86
void SetIntVal(int64_t i)
Sets the parameter to an integer value.
Definition: FilterParameter.cpp:307
int64_t GetIntVal() const
Returns the value of the parameter interpreted as an integer.
Definition: FilterParameter.h:119
Generic representation of an oscilloscope, logic analyzer, or spectrum analyzer.
Definition: Oscilloscope.h:50
Descriptor for a single stream coming off a channel.
Definition: StreamDescriptor.h:46
Base class for all triggers that have two thresholds rather than one.
Definition: TwoLevelTrigger.h:45
Window trigger - detect when the signal leaves a specified range.
Definition: WindowTrigger.h:46
WindowType GetWindowType()
Gets the type of window.
Definition: WindowTrigger.h:102
void SetWindowType(WindowType type)
Sets the type of window.
Definition: WindowTrigger.h:98
void SetWidth(int64_t ps)
Sets the time the signal needs to stay in/outside the window.
Definition: WindowTrigger.h:110
FilterParameter & m_width
Time the signal needs to stay in / outside the window.
Definition: WindowTrigger.h:123
void SetCrossingDirection(Crossing dir)
Sets the crossing direction (only used for "stay inside" and "stay outside" window types)
Definition: WindowTrigger.h:90
WindowTrigger(Oscilloscope *scope)
Creates a new window trigger.
Definition: WindowTrigger.cpp:51
FilterParameter & m_windowType
Condition to trigger on.
Definition: WindowTrigger.h:129
static std::string GetTriggerName()
Return the constant trigger name "Window".
Definition: WindowTrigger.cpp:92
FilterParameter & m_crossingType
Crossing direction for stay-inside and stay-outside types.
Definition: WindowTrigger.h:126
WindowType
How to trigger.
Definition: WindowTrigger.h:75
@ WINDOW_EXIT
Trigger immediately upon exit from the window.
Definition: WindowTrigger.h:80
@ WINDOW_ENTER
Trigger immediately upon entry to the window.
Definition: WindowTrigger.h:77
@ WINDOW_ENTER_TIMED
Trigger upon entry to the window, if we were outside it for at least X time.
Definition: WindowTrigger.h:86
@ WINDOW_EXIT_TIMED
Trigger upon exit from the window, if we were in it for at least X time.
Definition: WindowTrigger.h:83
int64_t GetWidth()
Gets the time the signal needs to stay in / outside the winodw.
Definition: WindowTrigger.h:114
Crossing GetCrossingDirection()
Gets the selected crossing direction.
Definition: WindowTrigger.h:94
Crossing
Type of level crossing to detect for "stay inside" and "stay outside" windows.
Definition: WindowTrigger.h:57
@ CROSS_NONE
Nothing.
Definition: WindowTrigger.h:68
@ CROSS_UPPER
Upper threshold.
Definition: WindowTrigger.h:59
@ CROSS_EITHER
Either threshold.
Definition: WindowTrigger.h:65
@ CROSS_LOWER
Lower threshold.
Definition: WindowTrigger.h:62