refactor: what counts as an event moves into its own evaluator, so a search can ask the same question the trigger asks
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
178cf54ef6
commit
b3fd9ae00f
6 files changed
+189
-50
No files matched your search
+11
-9
@@ -6,10 +6,9 @@
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace udpscope {
|
||||
#include "condition.hpp"
|
||||
|
||||
/// Which way the trigger signal crosses the level.
|
||||
enum class TriggerEdge { Rising, Falling, Both };
|
||||
namespace udpscope {
|
||||
|
||||
/// How an armed trigger re-arms after it fired.
|
||||
enum class TriggerMode { Normal, Single };
|
||||
@@ -24,8 +23,10 @@ struct TriggerConfig {
|
||||
bool enabled = false; ///< trigger mode on/off (toolbar).
|
||||
bool armed = false; ///< arm/disarm button.
|
||||
int channel = -1; ///< index into ScopeModel::channels(), -1 = none.
|
||||
double level = 0.0;
|
||||
TriggerEdge edge = TriggerEdge::Rising;
|
||||
/// What counts as an event on that channel: the level and edge, and for the qualified
|
||||
/// shapes the width, band or timeout as well. The engine does not interpret it -- it
|
||||
/// hands it to an `EventDetector`.
|
||||
EventCondition condition{};
|
||||
double pretrigger_pct = 50.0; ///< share of the buffer shown before the event.
|
||||
double holdoff_s = 0.010; ///< default from the spec.
|
||||
TriggerMode mode = TriggerMode::Normal;
|
||||
@@ -92,8 +93,8 @@ class TriggerEngine {
|
||||
/// pre-trigger window an edge needs before it may open a capture.
|
||||
double history() const noexcept { return last_t_s_ - oldest_s_; }
|
||||
double pre_seconds() const noexcept { return pre_seconds_; }
|
||||
double last_value() const noexcept { return prev_; }
|
||||
bool have_last() const noexcept { return have_prev_; }
|
||||
double last_value() const noexcept { return detector_.last_value(); }
|
||||
bool have_last() const noexcept { return detector_.have_last(); }
|
||||
double last_t() const noexcept { return last_t_s_; }
|
||||
double holdoff_until() const noexcept { return holdoff_until_s_; }
|
||||
|
||||
@@ -107,8 +108,9 @@ class TriggerEngine {
|
||||
TriggerConfig cfg_{};
|
||||
std::string channel_name_; ///< the trigger channel's stable identity (see `configure`).
|
||||
bool armed_ = false;
|
||||
bool have_prev_ = false;
|
||||
double prev_ = 0.0;
|
||||
/// What an event *is*. The engine owns when one may open a capture; this owns whether
|
||||
/// the sample is one at all.
|
||||
EventDetector detector_{};
|
||||
bool pending_ = false; ///< an edge was seen; collecting the post window
|
||||
double pending_start_s_ = 0.0;
|
||||
double holdoff_until_s_ = 0.0;
|
||||
|
||||
Reference in new issue
Block a user