fix(twincat): TOD write bound, historian note, driver-level refused-write test (#306)
Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
@@ -35,7 +35,7 @@ internal static class TwinCATTemporalCodec
|
||||
switch (type)
|
||||
{
|
||||
case TwinCATDataType.Time or TwinCATDataType.TimeOfDay:
|
||||
return value switch
|
||||
var ms = value switch
|
||||
{
|
||||
TimeSpan ts => ToUInt(ts.TotalMilliseconds),
|
||||
DateTime => throw new InvalidCastException($"{type} takes a duration in milliseconds, not a DateTime"),
|
||||
@@ -43,6 +43,10 @@ internal static class TwinCATTemporalCodec
|
||||
float f => ToUInt(f),
|
||||
_ => Convert.ToUInt32(value),
|
||||
};
|
||||
// TOD is a time of day: a full day or more is not representable.
|
||||
if (type == TwinCATDataType.TimeOfDay && ms >= 86_400_000u)
|
||||
throw new OverflowException($"{ms} ms is not a time of day (< 86 400 000)");
|
||||
return ms;
|
||||
case TwinCATDataType.Date or TwinCATDataType.DateTime:
|
||||
if (value is DateTime dt)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user