ngscopeclient 0.1-dev+51fbda87c
SerialTrigger.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopehal v0.1 *
4* *
5* Copyright (c) 2012-2021 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 SerialTrigger_h
36#define SerialTrigger_h
37
41class SerialTrigger : public Trigger
42{
43public:
45 virtual ~SerialTrigger();
46
47 enum Radix
48 {
49 RADIX_ASCII,
50 RADIX_HEX,
51 RADIX_BINARY
52 };
53
54 void SetCondition(Condition cond)
55 { m_parameters[m_conditionname].SetIntVal(cond); }
56
57 Condition GetCondition()
58 { return (Condition) m_parameters[m_conditionname].GetIntVal(); }
59
60 void SetRadix(Radix rad)
61 { m_parameters[m_radixname].SetIntVal(rad); }
62
63 Radix GetRadix()
64 { return (Radix) m_parameters[m_radixname].GetIntVal(); }
65
66 void SetPatterns(std::string p1, std::string p2, bool ignore_p2);
67
68 std::string GetPattern1()
69 { return FormatPattern(m_parameters[m_patternname].ToString()); }
70
71 std::string GetPattern2()
72 { return FormatPattern(m_parameters[m_pattern2name].ToString()); }
73
74protected:
75
76 std::string FormatPattern(std::string str);
77
78 std::string m_radixname;
79 std::string m_conditionname;
80 std::string m_patternname;
81 std::string m_pattern2name;
82};
83
84#endif
Generic representation of an oscilloscope, logic analyzer, or spectrum analyzer.
Definition: Oscilloscope.h:50
Abstract base class for serial protocol triggers with pattern matching.
Definition: SerialTrigger.h:42
void SetPatterns(std::string p1, std::string p2, bool ignore_p2)
Converts a pattern from ASCII ternary (0-1-x) to a more display-friendly format.
Definition: SerialTrigger.cpp:78
std::string FormatPattern(std::string str)
Converts a pattern in the current radix back to ASCII ternary.
Definition: SerialTrigger.cpp:198
Abstract base class for oscilloscope / logic analyzer trigger inputs.
Definition: Trigger.h:46
Condition
Conditions for triggers that perform logical comparisons of values.
Definition: Trigger.h:69