Skip to content
21 changes: 21 additions & 0 deletions App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Threading;
using ArIED61850Tester.Services;

namespace ArIED61850Tester;

Expand All @@ -22,6 +23,20 @@ protected override void OnStartup(StartupEventArgs e)
WindowsApplicationIdentity.Apply();
base.OnStartup(e);

if (SclSafeTrialCommand.IsRequested(e.Args))
{
var trial = SclSafeTrialRunner.RunAsync(e.Args, CancellationToken.None)
.GetAwaiter()
.GetResult();
MessageBox.Show(
$"{trial.Message}\n\nEvidence: {trial.EvidencePath}",
trial.IsSuccess ? "SCL Safe Trial — PASS" : "SCL Safe Trial — NOT PROVEN",
MessageBoxButton.OK,
trial.IsSuccess ? MessageBoxImage.Information : MessageBoxImage.Warning);
Shutdown(trial.ExitCode);
return;
}

// P2 installs one calm industrial visual system before StartupUri materializes.
// Existing XAML keeps its semantic resource keys while the overlay replaces
// glare-heavy white/blue surfaces with Blue Steel + Light Greige equivalents.
Expand Down Expand Up @@ -64,6 +79,12 @@ protected override void OnActivated(EventArgs e)
// tiny P2 adapter when windows activate so newly opened FAT workspaces also
// inherit the selected industrial theme without touching engine workflows.
P2BlueSteelGreigeUx.ApplyToOpenWindows(this);

// Keep IED onboarding task-first without replacing the existing protocol owners:
// Add IED offers SCL-first or live-IP discovery, and bulk connect is surfaced only
// when more than one loaded IED makes the action useful.
if (Current?.MainWindow is MainWindow mainWindow)
SmartIedOnboardingBehavior.Install(mainWindow);
}

private void InstallP2BlueSteelGreigeTheme()
Expand Down
29 changes: 29 additions & 0 deletions Services/Iec61850ConnectionPathPolicy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using ArIED61850Tester.Models;

namespace ArIED61850Tester.Services;

public enum Iec61850ConnectionPath
{
FullDiscovery,
CachedLiveModel,
SclAssisted
}

/// <summary>
/// Pure routing policy. SCL design authority is distinct from a saved live-discovery
/// cache: Play/Connect uses the SCL-assisted path, while Re-scan remains an explicit
/// caller of full discovery.
/// </summary>
public static class Iec61850ConnectionPathPolicy
{
public static Iec61850ConnectionPath SelectForFastConnect(Iec61850MonitorDevice device)
{
ArgumentNullException.ThrowIfNull(device);

if (device.HasSclDesignModel)
return Iec61850ConnectionPath.SclAssisted;
if (device.HasDiscoveryCache && device.Signals.Count > 0)
return Iec61850ConnectionPath.CachedLiveModel;
return Iec61850ConnectionPath.FullDiscovery;
}
}
Loading
Loading