test(grpc-data): A1 L4 — signal-latency LiveIntegration harness + measured evidence (OpcUaClient, FOCAS, MTConnect, AbCip; Galaxy/Heidenhain blocked)

This commit is contained in:
Joseph Doherty
2026-11-24 10:32:14 -05:00
parent 141e4412d2
commit 3c2cf96af2
5 changed files with 394 additions and 0 deletions
@@ -0,0 +1,92 @@
# A1 exit gate L4: native initial-alarm-state signal latency
Plan `docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md` (rev. 7), §9.3 row L4. Measured 2026-11-24 on branch
`worktree-agent-ad44f71fa7ab46039`, from the macOS dev host against the shared Docker host `10.100.0.35`. One AbCip leg ran
against a private local container (see that row).
## What is measured
For each native alarm source, the latency from **quality Good** to the driver's first
`IAlarmInitialStateSignal.InitialAlarmStateDelivered`.
- **Quality Good** is the moment the driver's `InitializeAsync` returns. That is when `DriverInstanceActor` enters
`Connected` and the host starts its F5 window (`OnConditionSignalConnectivity`).
- The driver is then subscribed to its alarm refs (as the actor does) and the stopwatch stops in the signal handler.
- **"with connect"** also counts `InitializeAsync` itself. It is an upper bound for a cold start.
- **N = 20 per leg.** Each sample is a fresh driver instance: connect, alarm subscribe, first read/refresh, signal, then shutdown.
- **p50 / p99** use the nearest-rank method. With N = 20, p99 is the maximum.
- All fixture use was **read-only**: no fixture was restarted or reconfigured, and no alarm was scheduled on any mock.
The harness is a set of `Category=LiveIntegration`, `Phase=L4` tests:
- `tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.IntegrationTests/OpcUaClientAlarmSignalLatencyTests.cs`
- `tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.IntegrationTests/FocasAlarmSignalLatencyTests.cs`
- `tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.MTConnect.IntegrationTests/MTConnectAlarmSignalLatencyTests.cs`
- `tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbCip.IntegrationTests/AbCipAlarmSignalLatencyTests.cs`
To re-run a leg:
```bash
OTOPCUA_L4_RESULTS=/path/l4.jsonl timeout 1200 dotnet test tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.<X>.IntegrationTests \
--filter "Phase=L4" --blame-hang-timeout 300s
# AbCip additionally needs OTOPCUA_L4_ALMD_ENDPOINT=<host:port> of an ab_server with the AlmA.* tags (below).
```
## Results
| Source | Fixture | Signal path measured | N | p50 (ms) | p99 (ms) | with connect p50 / p99 (ms) | `ConditionKnownSignalTimeout` |
|---|---|---|---|---|---|---|---|
| OpcUaClient | `otopcua-opc-plc` `opc.tcp://10.100.0.35:50000` (`--pn=50000 --ut --aa --alm`, verified) | `RefreshEnd` of the alarm subscription's ConditionRefresh, `Unsignalable=false` asserted | 20 | 567.8 | 642.3 | 989.2 / 1372.6 | **120 s** (default; 3× p99 = 4.1 s) |
| FOCAS | `otopcua-focas-fixture` focas-mock `focas://10.100.0.35:8193` (serves `cnc_rdalmmsg2`) | first successful alarm-read tick, `ALARM:*` condition | 20 | 95.7 | 256.2 | 95.7 / 266.5 | **120 s** (default; 3× p99 = 0.8 s) |
| MTConnect | `otopcua-mtconnect-agent` `http://10.100.0.35:5000` (2 CONDITION items: `fixture_x_travel`, `fixture_logic`) | resync emission in `SubscribeAlarmsAsync` over the init-time `/current` baseline | 20 | 0.0 | 1.5 | 24.2 / 120.7 | **120 s** (default; 3× p99 with connect = 0.4 s) |
| AbCip ALMD | **private** ab_server (image `otopcua-ab-server:libplctag-release`, copied from the Docker host), `127.0.0.1:44918`, tags `AlmA.InAlarm:BOOL`, `AlmA.Severity:DINT`, `AlmA.Acked:BOOL`, run under amd64 emulation on the Mac | first poll tick whose `InAlarm` read Good (default 1 s cadence, native transport) | 20 | 999.0 | 1005.1 | 999.3 / 1005.2 | **120 s** (default; 3× p99 = 3.0 s) |
| Galaxy | — | — | — | — | — | — | **120 s** (default) — **blocked** |
| Heidenhain | — | — | — | — | — | — | **120 s** (default) — **blocked** |
Raw samples (ms, signal latency from quality Good):
- OpcUaClient: 622.8, 555.6, 583.7, 605, 560.8, 512.4, 615.1, 514.6, 536.4, 642.3, 574.8, 527.2, 602.7, 560.2, 567.8, 512.6, 557.3, 622.3, 632.3, 573.1
- FOCAS: 256.2, 142.7, 73.8, 60.3, 155, 86.9, 79, 74.9, 85.2, 178.7, 95.7, 87.3, 110.6, 176.6, 109.3, 115.9, 92.4, 222.2, 110.8, 84.2
- MTConnect: 1.5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0
- AbCip: 37.6, 976.6, 1004.4, 998.9, 1000.2, 997.8, 1003.1, 996, 999.2, 1004.1, 997.9, 1003.6, 995.5, 998.1, 1005.1, 998.7, 1002.7, 1000.8, 999, 1002.1
### Observations
- **OpcUaClient.** About 0.55 s is the ConditionRefresh round trip plus the alarm subscription's 500 ms publishing interval: the
`RefreshEnd` rides the next publish. The signal never came from `ConditionRefreshAsync` returning; the F1 path was taken on
every sample.
- **MTConnect.** The `/current` baseline is read inside `InitializeAsync`, so the resync in `SubscribeAlarmsAsync` signals
synchronously, about 0 ms after Good. The cost is the connect itself, up to 121 ms.
- **AbCip.** 19 of 20 samples took one full poll interval. Inferred, not traced: the first tick's `InAlarm` read on a fresh
native session does not come back Good, so that tick establishes nothing, and the second tick, 1 s later, signals. That is consistent with G1: no signal until
`InAlarm` actually reads Good. The one fast sample (37.6 ms) was the run's first driver.
- ab_server has no ALMD instruction. The shared `otopcua-ab-server-controllogix` fixture also serves no `InAlarm` member, so
it cannot produce ALMD alarms.
- That is why the leg used a separate local container with the ALMD member layout as flat dotted tags (Docker patch 0003
serves `X.Y` member paths). This measures the driver's poll-tick signal path, not Logix ALMD semantics, and ALMA was not
measured.
- The shared fixture was **not** touched. The private container was started with `--rm` and stopped after the run.
- **FOCAS.** One successful `cnc_rdalmmsg2` per sample. The mock's alarm list was read, never modified.
## Chosen timeouts
`DataConnections:ConditionKnownSignalTimeout:<DriverType>` stays at the **120 s default for every type**. No configuration
key is added, for three reasons:
- Every measured p99 is at most 1.4 s even with connect, so 120 s is at least 29× the observed p99. That satisfies the gate,
which requires at least 3×.
- These are LAN fixtures. Production CNCs, PLCs and upstream servers on plant networks can be much slower, and a lower
timeout would only raise the F5 "initial alarm state not signalled" diagnostic earlier. It would never make a condition
known sooner, because the signal does that.
- On expiry the conditions stay unknown either way, so a generous bound costs nothing but diagnostic latency.
`DataConnections:ConditionKnownSettle:OpcUaClient` (the backstop, default 60 s) needs no calibration. It applies only to an
upstream without ConditionRefresh (documented residual).
## Blocked legs
| Leg | Why it could not run | Timeout kept |
|---|---|---|
| **Galaxy** | Needs the mxaccessgw gateway with a deployed ArchestrA Platform behind the corporate VPN, which is down. No remote commands on the wonder boxes. The driver path is covered by unit tests against the real `GatewayGalaxyAlarmFeed` (`GalaxyInitialAlarmStateSignalTests`). | 120 s default |
| **Heidenhain** | No LSV2 fixture exists. The in-process simulator in `Heidenhain.Tests` is not a latency rig, and the iTNC 530 hardware was not available for this run. Covered by `HeidenhainInitialAlarmStateSignalTests`. | 120 s default |
| AbCip on the **shared** fixture | `otopcua-ab-server-controllogix` serves no ALMD/ALMA member, so it cannot produce alarms. Measured instead on a private same-image container (above). Real-Logix ALMD latency (e.g. Z35162, which has no ALMD/ALMA) remains unmeasured. | 120 s default |
@@ -0,0 +1,79 @@
using System.Diagnostics;
using System.Text.Json;
using Shouldly;
using Xunit;
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
namespace ZB.MOM.WW.OtOpcUa.Driver.AbCip.IntegrationTests;
/// <summary>
/// grpc-data A1 exit gate L4 — AbCip leg. The shared ab_server fixture serves no ALMD, so this runs against a
/// PRIVATE ab_server (same image) started with ALMD-shaped member tags <c>AlmA.InAlarm</c> / <c>AlmA.Severity</c> /
/// <c>AlmA.Acked</c> (patch 0003 serves dotted member paths as flat tags), named by
/// <c>OTOPCUA_L4_ALMD_ENDPOINT</c> (<c>host:port</c>); skipped otherwise. Measures InitializeAsync returning
/// (quality Good) → the first <see cref="IAlarmInitialStateSignal.InitialAlarmStateDelivered"/> (first ALMD poll
/// tick, production default cadence). N samples, each a fresh driver. Results: <c>OTOPCUA_L4_RESULTS</c> when set.
/// </summary>
[Trait("Category", "LiveIntegration")]
[Trait("Feature", "GrpcData")]
[Trait("Phase", "L4")]
public sealed class AbCipAlarmSignalLatencyTests(ITestOutputHelper output)
{
private const int Samples = 20;
[Fact]
public async Task First_ALMD_tick_signal_latency_from_connected()
{
if (Environment.GetEnvironmentVariable("OTOPCUA_L4_ALMD_ENDPOINT") is not { Length: > 0 } endpoint)
{
Assert.Skip("OTOPCUA_L4_ALMD_ENDPOINT not set (a private ab_server with AlmA.InAlarm/Severity/Acked tags).");
return;
}
var ct = TestContext.Current.CancellationToken;
var device = $"ab://{endpoint}/1,0";
var almd = new AbCipTagDefinition("AlmA", device, "AlmA", AbCipDataType.Structure,
Members: [new AbCipStructureMember("InAlarm", AbCipDataType.Bool), new AbCipStructureMember("Acked", AbCipDataType.Bool),
new AbCipStructureMember("Severity", AbCipDataType.DInt)]);
var latencies = new List<double>();
var withConnect = new List<double>();
for (var i = 0; i < Samples; i++)
{
var drv = new AbCipDriver(new AbCipDriverOptions
{
Devices = [new AbCipDeviceOptions(device, AbCipPlcFamily.ControlLogix)],
RawTags = AbCipRawTags.From(almd),
Timeout = TimeSpan.FromSeconds(5),
EnableAlarmProjection = true,
Probe = new AbCipProbeOptions { Enabled = false },
}, $"abcip-l4-{i}");
var signalled = new TaskCompletionSource<AlarmInitialStateEventArgs>(TaskCreationOptions.RunContinuationsAsynchronously);
drv.InitialAlarmStateDelivered += (_, e) => signalled.TrySetResult(e);
drv.OnAlarmEvent += (_, _) => { };
var total = Stopwatch.StartNew();
await drv.InitializeAsync("{}", ct);
var sw = Stopwatch.StartNew();
var handle = await drv.SubscribeAlarmsAsync(["AlmA"], ct);
var args = await signalled.Task.WaitAsync(TimeSpan.FromSeconds(30), ct);
sw.Stop();
args.ConditionIds.ShouldBe(["AlmA"]);
latencies.Add(sw.Elapsed.TotalMilliseconds);
withConnect.Add(total.Elapsed.TotalMilliseconds);
await drv.UnsubscribeAlarmsAsync(handle, ct);
await drv.ShutdownAsync(ct);
}
var sorted = latencies.OrderBy(x => x).ToArray();
var sc = withConnect.OrderBy(x => x).ToArray();
double P(double[] a, double q) => a[Math.Clamp((int)Math.Ceiling(q * a.Length) - 1, 0, a.Length - 1)];
var line = JsonSerializer.Serialize(new
{
driverType = "AbCip", fixture = device, n = sorted.Length, p50 = P(sorted, 0.50), p99 = P(sorted, 0.99),
max = sorted[^1], samplesMs = latencies.Select(x => Math.Round(x, 1)),
withConnectP50 = P(sc, 0.50), withConnectP99 = P(sc, 0.99),
});
output.WriteLine(line);
if (Environment.GetEnvironmentVariable("OTOPCUA_L4_RESULTS") is { Length: > 0 } path)
File.AppendAllText(path, line + Environment.NewLine);
}
}
@@ -0,0 +1,79 @@
using System.Diagnostics;
using System.Text.Json;
using Shouldly;
using Xunit;
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
using ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Wire;
namespace ZB.MOM.WW.OtOpcUa.Driver.FOCAS.IntegrationTests;
/// <summary>
/// grpc-data A1 exit gate L4 — FOCAS leg: against the live focas-mock, the latency from InitializeAsync returning
/// (the host's quality-Good edge) to the first <see cref="IAlarmInitialStateSignal.InitialAlarmStateDelivered"/>
/// (first successful <c>cnc_rdalmmsg2</c> tick, default 1 s alarm poll cadence). N samples, each a fresh driver.
/// Read-only: the mock's alarm list is read, never scheduled. Results: <c>OTOPCUA_L4_RESULTS</c> when set.
/// </summary>
[Collection(FocasSimCollection.Name)]
[Trait("Category", "LiveIntegration")]
[Trait("Feature", "GrpcData")]
[Trait("Phase", "L4")]
public sealed class FocasAlarmSignalLatencyTests(FocasSimFixture fx, ITestOutputHelper output)
{
private const int Samples = 20;
[Fact]
public async Task First_alarm_read_signal_latency_from_connected()
{
if (fx.SkipReason is not null) Assert.Skip(fx.SkipReason);
var ct = TestContext.Current.CancellationToken;
const string rawPath = "Plant/Cnc/l4/alarms";
var latencies = new List<double>();
var withConnect = new List<double>();
for (var i = 0; i < Samples; i++)
{
var driver = new FocasDriver(new FocasDriverOptions
{
Devices = [new FocasDeviceOptions(fx.DeviceUri, DeviceName: "l4")],
RawTags =
[
new RawTagEntry(rawPath, JsonSerializer.Serialize(new Dictionary<string, object>
{
["address"] = "ALARM:*",
["dataType"] = "Int32",
["alarm"] = new Dictionary<string, object> { ["alarmType"] = "AlarmCondition" },
}), WriteIdempotent: false, DeviceName: "l4"),
],
Probe = new FocasProbeOptions { Enabled = false },
}, driverInstanceId: $"focas-l4-{i}", clientFactory: new WireFocasClientFactory());
await using (driver)
{
var signalled = new TaskCompletionSource<AlarmInitialStateEventArgs>(TaskCreationOptions.RunContinuationsAsynchronously);
driver.InitialAlarmStateDelivered += (_, e) => signalled.TrySetResult(e);
driver.OnAlarmEvent += (_, _) => { };
var total = Stopwatch.StartNew();
await driver.InitializeAsync("{}", ct);
var sw = Stopwatch.StartNew();
await driver.SubscribeAlarmsAsync([rawPath], ct);
var args = await signalled.Task.WaitAsync(TimeSpan.FromSeconds(30), ct);
sw.Stop();
args.ConditionIds.ShouldBe([rawPath]);
latencies.Add(sw.Elapsed.TotalMilliseconds); withConnect.Add(total.Elapsed.TotalMilliseconds);
await driver.ShutdownAsync(ct);
}
}
var sorted = latencies.OrderBy(x => x).ToArray();
var sc = withConnect.OrderBy(x => x).ToArray();
double Pc(double q) => sc[Math.Clamp((int)Math.Ceiling(q * sc.Length) - 1, 0, sc.Length - 1)];
double P(double q) => sorted[Math.Clamp((int)Math.Ceiling(q * sorted.Length) - 1, 0, sorted.Length - 1)];
var line = JsonSerializer.Serialize(new
{
driverType = "FOCAS", fixture = fx.DeviceUri, n = sorted.Length, p50 = P(0.50), p99 = P(0.99), max = sorted[^1],
samplesMs = latencies.Select(x => Math.Round(x, 1)),
withConnectP50 = Pc(0.50), withConnectP99 = Pc(0.99),
});
output.WriteLine(line);
if (Environment.GetEnvironmentVariable("OTOPCUA_L4_RESULTS") is { Length: > 0 } path)
File.AppendAllText(path, line + Environment.NewLine);
}
}
@@ -0,0 +1,75 @@
using System.Diagnostics;
using System.Text.Json;
using Shouldly;
using Xunit;
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
namespace ZB.MOM.WW.OtOpcUa.Driver.MTConnect.IntegrationTests;
/// <summary>
/// grpc-data A1 exit gate L4 — MTConnect leg: against the live fixture Agent, the latency from InitializeAsync
/// returning (the host's quality-Good edge; the <c>/current</c> baseline is read during it) to the resync emission's
/// <see cref="IAlarmInitialStateSignal.InitialAlarmStateDelivered"/>, over every CONDITION item the Agent declares.
/// N samples, each a fresh driver. Read-only. Results: <c>OTOPCUA_L4_RESULTS</c> when set.
/// </summary>
[Collection(MTConnectAgentCollection.Name)]
[Trait("Category", "LiveIntegration")]
[Trait("Feature", "GrpcData")]
[Trait("Phase", "L4")]
public sealed class MTConnectAlarmSignalLatencyTests(MTConnectAgentFixture agent, ITestOutputHelper output)
{
private const int Samples = 20;
[Fact]
public async Task Resync_signal_latency_from_connected()
{
if (agent.SkipReason is not null) Assert.Skip(agent.SkipReason);
var ct = TestContext.Current.CancellationToken;
var conditions = agent.DeclaredDataItems
.Where(d => string.Equals(d.Category, "CONDITION", StringComparison.OrdinalIgnoreCase) && !d.InComposition)
.Select(d => d.Id)
.ToList();
if (conditions.Count == 0) Assert.Skip($"The Agent at {agent.AgentUri} declares no CONDITION data items.");
var rawTags = conditions.Select(id => new RawTagEntry($"Plant/MT/l4/{id}",
JsonSerializer.Serialize(new { address = id, alarm = new { alarmType = "AlarmCondition" } }), false, "l4")).ToArray();
var latencies = new List<double>();
var withConnect = new List<double>();
for (var i = 0; i < Samples; i++)
{
var driver = new MTConnectDriver(new MTConnectDriverOptions
{
AgentUri = agent.AgentUri,
RequestTimeoutMs = 15_000,
RawTags = rawTags,
Probe = new MTConnectProbeOptions { Enabled = false },
}, $"mtconnect-l4-{i}");
var signalled = new TaskCompletionSource<AlarmInitialStateEventArgs>(TaskCreationOptions.RunContinuationsAsynchronously);
driver.InitialAlarmStateDelivered += (_, e) => signalled.TrySetResult(e);
driver.OnAlarmEvent += (_, _) => { };
var total = Stopwatch.StartNew();
await driver.InitializeAsync("{}", ct);
var sw = Stopwatch.StartNew();
await driver.SubscribeAlarmsAsync([.. rawTags.Select(t => t.RawPath)], ct);
var args = await signalled.Task.WaitAsync(TimeSpan.FromSeconds(30), ct);
sw.Stop();
args.ConditionIds.ShouldNotBeEmpty();
latencies.Add(sw.Elapsed.TotalMilliseconds); withConnect.Add(total.Elapsed.TotalMilliseconds);
await driver.ShutdownAsync(ct);
}
var sorted = latencies.OrderBy(x => x).ToArray();
var sc = withConnect.OrderBy(x => x).ToArray();
double Pc(double q) => sc[Math.Clamp((int)Math.Ceiling(q * sc.Length) - 1, 0, sc.Length - 1)];
double P(double q) => sorted[Math.Clamp((int)Math.Ceiling(q * sorted.Length) - 1, 0, sorted.Length - 1)];
var line = JsonSerializer.Serialize(new
{
driverType = "MTConnect", fixture = agent.AgentUri, n = sorted.Length, conditions = conditions.Count,
p50 = P(0.50), p99 = P(0.99), max = sorted[^1], samplesMs = latencies.Select(x => Math.Round(x, 1)),
withConnectP50 = Pc(0.50), withConnectP99 = Pc(0.99),
});
output.WriteLine(line);
if (Environment.GetEnvironmentVariable("OTOPCUA_L4_RESULTS") is { Length: > 0 } path)
File.AppendAllText(path, line + Environment.NewLine);
}
}
@@ -0,0 +1,69 @@
using System.Diagnostics;
using Shouldly;
using Xunit;
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
namespace ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.IntegrationTests;
/// <summary>
/// grpc-data A1 exit gate L4 — OpcUaClient leg: against the live <c>opc-plc --alm</c>, the latency from the driver
/// being connected (InitializeAsync returned = the host's quality-Good edge) to
/// <see cref="IAlarmInitialStateSignal.InitialAlarmStateDelivered"/> raised on the alarm subscription's RefreshEnd.
/// N samples, each a fresh driver (connect + alarm subscribe + ConditionRefresh). Read-only against the fixture.
/// Results: <c>OTOPCUA_L4_RESULTS</c> (JSON lines) when set, and the test output.
/// </summary>
[Collection(OpcPlcCollection.Name)]
[Trait("Category", "LiveIntegration")]
[Trait("Feature", "GrpcData")]
[Trait("Phase", "L4")]
public sealed class OpcUaClientAlarmSignalLatencyTests(OpcPlcFixture sim, ITestOutputHelper output)
{
private const int Samples = 20;
[Fact]
public async Task RefreshEnd_signal_latency_from_connected()
{
if (sim.SkipReason is not null) Assert.Skip(sim.SkipReason);
var ct = TestContext.Current.CancellationToken;
var latencies = new List<double>();
var withConnect = new List<double>();
for (var i = 0; i < Samples; i++)
{
await using var drv = new OpcUaClientDriver(OpcPlcProfile.BuildOptions(sim.EndpointUrl), $"opcua-l4-{i}");
var signalled = new TaskCompletionSource<AlarmInitialStateEventArgs>(TaskCreationOptions.RunContinuationsAsynchronously);
drv.InitialAlarmStateDelivered += (_, e) => signalled.TrySetResult(e);
drv.OnAlarmEvent += (_, _) => { };
var total = Stopwatch.StartNew();
await drv.InitializeAsync("{}", ct);
var sw = Stopwatch.StartNew();
await drv.SubscribeAlarmsAsync(["Plant/opc/plc/l4"], ct);
var args = await signalled.Task.WaitAsync(TimeSpan.FromSeconds(30), ct);
sw.Stop();
args.Unsignalable.ShouldBeFalse("opc-plc --alm supports ConditionRefresh, so the RefreshEnd signals");
latencies.Add(sw.Elapsed.TotalMilliseconds); withConnect.Add(total.Elapsed.TotalMilliseconds);
await drv.ShutdownAsync(ct);
}
L4Report.Write("OpcUaClient", sim.EndpointUrl, latencies, withConnect, output);
}
}
internal static class L4Report
{
public static void Write(string driverType, string fixture, List<double> ms, List<double> withConnect, ITestOutputHelper output)
{
var sorted = ms.OrderBy(x => x).ToArray();
var sc = withConnect.OrderBy(x => x).ToArray();
double Pc(double q) => sc[Math.Clamp((int)Math.Ceiling(q * sc.Length) - 1, 0, sc.Length - 1)];
double P(double q) => sorted[Math.Clamp((int)Math.Ceiling(q * sorted.Length) - 1, 0, sorted.Length - 1)];
var line = System.Text.Json.JsonSerializer.Serialize(new
{
driverType, fixture, n = sorted.Length, p50 = P(0.50), p99 = P(0.99), max = sorted[^1],
samplesMs = ms.Select(x => Math.Round(x, 1)),
withConnectP50 = Pc(0.50), withConnectP99 = Pc(0.99),
});
output.WriteLine(line);
if (Environment.GetEnvironmentVariable("OTOPCUA_L4_RESULTS") is { Length: > 0 } path)
File.AppendAllText(path, line + Environment.NewLine);
}
}