This is an automated email from the ASF dual-hosted git repository. cdutz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git
commit 4e750d61832453f139786acabb3b64ee8484b035 Author: Christofer Dutz <christofer.d...@c-ware.de> AuthorDate: Fri Sep 14 17:34:48 2018 +0200 - Added some of the correct codes for some of the new datatypes. --- .../plc4x/java/s7/netty/Plc4XS7Protocol.java | 2 +- .../org/apache/plc4x/java/s7/types/S7DataType.java | 38 ++++++++++++++++------ .../apache/plc4x/java/s7/issues/PLC4X47Test.java | 2 +- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java b/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java index 2a52b01..6db3b37 100644 --- a/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java +++ b/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java @@ -539,7 +539,7 @@ public class Plc4XS7Protocol extends PlcMessageToMessageCodec<S7Message, PlcRequ break; } case WCHAR: { // 2 byte - // TODO: Double check, if this is ok? + // TODO: Double check, if this is ok? Alternatives: BMP, UCS2 String stringValue = data.readCharSequence(2, Charset.forName("UTF-16")).toString(); fieldItem = new S7StringFieldItem(field.getDataType(), stringValue); break; diff --git a/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/types/S7DataType.java b/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/types/S7DataType.java index fadea90..e325ffa 100644 --- a/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/types/S7DataType.java +++ b/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/types/S7DataType.java @@ -39,43 +39,51 @@ public enum S7DataType { WORD(0x04, "W", 2, null, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.S7_ANY), DWORD(0x06, "D", 4, WORD, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.S7_ANY), // Only got a basic TIA license (S7-1500 needed to find this out) + // TODO: Find the code LWORD(0x00, "X", 8, null, null, S7ControllerType.S7_1200, S7ControllerType.S7_1500), // ----------------------------------------- // Integers // ----------------------------------------- + // Signed Int INT(0x05, "W", 2, null, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.S7_ANY), + // Unsigned Int + UINT(0x05, "W", 2, INT, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.S7_1200, S7ControllerType.S7_1500), + // (Signed) Small Int + SINT(0x02, "B", 1, INT, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.S7_1200, S7ControllerType.S7_1500), + // Unsigned Small Int + USINT(0x02, "B", 1, INT, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.S7_1200, S7ControllerType.S7_1500), // Double Precision Int DINT(0x07, "D", 4, INT, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.S7_ANY), - // Unsigned Small Int - USINT(0x00, "B", 1, INT, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.S7_1200, S7ControllerType.S7_1500), - // (Signed) Small Int - SINT(0x00, "B", 1, INT, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.S7_1200, S7ControllerType.S7_1500), - // Unsigned Int - UINT(0x00, "W", 2, INT, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.S7_1200, S7ControllerType.S7_1500), // Unsigned Double Precision Int - UDINT(0x00, "D", 4, INT, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.S7_1200, S7ControllerType.S7_1500), + UDINT(0x07, "D", 4, INT, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.S7_1200, S7ControllerType.S7_1500), // Only got a basic TIA license (S7-1500 needed to find this out) + // TODO: Find the code LINT(0x00, "X", 8, INT, null, S7ControllerType.S7_1500), // Only got a basic TIA license (S7-1500 needed to find this out) + // TODO: Find the code ULINT(0x00, "X", 16, INT, null, S7ControllerType.S7_1500), // ----------------------------------------- // Reals // ----------------------------------------- REAL(0x08, "D", 4, null, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.S7_ANY), - LREAL(0x00, "X", 8, REAL, null, S7ControllerType.S7_1200, S7ControllerType.S7_1500), + // TODO: Find the code + LREAL(0x00, "X", 8, REAL, null, S7ControllerType.S7_1200, S7ControllerType.S7_1200, S7ControllerType.S7_1500), // ----------------------------------------- // Durations // ----------------------------------------- // IEC time TIME(0x0B, "X", 4, null, null, S7ControllerType.S7_ANY), + // TODO: Find the code + LTIME(0x00, "X", 8, TIME, null, S7ControllerType.S7_1500), // ----------------------------------------- // Date // ----------------------------------------- // IEC date (yyyy-m-d) + // TODO: Find the code DATE(0x00, "X", 2, null, null, S7ControllerType.S7_ANY), // ----------------------------------------- @@ -95,14 +103,24 @@ public enum S7DataType { // Single-byte character CHAR(0x03, "B", 1, null, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.S7_ANY), // Double-byte character - WCHAR(0x00, "X", 2, null, null, S7ControllerType.S7_ANY), + WCHAR(0x13, "X", 2, null, null, S7ControllerType.S7_1200, S7ControllerType.S7_1500), // Variable-length single-byte character string + // TODO: Find the code (Eventually 0x03) STRING(0x00, "X", -1, null, null, S7ControllerType.S7_ANY), // Variable-length double-byte character string - WSTRING(0x00, "X", -1, null, null, S7ControllerType.S7_ANY); + // TODO: Find the code (Eventually 0x13) + WSTRING(0x00, "X", -1, null, null, S7ControllerType.S7_1200, S7ControllerType.S7_1500); /* TO BE CONTINUED */ + // Codes and their types: + // 0x1C: Counter + // 0x1D: Timer + // 0x1E: IEC Timer + // 0x1F: IEC Counter + // 0x20: HS Counter + // + private final byte typeCode; private final String sizeCode; private int sizeInBytes; diff --git a/plc4j/protocols/s7/src/test/java/org/apache/plc4x/java/s7/issues/PLC4X47Test.java b/plc4j/protocols/s7/src/test/java/org/apache/plc4x/java/s7/issues/PLC4X47Test.java index a667b66..d1c9e8d 100644 --- a/plc4j/protocols/s7/src/test/java/org/apache/plc4x/java/s7/issues/PLC4X47Test.java +++ b/plc4j/protocols/s7/src/test/java/org/apache/plc4x/java/s7/issues/PLC4X47Test.java @@ -41,7 +41,7 @@ public class PLC4X47Test { PlcReadRequest.Builder builder = connection.readRequestBuilder(); for (int i = 1; i <= 30; i++) { // just the first byte of each db - builder.addItem("field-" + i, "%DB3.DB" + i + ":INT"); + builder.addItem("field-" + i, "%DB3.DB" + i + ":SINT"); } PlcReadRequest readRequest = builder.build(); PlcReadResponse<?> readResponse = connection.read(readRequest).get();