ngscopeclient v0.2
Loading...
Searching...
No Matches
Trigger.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopehal *
4* *
5* Copyright (c) 2012-2026 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:
49 virtual ~Trigger();
50
51 virtual void Refresh(vk::raii::CommandBuffer& cmdBuf, std::shared_ptr<QueueHandle> queue) override;
52
54 float GetLevel()
55 { return m_level.GetFloatVal(); }
56
57 float GetUpperLevel()
58 { return m_level.GetFloatVal(); }
59
65 void SetLevel(float level)
66 {
67 m_level.SetFloatVal(level);
68 m_triggerLevel.SetFloatVal(level);
69 m_upperLevel.SetFloatVal(level);
70 }
71
72 void SetUpperLevel(float level)
73 {
74 m_level.SetFloatVal(level);
75 m_triggerLevel.SetFloatVal(level);
76 m_upperLevel.SetFloatVal(level);
77 }
78
81 { return m_scope; }
82
113
114protected:
115
118
121 FilterParameter& m_triggerLevel;
122 FilterParameter& m_upperLevel;
123
124public:
125 virtual std::string GetTriggerDisplayName() =0;
126
127 typedef Trigger* (*CreateProcType)(Oscilloscope*);
128 static void DoAddTriggerClass(std::string name, CreateProcType proc);
129
130 static void EnumTriggers(std::vector<std::string>& names);
131 static Trigger* CreateTrigger(std::string name, Oscilloscope* scope);
132
133 virtual YAML::Node SerializeConfiguration(IDTable& table) override;
134
135protected:
137 typedef std::map< std::string, CreateProcType > CreateMapType;
138
141};
142
143#define TRIGGER_INITPROC(T) \
144 static Trigger* CreateInstance(Oscilloscope* scope) \
145 { return new T(scope); } \
146 virtual std::string GetTriggerDisplayName() override \
147 { return GetTriggerName(); }
148
149#define AddTriggerClass(T) Trigger::DoAddTriggerClass(T::GetTriggerName(), T::CreateInstance)
150
151#endif
Declaration of FlowGraphNode.
Definition AcceleratorBuffer.h:204
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:144
Abstract base class for a node in the signal flow graph.
Definition FlowGraphNode.h:81
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:51
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:96
virtual YAML::Node SerializeConfiguration(IDTable &table) override
Serializes this trigger's configuration to a YAML string.
Definition Trigger.cpp:129
static Trigger * CreateTrigger(std::string name, Oscilloscope *scope)
Creates a new trigger for an oscilloscope.
Definition Trigger.cpp:110
Oscilloscope * m_scope
The scope this trigger is part of.
Definition Trigger.h:117
static void DoAddTriggerClass(std::string name, CreateProcType proc)
Register a new trigger class for dynamic creation.
Definition Trigger.cpp:83
static CreateMapType m_createprocs
Map of trigger type names to factory methods.
Definition Trigger.h:140
Condition
Conditions for triggers that perform logical comparisons of values.
Definition Trigger.h:85
@ CONDITION_NOT_BETWEEN
Match when value is not between two targets.
Definition Trigger.h:108
@ CONDITION_GREATER_OR_EQUAL
Match when value is greater than or equal to target.
Definition Trigger.h:102
@ CONDITION_GREATER
Match when value is greater than target.
Definition Trigger.h:99
@ CONDITION_LESS
Match when value is less than target.
Definition Trigger.h:93
@ CONDITION_BETWEEN
Match when value is greater than one target but less than another.
Definition Trigger.h:105
@ CONDITION_NOT_EQUAL
Match when value is not equal to target.
Definition Trigger.h:90
@ CONDITION_ANY
Always match.
Definition Trigger.h:111
@ CONDITION_LESS_OR_EQUAL
Match when value is less than or equal to target.
Definition Trigger.h:96
@ CONDITION_EQUAL
Match when value is equal to target.
Definition Trigger.h:87
FilterParameter & m_level
"Trigger level" parameter
Definition Trigger.h:120
std::map< std::string, CreateProcType > CreateMapType
Helper typedef for m_createprocs.
Definition Trigger.h:137
Oscilloscope * GetScope()
Gets the scope this trigger is attached to.
Definition Trigger.h:80
void SetLevel(float level)
Sets the trigger level.
Definition Trigger.h:65
float GetLevel()
Get the trigger level.
Definition Trigger.h:54