Skip to content

Commit 3aa42c3

Browse files
committed
Reqorking types!
1 parent a1d280d commit 3aa42c3

File tree

3 files changed

+148
-4
lines changed

3 files changed

+148
-4
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
New:
2+
3+
BOOL(Boolean.class),
4+
5+
BYTE(Byte.class),
6+
7+
INT16(Short.class),
8+
UINT16(Short.class),
9+
10+
INT32(Integer.class),
11+
UINT32(Integer.class),
12+
13+
INT64(Long.class),
14+
15+
REAL(Float.class),
16+
17+
LREAL(Double.class),
18+
19+
TIME(Long.class)
20+
21+
STRING(String.class),
22+
23+
DATE(LocalDate.class),
24+
TIME_OF_DAY(LocalTime.class),
25+
DATE_AND_TIME(LocalDateTime.class),
26+
27+
28+
NULL((short) 0x00, null),
29+
30+
BOOL((short) 0x01, Boolean.class),
31+
32+
BYTE((short) 0x02, Byte.class),
33+
SINT((short) 0x21, Byte.class),
34+
35+
WORD((short) 0x03, Short.class),
36+
USINT((short) 0x11, Short.class),
37+
INT((short) 0x22, Short.class),
38+
WCHAR((short) 0x42, Short.class),
39+
40+
DWORD((short) 0x04, Integer.class),
41+
UINT((short) 0x12, Integer.class),
42+
DINT((short) 0x23, Integer.class),
43+
44+
LWORD((short) 0x05, Long.class),
45+
UDINT((short) 0x13, Long.class),
46+
LINT((short) 0x24, Long.class),
47+
48+
ULINT((short) 0x14, BigInteger.class),
49+
50+
STRING((short) 0x43, String.class),
51+
WSTRING((short) 0x44, String.class),
52+
53+
REAL((short) 0x31, Float.class),
54+
LREAL((short) 0x32, Double.class),
55+
56+
CHAR((short) 0x41, Character.class),
57+
58+
59+
TIME((short) 0x51, Duration.class),
60+
LTIME((short) 0x52, Duration.class),
61+
DATE((short) 0x53, LocalDate.class),
62+
LDATE((short) 0x54, LocalDate.class),
63+
TIME_OF_DAY((short) 0x55, LocalTime.class),
64+
LTIME_OF_DAY((short) 0x56, LocalTime.class),
65+
DATE_AND_TIME((short) 0x57, LocalDateTime.class),
66+
LDATE_AND_TIME((short) 0x58, LocalDateTime.class),
67+
RAW_BYTE_ARRAY((short) 0x71, Byte.class);

modules/hivemq-edge-module-s7/src/main/java/com/hivemq/edge/adapters/s7/config/S7DataType.java

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,61 @@
1515
*/
1616
package com.hivemq.edge.adapters.s7.config;
1717

18+
import java.math.BigInteger;
1819
import java.time.LocalDate;
1920
import java.time.LocalDateTime;
2021
import java.time.LocalTime;
22+
import java.util.List;
23+
24+
import static com.hivemq.edge.adapters.s7.config.S7Versions.S7_1200;
25+
import static com.hivemq.edge.adapters.s7.config.S7Versions.S7_1500;
26+
import static com.hivemq.edge.adapters.s7.config.S7Versions.S7_200;
27+
import static com.hivemq.edge.adapters.s7.config.S7Versions.S7_300;
28+
import static com.hivemq.edge.adapters.s7.config.S7Versions.S7_400;
2129

