Skip to content

feat(dashboard): time-varying threshold specs in FastSenseWidget#204

Merged
HanSur94 merged 2 commits into
mainfrom
feat/widget-time-varying-thresholds
Jun 11, 2026
Merged

feat(dashboard): time-varying threshold specs in FastSenseWidget#204
HanSur94 merged 2 commits into
mainfrom
feat/widget-time-varying-thresholds

Conversation

@HanSur94

Copy link
Copy Markdown
Owner

Motivation

FastSense core already supports dynamic (time-varying) thresholdsaddThreshold(thX, thY, ...) draws step-function limits with full violation detection (compute_violations_dynamic + violation_cull MEX), label tracking on zoom, and clone support. But the Dashboard layer couldn't reach it: FastSenseWidget's 'Thresholds' option only understood scalar struct('Value',..) entries.

This matters for state-dependent limits (the classic case: a band that only applies while a machine is MEASURING). Discovered converting a legacy Zeiss monitoring system whose plots drew exactly such per-sample threshold series — dashboards built on FastSenseWidget had no way to reproduce them.

Change

Spec entries may now carry X/Y vectors instead of Value:

engine.addWidget('fastsense', 'Tag', sensorTag, 'Thresholds', { ...
    struct('Value', 28.5, 'Direction', 'upper', 'Label', 'UAL'), ...          % scalar, as before
    struct('X', thX, 'Y', thY, 'Direction', 'upper', 'Label', 'UWL')});       % time-varying
  • applyThresholds_ forwards X/Y entries to the core's existing time-varying form; NaN Y samples mean no limit here and break the drawn line
  • Scalar and time-varying entries mix freely in one spec; scalar behavior unchanged
  • autoscaleY_ folds the finite part of Y series into the auto Y-range (omitnan), matching scalar-Value handling

No core (FastSense.m) changes — pure pass-through plumbing.

Testing

  • testTimeVaryingThresholdSpecReachesFastSense — X/Y entry creates exactly one core threshold, keeps its per-sample series, carries no scalar Value, preserves Direction/Label
  • testMixedScalarAndTimeVaryingThresholds — both forms coexist in one spec
  • mh_style / mh_lint clean; MATLAB Code Analyzer clean on the touched regions (remaining findings pre-exist on main)
  • Exercised end-to-end (rendered, hidden + visible) against R2025b/macOS via an identical patch on a vendored snapshot driving 39 production-shaped dashboards

🤖 Generated with Claude Code

FastSense core has long supported dynamic limits —
addThreshold(thX, thY, ...) draws step-function thresholds with full
violation detection (compute_violations_dynamic + violation_cull MEX).
But FastSenseWidget's 'Thresholds' option only understood scalar
struct('Value',..) entries, so dashboards could never reach that
capability: state-dependent limits (e.g. a tighter band only while a
machine is MEASURING) had to be drawn as constant lines.

Spec entries may now carry X/Y vectors instead of Value:

  {struct('X', thX, 'Y', thY, 'Direction', 'upper', 'Label', 'UWL')}

applyThresholds_ forwards them to the core's time-varying form; NaN Y
samples mean "no limit here" and break the drawn line. Scalar and
time-varying entries mix freely in one spec. autoscaleY_ now folds the
finite part of Y series into the auto Y-range (omitnan), matching the
scalar-Value behavior.

Two new suite tests cover the X/Y pass-through (fields preserved,
Value stays empty) and scalar/time-varying coexistence.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.23810% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
libs/Dashboard/FastSenseWidget.m 95.23% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Threshold spec entries can now carry optional Color and LineStyle,
forwarded to FastSense.addThreshold so dashboards can severity-style
limit lines (e.g. warn yellow solid, alarm red solid) per entry instead
of inheriting the theme default for every line.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@HanSur94

Copy link
Copy Markdown
Owner Author

Reviewed: diff is backward-compatible (scalar specs unchanged, X/Y + Color/LineStyle additive), autoscale correctly folds finite Y with omitnan and skips all-NaN series. Local TestFastSenseWidget: 19/19 passed (R2025b). CI: sole failure is the pre-existing testPreviewStillFull render-cache regression on main (first red at 2355661) — unrelated to this PR.

🤖 Generated with Claude Code

@HanSur94 HanSur94 merged commit b3ccd48 into main Jun 11, 2026
19 of 20 checks passed
@HanSur94 HanSur94 deleted the feat/widget-time-varying-thresholds branch June 11, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant