You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2018/02/16 21:42:27 UTC

[incubator-plc4x] branch master updated: + Cleanup types + Added string parsers + Fixed date representation of TimeStamp

This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git


The following commit(s) were added to refs/heads/master by this push:
     new 08bb020  + Cleanup types + Added string parsers + Fixed date representation of TimeStamp
08bb020 is described below

commit 08bb02006980a0b5eeab29a87d68bd645282de86
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Fri Feb 16 22:42:22 2018 +0100

    + Cleanup types
    + Added string parsers
    + Fixed date representation of TimeStamp
---
 .../java/ads/api/commands/types/ADSState.java      |  9 ++-
 .../ads/api/commands/types/AdsStampHeader.java     | 12 +++-
 .../java/ads/api/commands/types/CycleTime.java     | 13 ++++-
 .../plc4x/java/ads/api/commands/types/Data.java    | 13 +++++
 .../plc4x/java/ads/api/commands/types/Device.java  | 20 ++++++-
 .../java/ads/api/commands/types/DeviceState.java   |  9 ++-
 .../java/ads/api/commands/types/IndexGroup.java    | 13 ++++-
 .../java/ads/api/commands/types/IndexOffset.java   | 13 ++++-
 .../plc4x/java/ads/api/commands/types/Length.java  | 11 ++--
 .../java/ads/api/commands/types/MajorVersion.java  | 15 ++++-
 .../java/ads/api/commands/types/MaxDelay.java      | 13 ++++-
 .../java/ads/api/commands/types/MinorVersion.java  | 13 +++++
 .../ads/api/commands/types/NotificationHandle.java | 13 ++++-
 .../java/ads/api/commands/types/ReadLength.java    | 17 +++---
 .../plc4x/java/ads/api/commands/types/Result.java  | 13 ++++-
 .../java/ads/api/commands/types/SampleSize.java    | 17 +++---
 .../plc4x/java/ads/api/commands/types/Samples.java | 16 ++++--
 .../plc4x/java/ads/api/commands/types/Stamps.java  | 13 ++++-
 .../java/ads/api/commands/types/TimeStamp.java     | 64 +++++++++++++++++++---
 .../ads/api/commands/types/TransmissionMode.java   | 13 ++++-
 .../plc4x/java/ads/api/commands/types/Version.java | 12 ++--
 .../java/ads/api/commands/types/WriteLength.java   | 17 +++---
 .../java/ads/api/generic/types/DataLength.java     | 17 +++---
 .../plc4x/java/ads/api/generic/types/Invoke.java   | 13 ++++-
 .../plc4x/java/ads/api/generic/types/Length.java   | 17 +++---
 .../plc4x/java/ads/api/generic/types/State.java    |  8 ++-
 .../java/ads/api/util/UnsignedIntLEByteValue.java  |  4 ++
 .../ads/api/util/UnsignedShortLEByteValue.java     |  8 ++-
 .../plc4x/java/ads/netty/ADSProtocolTest.java      |  4 +-
 29 files changed, 322 insertions(+), 98 deletions(-)

diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/ADSState.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/ADSState.java
index f2536cb..cb05cc0 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/ADSState.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/ADSState.java
@@ -33,6 +33,10 @@ public class ADSState extends UnsignedShortLEByteValue {
         super(value);
     }
 
+    public ADSState(String value) {
+        super(value);
+    }
+
     protected ADSState(ByteBuf byteBuf) {
         super(byteBuf);
     }
@@ -42,7 +46,6 @@ public class ADSState extends UnsignedShortLEByteValue {
     }
 
     public static ADSState of(int value) {
-        checkUnsignedBounds(value, NUM_BYTES);
         return new ADSState(value);
     }
 
@@ -50,7 +53,7 @@ public class ADSState extends UnsignedShortLEByteValue {
         return new ADSState(byteBuf);
     }
 