2230
/**
23-
* @author Simon L Johnson
31+
* Documented here:
32+
* https://support.industry.siemens.com/cs/mdm/109054417?c=69695636619&lc=en-GE
2433
*/
2534
public enum S7DataType {
26-
BOOL(Boolean.class),
27-
BYTE(Byte.class),
35+
BOOL(Boolean.class, 1, List.of(S7_300, S7_400, S7_1200, S7_1500), "Boolean", "https://support.industry.siemens.com/cs/mdm/109054417?c=46422035979&lc=en-GE"),
36+
BYTE(Byte.class, 8, List.of(S7_300, S7_400, S7_1200, S7_1500), "Byte", "https://support.industry.siemens.com/cs/mdm/109054417?c=56595553163&lc=en-GE"),
37+
WORD(Byte[].class, 16, List.of(S7_300, S7_400, S7_1200, S7_1500), "Word", "https://support.industry.siemens.com/cs/mdm/109054417?c=56595472523&lc=en-GE"),
38+
DWORD(Byte[].class, 32, List.of(S7_300, S7_400, S7_1200, S7_1500), "Double Word", "https://support.industry.siemens.com/cs/mdm/109054417?c=56595322763&lc=en-GE"),
39+
LWORD(Byte[].class, 64, List.of(S7_1500), "Long Word", "https://support.industry.siemens.com/cs/mdm/109054417?c=56595507211&lc=en-GE"),
40+
USINT(Short.class, 8, List.of(S7_1200, S7_1500), "Unsigned Short Integer", "https://support.industry.siemens.com/cs/mdm/109054417?c=46521647883&lc=en-GE"),
41+
UINT(Integer.class, 16, List.of(S7_1200, S7_1500), "Unsigned Integer", "https://support.industry.siemens.com/cs/mdm/109054417?c=46521834123&lc=en-GE"),
42+
UDINT(Long.class, 32, List.of(S7_1200, S7_1500), "Unsigned Double Integer", "https://support.industry.siemens.com/cs/mdm/109054417?c=46521930763&lc=en-GE"),
43+
ULINT(BigInteger.class, 64, List.of(S7_1500), "Unsigned Long Integer", "https://support.industry.siemens.com/cs/mdm/109054417?c=59653945739&lc=en-GE"),
44+
SINT(Byte.class, 8, List.of(S7_1200, S7_1500), "Short Integer", "https://support.industry.siemens.com/cs/mdm/109054417?c=68894861835&lc=en-GE"),
45+
INT(Short.class, 16, List.of(S7_300, S7_400, S7_1200, S7_1500),"Integer", "https://support.industry.siemens.com/cs/mdm/109054417?c=63679745547&lc=en-GE"),
46+
DINT(Integer.class, 32, List.of(S7_300, S7_400, S7_1200, S7_1500), "Double Integer", "https://support.industry.siemens.com/cs/mdm/109054417?c=46521869963&lc=en-GE"),
47+
LINT(Long.class, 64, List.of(S7_1500), "Long Integer", "https://support.industry.siemens.com/cs/mdm/109054417?c=66825552267&lc=en-GE"),
48+
REAL(Float.class, 32, List.of(S7_300, S7_400, S7_1200, S7_1500), "Real", "https://support.industry.siemens.com/cs/mdm/109054417?c=68826794251&lc=en-GE"),
49+
LREAL(Float.class, 64, List.of(S7_1200, S7_1500), "Long Real", "https://support.industry.siemens.com/cs/mdm/109054417?c=68826903691&lc=en-GE"),
50+
51+
CHAR(Character.class, 8, List.of(S7_300, S7_400, S7_1200, S7_1500), "Character", "https://support.industry.siemens.com/cs/mdm/109054417?c=57152595083&lc=en-GE"),
52+
WCHAR(Short.class, 16, List.of(S7_1200, S7_1500), "Wide Character", "https://support.industry.siemens.com/cs/mdm/109054417?c=10488733835&lc=en-GE"),
53+
STRING(String.class, -1, List.of(S7_300, S7_400, S7_1200, S7_1500), "String, 0 to 254 characters only ASCII", "https://support.industry.siemens.com/cs/mdm/109054417?c=63689840011&lc=en-GE"),
54+
WSTRING(String.class, -1, List.of(S7_1200, S7_1500), "Wide String, 0 to 254 characters only Unicode", "https://support.industry.siemens.com/cs/mdm/109054417?c=61472021771&lc=en-GE"), //
55+
56+
TIME(Long.class, 32, List.of(S7_300, S7_400, S7_1200, S7_1500), "IEC Time (ms)", "https://support.industry.siemens.com/cs/mdm/109054417?c=61085966091&lc=en-GE"),
57+
LTIME(BigInteger.class, 64, List.of(S7_1500), "IEC Time (ns)", "https://support.industry.siemens.com/cs/mdm/109054417?c=61410814475&lc=en-GE"),
58+
59+
DATE(Short.class, 8, List.of(S7_300, S7_400, S7_1200, S7_1500), "IEC Date, since 01-01-1990 (Year-Month-Day)", "https://support.industry.siemens.com/cs/mdm/109054417?c=46522046859&lc=en-GE"),
60+
TOD(Long.class, 32, List.of(S7_300, S7_400, S7_1200, S7_1500), "Time Of Day (hours:minutes:seconds.milliseconds)", "https://support.industry.siemens.com/cs/mdm/109054417?c=64869849355&lc=en-GE"),
61+
LTOD(BigInteger.class, 64, List.of(S7_1500), "Time-of-day (hours:minutes:seconds.nanoseconds)", "https://support.industry.siemens.com/cs/mdm/109054417?c=64869390987&lc=en-GE"),
62+
DT(BigInteger.class, 64, List.of(S7_1500), "Date and time (year-month-day-hour:minute:second:millisecond)", "https://support.industry.siemens.com/cs/mdm/109054417?c=61473284875&lc=en-GE"),
63+
LDT(BigInteger.class, 64, List.of(S7_1500), "Date and time (year-month-day-hour:minute:second:nanoseconds)", "https://support.industry.siemens.com/cs/mdm/109054417?c=71834521483&lc=en-GE"),
64+
DTL(BigInteger.class, 64, List.of(S7_1500), "Date and time (year-month-day-hour:minute:second:nanoseconds)", "https://support.industry.siemens.com/cs/mdm/109054417?c=64682916235&lc=en-GE"),
65+
66+
67+
/**
68+
* UNSUPPORTED
69+
* S5TIME https://support.industry.siemens.com/cs/mdm/109054417?c=63689295627&lc=en-GE
70+
*/
71+
72+
BYTE_ARRAY(Byte[].class),
2873
INT16(Short.class),
2974
UINT16(Short.class),
3075
INT32(Integer.class),
@@ -38,13 +83,36 @@ public enum S7DataType {
3883
DATE_AND_TIME(LocalDateTime.class),
3984
TIME(Long.class);
4085

41-
S7DataType(Class<?> javaType){
86+
S7DataType(Class<?> javaType, int lengthInBits, List<S7Versions> availableOn, String description, String docs){
4287
this.javaType = javaType;
88+
this.lengthInBits = lengthInBits;
89+
this.availableOn = availableOn;
90+
this.description = description;
91+
this.docs = docs;
4392
}
4493
private Class<?> javaType;
94+
private final int lengthInBits;
95+
private final List<S7Versions> availableOn;
96+
private final String description;
97+
private final String docs;
4598

4699
public Class<?> getJavaType() {
47100
return javaType;
48101
}
49102

103+
public int getLengthInBits() {
104+
return lengthInBits;
105+
}
106+
107+
public List<S7Versions> getAvailableOn() {
108+
return availableOn;
109+
}
110+
111+
public String getDescription() {
112+
return description;
113+
}
114+
115+
public String getDocs() {
116+
return docs;
117+
}
50118
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.hivemq.edge.adapters.s7.config;
2+
3+
public enum S7Versions {
4+
S7_200,
5+
S7_300,
6+
S7_400,
7+
S7_1200,
8+
S7_1500
9+
}

0 commit comments

Comments
 (0)