diff --git a/S7.Net.UnitTest/S7.Net.UnitTest.csproj b/S7.Net.UnitTest/S7.Net.UnitTest.csproj
index a87d0e2..62d54d0 100644
--- a/S7.Net.UnitTest/S7.Net.UnitTest.csproj
+++ b/S7.Net.UnitTest/S7.Net.UnitTest.csproj
@@ -81,7 +81,7 @@
-
+
diff --git a/S7.Net.UnitTest/TypeTests/DtlTests.cs b/S7.Net.UnitTest/TypeTests/DateTimeLongTests.cs
similarity index 67%
rename from S7.Net.UnitTest/TypeTests/DtlTests.cs
rename to S7.Net.UnitTest/TypeTests/DateTimeLongTests.cs
index 23b6217..2ef8fb2 100644
--- a/S7.Net.UnitTest/TypeTests/DtlTests.cs
+++ b/S7.Net.UnitTest/TypeTests/DateTimeLongTests.cs
@@ -4,7 +4,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace S7.Net.UnitTest.TypeTests
{
- public static class DtlTests
+ public static class DateTimeLongTests
{
private static readonly DateTime SampleDateTime = new DateTime(1993, 12, 25, 8, 12, 34, 567);
@@ -12,12 +12,12 @@ namespace S7.Net.UnitTest.TypeTests
private static readonly byte[] SpecMinByteArray =
{
- 0x07, 0xB2, 0x01, 0x01, (byte) (int) (Types.Dtl.SpecMinimumDateTime.DayOfWeek + 1), 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ 0x07, 0xB2, 0x01, 0x01, (byte) (int) (Types.DateTimeLong.SpecMinimumDateTime.DayOfWeek + 1), 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
private static readonly byte[] SpecMaxByteArray =
{
- 0x08, 0xD6, 0x04, 0x0B, (byte) (int) (Types.Dtl.SpecMaximumDateTime.DayOfWeek + 1), 0x17, 0x2F, 0x10, 0x32, 0xE7, 0x01, 0x80
+ 0x08, 0xD6, 0x04, 0x0B, (byte) (int) (Types.DateTimeLong.SpecMaximumDateTime.DayOfWeek + 1), 0x17, 0x2F, 0x10, 0x32, 0xE7, 0x01, 0x80
};
[TestClass]
@@ -32,97 +32,97 @@ namespace S7.Net.UnitTest.TypeTests
[TestMethod]
public void SpecMinimum()
{
- AssertFromByteArrayEquals(Types.Dtl.SpecMinimumDateTime, SpecMinByteArray);
+ AssertFromByteArrayEquals(Types.DateTimeLong.SpecMinimumDateTime, SpecMinByteArray);
}
[TestMethod]
public void SpecMaximum()
{
- AssertFromByteArrayEquals(Types.Dtl.SpecMaximumDateTime, SpecMaxByteArray);
+ AssertFromByteArrayEquals(Types.DateTimeLong.SpecMaximumDateTime, SpecMaxByteArray);
}
[TestMethod, ExpectedException(typeof(ArgumentOutOfRangeException))]
public void ThrowsOnLessThan12Bytes()
{
- Types.Dtl.FromByteArray(new byte[11]);
+ Types.DateTimeLong.FromByteArray(new byte[11]);
}
[TestMethod, ExpectedException(typeof(ArgumentOutOfRangeException))]
public void ThrowsOnMoreTHan12Bytes()
{
- Types.Dtl.FromByteArray(new byte[13]);
+ Types.DateTimeLong.FromByteArray(new byte[13]);
}
[TestMethod, ExpectedException(typeof(ArgumentOutOfRangeException))]
public void ThrowsOnInvalidYear()
{
- Types.Dtl.FromByteArray(MutateSample(0, 0xa0));
+ Types.DateTimeLong.FromByteArray(MutateSample(0, 0xa0));
}
[TestMethod, ExpectedException(typeof(ArgumentOutOfRangeException))]
public void ThrowsOnZeroMonth()
{
- Types.Dtl.FromByteArray(MutateSample(2, 0x00));
+ Types.DateTimeLong.FromByteArray(MutateSample(2, 0x00));
}
[TestMethod, ExpectedException(typeof(ArgumentOutOfRangeException))]
public void ThrowsOnTooLargeMonth()
{
- Types.Dtl.FromByteArray(MutateSample(2, 0x13));
+ Types.DateTimeLong.FromByteArray(MutateSample(2, 0x13));
}
[TestMethod, ExpectedException(typeof(ArgumentOutOfRangeException))]
public void ThrowsOnZeroDay()
{
- Types.Dtl.FromByteArray(MutateSample(3, 0x00));
+ Types.DateTimeLong.FromByteArray(MutateSample(3, 0x00));
}
[TestMethod, ExpectedException(typeof(ArgumentOutOfRangeException))]
public void ThrowsOnTooLargeDay()
{
- Types.Dtl.FromByteArray(MutateSample(3, 0x32));
+ Types.DateTimeLong.FromByteArray(MutateSample(3, 0x32));
}
[TestMethod, ExpectedException(typeof(ArgumentOutOfRangeException))]
public void ThrowsOnInvalidHour()
{
- Types.Dtl.FromByteArray(MutateSample(5, 0x24));
+ Types.DateTimeLong.FromByteArray(MutateSample(5, 0x24));
}
[TestMethod, ExpectedException(typeof(ArgumentOutOfRangeException))]
public void ThrowsOnInvalidMinute()
{
- Types.Dtl.FromByteArray(MutateSample(6, 0x60));
+ Types.DateTimeLong.FromByteArray(MutateSample(6, 0x60));
}
[TestMethod, ExpectedException(typeof(ArgumentOutOfRangeException))]
public void ThrowsOnInvalidSecond()
{
- Types.Dtl.FromByteArray(MutateSample(7, 0x60));
+ Types.DateTimeLong.FromByteArray(MutateSample(7, 0x60));
}
[TestMethod, ExpectedException(typeof(ArgumentOutOfRangeException))]
public void ThrowsOnInvalidNanosecondsFirstDigit()
{
- Types.Dtl.FromByteArray(MutateSample(8, 0x3B));
+ Types.DateTimeLong.FromByteArray(MutateSample(8, 0x3B));
}
[TestMethod, ExpectedException(typeof(ArgumentOutOfRangeException))]
public void ThrowsOnZeroDayOfWeek()
{
- Types.Dtl.FromByteArray(MutateSample(4, 0));
+ Types.DateTimeLong.FromByteArray(MutateSample(4, 0));
}
[TestMethod, ExpectedException(typeof(ArgumentOutOfRangeException))]
public void ThrowsOnTooLargeDayOfWeek()
{
- Types.Dtl.FromByteArray(MutateSample(4, 8));
+ Types.DateTimeLong.FromByteArray(MutateSample(4, 8));
}
private static void AssertFromByteArrayEquals(DateTime expected, params byte[] bytes)
{
- Assert.AreEqual(expected, Types.Dtl.FromByteArray(bytes));
+ Assert.AreEqual(expected, Types.DateTimeLong.FromByteArray(bytes));
}
private static byte[] MutateSample(int index, byte value) =>
@@ -141,30 +141,30 @@ namespace S7.Net.UnitTest.TypeTests
[TestMethod]
public void SpecMinimum()
{
- AssertToByteArrayEquals(Types.Dtl.SpecMinimumDateTime, SpecMinByteArray);
+ AssertToByteArrayEquals(Types.DateTimeLong.SpecMinimumDateTime, SpecMinByteArray);
}
[TestMethod]
public void SpecMaximum()
{
- AssertToByteArrayEquals(Types.Dtl.SpecMaximumDateTime, SpecMaxByteArray);
+ AssertToByteArrayEquals(Types.DateTimeLong.SpecMaximumDateTime, SpecMaxByteArray);
}
[TestMethod, ExpectedException(typeof(ArgumentOutOfRangeException))]
public void ThrowsOnTimeBeforeSpecMinimum()
{
- Types.Dtl.ToByteArray(new DateTime(1950, 1, 1));
+ Types.DateTimeLong.ToByteArray(new DateTime(1950, 1, 1));
}
[TestMethod, ExpectedException(typeof(ArgumentOutOfRangeException))]
public void ThrowsOnTimeAfterSpecMaximum()
{
- Types.Dtl.ToByteArray(new DateTime(2790, 1, 1));
+ Types.DateTimeLong.ToByteArray(new DateTime(2790, 1, 1));
}
private static void AssertToByteArrayEquals(DateTime value, params byte[] expected)
{
- CollectionAssert.AreEqual(expected, Types.Dtl.ToByteArray(value));
+ CollectionAssert.AreEqual(expected, Types.DateTimeLong.ToByteArray(value));
}
}
}
diff --git a/S7.Net/Enums.cs b/S7.Net/Enums.cs
index 452fa44..6082d28 100644
--- a/S7.Net/Enums.cs
+++ b/S7.Net/Enums.cs
@@ -189,8 +189,8 @@
DateTime,
///
- /// DTL variable type
+ /// DateTimeLong variable type
///
- Dtl
+ DateTimeLong
}
}
diff --git a/S7.Net/PLCHelpers.cs b/S7.Net/PLCHelpers.cs
index 6d8fd5b..602c6a6 100644
--- a/S7.Net/PLCHelpers.cs
+++ b/S7.Net/PLCHelpers.cs
@@ -156,14 +156,14 @@ namespace S7.Net
{
return DateTime.ToArray(bytes);
}
- case VarType.Dtl:
+ case VarType.DateTimeLong:
if (varCount == 1)
{
- return Dtl.FromByteArray(bytes);
+ return DateTimeLong.FromByteArray(bytes);
}
else
{
- return Dtl.ToArray(bytes);
+ return DateTimeLong.ToArray(bytes);
}
default:
return null;
@@ -199,7 +199,7 @@ namespace S7.Net
return varCount * 4;
case VarType.DateTime:
return varCount * 8;
- case VarType.Dtl:
+ case VarType.DateTimeLong:
return varCount * 12;
default:
return 0;
diff --git a/S7.Net/Protocol/Serialization.cs b/S7.Net/Protocol/Serialization.cs
index 56be593..66142c2 100644
--- a/S7.Net/Protocol/Serialization.cs
+++ b/S7.Net/Protocol/Serialization.cs
@@ -64,8 +64,8 @@ namespace S7.Net.Protocol
return Types.String.ToByteArray(stringVal, stringVal.Length);
case "DateTime[]":
return Types.DateTime.ToByteArray((System.DateTime[]) value);
- case "Dtl[]":
- return Types.Dtl.ToByteArray((System.DateTime[])value);
+ case "DateTimeLong[]":
+ return Types.DateTimeLong.ToByteArray((System.DateTime[])value);
default:
throw new InvalidVariableTypeException();
}
diff --git a/S7.Net/Types/Dtl.cs b/S7.Net/Types/DateTimeLong.cs
similarity index 90%
rename from S7.Net/Types/Dtl.cs
rename to S7.Net/Types/DateTimeLong.cs
index 22b0897..452543f 100644
--- a/S7.Net/Types/Dtl.cs
+++ b/S7.Net/Types/DateTimeLong.cs
@@ -5,9 +5,9 @@ using System.IO;
namespace S7.Net.Types
{
///
- /// Contains the methods to convert between and S7 representation of DTL values.
+ /// Contains the methods to convert between and S7 representation of DateTimeLong (DTL) values.
///
- public static class Dtl
+ public static class DateTimeLong
{
///
/// The minimum value supported by the specification.
@@ -49,7 +49,7 @@ namespace S7.Net.Types
if (bytes.Length % 12 != 0)
{
throw new ArgumentOutOfRangeException(nameof(bytes), bytes.Length,
- $"Parsing an array of Dtl requires a multiple of 12 bytes of input data, input data is '{bytes.Length}' long.");
+ $"Parsing an array of DateTimeLong requires a multiple of 12 bytes of input data, input data is '{bytes.Length}' long.");
}
var cnt = bytes.Length / 12;
@@ -70,7 +70,7 @@ namespace S7.Net.Types
if (bytes.Length != 12)
{
throw new ArgumentOutOfRangeException(nameof(bytes), bytes.Length,
- $"Parsing a Dtl requires exactly 12 bytes of input data, input data is {bytes.Length} bytes long.");
+ $"Parsing a DateTimeLong requires exactly 12 bytes of input data, input data is {bytes.Length} bytes long.");
}
@@ -94,7 +94,7 @@ namespace S7.Net.Types
/// Converts a value to a byte array.
///
/// The DateTime value to convert.
- /// A byte array containing the S7 DTL representation of .
+ /// A byte array containing the S7 DateTimeLong representation of .
///
/// Thrown when the value of
/// is before
@@ -105,13 +105,13 @@ namespace S7.Net.Types
if (dateTime < SpecMinimumDateTime)
{
throw new ArgumentOutOfRangeException(nameof(dateTime), dateTime,
- $"Date time '{dateTime}' is before the minimum '{SpecMinimumDateTime}' supported in S7 DTL representation.");
+ $"Date time '{dateTime}' is before the minimum '{SpecMinimumDateTime}' supported in S7 DateTimeLong representation.");
}
if (dateTime > SpecMaximumDateTime)
{
throw new ArgumentOutOfRangeException(nameof(dateTime), dateTime,
- $"Date time '{dateTime}' is after the maximum '{SpecMaximumDateTime}' supported in S7 DTL representation.");
+ $"Date time '{dateTime}' is after the maximum '{SpecMaximumDateTime}' supported in S7 DateTimeLong representation.");
}
var stream = new MemoryStream(12);
@@ -147,7 +147,7 @@ namespace S7.Net.Types
/// Converts an array of values to a byte array.
///
/// The DateTime values to convert.
- /// A byte array containing the S7 DTL representations of .
+ /// A byte array containing the S7 DateTimeLong representations of .
///
/// Thrown when any value of
/// is before