Skip to content

Commit

Permalink
Add IEC Date VarType support to PLCHelpers.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dawid Pągowski committed Aug 22, 2023
1 parent eb1fad9 commit a55ceba
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions S7.Net/PLCHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,15 @@ private static void BuildReadDataRequestPackage(System.IO.MemoryStream stream, D
{
return TimeSpan.ToArray(bytes);
}
case VarType.Date:
if (varCount == 1)
{
return Date.FromByteArray(bytes);
}
else
{
return Date.ToArray(bytes);
}
default:
return null;
}
Expand Down Expand Up @@ -273,6 +282,7 @@ internal static int VarTypeToByteLength(VarType varType, int varCount = 1)
case VarType.Timer:
case VarType.Int:
case VarType.Counter:
case VarType.Date:
return varCount * 2;
case VarType.DWord:
case VarType.DInt:
Expand Down

0 comments on commit a55ceba

Please sign in to comment.