Repository navigation
fix(sv): truthful per-stream engineering scales, no-SCL 4I4V profile, safe power #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
masarray
merged 8 commits into
main
from
fix/sv-engineering-scaling-and-field-diagnostics-20261016
Oct 16, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0768e86
fix(sv): explicit per-stream measurement scaling, safe raw defaults a…
masarray 4d71836
ci(candidate): verify native Windows bugfix PR builds as distributabl…
masarray e9e55fb
test(sv): import engineering scale contract and reassert selected aut…
masarray 6b5988e
fix(scope): keep raw voltage/current autoranges isolated and prevent …
masarray fd55854
refactor(metering): single pure power authority rejects raw counts an…
masarray 9ae894e
test(metering): prohibit bogus megawatts and prove 1A/57.74V 30-degre…
masarray 21607ed
docs(lab): no-SCL metering, scaling authority and physical SV accepta…
masarray 9fd74d6
feat(metering): one-click copy diagnostics alongside selected SV scale
masarray File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # SV Engineering Units — independent capture lab | ||
|
|
||
| Process Bus Insight is receive-only. It cannot prove physical A/V scaling from | ||
| IEC 61850 SV packet identity, raw payload width, APPID, svID or a waveform plot. | ||
|
|
||
| ## Simple workflow (no SCL required) | ||
|
|
||
| 1. Run the publisher, select the receiving Ethernet/Npcap adapter in Process | ||
| Bus Insight, press **Run**, then select the *canonical* stream under SV Stream | ||
| Explorer. The separate broadcast diagnostic mirror remains independent. | ||
| 2. Check waveform and phase relationships immediately; this works in **Raw | ||
| counts (uncalibrated)** mode. RMS and waveform axes indicate **counts**. | ||
| P/Q/S/PF are unavailable rather than fictional MW/Mvar. | ||
| 3. In **Metering > SV units**, opt in to **4I+4V nominal (1 mA / 10 mV per | ||
| count)** *only* when that is the known mapping of the selected lab publisher. | ||
| For example, raw 1000 corresponds to 1.000 A; raw 5774 corresponds to | ||
| 57.74 V. This is not independent calibration or a universal SV rule. | ||
| 4. Check A/V RMS, 50 Hz, coherent phasors, waveform, P/Q/S and power factor. | ||
| Try changing a single phase while the publisher runs; compare the | ||
| timestamp-aligned evidence rather than screenshots taken at different times. | ||
| 5. Use **Diagnostics > Copy Evidence**. Text includes per-stream SV identity, | ||
| sample counters, decode and timing evidence, the selected engineering scale, | ||
| the operator authority warning, RMS A/V/count values and P/Q/S/PF. | ||
| 6. Select another stream: it defaults to **Raw counts** until explicitly | ||
| configured. Return to the first stream to restore its own scaling choice. | ||
| A fresh capture reset clears the analyzer's runtime state; select the | ||
| nominal profile again when needed. | ||
|
|
||
| ## Acceptance boundaries | ||
|
|
||
| - Known 4I+4V: `I=0.001 A/count`, `U=0.01 V/count`; voltage/current axes | ||
| have separate autorange and do not accept fixed A/V limits while uncalibrated. | ||
| - One coherent selected-stream snapshot owns waveform, RMS, phasor and power. | ||
| - Pure power regression: three phases at 57.74 V, 1 A and 30 degree angle | ||
| offset produce roughly 173.22 VA, 150 W and 86.61 var. Any raw-count, | ||
| missing-phase or nonfinite input rejects physical power. | ||
| - Packet quality, sample continuity, VLAN visibility, Npcap capture drops, | ||
| host arrival jitter and hardware PTP lock remain separate facts. | ||
| - Use locally held operator PCAP and physical ESP32-P4 to validate Windows | ||
| candidate; do not commit private recordings or identifying site data. | ||
| - A successful waveform or power calculation does not prove calibration, | ||
| hardware timestamp quality or that a real IED accepted SV. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| namespace ProcessBus.Core.Models; | ||
|
|
||
| /// <summary> | ||
| /// Explicit scale authority for a selected SV stream. Packet shape, svID, APPID, | ||
| /// and a missing SCL are NOT evidence of engineering calibration. | ||
| /// </summary> | ||
| public enum SvEngineeringScale | ||
| { | ||
| RawCounts = 0, | ||
| Nominal4I4V = 1 | ||
| } | ||
|
|
||
| public static class SvEngineeringScaleFactors | ||
| { | ||
| // This explicitly opted-in 4I+4V lab/nominal profile is 1 mA per | ||
| // current count and 10 mV per voltage count. It is NOT universal | ||
| // IEC 61850 SV scaling and must never be auto-selected by svID. | ||
| public static double Factor(SvEngineeringScale mode, string channel) | ||
| => mode == SvEngineeringScale.Nominal4I4V | ||
| ? (channel.StartsWith("U", StringComparison.OrdinalIgnoreCase) ? 0.01 : 0.001) | ||
| : 1.0; | ||
|
|
||
| public static string Unit(SvEngineeringScale mode, string channel) | ||
| => mode != SvEngineeringScale.Nominal4I4V | ||
| ? "counts" | ||
| : channel.StartsWith("U", StringComparison.OrdinalIgnoreCase) ? "V" : "A"; | ||
|
|
||
| public static bool IsPhysical(SvEngineeringScale mode) | ||
| => mode == SvEngineeringScale.Nominal4I4V; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| namespace ProcessBus.Core.Models; | ||
|
|
||
| // Physical watts/vars require real A/V units for every phase in one | ||
| // selected-stream coherent snapshot. Raw INT32 counts never qualify. | ||
| public readonly record struct SvPhysicalPowerTotals(double P, double Q, double S); | ||
|
|
||
| public static class SvPhysicalPowerMeter | ||
| { | ||
| public static bool TryCompute(AnalogValuesSnapshot snapshot, out SvPhysicalPowerTotals totals) | ||
| { | ||
| totals = default; | ||
| if (snapshot is null) return false; | ||
| var phases = new[] | ||
| { | ||
| (U: snapshot.Ua, I: snapshot.Ia), | ||
| (U: snapshot.Ub, I: snapshot.Ib), | ||
| (U: snapshot.Uc, I: snapshot.Ic) | ||
| }; | ||
| var p = 0.0; | ||
| var q = 0.0; | ||
| var s = 0.0; | ||
| foreach (var (u, i) in phases) | ||
| { | ||
| if (u.Unit != "V" || i.Unit != "A" || | ||
| u.RmsValue is not { } uRms || i.RmsValue is not { } iRms || | ||
| u.AngleDegrees is not { } uAngle || i.AngleDegrees is not { } iAngle || | ||
| !double.IsFinite(uRms) || !double.IsFinite(iRms) || | ||
| !double.IsFinite(uAngle) || !double.IsFinite(iAngle) || | ||
| uRms < 0 || iRms < 0) | ||
| return false; | ||
|
|
||
| var apparent = uRms * iRms; | ||
| var delta = (uAngle - iAngle) * Math.PI / 180.0; | ||
| p += apparent * Math.Cos(delta); | ||
| q += apparent * Math.Sin(delta); | ||
| s += apparent; | ||
| } | ||
| if (!double.IsFinite(p) || !double.IsFinite(q) || !double.IsFinite(s)) return false; | ||
| totals = new SvPhysicalPowerTotals(p, q, s); | ||
| return true; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.