refactor: migrate client applications to OPC UA SDK 2.0

This commit is contained in:
Joseph Doherty
2026-11-10 10:08:18 -05:00
parent 9af1a824b3
commit 586ce9422d
21 changed files with 247 additions and 165 deletions
@@ -89,11 +89,11 @@ public class HistoryUpdateCommand : CommandBase
throw new CommandException(
$"--value and --time must be supplied in pairs ({values.Count} value(s), {times.Count} time(s)).");
var updates = new DataValueCollection();
var updates = new List<DataValue>();
for (var i = 0; i < values.Count; i++)
{
var ts = ParseTime(times[i], "--time");
updates.Add(new DataValue(new Variant(ParseValue(values[i], Type)), StatusCodes.Good, ts, ts));
updates.Add(new DataValue(ZB.MOM.WW.OtOpcUa.Client.Shared.Helpers.ValueConverter.ToVariant(ParseValue(values[i], Type)), StatusCodes.Good, ts, ts));
}
return new UpdateDataDetails
@@ -105,7 +105,7 @@ public class HistoryUpdateCommand : CommandBase
"replace" => PerformUpdateType.Replace,
_ => PerformUpdateType.Update
},
UpdateValues = updates
UpdateValues = updates.ToArrayOf()
};
}
case "delete-raw":
@@ -134,9 +134,9 @@ public class HistoryUpdateCommand : CommandBase
throw new CommandException("--mode delete-at-time takes --time only; --value is not allowed.");
if (times.Count == 0)
throw new CommandException("--mode delete-at-time requires at least one --time.");
var req = new DateTimeCollection();
var req = new List<DateTimeUtc>();
foreach (var t in times) req.Add(ParseTime(t, "--time"));
return new DeleteAtTimeDetails { NodeId = nodeId, ReqTimes = req };
return new DeleteAtTimeDetails { NodeId = nodeId, ReqTimes = req.ToArrayOf() };
}
}
}
@@ -238,8 +238,8 @@ public class HistoryUpdateCommand : CommandBase
/// <returns>The status name, or <c>0xXXXXXXXX</c>.</returns>
private static string StatusName(StatusCode code)
{
var name = StatusCodes.GetBrowseName(code.Code);
if (string.IsNullOrEmpty(name)) name = StatusCodes.GetBrowseName(code.Code & 0xFFFF0000u);
var name = code.SymbolicId;
if (string.IsNullOrEmpty(name)) name = new StatusCode(code.Code & 0xFFFF0000u).SymbolicId;
return string.IsNullOrEmpty(name) ? $"0x{code.Code:X8}" : name;
}
@@ -247,8 +247,8 @@ public class HistoryUpdateCommand : CommandBase
{
return details switch
{
UpdateDataDetails u => u.UpdateValues.Select(v => v.SourceTimestamp.ToString("O")).ToList(),
DeleteAtTimeDetails d => d.ReqTimes.Select(t => t.ToString("O")).ToList(),
UpdateDataDetails u => (u.UpdateValues.ToArray() ?? []).Select(v => v.SourceTimestamp.ToString("O")).ToList(),
DeleteAtTimeDetails d => (d.ReqTimes.ToArray() ?? []).Select(t => t.ToString("O")).ToList(),
DeleteRawModifiedDetails r => [$"{r.StartTime:O}..{r.EndTime:O}"],
_ => []
};