Skip to content

Refactor/extract capture engine - #10

Merged
Fyfar merged 11 commits into
mainfrom
refactor/extract-capture-engine
Oct 8, 2026
Merged

Fyfar merged 11 commits into
mainfrom
refactor/extract-capture-engine

Conversation

@Fyfar

@Fyfar Fyfar commented Oct 3, 2026

Copy link
Copy Markdown
Owner

No description provided.

Fyfar added 11 commits October 3, 2026 11:43
Move the per-batch read loop (stable-run detection, trigger edges with
hysteresis, discontinuity handling, both capture latches, mode-change
flush/preserve, staged append, session stats, histogram counts and the
Pass/Fail rows) out of app/page.tsx into a stateful CaptureEngine class
with no React dependency. ingest(readings) returns a BatchResult that the
page commits to state once per batch, in the original setter order.

Behaviour-preserving: same features, same known limitations. Settings,
trigger armed/threshold and Pass/Fail config still reach the loop through
separate effects with the original timing.

Add scripts/check-capture.mts, a characterization check of current
engine behaviour, to npm run check. Bump version to 1.8.1.
… CSV

Pass/Fail captured verdicts and played tones on every view whenever a
reference was set, so a cleared batch kept filling and beeping from the
Dashboard. Capture is now gated on the Pass/Fail view being open. The
reference, tolerance and stored rows are kept when leaving it, and the
probe-lift re-arm keeps running, so a held part is not re-captured on
return.

Pass/Fail rows now follow "Keep log on mode change" like the Data Log:
kept when on, cleared when off. The reference is still cleared on any
mode change. Measured Spread covers only the rows since the last mode
change, so it never mixes units. The setting's help text says so.

The verdict CSV wrote float noise (-11.100000000000023 for -11.1).
verdictCsvLine strips division noise from Measured and Reference and
computes Deviation from them, rounded to the finer operand's decimals.
Rounding the result is not enough because near-equal operands cancel.
- Move LSD/equal-width binning from RealtimeChart into lib/histogram.ts,
  returning numeric bins instead of label strings; bins and counts are
  identical to before.
- Histogram x-axis now uses one shared SI prefix (in the axis title) via
  new siAxisScale, also used by the line y-axis. Fixes raw labels like
  "11113000" for an ~11 MΩ session; capacitance reads in prefixed farads.
- Zero extent falls back to one base unit, so capacitance never shows a
  bare "F" (axis or Statistics zero); Ω/V/A unchanged.
- Add check-histogram.mts (28 assertions) and siAxisScale checks.
- v1.8.2
…port

Pass/Fail rows now record the meter's unit token and digit count at
capture. The verdict CSV writes Measured as the meter showed it
(3.000,MOM / 470.0,nF), with Reference and Deviation in that row's unit,
instead of plain ohms/farads (3000000 / 4.7e-7). Deviation is still
recomputed from the exported values, so it stays free of float noise.

BREAKING CHANGE: verdict CSV Measured/Reference/Deviation/Unit columns
are now in the meter's range unit per row, not SI base units.
Data Log table, its search, and both CSV exports now show local time as
ISO 8601 with the UTC offset (2026-10-03T17:29:05.123+03:00) instead of
UTC with Z. The Pass/Fail table already showed local time; its CSV now
agrees. One formatter (localIso + its per-second cache) feeds all of them,
so screen, search and files show the same string.

check-search runs under five zones (UTC, DST, -03:30, +05:45, +12:45),
compares against an independent offset-shift reference, and crosses a
DST switch to exercise the per-second cache.

BREAKING CHANGE: CSV Timestamp columns are local time with offset, not UTC.
…n screen; CSV BOM

- Pass/Fail readout, Measured and Deviation use formatSiValue at the reading's LSD:
  trailing zeros kept, no fixed digit count, no '+0 F' / '-0 pF' on an exact match
- Pass/Fail time column is the CSV timestamp's time part (24h, ms)
- ASCII uF displays as µF on screen; CSVs keep the wire token
- Both CSVs start with a UTF-8 BOM so Excel decodes ±, Ω and non-Latin notes
- v2.0.1
Duplication (jscpd):
- RecordButton shared by Controls and DataLog
- copyChunk in SampleStore for snapshot()/from()

Readability:
- page.tsx: persisted settings held as one object; load/save no longer
  repeat the 13-field list. Drop write-only autoScaleRef/timeRangeRef.
  Header extracted to AppHeader.
- Settings view takes settings + onChange(patch) instead of 14 props.
- lib/passfail: parseEntry is the one ref/tol/band derivation used by both
  the engine config and the Pass/Fail view; summarizeBatch moves the
  yield/spread scan out of the component (+6 assertions).
- PassFail: UnsupportedMode and Tile components.
- RealtimeChart: histogram branch extracted to drawHistogram; clsx instead
  of a template-literal className; drop duplicate unitRef write; fix
  truncated "line view unavailable" copy.
fallow audit runs in CI on PRs and branches against origin/main: new dead
code or duplication fails the check, complexity only annotates. CRAP is
disabled (no coverage data); public/sw.js is declared dynamically loaded.

Clears every existing finding instead of suppressing it: unexported
ChartType, folds the mirrored min/max merge in RenderTier, and extracts
shared helpers in check-tier (columnExtremes, grownAndDirect) and
check-capture (tenKOnView).
@Fyfar
Fyfar merged commit 0869a0e into main Oct 8, 2026
3 checks passed
@Fyfar
Fyfar deleted the refactor/extract-capture-engine branch October 8, 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