P1D: redesign COMTRADE as synchronized disturbance workspace - #295
P1D: redesign COMTRADE as synchronized disturbance workspace#295masarray wants to merge 13 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 49d7f12a27
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (TryResolveDisturbanceCursorFrame(out var cursorFrame)) | ||
| return cursorFrame; |
There was a problem hiding this comment.
Resolve the fallback from the visible disturbance viewport
When Cursor A is unset after the user zooms or pans the disturbance view, this falls through to ResolveAnalysisReferenceFrame, which still derives its center from the hidden legacy waveform's _requestedSourceViewport/_loadedSourceViewport. Those fields are never synchronized with either the disturbance source viewport or its local time zoom, so Phasor/Harmonics can be calculated at the full-record center while the UI labels the reference as the viewport center. Derive the fallback frame from the current DisturbanceView time bounds and disturbance source data instead.
Useful? React with 👍 / 👎.
| var fraction = Math.Clamp((cursor - start) / (end - start), 0.0, 1.0); | ||
| var offset = _disturbanceLoadedViewport.FrameCount <= 1 | ||
| ? 0UL | ||
| : checked((ulong)Math.Round((_disturbanceLoadedViewport.FrameCount - 1) * fraction, MidpointRounding.AwayFromZero)); | ||
| frame = Math.Min(_record.Info.FrameCount - 1, _disturbanceLoadedViewport.StartFrame + offset); |
There was a problem hiding this comment.
Map reduced-view cursors using timestamps instead of frame fractions
For records above ExactSignalFrameLimit, this maps the cursor's time fraction directly to a frame fraction. Valid COMTRADE records can contain multiple sample-rate sections, so elapsed time is not proportional to frame number; a cursor placed on a displayed disturbance can therefore select a substantially different source frame for native phasor or harmonic analysis. Preserve the decimated series' source-frame indices and locate the nearest timestamp, rather than interpolating across the viewport frame count.
Useful? React with 👍 / 👎.
| <!-- Compatibility one-channel renderer retained internally during P1D migration. --> | ||
| <controls:ComtradeWaveformView x:Name="WaveformView" MinHeight="330" Visibility="Collapsed"/> |
There was a problem hiding this comment.
Stop loading the collapsed legacy waveform on row selection
Although the one-channel renderer is now permanently collapsed, SignalList still invokes SignalList_SelectionChanged, which calls LoadAndDisplaySignalAsync for every selected analysis-family row. On records above 500,000 frames this scans the selected channel's full source range and holds _nativeGate, delaying the requested phasor/harmonic calculation and overwriting disturbance status with information for an invisible view. Row selection should update _activeSignal without performing the obsolete waveform read.
Useful? React with 👍 / 👎.
| for (var i = 1; i < count; i++) | ||
| { | ||
| var before = track.Digital[i - 1] != 0; | ||
| var after = track.Digital[i] != 0; | ||
| if (before == after) continue; | ||
| var time = ComtradeTimeMath.ToMilliseconds(track.Timestamps[i], _record.Info.TimeMultiplier); |
There was a problem hiding this comment.
Preserve sampled digital transitions in the event table
When a large digital channel exceeds FullRecordDigitalTransitionCap, BuildDigitalTransitions retains every Nth actual transition; once N is even, consecutive retained entries in a toggling signal commonly have the same state. This filter then discards those retained transition timestamps, often leaving the protection timeline empty despite the bounded scan finding transitions. Build event rows from retained transition metadata/source frames rather than inferring events only from adjacent sampled states.
Useful? React with 👍 / 👎.
P1D.1 — synchronized disturbance analysis UX
Replace the one-selected-signal waveform model with a protection-engineering disturbance workspace while preserving ArdIrec native parsing/analysis and P1B large-record source reload.
Waveform / digital
Protection event timeline
Native analysis integration
Large records
Final validation
Exact field-test head:
49d7f12a2758dd12cd19c6a000ffab351966fccaKeep unmerged until field validation of the synchronized disturbance UX on a real protection COMTRADE record.