Fixed triggering mode change when acquiring

This commit is contained in:
Martino Ferrari committed 2026-10-01 17:54:17 +02:00
1 parent 3d4085898e
commit 0d741c401b
10 files changed
+504 -106

No files matched your search

+31
View File
@@ -349,6 +349,32 @@ void Acquisition::on_data(const udps_frame_t* frame) {
model_.trigger_armed().store(true, std::memory_order_relaxed);
}
} else if (engine.armed()) {
// Disarm cuts a capture in progress where it got to and keeps it, instead of
// discarding it. `engine.disarm()` clears `pending_`, which drops the display out of
// `Capturing`; with nothing published the view fell back to the *previous* event, or
// to blank if this was the first -- the capture the user was watching simply
// vanished. Publishing first means the same snapshot path freezes it, so what is on
// screen at the moment of the Disarm stays on screen.
//
// The full post window is requested and `live_window_locked()` clips it to what the
// rings hold, so the snapshot ends at the newest sample and reports its own shorter
// `post_s` -- the same way a first latch whose pre window was short reports its own
// `pre_s`. No event fired, so `trigger_latches()` is deliberately *not* bumped; the
// UI notices the new picture through `event_seq()`.
if (engine.pending()) {
const double edge = engine.last_trigger_time();
model_.publish_event(event_span - post_want, post_want, edge);
model_.trigger_time().store(edge, std::memory_order_relaxed);
model_.trigger_time_valid().store(true, std::memory_order_relaxed);
auto snap = model_.event();
std::fprintf(stderr,
"[udpscope] trigger: disarmed mid-capture, edge at %.3f s kept as "
"[-%.4f..%.4f] n=%llu (post window asked %.4f s, filled %.4f s)\n",
edge, snap ? snap->pre_s : 0.0, snap ? snap->post_s : 0.0,
static_cast<unsigned long long>(snap ? snap->stamps.size() : 0), post_want,
engine.post_elapsed());
std::fflush(stderr);
}
engine.disarm();
model_.trigger_armed().store(false, std::memory_order_relaxed);
}
@@ -437,6 +463,11 @@ void Acquisition::on_data(const udps_frame_t* frame) {
last_stamp_ = last_stamp_used;
model_.trigger_armed().store(engine.armed(), std::memory_order_relaxed);
// The edge goes out before the flag that makes the UI read it (release/acquire on
// `trigger_pending`), so a tick that sees a capture open sees which edge it is for. A
// capture that opens and latches inside this one frame never reports pending, and that
// is right: the display goes straight to the frozen event.
if (engine.pending()) model_.set_capture_edge(engine.last_trigger_time());
model_.set_trigger_pending(engine.pending());
static std::int64_t next_engine_log = 0;
const std::int64_t now_e = static_cast<std::int64_t>(frame->recv_time * 1.0e6);