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/01/26 18:29:43 UTC

[incubator-plc4x] branch feature/Beckhoff_ADS_protocol updated: extracted classes from generic model

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

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


The following commit(s) were added to refs/heads/feature/Beckhoff_ADS_protocol by this push:
     new 497730c  extracted classes from generic model
497730c is described below

commit 497730c51873a0799978dcce9341b0131b4b20c3
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Fri Jan 26 19:29:39 2018 +0100

    extracted classes from generic model
---
 .../plc4x/java/ads/model/generic/AMSHeader.java    | 175 +++------------------
 .../plc4x/java/ads/model/generic/AMSTCPHeader.java |  20 +--
 .../java/ads/model/generic/types/AMSNetId.java     |  44 ++++++
 .../java/ads/model/generic/types/AMSPort.java      |  35 +++++
 .../java/ads/model/generic/types/Command.java      |  56 +++++++
 .../plc4x/java/ads/model/generic/types/Data.java   |  27 ++++
 .../java/ads/model/generic/types/DataLength.java   |  34 ++++
 .../plc4x/java/ads/model/generic/types/Error.java  |  28 ++++
 .../plc4x/java/ads/model/generic/types/Invoke.java |  28 ++++
 .../plc4x/java/ads/model/generic/types/Length.java |  28 ++++
 .../plc4x/java/ads/model/generic/types/State.java  |  62 ++++++++
 11 files changed, 366 insertions(+), 171 deletions(-)

diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/AMSHeader.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/AMSHeader.java
index 6e26563..38e78fb 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/AMSHeader.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/AMSHeader.java
@@ -19,11 +19,8 @@
 package org.apache.plc4x.java.ads.model.generic;
 
 import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
+import org.apache.plc4x.java.ads.model.generic.types.*;
 import org.apache.plc4x.java.ads.model.util.ByteReadable;
-import org.apache.plc4x.java.ads.model.util.ByteValue;
-
-import java.nio.ByteBuffer;
 
 /**
  * AMS Header	32 bytes	The AMS/TCP-Header contains the addresses of the transmitter and receiver. In addition the AMS error code , the ADS command Id and some other information.
@@ -45,20 +42,35 @@ public class AMSHeader implements ByteReadable {
      * This contains the AMSPort of the station, from which the packet was sent.
      */
     private final AMSPort sourceAmsPort;
-
+    /**
+     * 2 bytes.
+     */
     private final Command commandId;
 
     private final State stateFlags;
 
+    /**
+     * 4 bytes	Size of the data range. The unit is byte.
+     */
     private final DataLength dataLength;
 
-    private final Error code;
+    /**
+     * 4 bytes	AMS error number. See ADS Return Codes.
+     */
+    private final org.apache.plc4x.java.ads.model.generic.types.Error code;
 
+    /**
+     * 4 bytes	Free usable 32 bit array. Usually this array serves to send an Id. This Id makes is possible to assign a received response to a request, which was sent before.
+     */
     private final Invoke invokeId;
 
+    /**
+     * bytes	Data range. The data range contains the parameter of the considering ADS commands.
+     */
+    // TODO: check if this is indeed {@link ADSData} and the documentation is just confusing at this point
     private final Data nData;
 
