fix(client): TimedShelve milliseconds + shelve node guard + service-layer tests
Important 1: ShelveAlarmAsync Timed branch now multiplies shelvingTimeSeconds × 1000.0
before passing to CallMethodAsync — OPC UA Part 9 TimedShelve ShelvingTime is a Duration
in milliseconds, not seconds. IOpcUaClientService XML doc and ShelveCommand --duration
description updated to document the seconds-in / ms-out contract.
Important 2: ShelveAlarmAsync builds shelvingStateNodeId with the same
EndsWith(".ShelvingState") guard already used by the .Condition suffix in
AcknowledgeAlarmAsync / ConfirmAlarmAsync, preventing double-append.
Important 3: Add 6 service-layer tests to OpcUaClientServiceTests —
ConfirmAlarmAsync_OnSuccess_ReturnsGood
ConfirmAlarmAsync_OnServiceResultException_ReturnsBadStatusCode
ShelveAlarmAsync_OneShot_CallsMethodWithNoArgs
ShelveAlarmAsync_Timed_PassesDurationInMilliseconds (regression guard for Important 1)
ShelveAlarmAsync_Unshelve_CallsMethodWithNoArgs
ShelveAlarmAsync_OnServiceResultException_ReturnsBadStatusCode
FakeSessionAdapter extended with CallMethodInputArgs list to record per-call input
arguments so the Timed test can assert the ms value.
Minor 4: ShelveCommand output changed from "Shelve (OneShot) successful" to
"{shelveKind} successful/failed" so Unshelve reads "Unshelve successful: …".
Minor 6: ShelveCommand --duration description updated to "(must be > 0; in seconds,
converted to milliseconds for the OPC UA call; required for --kind Timed)".
This commit is contained in:
@@ -31,9 +31,10 @@ public class ShelveCommand : CommandBase
|
||||
public string Kind { get; init; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the shelving duration in seconds for Timed shelving (ignored for OneShot and Unshelve).
|
||||
/// Gets the shelving duration in seconds for Timed shelving (must be > 0; ignored for OneShot and Unshelve).
|
||||
/// The value is passed in seconds by the operator and converted to milliseconds for the OPC UA TimedShelve call.
|
||||
/// </summary>
|
||||
[CommandOption("duration", 'd', Description = "Shelving duration in seconds (required for --kind Timed)")]
|
||||
[CommandOption("duration", 'd', Description = "Shelving duration in seconds (must be > 0; in seconds, converted to milliseconds for the OPC UA call; required for --kind Timed)")]
|
||||
public double DurationSeconds { get; init; }
|
||||
|
||||
/// <summary>
|
||||
@@ -61,9 +62,9 @@ public class ShelveCommand : CommandBase
|
||||
var statusCode = await service.ShelveAlarmAsync(NodeId, shelveKind, DurationSeconds, ct);
|
||||
|
||||
if (StatusCode.IsGood(statusCode))
|
||||
await console.Output.WriteLineAsync($"Shelve ({shelveKind}) successful: {NodeId}");
|
||||
await console.Output.WriteLineAsync($"{shelveKind} successful: {NodeId}");
|
||||
else
|
||||
await console.Output.WriteLineAsync($"Shelve ({shelveKind}) failed: {statusCode}");
|
||||
await console.Output.WriteLineAsync($"{shelveKind} failed: {statusCode}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user