Auto: twincat-1.2 — native UA TIME/DATE/DT/TOD

IEC 61131-3 TIME/TOD now surface as TimeSpan (UA Duration); DATE/DT
surface as DateTime (UTC). The wire form stays UDINT — AdsTwinCATClient
post-processes raw values in ReadValueAsync and OnAdsNotificationEx,
and accepts native CLR types in ConvertForWrite. Added Duration to
DriverDataType (back-compat: existing switches default to BaseDataType
for unknown enum values) and mapped it to DataTypeIds.Duration in
DriverNodeManager.

Closes #306
This commit is contained in:
Joseph Doherty
2026-04-25 17:14:12 -04:00
parent 8286255ae5
commit 80b2d7f8c3
5 changed files with 171 additions and 6 deletions
@@ -42,8 +42,11 @@ public static class TwinCATDataTypeExtensions
TwinCATDataType.Real => DriverDataType.Float32,
TwinCATDataType.LReal => DriverDataType.Float64,
TwinCATDataType.String or TwinCATDataType.WString => DriverDataType.String,
TwinCATDataType.Time or TwinCATDataType.Date
or TwinCATDataType.DateTime or TwinCATDataType.TimeOfDay => DriverDataType.Int32,
// IEC 61131-3 TIME / TOD are durations (ms); DATE / DT are absolute timestamps.
// The wire form is UDINT but the driver post-processes into TimeSpan / DateTime so the
// address space surfaces native UA Duration / DateTime instead of opaque integers.
TwinCATDataType.Time or TwinCATDataType.TimeOfDay => DriverDataType.Duration,
TwinCATDataType.Date or TwinCATDataType.DateTime => DriverDataType.DateTime,
TwinCATDataType.Structure => DriverDataType.String,
_ => DriverDataType.Int32,
};