-    public AMSHeader(AMSNetId targetAmsNetId, AMSPort targetAmsPort, AMSNetId sourceAmsNetId, AMSPort sourceAmsPort, Command commandId, State stateFlags, DataLength dataLength, Error code, Invoke invokeId, Data nData) {
+    public AMSHeader(AMSNetId targetAmsNetId, AMSPort targetAmsPort, AMSNetId sourceAmsNetId, AMSPort sourceAmsPort, Command commandId, State stateFlags, DataLength dataLength, org.apache.plc4x.java.ads.model.generic.types.Error code, Invoke invokeId, Data nData) {
         this.targetAmsNetId = targetAmsNetId;
         this.targetAmsPort = targetAmsPort;
         this.sourceAmsNetId = sourceAmsNetId;
@@ -71,155 +83,6 @@ public class AMSHeader implements ByteReadable {
         this.nData = nData;
     }
 
-    /**
-     * The AMSNetId consists of 6 bytes and addresses the transmitter or receiver. One possible AMSNetId would be e.g.. 172.16.17.10.1.1. The storage arrangement in this example is as follows:
-     * <p>
-     * _____0     1     2     3     4     5
-     * __+-----------------------------------+
-     * 0 | 127 |  16 |  17 |  10 |   1 |   1 |
-     * __+-----------------------------------+
-     * <p>
-     * <p>
-     * The AMSNetId is purely logical and has usually no relation to the IP address. The AMSNetId is configurated at the target system. At the PC for this the TwinCAT System Control is used. If you use other hardware, see the considering documentation for notes about settings of the AMS NetId.
-     */
-    public static class AMSNetId extends ByteValue {
-
-        public AMSNetId(int octed1, int octed2, int octed3, int octed4, int octed5, int octed6) {
-            super((byte) octed1, (byte) octed2, (byte) octed3, (byte) octed4, (byte) octed5, (byte) octed6);
-        }
-
-        public AMSNetId(byte... value) {
-            super(value);
-            assertLength(6);
-        }
-    }
-
-    public static class AMSPort extends ByteValue {
-
-        public AMSPort(int port) {
-            super(ByteBuffer.allocate(2).putInt(port).array());
-        }
-
-        public AMSPort(byte... value) {
-            super(value);
-            assertLength(2);
-        }
-    }
-
-    /**
-     * 2 bytes	see below.
-     */
-    enum Command implements ByteReadable {
-        Invalid(0x0000),
-        ADS_Read_Device_Info(0x0001),
-        ADS_Read(0x0002),
-        ADS_Write(0x0003),
-        ADS_Read_State(0x0004),
-        ADS_Write_Control(0x0005),
-        ADS_Add_Device_Notification(0x0006),
-        ADS_Delete_Device_Notification(0x0007),
-        ADS_Device_Notification(0x0008),
-        ADS_Read_Write(0x0009),
-        /**
-         * Other commands are not defined or are used internally. Therefore the Command Id  is only allowed to contain the above enumerated values!
-         */
-        UNKNOWN(0xffff);
-        final byte[] value;
-
-        Command(int value) {
-            this.value = ByteBuffer.allocate(4).putInt(value).array();
-        }
-
-        @Override
-        public byte[] getBytes() {
-            return value;
-        }
-
-        public ByteBuf getByteBuf() {
-            return Unpooled.buffer().writeBytes(value);
-        }
-    }
-
-    /**
-     * 2 bytes	see below.
-     * <p>
-     * State Flags
-     * Flag     Description
-     * 0x0001	0: Request / 1: Response
-     * 0x0004	ADS command
-     * The first bit marks, whether it´s a request or response. The third bit must be set to 1, to exchange data with ADS commands. The other bits are not defined or were used for other internal purposes.
-     * <p>
-     * Therefore the other bits must be set to 0!
-     * <p>
-     * Flag     Description
-     * 0x000x	TCP Protocol
-     * 0x004x	UDP Protocol
-     * Bit number 7 marks, if it should be transfered with TCP or UDP.
-     */
-    enum State implements ByteReadable {
-        ADS_REQUEST_TCP(0x0004),
-        ADS_RESPONSE_TCP(0x0005),
-        ADS_REQUEST_UDP(0x0044),
-        ADS_RESPONSE_UDP(0x0045);
-        final byte[] value;
-
-        State(int value) {
-            this.value = ByteBuffer.allocate(4).putInt(value).array();
-        }
-
-        @Override
-        public byte[] getBytes() {
-            return value;
-        }
-
-        public ByteBuf getByteBuf() {
-            return Unpooled.buffer().writeBytes(value);
-        }
-    }
-
-    /**
-     * 4 bytes	Size of the data range. The unit is byte.
-     */
-    static class DataLength extends ByteValue {
-        public DataLength(int length) {
-            super(ByteBuffer.allocate(4).putInt(length).array());
-        }
-
-        public DataLength(byte... value) {
-            super(value);
-            assertLength(4);
-        }
-    }
-
-    /**
-     * 4 bytes	AMS error number. See ADS Return Codes.
-     */
-    static class Error extends ByteValue {
-        public Error(byte... value) {
-            super(value);
-            assertLength(4);
-        }
-    }
-
-    /**
-     * 4 bytes	Free usable 32 bit array. Usually this array serves to send an Id. This Id makes is possible to assign a received response to a request, which was sent before.
-     */
-    static class Invoke extends ByteValue {
-        public Invoke(byte... value) {
-            super(value);
-            assertLength(4);
-        }
-    }
-
-    /**
-     * bytes	Data range. The data range contains the parameter of the considering ADS commands.
-     */
-    static class Data extends ByteValue {
-        public Data(byte... value) {
-            super(value);
-        }
-    }
-
     @Override
     public ByteBuf getByteBuf() {
         return AMSTCPPaket.buildByteBuff(
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/AMSTCPHeader.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/AMSTCPHeader.java
index c2f5c99..adb30fe 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/AMSTCPHeader.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/AMSTCPHeader.java
@@ -19,6 +19,7 @@
 package org.apache.plc4x.java.ads.model.generic;
 
 import io.netty.buffer.ByteBuf;
+import org.apache.plc4x.java.ads.model.generic.types.Length;
 import org.apache.plc4x.java.ads.model.util.ByteReadable;
 import org.apache.plc4x.java.ads.model.util.ByteValue;
 
@@ -38,32 +39,21 @@ public class AMSTCPHeader implements ByteReadable {
 
     @Override
     public ByteBuf getByteBuf() {
-        return AMSTCPPaket.buildByteBuff(reserved,length);
+        return AMSTCPPaket.buildByteBuff(reserved, length);
     }
 
     /**
      * Size: 2 bytes
      * These bytes must be set to 0.
      */
-    static class Reserved extends ByteValue {
+    private static class Reserved extends ByteValue {
 
-        static final Reserved CONSTANT = new Reserved();
+        private static final Reserved CONSTANT = new Reserved();
 
-        public Reserved() {
+        private Reserved() {
             super((byte) 0x00, (byte) 0x00);
             assertLength(2);
         }
     }
 
-    /**
-     * Size: 4 bytes
-     * This array contains the length of the data packet. It consists of the AMS-Header and the enclosed ADS data. The unit is bytes.
-     */
-    static class Length extends ByteValue {
-
-        public Length(byte... value) {
-            super(value);
-            assertLength(4);
-        }
-    }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/AMSNetId.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/AMSNetId.java
new file mode 100644
index 0000000..d5967d7
--- /dev/null
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/AMSNetId.java
@@ -0,0 +1,44 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package org.apache.plc4x.java.ads.model.generic.types;
+
+import org.apache.plc4x.java.ads.model.util.ByteValue;
+
+/**
+ * The AMSNetId consists of 6 bytes and addresses the transmitter or receiver. One possible AMSNetId would be e.g.. 172.16.17.10.1.1. The storage arrangement in this example is as follows:
+ * <p>
+ * _____0     1     2     3     4     5
+ * __+-----------------------------------+
+ * 0 | 127 |  16 |  17 |  10 |   1 |   1 |
+ * __+-----------------------------------+
+ * <p>
+ * <p>
+ * The AMSNetId is purely logical and has usually no relation to the IP address. The AMSNetId is configurated at the target system. At the PC for this the TwinCAT System Control is used. If you use other hardware, see the considering documentation for notes about settings of the AMS NetId.
+ */
+public class AMSNetId extends ByteValue {
+
+    public AMSNetId(int octed1, int octed2, int octed3, int octed4, int octed5, int octed6) {
+        super((byte) octed1, (byte) octed2, (byte) octed3, (byte) octed4, (byte) octed5, (byte) octed6);
+    }
+
+    public AMSNetId(byte... value) {
+        super(value);
+        assertLength(6);
+    }
+}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/AMSPort.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/AMSPort.java
new file mode 100644
index 0000000..52dd779
--- /dev/null
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/AMSPort.java
@@ -0,0 +1,35 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package org.apache.plc4x.java.ads.model.generic.types;
+
+import org.apache.plc4x.java.ads.model.util.ByteValue;
+
+import java.nio.ByteBuffer;
+
+public class AMSPort extends ByteValue {
+
+    public AMSPort(int port) {
+        super(ByteBuffer.allocate(2).putInt(port).array());
+    }
+
+    public AMSPort(byte... value) {
+        super(value);
+        assertLength(2);
+    }
+}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/Command.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/Command.java
new file mode 100644
index 0000000..f16f7d7
--- /dev/null
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/Command.java
@@ -0,0 +1,56 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package org.apache.plc4x.java.ads.model.generic.types;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import org.apache.plc4x.java.ads.model.util.ByteReadable;
+
+import java.nio.ByteBuffer;
+
+public enum Command implements ByteReadable {
+    Invalid(0x0000),
+    ADS_Read_Device_Info(0x0001),
+    ADS_Read(0x0002),
+    ADS_Write(0x0003),
+    ADS_Read_State(0x0004),
+    ADS_Write_Control(0x0005),
+    ADS_Add_Device_Notification(0x0006),
+    ADS_Delete_Device_Notification(0x0007),
+    ADS_Device_Notification(0x0008),
+    ADS_Read_Write(0x0009),
+    /**
+     * Other commands are not defined or are used internally. Therefore the Command Id  is only allowed to contain the above enumerated values!
+     */
+    UNKNOWN(0xffff);
+    final byte[] value;
+
+    Command(int value) {
+        this.value = ByteBuffer.allocate(4).putInt(value).array();
+    }
+
+    @Override
+    public byte[] getBytes() {
+        return value;
+    }
+
+    public ByteBuf getByteBuf() {
+        return Unpooled.buffer().writeBytes(value);
+    }
+}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/Data.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/Data.java
new file mode 100644
index 0000000..eaf19a9
--- /dev/null
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/Data.java
@@ -0,0 +1,27 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package org.apache.plc4x.java.ads.model.generic.types;
+
+import org.apache.plc4x.java.ads.model.util.ByteValue;
+
+public class Data extends ByteValue {
+    public Data(byte... value) {
+        super(value);
+    }
+}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/DataLength.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/DataLength.java
new file mode 100644
index 0000000..7433d5f
--- /dev/null
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/DataLength.java
@@ -0,0 +1,34 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package org.apache.plc4x.java.ads.model.generic.types;
+
+import org.apache.plc4x.java.ads.model.util.ByteValue;
+
+import java.nio.ByteBuffer;
+
+public class DataLength extends ByteValue {
+    public DataLength(int length) {
+        super(ByteBuffer.allocate(4).putInt(length).array());
+    }
+
+    public DataLength(byte... value) {
+        super(value);
+        assertLength(4);
+    }
+}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/Error.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/Error.java
new file mode 100644
index 0000000..1d1bed5
--- /dev/null
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/Error.java
@@ -0,0 +1,28 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package org.apache.plc4x.java.ads.model.generic.types;
+
+import org.apache.plc4x.java.ads.model.util.ByteValue;
+
+public class Error extends ByteValue {
+    public Error(byte... value) {
+        super(value);
+        assertLength(4);
+    }
+}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/Invoke.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/Invoke.java
new file mode 100644
index 0000000..c057f84
--- /dev/null
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/Invoke.java
@@ -0,0 +1,28 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package org.apache.plc4x.java.ads.model.generic.types;
+
+import org.apache.plc4x.java.ads.model.util.ByteValue;
+
+public class Invoke extends ByteValue {
+    public Invoke(byte... value) {
+        super(value);
+        assertLength(4);
+    }
+}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/Length.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/Length.java
new file mode 100644
index 0000000..9a5f95c
--- /dev/null
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/Length.java
@@ -0,0 +1,28 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package org.apache.plc4x.java.ads.model.generic.types;
+
+import org.apache.plc4x.java.ads.model.util.ByteValue;
+
+public class Length extends ByteValue {
+    public Length(byte... value) {
+        super(value);
+        assertLength(4);
+    }
+}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/State.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/State.java
new file mode 100644
index 0000000..294318e
--- /dev/null
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/generic/types/State.java
@@ -0,0 +1,62 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package org.apache.plc4x.java.ads.model.generic.types;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import org.apache.plc4x.java.ads.model.util.ByteReadable;
+
+import java.nio.ByteBuffer;
+
+/**
+ * 2 bytes	see below.
+ * <p>
+ * State Flags
+ * Flag     Description
+ * 0x0001	0: Request / 1: Response
+ * 0x0004	ADS command
+ * The first bit marks, whether it´s a request or response. The third bit must be set to 1, to exchange data with ADS commands. The other bits are not defined or were used for other internal purposes.
+ * <p>
+ * Therefore the other bits must be set to 0!
+ * <p>
+ * Flag     Description
+ * 0x000x	TCP Protocol
+ * 0x004x	UDP Protocol
+ * Bit number 7 marks, if it should be transfered with TCP or UDP.
+ */
+public enum State implements ByteReadable {
+    ADS_REQUEST_TCP(0x0004),
+    ADS_RESPONSE_TCP(0x0005),
+    ADS_REQUEST_UDP(0x0044),
+    ADS_RESPONSE_UDP(0x0045);
+    final byte[] value;
+
+    State(int value) {
+        this.value = ByteBuffer.allocate(4).putInt(value).array();
+    }
+
+    @Override
+    public byte[] getBytes() {
+        return value;
+    }
+
+    public ByteBuf getByteBuf() {
+        return Unpooled.buffer().writeBytes(value);
+    }
+}

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