[twincat] TwinCAT — Native UA TIME/DATE/DT/TOD #342

Merged
dohertj2 merged 1 commits from auto/twincat/1.2 into auto/driver-gaps 2026-04-25 17:16:41 -04:00
Owner

Summary

IEC TIME/DATE/DT/TOD now surface as native OPC UA types instead of raw UDINT.

  • Core.Abstractions/DriverDataType.cs — new Duration member (back-compat: sibling driver switches fall through to BaseDataType default).
  • Server/DriverNodeManager.csDuration mapped to OPC UA DataTypeIds.Duration.
  • TwinCATDataType.ToDriverDataType():
    • Time / TimeOfDayDuration
    • Date / DateAndTimeDateTime
    • (was: all four collapsed to Int32)
  • AdsTwinCATClient.cs — new PostProcessIecTime converts raw UDINT after the wire read:
    • TIME/TOD = ms → TimeSpan
    • DATE/DT = seconds since 1970-01-01 UTC → DateTime
    • Called from ReadValueAsync and OnAdsNotificationEx.
  • ConvertForWrite now accepts TimeSpan / double / DateTime for these types via DurationToUDInt and DateTimeToUDInt. Range-checks reject pre-1970 and post-2106 DT values.

Test plan

  • dotnet build — TwinCAT, Core.Abstractions, S7, AbCip, Modbus all clean. (Pre-existing DriverSubscriptionBridge.cs cref ambiguity in Server is unrelated — reproduces on HEAD without these changes.)
  • dotnet test tests/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Tests120 / 120 passed (11 new: TIME→TimeSpan, TOD→TimeSpan, DT→DateTime UTC, DATE→midnight UTC, passthrough for non-time types, write conversions for TimeSpan/double/DateTime, round-trip, pre-epoch rejection)
  • Integration tests — hardware-gated (TWINCAT_TARGET_NETID)

🤖 Auto-generated by the Mode-B execution loop. Closes #306.

Closes #306

## Summary IEC TIME/DATE/DT/TOD now surface as native OPC UA types instead of raw `UDINT`. - **`Core.Abstractions/DriverDataType.cs`** — new `Duration` member (back-compat: sibling driver switches fall through to `BaseDataType` default). - **`Server/DriverNodeManager.cs`** — `Duration` mapped to OPC UA `DataTypeIds.Duration`. - **`TwinCATDataType.ToDriverDataType()`**: - `Time` / `TimeOfDay` → `Duration` - `Date` / `DateAndTime` → `DateTime` - (was: all four collapsed to `Int32`) - **`AdsTwinCATClient.cs`** — new `PostProcessIecTime` converts raw UDINT after the wire read: - TIME/TOD = ms → `TimeSpan` - DATE/DT = seconds since 1970-01-01 UTC → `DateTime` - Called from `ReadValueAsync` and `OnAdsNotificationEx`. - `ConvertForWrite` now accepts `TimeSpan` / `double` / `DateTime` for these types via `DurationToUDInt` and `DateTimeToUDInt`. Range-checks reject pre-1970 and post-2106 DT values. ## Test plan - [x] `dotnet build` — TwinCAT, Core.Abstractions, S7, AbCip, Modbus all clean. (Pre-existing `DriverSubscriptionBridge.cs` cref ambiguity in Server is unrelated — reproduces on HEAD without these changes.) - [x] `dotnet test tests/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Tests` — **120 / 120 passed** (11 new: TIME→TimeSpan, TOD→TimeSpan, DT→DateTime UTC, DATE→midnight UTC, passthrough for non-time types, write conversions for TimeSpan/double/DateTime, round-trip, pre-epoch rejection) - [ ] Integration tests — hardware-gated (TWINCAT_TARGET_NETID) 🤖 Auto-generated by the Mode-B execution loop. Closes #306. Closes #306
dohertj2 added 1 commit 2026-04-25 17:16:37 -04:00
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
dohertj2 merged commit f83c467647 into auto/driver-gaps 2026-04-25 17:16:41 -04:00
dohertj2 deleted branch auto/twincat/1.2 2026-04-25 17:16:42 -04:00
Sign in to join this conversation.