ngscopeclient 0.1-dev+51fbda87c
Trigger.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 Trigger_h
37#define Trigger_h
38
39#include "FlowGraphNode.h"
40
45class Trigger : public FlowGraphNode
46{
47public:
48 Trigger(Oscilloscope* scope);
49 virtual ~Trigger();
50
52 float GetLevel()
53 { return m_level.GetFloatVal(); }
54
60 void SetLevel(float level)
61 { m_level.SetFloatVal(level); }
62
65 { return m_scope; }
66
69 {
72
75
78
81
84
87
90
93
96 };
97
98protected:
99
102
105
106public:
107 virtual std::string GetTriggerDisplayName() =0;
108
109 typedef Trigger* (*CreateProcType)(Oscilloscope*);
110 static void DoAddTriggerClass(std::string name, CreateProcType proc);
111
112 static void EnumTriggers(std::vector<std::string>& names);
113 static Trigger* CreateTrigger(std::string name, Oscilloscope* scope);
114
115 virtual YAML::Node SerializeConfiguration(IDTable& table) override;
116
117protected:
119 typedef std::map< std::string, CreateProcType > CreateMapType;
120
123};
124
125#define TRIGGER_INITPROC(T) \
126 static Trigger* CreateInstance(Oscilloscope* scope) \
127 { return new T(scope); } \
128 virtual std::string GetTriggerDisplayName() override \
129 { return GetTriggerName(); }
130
131#define AddTriggerClass(T) Trigger::DoAddTriggerClass(T::GetTriggerName(), T::CreateInstance)
132
133#endif
Declaration of FlowGraphNode.
A parameter to a filter.
Definition: FilterParameter.h:86
void SetFloatVal(float f)
Sets the parameter to a floating point value.
Definition: FilterParameter.cpp:323
float GetFloatVal() const
Returns the value of the parameter interpreted as a floating point number.
Definition: FilterParameter.h:125
Abstract base class for a node in the signal flow graph.
Definition: FlowGraphNode.h:54
Bidirectional table mapping integer IDs in scopesession files to object pointers.
Definition: IDTable.h:49
Generic representation of an oscilloscope, logic analyzer, or spectrum analyzer.
Definition: Oscilloscope.h:50
Abstract base class for oscilloscope / logic analyzer trigger inputs.
Definition: Trigger.h:46
static void EnumTriggers(std::vector< std::string > &names)
Gets a list of all registered trigger types.
Definition: Trigger.cpp:84
virtual YAML::Node SerializeConfiguration(IDTable &table) override
Serializes this trigger's configuration to a YAML string.
Definition: Trigger.cpp:110
static Trigger * CreateTrigger(std::string name, Oscilloscope *scope)
Creates a new trigger for an oscilloscope.
Definition: Trigger.cpp:98
Oscilloscope * m_scope
The scope this trigger is part of.
Definition: Trigger.h:101
static void DoAddTriggerClass(std::string name, CreateProcType proc)
Register a new trigger class for dynamic creation.
Definition: Trigger.cpp:74
static CreateMapType m_createprocs
Map of trigger type names to factory methods.
Definition: Trigger.h:122
Condition
Conditions for triggers that perform logical comparisons of values.
Definition: Trigger.h:69
@ CONDITION_NOT_BETWEEN
Match when value is not between two targets.
Definition: Trigger.h:92
@ CONDITION_GREATER_OR_EQUAL
Match when value is greater than or equal to target.
Definition: Trigger.h:86
@ CONDITION_GREATER
Match when value is greater than target.
Definition: Trigger.h:83
@ CONDITION_LESS
Match when value is less than target.
Definition: Trigger.h:77
@ CONDITION_BETWEEN
Match when value is greater than one target but less than another.
Definition: Trigger.h:89
@ CONDITION_NOT_EQUAL
Match when value is not equal to target.
Definition: Trigger.h:74
@ CONDITION_ANY
Always match.
Definition: Trigger.h:95
@ CONDITION_LESS_OR_EQUAL
Match when value is less than or equal to target.
Definition: Trigger.h:80
@ CONDITION_EQUAL
Match when value is equal to target.
Definition: Trigger.h:71
FilterParameter & m_level
"Trigger level" parameter
Definition: Trigger.h:104
std::map< std::string, CreateProcType > CreateMapType
Helper typedef for m_createprocs.
Definition: Trigger.h:119
Oscilloscope * GetScope()
Gets the scope this trigger is attached to.
Definition: Trigger.h:64
void SetLevel(float level)
Sets the trigger level.
Definition: Trigger.h:60
Trigger(Oscilloscope *scope)
Initialize a new trigger.
Definition: Trigger.cpp:51
float GetLevel()
Get the trigger level.
Definition: Trigger.h:52