-    public static ADSState of(String length) {
-        return of(Integer.parseInt(length));
+    public static ADSState of(String value) {
+        return new ADSState(value);
     }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/AdsStampHeader.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/AdsStampHeader.java
index 701768b..01547d8 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/AdsStampHeader.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/AdsStampHeader.java
@@ -29,7 +29,7 @@ import static org.apache.plc4x.java.ads.api.util.ByteReadableUtils.buildByteBuff
 public class AdsStampHeader implements ByteReadable {
 
     /**
-     * 8 bytes	The timestamp is coded after the Windos FILETIME format. I.e. the value contains the number of the nano seconds, which passed since 1.1.1601. In addition, the local time change is not considered. Thus the time stamp is present as universal Coordinated time (UTC).
+     * 8 bytes	The timestamp is coded after the Windows FILETIME format. I.e. the value contains the number of the nano seconds, which passed since 1.1.1601. In addition, the local time change is not considered. Thus the time stamp is present as universal Coordinated time (UTC).
      */
     private final TimeStamp timeStamp;
     /**
@@ -47,10 +47,20 @@ public class AdsStampHeader implements ByteReadable {
         this.adsNotificationSamples = Objects.requireNonNull(adsNotificationSamples);
     }
 
+    protected AdsStampHeader(TimeStamp timeStamp, List<AdsNotificationSample> adsNotificationSamples) {
+        this.timeStamp = Objects.requireNonNull(timeStamp);
+        this.adsNotificationSamples = Objects.requireNonNull(adsNotificationSamples);
+        this.samples = Samples.of(adsNotificationSamples.size());
+    }
+
     public static AdsStampHeader of(TimeStamp timeStamp, Samples samples, List<AdsNotificationSample> adsNotificationSamples) {
         return new AdsStampHeader(timeStamp, samples, adsNotificationSamples);
     }
 
+    public static AdsStampHeader of(TimeStamp timeStamp, List<AdsNotificationSample> adsNotificationSamples) {
+        return new AdsStampHeader(timeStamp, adsNotificationSamples);
+    }
+
     @Override
     public ByteBuf getByteBuf() {
         return buildByteBuff(timeStamp, samples, () -> buildByteBuff(adsNotificationSamples.toArray(new ByteReadable[adsNotificationSamples.size()])));
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/CycleTime.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/CycleTime.java
index 43fcb66..216f0a2 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/CycleTime.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/CycleTime.java
@@ -37,13 +37,20 @@ public class CycleTime extends UnsignedIntLEByteValue {
         super(byteBuf);
     }
 
+    public CycleTime(String value) {
+        super(value);
+    }
+
     public static CycleTime of(byte... values) {
         return new CycleTime(values);
     }
 
-    public static CycleTime of(long errorCode) {
-        checkUnsignedBounds(errorCode, NUM_BYTES);
-        return new CycleTime(errorCode);
+    public static CycleTime of(long value) {
+        return new CycleTime(value);
+    }
+
+    public static CycleTime of(String value) {
+        return new CycleTime(value);
     }
 
     public static CycleTime of(ByteBuf byteBuf) {
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Data.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Data.java
index a44a2b8..c4e00c3 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Data.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Data.java
@@ -20,6 +20,9 @@ package org.apache.plc4x.java.ads.api.commands.types;
 
 import org.apache.plc4x.java.ads.api.util.ByteValue;
 
+import java.nio.charset.Charset;
+import java.util.Objects;
+
 public class Data extends ByteValue {
     Data(byte... values) {
         super(values);
@@ -29,6 +32,16 @@ public class Data extends ByteValue {
         return new Data(values);
     }
 
+    public static Data of(String value) {
+        Objects.requireNonNull(value);
+        return new Data(value.getBytes());
+    }
+
+    public static Data of(String value, Charset charset) {
+        Objects.requireNonNull(value);
+        return new Data(value.getBytes(charset));
+    }
+
     @Override
     public String toString() {
         return "Data{" + new String(value) + "} " + super.toString();
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Device.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Device.java
index a1cba41..3814400 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Device.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Device.java
@@ -21,11 +21,14 @@ package org.apache.plc4x.java.ads.api.commands.types;
 import io.netty.buffer.ByteBuf;
 import org.apache.plc4x.java.ads.api.util.ByteValue;
 
+import java.nio.charset.Charset;
+import java.util.Objects;
+
 public class Device extends ByteValue {
 
     public static final int NUM_BYTES = 16;
 
-    Device(byte... values) {
+    protected Device(byte... values) {
         super(values);
         assertLength(NUM_BYTES);
     }
@@ -39,4 +42,19 @@ public class Device extends ByteValue {
         byteBuf.readBytes(values);
         return of(values);
     }
+
+    public static Device of(String value) {
+        Objects.requireNonNull(value);
+        return new Device(value.getBytes());
+    }
+
+    public static Device of(String value, Charset charset) {
+        Objects.requireNonNull(value);
+        return new Device(value.getBytes(charset));
+    }
+
+    @Override
+    public String toString() {
+        return "Device{" + new String(value) + "} " + super.toString();
+    }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/DeviceState.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/DeviceState.java
index 9fe6eee..ae219da 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/DeviceState.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/DeviceState.java
@@ -33,6 +33,10 @@ public class DeviceState extends UnsignedShortLEByteValue {
         super(value);
     }
 
+    protected DeviceState(String value) {
+        super(value);
+    }
+
     protected DeviceState(ByteBuf byteBuf) {
         super(byteBuf);
     }
@@ -42,7 +46,6 @@ public class DeviceState extends UnsignedShortLEByteValue {
     }
 
     public static DeviceState of(int value) {
-        checkUnsignedBounds(value, NUM_BYTES);
         return new DeviceState(value);
     }
 
@@ -50,7 +53,7 @@ public class DeviceState extends UnsignedShortLEByteValue {
         return new DeviceState(byteBuf);
     }
 
-    public static DeviceState of(String length) {
-        return of(Integer.parseInt(length));
+    public static DeviceState of(String value) {
+        return new DeviceState(value);
     }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/IndexGroup.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/IndexGroup.java
index b162ae9..f4998f7 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/IndexGroup.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/IndexGroup.java
@@ -33,6 +33,10 @@ public class IndexGroup extends UnsignedIntLEByteValue {
         super(value);
     }
 
+    protected IndexGroup(String value) {
+        super(value);
+    }
+
     protected IndexGroup(ByteBuf byteBuf) {
         super(byteBuf);
     }
@@ -41,9 +45,12 @@ public class IndexGroup extends UnsignedIntLEByteValue {
         return new IndexGroup(values);
     }
 
-    public static IndexGroup of(long errorCode) {
-        checkUnsignedBounds(errorCode, NUM_BYTES);
-        return new IndexGroup(errorCode);
+    public static IndexGroup of(long value) {
+        return new IndexGroup(value);
+    }
+
+    public static IndexGroup of(String value) {
+        return new IndexGroup(value);
     }
 
     public static IndexGroup of(ByteBuf byteBuf) {
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/IndexOffset.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/IndexOffset.java
index f94a82e..67bb3a1 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/IndexOffset.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/IndexOffset.java
@@ -33,6 +33,10 @@ public class IndexOffset extends UnsignedIntLEByteValue {
         super(value);
     }
 
+    protected IndexOffset(String value) {
+        super(value);
+    }
+
     protected IndexOffset(ByteBuf byteBuf) {
         super(byteBuf);
     }
@@ -41,9 +45,12 @@ public class IndexOffset extends UnsignedIntLEByteValue {
         return new IndexOffset(values);
     }
 
-    public static IndexOffset of(long errorCode) {
-        checkUnsignedBounds(errorCode, NUM_BYTES);
-        return new IndexOffset(errorCode);
+    public static IndexOffset of(long value) {
+        return new IndexOffset(value);
+    }
+
+    public static IndexOffset of(String value) {
+        return new IndexOffset(value);
     }
 
     public static IndexOffset of(ByteBuf byteBuf) {
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Length.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Length.java
index 7ce8239..7d4693c 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Length.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Length.java
@@ -33,6 +33,10 @@ public class Length extends UnsignedIntLEByteValue {
         super(value);
     }
 
+    protected Length(String length) {
+        super(length);
+    }
+
     protected Length(ByteBuf byteBuf) {
         super(byteBuf);
     }
@@ -41,9 +45,8 @@ public class Length extends UnsignedIntLEByteValue {
         return new Length(values);
     }
 
-    public static Length of(long errorCode) {
-        checkUnsignedBounds(errorCode, NUM_BYTES);
-        return new Length(errorCode);
+    public static Length of(long value) {
+        return new Length(value);
     }
 
     public static Length of(ByteBuf byteBuf) {
@@ -51,7 +54,7 @@ public class Length extends UnsignedIntLEByteValue {
     }
 
     public static Length of(String length) {
-        return of(Long.parseLong(length));
+        return new Length(length);
     }
 
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/MajorVersion.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/MajorVersion.java
index fead91e..6888b2d 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/MajorVersion.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/MajorVersion.java
@@ -21,11 +21,13 @@ package org.apache.plc4x.java.ads.api.commands.types;
 import io.netty.buffer.ByteBuf;
 import org.apache.plc4x.java.ads.api.util.ByteValue;
 
+import java.util.Arrays;
+
 public class MajorVersion extends ByteValue {
 
     public static final int NUM_BYTES = 1;
 
-    MajorVersion(byte... values) {
+    protected MajorVersion(byte... values) {
         super(values);
         assertLength(NUM_BYTES);
     }
@@ -34,9 +36,20 @@ public class MajorVersion extends ByteValue {
         return new MajorVersion(values);
     }
 
+    public static MajorVersion of(int value) {
+        return new MajorVersion((byte) value);
+    }
+
     public static MajorVersion of(ByteBuf byteBuf) {
         byte[] values = new byte[NUM_BYTES];
         byteBuf.readBytes(values);
         return of(values);
     }
+
+    @Override
+    public String toString() {
+        return "MajorVersion{" +
+            "value=" + Arrays.toString(value) +
+            "} " + super.toString();
+    }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/MaxDelay.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/MaxDelay.java
index 582a971..f381755 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/MaxDelay.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/MaxDelay.java
@@ -33,6 +33,10 @@ public class MaxDelay extends UnsignedIntLEByteValue {
         super(value);
     }
 
+    protected MaxDelay(String value) {
+        super(value);
+    }
+
     protected MaxDelay(ByteBuf byteBuf) {
         super(byteBuf);
     }
@@ -41,9 +45,12 @@ public class MaxDelay extends UnsignedIntLEByteValue {
         return new MaxDelay(values);
     }
 
-    public static MaxDelay of(long errorCode) {
-        checkUnsignedBounds(errorCode, NUM_BYTES);
-        return new MaxDelay(errorCode);
+    public static MaxDelay of(long value) {
+        return new MaxDelay(value);
+    }
+
+    public static MaxDelay of(String value) {
+        return new MaxDelay(value);
     }
 
     public static MaxDelay of(ByteBuf byteBuf) {
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/MinorVersion.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/MinorVersion.java
index 5f41a33..2579e27 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/MinorVersion.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/MinorVersion.java
@@ -21,6 +21,8 @@ package org.apache.plc4x.java.ads.api.commands.types;
 import io.netty.buffer.ByteBuf;
 import org.apache.plc4x.java.ads.api.util.ByteValue;
 
+import java.util.Arrays;
+
 public class MinorVersion extends ByteValue {
 
     public static final int NUM_BYTES = 1;
@@ -34,9 +36,20 @@ public class MinorVersion extends ByteValue {
         return new MinorVersion(values);
     }
 
+    public static MinorVersion of(int value) {
+        return new MinorVersion((byte) value);
+    }
+
     public static MinorVersion of(ByteBuf byteBuf) {
         byte[] values = new byte[NUM_BYTES];
         byteBuf.readBytes(values);
         return of(values);
     }
+
+    @Override
+    public String toString() {
+        return "MinorVersion{" +
+            "value=" + Arrays.toString(value) +
+            "} " + super.toString();
+    }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/NotificationHandle.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/NotificationHandle.java
index cc35db1..27ebe0a 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/NotificationHandle.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/NotificationHandle.java
@@ -37,13 +37,20 @@ public class NotificationHandle extends UnsignedIntLEByteValue {
         super(byteBuf);
     }
 
+    protected NotificationHandle(String value) {
+        super(value);
+    }
+
     public static NotificationHandle of(byte... values) {
         return new NotificationHandle(values);
     }
 
-    public static NotificationHandle of(long errorCode) {
-        checkUnsignedBounds(errorCode, NUM_BYTES);
-        return new NotificationHandle(errorCode);
+    public static NotificationHandle of(long value) {
+        return new NotificationHandle(value);
+    }
+
+    public static NotificationHandle of(String value) {
+        return new NotificationHandle(value);
     }
 
     public static NotificationHandle of(ByteBuf byteBuf) {
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/ReadLength.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/ReadLength.java
index 3421f4a..d1579bb 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/ReadLength.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/ReadLength.java
@@ -33,6 +33,10 @@ public class ReadLength extends UnsignedIntLEByteValue {
         super(value);
     }
 
+    public ReadLength(String length) {
+        super(length);
+    }
+
     protected ReadLength(ByteBuf byteBuf) {
         super(byteBuf);
     }
@@ -41,16 +45,15 @@ public class ReadLength extends UnsignedIntLEByteValue {
         return new ReadLength(values);
     }
 
-    public static ReadLength of(long errorCode) {
-        checkUnsignedBounds(errorCode, NUM_BYTES);
-        return new ReadLength(errorCode);
+    public static ReadLength of(long value) {
+        return new ReadLength(value);
     }
 
-    public static ReadLength of(ByteBuf byteBuf) {
-        return new ReadLength(byteBuf);
+    public static ReadLength of(String length) {
+        return new ReadLength(length);
     }
 
-    public static ReadLength of(String length) {
-        return of(Long.parseLong(length));
+    public static ReadLength of(ByteBuf byteBuf) {
+        return new ReadLength(byteBuf);
     }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Result.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Result.java
index 5a3dd68..02eb0df 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Result.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Result.java
@@ -33,6 +33,10 @@ public class Result extends UnsignedIntLEByteValue {
         super(value);
     }
 
+    public Result(String value) {
+        super(value);
+    }
+
     protected Result(ByteBuf byteBuf) {
         super(byteBuf);
     }
@@ -41,9 +45,12 @@ public class Result extends UnsignedIntLEByteValue {
         return new Result(values);
     }
 
-    public static Result of(long errorCode) {
-        checkUnsignedBounds(errorCode, NUM_BYTES);
-        return new Result(errorCode);
+    public static Result of(long value) {
+        return new Result(value);
+    }
+
+    public static Result of(String value) {
+        return new Result(value);
     }
 
     public static Result of(ByteBuf byteBuf) {
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/SampleSize.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/SampleSize.java
index ddb9d1b..4fe5345 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/SampleSize.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/SampleSize.java
@@ -33,6 +33,10 @@ public class SampleSize extends UnsignedIntLEByteValue {
         super(value);
     }
 
+    public SampleSize(String size) {
+        super(size);
+    }
+
     protected SampleSize(ByteBuf byteBuf) {
         super(byteBuf);
     }
@@ -41,16 +45,15 @@ public class SampleSize extends UnsignedIntLEByteValue {
         return new SampleSize(values);
     }
 
-    public static SampleSize of(long errorCode) {
-        checkUnsignedBounds(errorCode, NUM_BYTES);
-        return new SampleSize(errorCode);
+    public static SampleSize of(long value) {
+        return new SampleSize(value);
     }
 
-    public static SampleSize of(ByteBuf byteBuf) {
-        return new SampleSize(byteBuf);
+    public static SampleSize of(String size) {
+        return new SampleSize(size);
     }
 
-    public static SampleSize of(String size) {
-        return of(Long.parseLong(size));
+    public static SampleSize of(ByteBuf byteBuf) {
+        return new SampleSize(byteBuf);
     }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Samples.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Samples.java
index a586026..b44b468 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Samples.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Samples.java
@@ -33,6 +33,10 @@ public class Samples extends UnsignedIntLEByteValue {
         super(value);
     }
 
+    protected Samples(String value) {
+        super(value);
+    }
+
     protected Samples(ByteBuf byteBuf) {
         super(byteBuf);
     }
@@ -41,16 +45,16 @@ public class Samples extends UnsignedIntLEByteValue {
         return new Samples(values);
     }
 
-    public static Samples of(long errorCode) {
-        checkUnsignedBounds(errorCode, NUM_BYTES);
-        return new Samples(errorCode);
+    public static Samples of(long value) {
+        return new Samples(value);
+    }
+
+    public static Samples of(String value) {
+        return new Samples(value);
     }
 
     public static Samples of(ByteBuf byteBuf) {
         return new Samples(byteBuf);
     }
 
-    public static Samples of(String size) {
-        return of(Long.parseLong(size));
-    }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Stamps.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Stamps.java
index 86c658a..d91ba5e 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Stamps.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Stamps.java
@@ -33,6 +33,10 @@ public class Stamps extends UnsignedIntLEByteValue {
         super(value);
     }
 
+    protected Stamps(String value) {
+        super(value);
+    }
+
     protected Stamps(ByteBuf byteBuf) {
         super(byteBuf);
     }
@@ -41,9 +45,12 @@ public class Stamps extends UnsignedIntLEByteValue {
         return new Stamps(values);
     }
 
-    public static Stamps of(long errorCode) {
-        checkUnsignedBounds(errorCode, NUM_BYTES);
-        return new Stamps(errorCode);
+    public static Stamps of(long value) {
+        return new Stamps(value);
+    }
+
+    public static Stamps of(String value) {
+        return new Stamps(value);
     }
 
     public static Stamps of(ByteBuf byteBuf) {
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/TimeStamp.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/TimeStamp.java
index bb4627b..c490223 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/TimeStamp.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/TimeStamp.java
@@ -23,25 +23,46 @@ import org.apache.plc4x.java.ads.api.util.ByteValue;
 
 import java.math.BigInteger;
 import java.nio.ByteBuffer;
+import java.util.Date;
 
 public class TimeStamp extends ByteValue {
 
+    /**
+     * @see <a href="https://github.com/java-native-access/jna/blob/master/contrib/platform/src/com/sun/jna/platform/win32/WinBase.java">java-native-access WinBase</a>
+     */
+    public final static BigInteger EPOCH_DIFF_IN_MILLIS = BigInteger.valueOf((369L * 365L + 89L) * 86400L * 1000L);
+
     public static final int NUM_BYTES = 8;
 
-    TimeStamp(byte... values) {
+    protected final BigInteger bigIntegerValue;
+
+    protected TimeStamp(byte... values) {
         super(values);
         assertLength(NUM_BYTES);
+        bigIntegerValue = new BigInteger(new byte[]{
+            // LE
+            values[7],
+            values[6],
+            values[5],
+            values[4],
+
+            values[3],
+            values[2],
+            values[1],
+            values[0],
+        });
     }
 
-    public static TimeStamp of(long value) {
-        return of(BigInteger.valueOf(value));
+    protected TimeStamp(BigInteger value) {
+        super(ofBigInteger(value));
+        assertLength(NUM_BYTES);
+        bigIntegerValue = value;
     }
 
-    public static TimeStamp of(BigInteger value) {
-        checkUnsignedBounds(value, NUM_BYTES);
+    protected static byte[] ofBigInteger(BigInteger value) {
         byte[] valueBytes = value.toByteArray();
         int length = valueBytes.length;
-        return new TimeStamp(ByteBuffer.allocate(NUM_BYTES)
+        return ByteBuffer.allocate(NUM_BYTES)
             // LE
             .put(length > 0 ? valueBytes[0] : 0)
             .put(length > 1 ? valueBytes[1] : 0)
@@ -52,16 +73,45 @@ public class TimeStamp extends ByteValue {
             .put(length > 5 ? valueBytes[5] : 0)
             .put(length > 6 ? valueBytes[6] : 0)
             .put(length > 7 ? valueBytes[7] : 0)
-            .array());
+            .array();
+    }
+
+    public static TimeStamp of(BigInteger value) {
+        return new TimeStamp(value);
+    }
+
+    public static TimeStamp of(long value) {
+        return of(BigInteger.valueOf(value));
     }
 
     public static TimeStamp of(byte... values) {
         return new TimeStamp(values);
     }
 
+    public static TimeStamp of(Date timestamp) {
+        BigInteger timeMillisSince19700101 = BigInteger.valueOf(timestamp.getTime());
+        BigInteger timeMillisSince16010101 = EPOCH_DIFF_IN_MILLIS.add(timeMillisSince19700101);
+        return new TimeStamp(timeMillisSince16010101.multiply(BigInteger.valueOf(10_000)));
+    }
+
     public static TimeStamp of(ByteBuf byteBuf) {
         byte[] values = new byte[NUM_BYTES];
         byteBuf.readBytes(values);
         return of(values);
     }
+
+    public BigInteger getBigIntegerValue() {
+        return bigIntegerValue;
+    }
+
+    public Date getAsDate() {
+        BigInteger timeMillisSince16010101 = bigIntegerValue.divide(BigInteger.valueOf(10_000));
+        BigInteger timeMillisSince19700101 = timeMillisSince16010101.subtract(EPOCH_DIFF_IN_MILLIS);
+        return new Date(timeMillisSince19700101.longValue());
+    }
+
+    @Override
+    public String toString() {
+        return "TimeStamp{winTime=" + getBigIntegerValue() + "/date=" + getAsDate() + "} " + super.toString();
+    }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/TransmissionMode.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/TransmissionMode.java
index 923e0f3..c63bde7 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/TransmissionMode.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/TransmissionMode.java
@@ -33,6 +33,10 @@ public class TransmissionMode extends UnsignedIntLEByteValue {
         super(value);
     }
 
+    protected TransmissionMode(String value) {
+        super(value);
+    }
+
     protected TransmissionMode(ByteBuf byteBuf) {
         super(byteBuf);
     }
@@ -41,9 +45,12 @@ public class TransmissionMode extends UnsignedIntLEByteValue {
         return new TransmissionMode(values);
     }
 
-    public static TransmissionMode of(long errorCode) {
-        checkUnsignedBounds(errorCode, NUM_BYTES);
-        return new TransmissionMode(errorCode);
+    public static TransmissionMode of(long value) {
+        return new TransmissionMode(value);
+    }
+
+    public static TransmissionMode of(String value) {
+        return new TransmissionMode(value);
     }
 
     public static TransmissionMode of(ByteBuf byteBuf) {
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Version.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Version.java
index e1e4cf4..c9d49d8 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Version.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Version.java
@@ -33,6 +33,10 @@ public class Version extends UnsignedShortLEByteValue {
         super(value);
     }
 
+    protected Version(String value) {
+        super(value);
+    }
+
     protected Version(ByteBuf byteBuf) {
         super(byteBuf);
     }
@@ -46,11 +50,11 @@ public class Version extends UnsignedShortLEByteValue {
         return new Version(value);
     }
 
-    public static Version of(ByteBuf byteBuf) {
-        return new Version(byteBuf);
+    public static Version of(String value) {
+        return new Version(value);
     }
 
-    public static Version of(String length) {
-        return of(Integer.parseInt(length));
+    public static Version of(ByteBuf byteBuf) {
+        return new Version(byteBuf);
     }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/WriteLength.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/WriteLength.java
index 2df1cd3..0f8b8a0 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/WriteLength.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/WriteLength.java
@@ -33,6 +33,10 @@ public class WriteLength extends UnsignedIntLEByteValue {
         super(value);
     }
 
+    protected WriteLength(String length) {
+        super(length);
+    }
+
     protected WriteLength(ByteBuf byteBuf) {
         super(byteBuf);
     }
@@ -41,16 +45,15 @@ public class WriteLength extends UnsignedIntLEByteValue {
         return new WriteLength(values);
     }
 
-    public static WriteLength of(long errorCode) {
-        checkUnsignedBounds(errorCode, NUM_BYTES);
-        return new WriteLength(errorCode);
+    public static WriteLength of(long value) {
+        return new WriteLength(value);
     }
 
-    public static WriteLength of(ByteBuf byteBuf) {
-        return new WriteLength(byteBuf);
+    public static WriteLength of(String length) {
+        return new WriteLength(length);
     }
 
-    public static WriteLength of(String length) {
-        return of(Long.valueOf(length));
+    public static WriteLength of(ByteBuf byteBuf) {
+        return new WriteLength(byteBuf);
     }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/DataLength.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/DataLength.java
index 2b88ed9..e1d9e91 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/DataLength.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/DataLength.java
@@ -33,21 +33,24 @@ public class DataLength extends UnsignedIntLEByteValue {
         super(value);
     }
 
-    protected DataLength(ByteBuf byteBuf) {
-        super(byteBuf);
+    protected DataLength(String length) {
+        super(length);
     }
 
-    public static DataLength of(String length) {
-        return of(Long.parseLong(length));
+    protected DataLength(ByteBuf byteBuf) {
+        super(byteBuf);
     }
 
     public static DataLength of(byte... values) {
         return new DataLength(values);
     }
 
-    public static DataLength of(long errorCode) {
-        checkUnsignedBounds(errorCode, NUM_BYTES);
-        return new DataLength(errorCode);
+    public static DataLength of(long value) {
+        return new DataLength(value);
+    }
+
+    public static DataLength of(String length) {
+        return new DataLength(length);
     }
 
     public static DataLength of(ByteBuf byteBuf) {
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/Invoke.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/Invoke.java
index be89152..8759731 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/Invoke.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/Invoke.java
@@ -39,13 +39,20 @@ public class Invoke extends UnsignedIntLEByteValue {
         super(byteBuf);
     }
 
+    public Invoke(String invokeId) {
+        super(invokeId);
+    }
+
     public static Invoke of(byte... values) {
         return new Invoke(values);
     }
 
-    public static Invoke of(long errorCode) {
-        checkUnsignedBounds(errorCode, NUM_BYTES);
-        return new Invoke(errorCode);
+    public static Invoke of(long invokeId) {
+        return new Invoke(invokeId);
+    }
+
+    public static Invoke of(String invokeId) {
+        return new Invoke(invokeId);
     }
 
     public static Invoke of(ByteBuf byteBuf) {
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/Length.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/Length.java
index 6ccef82..5f7fe3f 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/Length.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/Length.java
@@ -35,21 +35,24 @@ public class Length extends UnsignedIntLEByteValue {
         super(value);
     }
 
-    protected Length(ByteBuf byteBuf) {
-        super(byteBuf);
+    protected Length(String length) {
+        super(length);
     }
 
-    public static Length of(String length) {
-        return of(Long.parseLong(length));
+    protected Length(ByteBuf byteBuf) {
+        super(byteBuf);
     }
 
     public static Length of(byte... values) {
         return new Length(values);
     }
 
-    public static Length of(long errorCode) {
-        checkUnsignedBounds(errorCode, NUM_BYTES);
-        return new Length(errorCode);
+    public static Length of(long value) {
+        return new Length(value);
+    }
+
+    public static Length of(String length) {
+        return new Length(length);
     }
 
     public static Length of(ByteBuf byteBuf) {
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/State.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/State.java
index 5627506..c81ce1d 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/State.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/State.java
@@ -96,6 +96,10 @@ public class State extends UnsignedShortLEByteValue {
         super(value);
     }
 
+    protected State(String stateId) {
+        super(stateId);
+    }
+
     protected State(ByteBuf byteBuf) {
         super(byteBuf);
     }
@@ -113,8 +117,8 @@ public class State extends UnsignedShortLEByteValue {
         return new State(byteBuf);
     }
 
-    public static State of(String length) {
-        return of(Integer.parseInt(length));
+    public static State of(String stateId) {
+        return new State(stateId);
     }
 
     public static State of(StateMask... stateMasks) {
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/util/UnsignedIntLEByteValue.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/util/UnsignedIntLEByteValue.java
index 6222766..7885a77 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/util/UnsignedIntLEByteValue.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/util/UnsignedIntLEByteValue.java
@@ -40,6 +40,10 @@ public abstract class UnsignedIntLEByteValue extends ByteValue {
         longValue = value;
     }
 
+    public UnsignedIntLEByteValue(String value) {
+        this(Long.parseLong(value));
+    }
+
     public UnsignedIntLEByteValue(ByteBuf byteBuf) {
         this(byteBuf.readUnsignedIntLE());
     }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/util/UnsignedShortLEByteValue.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/util/UnsignedShortLEByteValue.java
index 7b772ee..dc54f63 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/util/UnsignedShortLEByteValue.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/util/UnsignedShortLEByteValue.java
@@ -35,16 +35,20 @@ public abstract class UnsignedShortLEByteValue extends ByteValue {
     }
 
     public UnsignedShortLEByteValue(int value) {
-        super(ofLong(value));
+        super(ofInt(value));
         checkUnsignedBounds(value, NUM_BYTES);
         intValue = value;
     }
 
+    public UnsignedShortLEByteValue(String value) {
+        this(Integer.parseInt(value));
+    }
+
     public UnsignedShortLEByteValue(ByteBuf byteBuf) {
         this(byteBuf.readUnsignedShortLE());
     }
 
-    protected static byte[] ofLong(long value) {
+    protected static byte[] ofInt(long value) {
         return ByteBuffer.allocate(NUM_BYTES)
             // LE
             .put((byte) (value & 0xff))
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/netty/ADSProtocolTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/netty/ADSProtocolTest.java
index 9a225e1..a9b2ff0 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/netty/ADSProtocolTest.java
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/netty/ADSProtocolTest.java
@@ -36,6 +36,7 @@ import java.io.ByteArrayOutputStream;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Date;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -83,8 +84,7 @@ public class ADSProtocolTest {
                 Stamps.of(1),
                 Collections.singletonList(
                     // Nano times need to be offset by (1.1.1970 - 1.1.1601) years in nanos
-                    AdsStampHeader.of(TimeStamp.of(System.nanoTime()),
-                        Samples.of(1),
+                    AdsStampHeader.of(TimeStamp.of(new Date()),
                         Collections.singletonList(
                             AdsNotificationSample.of(NotificationHandle.of(0), data))
                     )

-- 
To stop receiving notification emails like this one, please contact
sruehl@apache.org.