feat(scada): add manual monitoring timeline
Generic Container CI/CD / test-build-publish (push) Successful in 1m12s
Frontend CI/CD / build-test-publish-and-deploy (push) Successful in 1m12s

This commit is contained in:
2026-11-04 14:27:08 +08:00
parent 78481903d7
commit 0801e161ec
22 changed files with 1314 additions and 664 deletions
@@ -0,0 +1,18 @@
import type { ScadaReplay } from "../api/scada-replay-client";
/** Keep projection identity when polling only advances the replay clock. */
export function reuseScadaReadings(previous: ScadaReplay["latest"] | null | undefined, next: ScadaReplay["latest"]): ScadaReplay["latest"] {
if (previous?.length !== next.length) return next;
const unchanged = next.every((row, index) => {
const old = previous[index];
return old.device_id === row.device_id && old.time === row.time && old.quality === row.quality
&& old.reason === row.reason && Object.is(old.monitored_value, row.monitored_value)
&& Object.is(old.cleaned_value, row.cleaned_value);
});
return unchanged ? previous : next;
}
export function reuseReplayProjection(previous: ScadaReplay | null, next: ScadaReplay | null): ScadaReplay | null {
if (!next || previous?.replay_id !== next.replay_id) return next;
return { ...next, latest: reuseScadaReadings(previous.latest, next.latest) };
}