fix(streamhub): stop the trigger going deaf between captures
TriggerEngine::CheckSample returned early in every state but ARMED, so an edge arriving while a capture was being collected or handed out was dropped, and the automatic rearm then waited for a FRESH edge. The engine was therefore blind from its own trigger point until the capture had been harvested — a post-window — and for the holdoff on top of that. On a sparse pulse train that rounds the capture spacing up to a whole pulse period: at the default 1 s window the blind stretch is 1 s, so a 1 Hz train was caught at 0.5 Hz and a wider window lost whole multiples. The comparator now keeps running through COLLECTING and TRIGGERED and remembers the first edge at or past trigTime + max(postSec, holdoffSec). The holdoff guards against re-triggering on the ringing of the same event and is measured from the trigger point, so it overlaps the post-window rather than adding to it. Rearm() fires on the remembered edge; it also keeps the tracked level, so the first sample after it has a real predecessor instead of being spent seeding one. Arm() stays the operator's arm and discards the held edge — they asked for the next event, not one already been and gone — and SetConfig() and Disarm() drop it too, since it was never judged against the new window. This is the same defect and the same remedy already validated in the Go hub (wshub/trigger.go, trigger_sporadic_test.go); the C++ hub had been left with the original semantics. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
fbae7d712c
commit
092fd3c775
@@ -88,9 +88,24 @@ public:
|
||||
*/
|
||||
uint32 GetConfigEpoch() const;
|
||||
|
||||
/** @brief Arm: any state → ARMED (resets edge detection). */
|
||||
/**
|
||||
* @brief Arm: any state → ARMED (resets edge detection).
|
||||
* This is the user's own arm, so it discards any edge remembered during the
|
||||
* previous capture: the user asked for the next event, not for one that has
|
||||
* already been and gone.
|
||||
*/
|
||||
void Arm();
|
||||
|
||||
/**
|
||||
* @brief The automatic arm at the end of a capture (normal mode).
|
||||
* Unlike Arm() it honours an edge seen while the capture was being
|
||||
* collected, firing on it at once rather than waiting for the next one, and
|
||||
* it keeps the tracked level so the first sample afterwards is compared
|
||||
* against its real predecessor. TRIGGERED → COLLECTING when an edge was
|
||||
* remembered, otherwise → ARMED.
|
||||
*/
|
||||
void Rearm();
|
||||
|
||||
/** @brief Disarm: any state → IDLE; clears the stopped flag. */
|
||||
void Disarm();
|
||||
|
||||
@@ -102,8 +117,10 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Edge-detect one decoded sample of the configured signal.
|
||||
* Receive-thread context. Only acts in ARMED state; on a matching edge
|
||||
* latches trigTime and the pre/post window and moves to COLLECTING.
|
||||
* Receive-thread context. In ARMED state a matching edge latches trigTime
|
||||
* and the pre/post window and moves to COLLECTING. While a capture is in
|
||||
* flight (COLLECTING/TRIGGERED) the comparator keeps running and the first
|
||||
* edge clear of that capture is remembered for the next Rearm().
|
||||
*/
|
||||
void CheckSample(float64 t, float64 v);
|
||||
|
||||
@@ -143,6 +160,21 @@ private:
|
||||
float64 firedPreSec_; ///< Window pre-part latched at fire time
|
||||
float64 firedPostSec_; ///< Window post-part latched at fire time
|
||||
bool firedValid_; ///< true after a fire, until Disarm()
|
||||
/**
|
||||
* The edge to fire on as soon as the FSM rearms, in sample time, recorded
|
||||
* while a capture is still being collected or handed out. Without it the
|
||||
* trigger is deaf from its own trigger point until the capture has been
|
||||
* harvested and the holdoff has run, and then waits for a fresh edge, which
|
||||
* on a sparse pulse train rounds the capture spacing up to a whole pulse
|
||||
* period. Remembering the edge instead makes the blind stretch exactly the
|
||||
* guard interval it has to be, since the capture is built from the edge's
|
||||
* own timestamp and the rings still hold everything around it.
|
||||
*/
|
||||
float64 pendingTime_;
|
||||
bool pendingValid_;
|
||||
|
||||
/** @brief Freeze the pre/post split at fire time; caller holds the mutex. */
|
||||
void LatchWindowLocked(float64 t);
|
||||
};
|
||||
|
||||
inline TriggerConfig::TriggerConfig()
|
||||
|
||||
Reference in New Issue
Block a user