diff --git a/FaultRecordUxBehavior.cs b/FaultRecordUxBehavior.cs index 2812514d1..b3e8e0ba5 100644 --- a/FaultRecordUxBehavior.cs +++ b/FaultRecordUxBehavior.cs @@ -197,8 +197,10 @@ private static void RefreshCapabilityState( Button fileButton, Button rcbButton) { - var hasGoose = device.SclWorkspace?.GooseStreams.Count > 0 || - device.LiveDiscoveryModel?.GooseControlBlocks.Count > 0; + // An Ethernet/Npcap probe is not evidence that this IED defines a GoCB. + // Connected IEDs require live-model proof; offline SCL inventory is + // explicitly advisory until the next association. + var hasGoose = device.HasGooseControlBlock; var hasSmv = device.SclWorkspace?.SampledValuesStreams.Count > 0 || device.LiveDiscoveryModel?.SampledValueControlBlocks.Count > 0; @@ -211,10 +213,10 @@ private static void RefreshCapabilityState( ApplyState( gooseButton, - hasGoose ? CapabilityState.Available : CapabilityState.ProbeReady, + hasGoose ? CapabilityState.Available : CapabilityState.Unavailable, hasGoose - ? $"Monitor IEC 61850 GOOSE frames for {device.Name}" - : $"Monitor raw GOOSE frames for {device.Name} (no GoCB model configured)"); + ? $"Open GOOSE monitoring for {device.Name} (GoCB present; frames still unverified)" + : $"{device.Name}: no {(device.IsConnected ? "live" : "SCL-declared")} GoCB; GOOSE unavailable"); ApplyState( smvButton, hasSmv ? CapabilityState.Available : CapabilityState.Unavailable, @@ -270,6 +272,8 @@ private static void OpenGooseWorkspace(MainWindow mainWindow, Iec61850MonitorDev { // The visible GOOSE capability pill is the operator's CTA. Route through // the same adapter-pick workflow as any other GOOSE shortcut. + if (!device.HasGooseControlBlock) + return; mainWindow.OpenIedGooseSubscriber(device); mainWindow.Activate(); } diff --git a/MainWindow.CommandPanelUx.cs b/MainWindow.CommandPanelUx.cs index 23052cd25..90a4785d8 100644 --- a/MainWindow.CommandPanelUx.cs +++ b/MainWindow.CommandPanelUx.cs @@ -215,8 +215,11 @@ private void ConfigureCommandPanelButton(Button button) // a control has received verified CDC evidence. Do not overwrite its // IsEnabled binding with ControlSupportsOperate (that would disable // the first-click preflight and create a dead control row). - if (content is "Open" or "Close") + if (content is "Open" or "Close" or "Model") { + // Open/Close retain their typed preflight; Model retains the + // connected-session read/write commissioning gate, even when + // ctlModel=0 and physical Operate must remain disabled. _configuredCommandButtons.Add(button, new Marker()); return; } diff --git a/MainWindow.IedGooseQuickStart.cs b/MainWindow.IedGooseQuickStart.cs index 02270805a..d539cf10b 100644 --- a/MainWindow.IedGooseQuickStart.cs +++ b/MainWindow.IedGooseQuickStart.cs @@ -88,13 +88,22 @@ private void InstallIedGooseQuickStart(UniformGrid actionGrid, Iec61850MonitorDe Child = icon } }; + // Same device authority as the visible GOOSE capability pill. + // The binding updates after live discovery/reconnect without polling. + button.SetBinding(UIElement.IsEnabledProperty, + new System.Windows.Data.Binding(nameof(Iec61850MonitorDevice.HasGooseControlBlock)) + { + Source = device, + Mode = System.Windows.Data.BindingMode.OneWay + }); button.Click += IedGooseQuickStart_Click; actionGrid.Children.Add(button); } private void IedGooseQuickStart_Click(object sender, RoutedEventArgs e) { - if (sender is Button { CommandParameter: Iec61850MonitorDevice device }) + if (sender is Button { CommandParameter: Iec61850MonitorDevice device } && + device.HasGooseControlBlock) OpenIedGooseSubscriber(device); } @@ -106,6 +115,8 @@ private void IedGooseQuickStart_Click(object sender, RoutedEventArgs e) /// internal void OpenIedGooseSubscriber(Iec61850MonitorDevice device) { + if (!device.HasGooseControlBlock) + return; SelectedDevice = device; _pendingIedGooseAutoStart = null; MainTabs.SelectedIndex = GooseSubscriberTabIndex; diff --git a/Models/MonitorModels.cs b/Models/MonitorModels.cs index cdd72b272..6ecbbbeea 100644 --- a/Models/MonitorModels.cs +++ b/Models/MonitorModels.cs @@ -738,10 +738,11 @@ public void RefreshCommandSignalProjection() private void RefreshCommandSignals() { - // Command Dock is an operator-action surface, not an inventory of - // selected CF/status-only objects. Keep those in Data Model/Signals. - // A typed live ctlModel and semantic CDC proof are mandatory here. - var selected = Iec61850ControlIdentity.DistinctOperable(Signals) + // Inventory membership is NOT operating authority. Show exact selected + // CO DataObjects including ZIV ctlModel=0 so commissioning can explicitly + // read/configure them; every physical action is still gated by typed + // live ctlModel + CDC proof in SignalDefinition/runtime. + var selected = Iec61850ControlIdentity.DistinctSelected(Signals) .OrderBy(signal => signal.SortPriority) .ThenBy(signal => signal.LogicalNode, StringComparer.OrdinalIgnoreCase) .ThenBy(signal => signal.Name, StringComparer.OrdinalIgnoreCase) @@ -749,7 +750,7 @@ private void RefreshCommandSignals() // Stable WPF row lifetime is an architectural invariant: report, // navigation, and repeated verification updates must never Reset the - // entire operator-action grid when the verified membership is unchanged. + // entire operator-action grid when the selected membership is unchanged. // Keep the same SignalDefinition objects (the control state authority), // and reconcile only actual membership/order changes. This small // operator command list deliberately uses granular notifications rather @@ -781,8 +782,18 @@ private void RefreshCommandSignals() } } + // Conservative GoCB evidence: current live association outranks saved SCL. + // Offline IEDs may expose a GoCB declared in their explicitly loaded SCL; + // a connected IED requires a GoCB in current live discovery, not an + // unrelated station capture capability or an advisory SCL entry. + [JsonIgnore] + public bool HasGooseControlBlock => IsConnected + ? LiveDiscoveryModel?.GooseControlBlocks.Count > 0 + : SclWorkspace?.GooseStreams.Count > 0; + public void RefreshComputed() { + Raise(nameof(HasGooseControlBlock)); Raise(nameof(EndpointText)); Raise(nameof(SclEndpointHint)); Raise(nameof(SignalCount)); diff --git a/docs/P109AA_ZIV_CONTROL_GO_CB_HANDOFF_2026-10-20.md b/docs/P109AA_ZIV_CONTROL_GO_CB_HANDOFF_2026-10-20.md new file mode 100644 index 000000000..40532bec1 --- /dev/null +++ b/docs/P109AA_ZIV_CONTROL_GO_CB_HANDOFF_2026-10-20.md @@ -0,0 +1,29 @@ +# ARSAS ZIV AVR selected-control inventory + per-IED GOOSE capability (2026-10-20) + +## Frozen approved UI source + +User explicitly approved integrated blue selection accent from UI Phase 3. Frozen checkpoint `checkpoint/arsas-phase3-bluebar-accepted-20261020` at `109b1f93eea0ddd47858c6e0ba6fd6ed9d54bb6f`, exact-source Windows CI run `39428581363` built commit `36568539605b4f07c2b9ced72fce4f504f6737f5` (identical source tree), all 10 PR workflows successful, 2,419 ARSAS + 24 engine + 6 packaged regressions, native and portable smoke pass. Do not force-update this checkpoint. This independent regression branch stacks on it. + +## Field evidence + +Attached ARSAS diagnostic `1.6.40+36568539`, 2026-10-20 20:49 WIB: two simultaneously connected/monitoring IEDs. ZIVAVR live discovery recorded **GoCB=3**, SIEBCU **GoCB=1**; the SCL and live models are device-specific. + +ZIVAVR has 5 selected CO DataObject roots: +- `ZIVAVRLD1/ATCC1.TapChg` (advisory SPC/BSC, live `ctlModel=0`) +- `ZIVAVRLD1/CSWI1.Pos` through `CSWI4.Pos` (DPC, live `ctlModel=0`). + +The exact live MMS read proof reports `ctlModel=0 (StatusOnly)` for all five. This **does not authorize SBOw/Operate**. A separate operator-initiated `ControlModelWriteWindow` already allows a conditional, exact single CF ctlModel write and mandatory readback. A verified post-write reinspection may *then* authorize an action if typed CDC, ctlVal, status, and semantic proof all succeed. + +## Root causes and implementation + +1. `Iec61850MonitorDevice.RefreshCommandSignals()` incorrectly used `DistinctOperable(Signals)` for **row membership** instead of `DistinctSelected(Signals)`. A valid control with ctlModel=0 vanished, making its deliberate commissioning workflow inaccessible. Now exact selected CO roots stay present with unchanged SignalDefinition identity; only live verified operability gates any write. In-place collection reconciliation remains; status-only changes never reset the whole grid. +2. Event-driven `ConfigureCommandPanelButton` applied `ControlSupportsOperate` to all buttons except Open/Close, silently overriding the per-session IsConnected binding on **Model**. Exclude Model from generic write gate; the Model dialog retains explicit live association checks and engine-mediated exact CF read/write/readback. No automatic ctlModel writes, retries, or bypasses. +3. `FaultRecordUxBehavior` treated missing GoCB as `ProbeReady` (enabled). It now requires `device.HasGooseControlBlock` (available or unavailable, never speculative probe). The per-IED read-only computed capability uses current live GoCB directory for connected devices or own SCL-declared directory offline; live empty overrides stale SCL. It notifies on connection/discovery/SCL changes. The legacy GoCB shortcut uses the *same* property with WPF binding and click guard, plus shared entry-point guard. Global GOOSE Sniff remains a separate manual raw capture feature. + +## Release / physical acceptance + +- Positive: five ZIV selected CO rows visible as StatusOnly; Model available on connected session; conditional CF configuration only after operator action; no Open/Close/SBO until successful exact readback + typed reinspection. +- Negative: live ctlModel=0, unknown, inspection pending, lost association, unsafe typed CDC/status -> all physical controls disabled. No MMS write created by tab switch, selection, card projection or GOOSE discovery. +- GOOSE positive: connected SIEBCU GoCB=1 and ZIVAVR GoCB=3 active; negative: connected 0 GoCB disabled even if saved SCL claims otherwise; no cross-IED leakage, reconnect updates enablement. GOOSE capture alone is not GoCB proof. +- Frozen visual: integrated blue rail, Command Dock white icons, one fixed under-IP progress slot. No UI XAML or ARIEC engine modified. +- Exact-head Windows CI + native bridge/package smoke then real relay FAT. Do not merge to main or claim real control safety without operator-isolated equipment test. diff --git a/tests/ARSAS.Tests/F650CanonicalCommandFailureTests.cs b/tests/ARSAS.Tests/F650CanonicalCommandFailureTests.cs index 67217d92d..ceaa04c2c 100644 --- a/tests/ARSAS.Tests/F650CanonicalCommandFailureTests.cs +++ b/tests/ARSAS.Tests/F650CanonicalCommandFailureTests.cs @@ -107,7 +107,9 @@ public void ProducersAndDispatcher_EnforceCanonicalIdentity() var projection = Read("Services/Iec61850StaticControlStatusProjectionService.cs"); Assert.Contains("Full DataObject is command identity", projection, StringComparison.Ordinal); var model = Read("Models/MonitorModels.cs"); - Assert.Contains("DistinctOperable(Signals)", model, StringComparison.Ordinal); + Assert.Contains("DistinctSelected(Signals)", model, StringComparison.Ordinal); + Assert.Contains("DistinctOperable(IEnumerable", + Read("Services/Iec61850ControlIdentity.cs"), StringComparison.Ordinal); Assert.Contains("ControlSupportsOperate", Read("Services/Iec61850ControlIdentity.cs"), StringComparison.Ordinal); var runtime = Read("Services/Iec61850MonitorRuntime.cs"); diff --git a/tests/ARSAS.Tests/F650CommandShoutIntegrationTests.cs b/tests/ARSAS.Tests/F650CommandShoutIntegrationTests.cs index bb201c6ff..afe86a7a2 100644 --- a/tests/ARSAS.Tests/F650CommandShoutIntegrationTests.cs +++ b/tests/ARSAS.Tests/F650CommandShoutIntegrationTests.cs @@ -222,7 +222,9 @@ public void IdentityProjection_AndSingleFlightProtection_StillActive() { var model = Read("Models/MonitorModels.cs"); var runtime = Read("Services/Iec61850MonitorRuntime.cs"); - Assert.Contains("Iec61850ControlIdentity.DistinctOperable(Signals)", model, StringComparison.Ordinal); + Assert.Contains("Iec61850ControlIdentity.DistinctSelected(Signals)", model, StringComparison.Ordinal); + Assert.Contains("DistinctOperable(IEnumerable", + Read("Services/Iec61850ControlIdentity.cs"), StringComparison.Ordinal); Assert.Contains("ControlSupportsOperate", Read("Services/Iec61850ControlIdentity.cs"), StringComparison.Ordinal); Assert.Contains("_activeControlTargets.TryAdd(targetKey, 0)", runtime, StringComparison.Ordinal); diff --git a/tests/ARSAS.Tests/IoListFatCommandPanelRegressionTests.cs b/tests/ARSAS.Tests/IoListFatCommandPanelRegressionTests.cs index 904d2ad80..c4026496d 100644 --- a/tests/ARSAS.Tests/IoListFatCommandPanelRegressionTests.cs +++ b/tests/ARSAS.Tests/IoListFatCommandPanelRegressionTests.cs @@ -84,11 +84,10 @@ public void FatCommandPanel_RemainsFailClosedForStatusOnlyOrUnsupportedControls( Assert.Contains("ControlSupportsOperate", bridge, StringComparison.Ordinal); Assert.Contains("StatusOnly", bridge, StringComparison.Ordinal); Assert.Contains("device.CommandSignals", bridge, StringComparison.Ordinal); - // Full selected control inventory remains in Signals; the FAT Dock - // shares only semantic-verified actionable controls and keeps the - // same execution gate as Engineering. Status-only items remain in - // Data Model and the selected inspection inventory. - Assert.Contains("DistinctOperable(Signals)", monitorModels, StringComparison.Ordinal); + // Selected CO objects remain visible for explicit commissioning. + // Real authorization is still verified by the runtime/typed model. + Assert.Contains("DistinctSelected(Signals)", monitorModels, StringComparison.Ordinal); + Assert.Contains("DistinctOperable(IEnumerable", identity, StringComparison.Ordinal); Assert.Contains("ControlSupportsOperate", identity, StringComparison.Ordinal); // A verified-only UI is not a replacement for runtime authorization. Assert.Contains("ControlModelResolved && s.ControlSupportsOperate", identity, StringComparison.Ordinal); diff --git a/tests/ARSAS.Tests/P109AAZivCommandAndGoCbCardTests.cs b/tests/ARSAS.Tests/P109AAZivCommandAndGoCbCardTests.cs new file mode 100644 index 000000000..1a7f332bd --- /dev/null +++ b/tests/ARSAS.Tests/P109AAZivCommandAndGoCbCardTests.cs @@ -0,0 +1,122 @@ +using System.Collections.Specialized; +using AR.Iec61850.Discovery; +using ArIED61850Tester.Models; +using ArIED61850Tester.Services; + +namespace ARSAS.Tests; + +/// +/// Regression from ZIV AVR physical diagnostic 2026-10-20: +/// five selected CO roots with live ctlModel=0 must remain visible for +/// explicit model commissioning, while ALL wire commands remain prohibited. +/// +public sealed class P109AAZivCommandAndGoCbCardTests +{ + private static SignalDefinition Row(string fullReference, string cdc, string model = "Status only") + => new() + { + Name = fullReference.Split('.').Last(), + ObjectReference = fullReference, + FunctionalConstraint = "CO", + IsControlSignal = true, + IsSelected = true, + ControlCdc = cdc, + ControlModelText = model + }; + + [Fact] + public void FiveZivStatusOnlyRootsStayStableAndCannotSendWireCommands() + { + var device = new Iec61850MonitorDevice { Name = "ZIVAVR" }; + var refs = new[] { + "ZIVAVRLD1/ATCC1.TapChg", + "ZIVAVRLD1/CSWI1.Pos", + "ZIVAVRLD1/CSWI2.Pos", + "ZIVAVRLD1/CSWI3.Pos", + "ZIVAVRLD1/CSWI4.Pos" }; + var controls = refs.Select((id,i)=>Row(id,i==0?"BSC":"DPC")).ToArray(); + device.Signals.ReplaceAll(controls); + device.RecountSelectedSignals(); + Assert.Equal(5, device.SelectedControlSignalCount); + Assert.Equal(5, device.CommandSignals.Count); + Assert.Empty(Iec61850ControlIdentity.DistinctOperable(device.Signals)); + var changes = new List(); + device.CommandSignals.CollectionChanged += (_,e)=>changes.Add(e.Action); + for (var index=0;index<25;index++) device.RefreshCommandSignalProjection(); + Assert.Empty(changes); + foreach(var control in controls) + { + Assert.Contains(control,device.CommandSignals); + Assert.Equal(Iec61850ControlModelKind.StatusOnly,control.ControlModelKind); + Assert.False(control.ControlSupportsOperate); + Assert.False(control.TryStageControlConfirmation("Open [01]","Open",out _)); + Assert.False(control.TryBeginDirectControlCommand("Open [01]","Open",out _,out _)); + } + // A detached SCL/ctlModel label alone must not grant authorization. + controls[1].ControlModelText = "Select Before Operate (SBO) • Enhanced security"; + device.RefreshCommandSignalProjection(); + Assert.Equal(5,device.CommandSignals.Count); + Assert.False(controls[1].ControlSupportsOperate); + Assert.Empty(Iec61850ControlIdentity.DistinctOperable(device.Signals)); + } + + [Fact] + public void GoCbAvailabilityIsPerIedAndLiveDiscoveryOverridesStaleScl() + { + var noGoose = new Iec61850MonitorDevice { Name = "NO_GOCB" }; + var withGoose = new Iec61850MonitorDevice { Name = "ZIVAVR" }; + noGoose.IsConnected = true; + withGoose.IsConnected = true; + var changes = new List(); + withGoose.PropertyChanged += (_,e)=>changes.Add(e.PropertyName); + noGoose.LiveDiscoveryModel = new LiveIedModelDiscoveryDocument(); + withGoose.LiveDiscoveryModel = new LiveIedModelDiscoveryDocument + { + GooseControlBlocks = [new LiveIedControlBlockModel + { + Name = "gcb1", Kind = "GOOSE", Domain = "LD1", + LogicalNode = "LLN0", Reference = "LD1/LLN0.GO.gcb1" + }] + }; + Assert.False(noGoose.HasGooseControlBlock); + Assert.True(withGoose.HasGooseControlBlock); + Assert.Contains(nameof(Iec61850MonitorDevice.HasGooseControlBlock),changes); + withGoose.LiveDiscoveryModel = new LiveIedModelDiscoveryDocument(); + Assert.False(withGoose.HasGooseControlBlock); + Assert.False(noGoose.HasGooseControlBlock); + // Do not reuse an old association's GoCB count after teardown. + withGoose.IsConnected = false; + Assert.False(withGoose.HasGooseControlBlock); + } + + [Fact] + public void ModelRemainsClickableAndBothGooseEntryPointsRequireGoCb() + { + string Read(string name) + { + var folder = new DirectoryInfo(AppContext.BaseDirectory); + while(folder != null) + { + var target = Path.Combine(folder.FullName,name); + if(File.Exists(target)) return File.ReadAllText(target); + folder = folder.Parent; + } + throw new FileNotFoundException(name); + } + var xaml = Read("MainWindow.xaml"); + var ux = Read("MainWindow.CommandPanelUx.cs"); + var cap = Read("FaultRecordUxBehavior.cs"); + var legacy = Read("MainWindow.IedGooseQuickStart.cs"); + var models = Read("Models/MonitorModels.cs"); + Assert.Contains("DistinctSelected(Signals)",models,StringComparison.Ordinal); + Assert.DoesNotContain("DistinctOperable(Signals)",models,StringComparison.Ordinal); + Assert.Contains("if (content is \"Open\" or \"Close\" or \"Model\")",ux,StringComparison.Ordinal); + Assert.Contains("Content=\"Model\"",xaml,StringComparison.Ordinal); + Assert.Contains("IsEnabled=\"{Binding ControlSupportsOperate}\"",xaml,StringComparison.Ordinal); + Assert.Contains("hasGoose ? CapabilityState.Available : CapabilityState.Unavailable",cap,StringComparison.Ordinal); + Assert.Contains("var hasGoose = device.HasGooseControlBlock;",cap,StringComparison.Ordinal); + Assert.Contains("if (!device.HasGooseControlBlock)",cap,StringComparison.Ordinal); + Assert.Contains("nameof(Iec61850MonitorDevice.HasGooseControlBlock)",legacy,StringComparison.Ordinal); + Assert.Contains("device.HasGooseControlBlock)",legacy,StringComparison.Ordinal); + } +} diff --git a/tests/ARSAS.Tests/P109LControlRecoveryTests.cs b/tests/ARSAS.Tests/P109LControlRecoveryTests.cs index c4416efc5..5dd9327bf 100644 --- a/tests/ARSAS.Tests/P109LControlRecoveryTests.cs +++ b/tests/ARSAS.Tests/P109LControlRecoveryTests.cs @@ -18,7 +18,7 @@ private static SignalDefinition Control(string reference, string cdc, bool selec }; [Fact] - public void FiveZivControlsRemainInInventoryButDockWaitsForTypedInspection() + public void FiveZivControlsRemainVisibleForModelCommissioning_ButCannotOperate() { var device = new Iec61850MonitorDevice(); foreach (var (reference, cdc) in new[] { @@ -32,7 +32,7 @@ public void FiveZivControlsRemainInInventoryButDockWaitsForTypedInspection() device.RecountSelectedSignals(); Assert.Equal(5, device.SelectedControlSignalCount); - Assert.Empty(device.CommandSignals); + Assert.Equal(5, device.CommandSignals.Count); var inventory = Iec61850ControlIdentity.DistinctSelected(device.Signals); Assert.Equal(5, inventory.Length); Assert.Equal(5, Iec61850ControlIdentity.InspectionRepresentatives(device.Signals).Length); @@ -57,7 +57,7 @@ public void UninspectedAndStatusOnlyRemainInCatalogWithAllWritesBlocked() device.Signals.Add(readOnly); device.RecountSelectedSignals(); - Assert.Empty(device.CommandSignals); + Assert.Equal(2, device.CommandSignals.Count); Assert.Equal(2, Iec61850ControlIdentity.DistinctSelected(device.Signals).Length); Assert.All(device.Signals, s => Assert.False(s.ControlSupportsOperate)); Assert.Single(Iec61850ControlIdentity.InspectionRepresentatives(device.Signals)); diff --git a/tests/ARSAS.Tests/P109MControlDockPresentationTests.cs b/tests/ARSAS.Tests/P109MControlDockPresentationTests.cs index ec5466558..af6adabe7 100644 --- a/tests/ARSAS.Tests/P109MControlDockPresentationTests.cs +++ b/tests/ARSAS.Tests/P109MControlDockPresentationTests.cs @@ -41,7 +41,7 @@ public void StatusOnly_DoesNotEraseDeclaredButtons_AndCommandsRemainBlocked( } [Fact] - public void CommandDockNeverIncludesStatusOnlyUnknownOrUnverifiedControls() + public void CommandDockShowsSelectedControlObjectsWithoutAuthorizingUnverifiedOnes() { var device = new Iec61850MonitorDevice(); var readOnly = Control("C264CONTROL/CSWI1.Mod", "ENC"); @@ -56,23 +56,30 @@ public void CommandDockNeverIncludesStatusOnlyUnknownOrUnverifiedControls() Assert.True(verified.ControlSupportsOperate); device.Signals.ReplaceAll([readOnly, unknown, unsafeSemantic, verified]); device.RecountSelectedSignals(); - Assert.Single(device.CommandSignals); - Assert.Same(verified, device.CommandSignals[0]); + Assert.Equal(4, device.CommandSignals.Count); + Assert.Contains(verified, device.CommandSignals); + Assert.Contains(readOnly, device.CommandSignals); + Assert.False(readOnly.ControlSupportsOperate); + Assert.False(unknown.ControlSupportsOperate); + Assert.False(unsafeSemantic.ControlSupportsOperate); + Assert.Single(Iec61850ControlIdentity.DistinctOperable(device.Signals)); Assert.Equal(4, Iec61850ControlIdentity.CountSelected(device.Signals)); // Connected inspection makes another Pos operable without a new // selection wizard, cache or second command model. unsafeSemantic.ControlSemanticVerified = true; device.RefreshCommandSignalProjection(); - Assert.Equal(2, device.CommandSignals.Count); - Assert.DoesNotContain(device.CommandSignals, x => x.Name == "Mod"); - Assert.DoesNotContain(device.CommandSignals, x => x.ControlModelKind == + Assert.Equal(4, device.CommandSignals.Count); + Assert.Equal(2, Iec61850ControlIdentity.DistinctOperable(device.Signals).Length); + Assert.Contains(device.CommandSignals, x => x.Name == "Mod"); + Assert.Contains(device.CommandSignals, x => x.ControlModelKind == Iec61850ControlModelKind.StatusOnly); - // Lost association revokes command authority in the same projection. + // Lost association revokes command authority, not operator inventory. verified.ClearLiveControlAuthority(); unsafeSemantic.ClearLiveControlAuthority(); device.RefreshCommandSignalProjection(); - Assert.Empty(device.CommandSignals); + Assert.Equal(4, device.CommandSignals.Count); + Assert.Empty(Iec61850ControlIdentity.DistinctOperable(device.Signals)); } [Fact] diff --git a/tests/ARSAS.Tests/P109UStableCommandProjectionTests.cs b/tests/ARSAS.Tests/P109UStableCommandProjectionTests.cs index 4d3ce37e0..bf82700f3 100644 --- a/tests/ARSAS.Tests/P109UStableCommandProjectionTests.cs +++ b/tests/ARSAS.Tests/P109UStableCommandProjectionTests.cs @@ -1,5 +1,6 @@ using System.Collections.Specialized; using ArIED61850Tester.Models; +using ArIED61850Tester.Services; namespace ARSAS.Tests; @@ -53,7 +54,7 @@ public void IdenticalVerifiedCatalog_NeverEmitsResetOrRecreatesRows() } [Fact] - public void GenuineAuthorityRevocation_RemovesOnlyAffectedRowAndNeverResetsGrid() + public void GenuineAuthorityRevocation_DisablesOnlyAffectedRowWithoutResettingGrid() { var first = Verified("LD0/CSWI1.Pos"); var second = Verified("LD0/CSWI2.Pos"); @@ -67,21 +68,23 @@ public void GenuineAuthorityRevocation_RemovesOnlyAffectedRowAndNeverResetsGrid( first.ClearLiveControlAuthority(); device.RefreshCommandSignalProjection(); - Assert.Single(device.CommandSignals); - Assert.Same(second, device.CommandSignals[0]); - Assert.Equal(new[] { NotifyCollectionChangedAction.Remove }, events); + Assert.Equal(2, device.CommandSignals.Count); + Assert.Same(first, device.CommandSignals[0]); + Assert.Same(second, device.CommandSignals[1]); + Assert.False(first.ControlSupportsOperate); + Assert.Empty(events); // Fresh live-typed authority is mandatory before the control can return. first.AcceptVerifiedLiveControlCdc("DPC"); first.ControlSemanticVerified = true; device.RefreshCommandSignalProjection(); Assert.Equal(2, device.CommandSignals.Count); - Assert.Contains(NotifyCollectionChangedAction.Add, events); - Assert.DoesNotContain(NotifyCollectionChangedAction.Reset, events); + Assert.True(first.ControlSupportsOperate); + Assert.Empty(events); } [Fact] - public void StatusOnlyAndUnknownObjectsNeverEnterOperatorGrid() + public void StatusOnlyAndUnknownObjectsRemainVisibleButCannotOperate() { var valid = Verified("LD0/CSWI1.Pos"); var readonlyControl = Verified("LD0/CSWI2.Pos"); @@ -93,8 +96,11 @@ public void StatusOnlyAndUnknownObjectsNeverEnterOperatorGrid() device.Signals.ReplaceAll([valid, readonlyControl, unknownControl]); device.RecountSelectedSignals(); - Assert.Single(device.CommandSignals); - Assert.Same(valid, device.CommandSignals[0]); + Assert.Equal(3, device.CommandSignals.Count); + Assert.Contains(valid, device.CommandSignals); + Assert.Contains(readonlyControl, device.CommandSignals); + Assert.Contains(unknownControl, device.CommandSignals); + Assert.Single(Iec61850ControlIdentity.DistinctOperable(device.Signals)); Assert.False(readonlyControl.ControlSupportsOperate); Assert.False(unknownControl.ControlSupportsOperate); } diff --git a/tests/ARSAS.Tests/P109WCommandDockLifecycleArchitectureTests.cs b/tests/ARSAS.Tests/P109WCommandDockLifecycleArchitectureTests.cs index aa1f20d31..8a585c391 100644 --- a/tests/ARSAS.Tests/P109WCommandDockLifecycleArchitectureTests.cs +++ b/tests/ARSAS.Tests/P109WCommandDockLifecycleArchitectureTests.cs @@ -124,7 +124,7 @@ public void FirstClickOpenCloseStillUsesReadOnlyModelPreflight() { var source = Source("MainWindow.CommandPanelUx.cs"); var xaml = Source("MainWindow.xaml"); - Assert.Contains("if (content is \"Open\" or \"Close\")", source, StringComparison.Ordinal); + Assert.Contains("if (content is \"Open\" or \"Close\" or \"Model\")", source, StringComparison.Ordinal); Assert.Contains("IsEnabled=\"{Binding ControlCanInspectPosition}\"", xaml, StringComparison.Ordinal); Assert.Contains("var enabledBinding = new MultiBinding", source, StringComparison.Ordinal); }