You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2020/09/26 15:52:44 UTC
[plc4x] 06/10: - Continued Ben's great work towards this. -
Refactored the existing Java type based PlcValues to a more generic IEC
61131-3 based type system. - Got everything working,
all tests to pass etc and did some testing of S7 and Modbus reading.
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit df0adc85dbd47779b170c3b3aff1a61231afb29b
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Fri Sep 25 17:08:24 2020 +0200
- Continued Ben's great work towards this.
- Refactored the existing Java type based PlcValues to a more generic IEC 61131-3 based type system.
- Got everything working, all tests to pass etc and did some testing of S7 and Modbus reading.
---
RELEASE_NOTES | 14 +-
.../org/apache/plc4x/java/api/value/PlcBOOL.java | 39 ++--
.../apache/plc4x/java/api/value/PlcBoolean.java | 168 --------------
.../org/apache/plc4x/java/api/value/PlcByte.java | 256 ++++++++++++---------
.../org/apache/plc4x/java/api/value/PlcCHAR.java | 6 +-
.../org/apache/plc4x/java/api/value/PlcDINT.java | 136 +++++++++--
.../org/apache/plc4x/java/api/value/PlcDWORD.java | 24 +-
.../org/apache/plc4x/java/api/value/PlcDouble.java | 168 --------------
.../org/apache/plc4x/java/api/value/PlcFloat.java | 168 --------------
.../apache/plc4x/java/api/value/PlcIECValue.java | 1 -
.../org/apache/plc4x/java/api/value/PlcINT.java | 139 +++++++++--
.../apache/plc4x/java/api/value/PlcInteger.java | 168 --------------
.../org/apache/plc4x/java/api/value/PlcLINT.java | 138 +++++++++--
.../org/apache/plc4x/java/api/value/PlcLREAL.java | 135 +++++++++--
.../org/apache/plc4x/java/api/value/PlcLWORD.java | 8 +-
.../org/apache/plc4x/java/api/value/PlcLong.java | 168 --------------
.../org/apache/plc4x/java/api/value/PlcREAL.java | 135 +++++++++--
.../org/apache/plc4x/java/api/value/PlcSINT.java | 137 +++++++++--
.../org/apache/plc4x/java/api/value/PlcShort.java | 168 --------------
.../org/apache/plc4x/java/api/value/PlcUDINT.java | 137 +++++++++--
.../org/apache/plc4x/java/api/value/PlcUINT.java | 132 +++++++++--
.../org/apache/plc4x/java/api/value/PlcULINT.java | 120 +++++++++-
.../org/apache/plc4x/java/api/value/PlcUSINT.java | 136 +++++++++--
.../org/apache/plc4x/java/api/value/PlcValues.java | 56 ++---
.../org/apache/plc4x/java/api/value/PlcWCHAR.java | 26 +--
.../org/apache/plc4x/java/api/value/PlcWORD.java | 22 +-
.../java/abeth/protocol/AbEthProtocolLogic.java | 7 +-
.../java/abeth/protocol/Plc4xAbEthProtocol.java | 4 +-
.../plc4x/java/ads/field/AdsFieldHandler.java | 81 +++----
.../attic/protocol/util/LittleEndianDecoder.java | 62 ++---
.../src/test/resources/testsuite/AdsDriverIT.xml | 12 +-
.../java/eip/readwrite/field/EipFieldHandler.java | 12 +-
.../eip/readwrite/protocol/EipProtocolLogic.java | 22 +-
.../resources/testsuite/EIPDriverTestsuite.xml | 2 +-
.../readwrite/field/FirmataFieldHandler.java | 13 +-
.../readwrite/protocol/FirmataProtocolLogic.java | 11 +-
.../java/knxnetip/field/KnxNetIpFieldHandler.java | 1 -
.../plc4x/java/modbus/field/ModbusField.java | 4 +-
.../modbus/field/ModbusFieldDiscreteInput.java | 10 +-
.../opcua/connection/OpcuaTcpPlcConnection.java | 26 +--
.../java/opcua/protocol/OpcuaPlcFieldHandler.java | 14 +-
.../plc4x/java/s7/readwrite/field/S7Field.java | 4 +-
.../java/s7/readwrite/field/S7PlcFieldHandler.java | 14 +-
.../s7/src/test/resources/testsuite/S7DriverIT.xml | 2 +-
.../simulated/field/SimulatedFieldHandler.java | 14 +-
.../simulated/connection/SimulatedDeviceTest.java | 4 +-
.../watertank/service/WaterTankService.java | 4 +-
.../plc4x/edgent/PlcConnectionAdapterTest.java | 1 -
.../java/spi/messages/DefaultPlcReadResponse.java | 2 +-
.../java/opm/PlcEntityManagerComplexTest.java | 4 +-
.../org/apache/plc4x/java/scraper/ScraperTest.java | 6 +-
.../triggeredscraper/TriggeredScraperImplTest.java | 16 +-
.../ads/src/main/resources/protocols/ads/ads.mspec | 58 ++---
.../resources/protocols/knxnetip/knxnetip.mspec | 28 +--
.../main/resources/protocols/modbus/modbus.mspec | 4 +-
.../s7/src/main/resources/protocols/s7/s7.mspec | 30 +--
.../java/examples/helloinflux/HelloInflux.java | 22 +-
.../plc4c/generated-sources/modbus/src/data_item.c | 248 +++++++++++++++++++-
.../modbus_pdu_write_file_record_request_item.c | 12 +-
.../modbus_pdu_write_file_record_response_item.c | 14 +-
sandbox/plc4c/generated-sources/s7/src/data_item.c | 30 +--
.../plc4x/java/bacnetip/ede/model/Datapoint.java | 20 +-
.../bacnetip/protocol/BacNetIpProtocolLogic.java | 6 +-
.../plc4x/java/df1/protocol/Plc4XDf1Protocol.java | 6 +-
64 files changed, 1986 insertions(+), 1649 deletions(-)
diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index cc1d79b..0d578d2 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -9,10 +9,14 @@ a particular topic.
New Features
------------
-The KNXnet/IP Driver now supports writing of values.
+- The KNXnet/IP Driver now supports writing of values.
-The Modbus driver now supports more common notations of
-Modbus addresses using a pure-numeric notation.
+- The Modbus driver now supports more common notations of
+ Modbus addresses using a pure-numeric notation.
+
+- Especially the Modbus driver has been enhanced to read
+ more complex types such as REAL, DINT, ... not just BOOL
+ and INT
Incompatible changes
--------------------
@@ -30,6 +34,10 @@ Incompatible changes
Read an array of 3 Strings where each is max 10 chars long:
%DB2:30:STRING(10)[3]
+- The PLCValue types have been refactored to align with the types
+ defined in IEC 61131-3 (https://en.wikipedia.org/wiki/IEC_61131-3)
+ directly using the older Java types (PlcBoolean) is no longer
+ possible.
Bug Fixes
---------
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcBOOL.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcBOOL.java
index b56ab22..ebc973b 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcBOOL.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcBOOL.java
@@ -25,8 +25,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
-import org.apache.plc4x.java.api.value.*;
-
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -44,8 +42,8 @@ public class PlcBOOL extends PlcIECValue<Boolean> {
public PlcBOOL(Byte value) {
super();
- if (value >= minValue && value <= maxValue) {
- this.value = ((value != null) && value >= 1) ? true : false;
+ if ((value != null) && (value >= minValue && value <= maxValue)) {
+ this.value = value >= 1;
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -56,8 +54,8 @@ public class PlcBOOL extends PlcIECValue<Boolean> {
public PlcBOOL(Short value) {
super();
- if (value >= minValue && value <= maxValue) {
- this.value = ((value != null) && value >= 1) ? true : false;
+ if ((value != null) && (value >= minValue && value <= maxValue)) {
+ this.value = value >= 1;
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -68,8 +66,8 @@ public class PlcBOOL extends PlcIECValue<Boolean> {
public PlcBOOL(Integer value) {
super();
- if (value >= minValue && value <= maxValue) {
- this.value = ((value != null) && value >= 1) ? true : false;
+ if ((value != null) && (value >= minValue && value <= maxValue)) {
+ this.value = value >= 1;
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -80,8 +78,8 @@ public class PlcBOOL extends PlcIECValue<Boolean> {
public PlcBOOL(Long value) {
super();
- if (value >= minValue && value <= maxValue) {
- this.value = ((value != null) && value >= 1) ? true : false;
+ if ((value != null) && (value >= minValue && value <= maxValue)) {
+ this.value = value >= 1;
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -92,8 +90,8 @@ public class PlcBOOL extends PlcIECValue<Boolean> {
public PlcBOOL(Float value) {
super();
- if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = ((value != null) && value >= 1) ? true : false;
+ if ((value != null) && (value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
+ this.value = value >= 1;
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -104,8 +102,8 @@ public class PlcBOOL extends PlcIECValue<Boolean> {
public PlcBOOL(Double value) {
super();
- if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = ((value != null) && value >= 1) ? true : false;
+ if ((value != null) && (value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
+ this.value = value >= 1;
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -116,8 +114,8 @@ public class PlcBOOL extends PlcIECValue<Boolean> {
public PlcBOOL(BigInteger value) {
super();
- if ((value.compareTo(BigInteger.valueOf(minValue)) >= 0) && (value.compareTo(BigInteger.valueOf(maxValue)) <= 0)) {
- this.value = ((value != null) && (value.compareTo(BigInteger.valueOf(maxValue)) >= 0)) ? true : false;
+ if ((value != null) && (value.compareTo(BigInteger.valueOf(minValue)) >= 0) && (value.compareTo(BigInteger.valueOf(maxValue)) <= 0)) {
+ this.value = value.compareTo(BigInteger.valueOf(maxValue)) >= 0;
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -128,8 +126,8 @@ public class PlcBOOL extends PlcIECValue<Boolean> {
public PlcBOOL(BigDecimal value) {
super();
- if ((value.compareTo(BigDecimal.valueOf(minValue)) >= 0) && (value.compareTo(BigDecimal.valueOf(maxValue)) <= 0) && (value.scale() <= 0)) {
- this.value = ((value != null) && (value.compareTo(BigDecimal.valueOf(maxValue)) >= 0)) ? true : false;
+ if ((value != null) && (value.compareTo(BigDecimal.valueOf(minValue)) >= 0) && (value.compareTo(BigDecimal.valueOf(maxValue)) <= 0) && (value.scale() <= 0)) {
+ this.value = value.compareTo(BigDecimal.valueOf(maxValue)) >= 0;
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -141,8 +139,7 @@ public class PlcBOOL extends PlcIECValue<Boolean> {
public PlcBOOL(String value) {
super();
try {
- boolean val = Boolean.parseBoolean(value);
- this.value = val;
+ this.value = Boolean.parseBoolean(value);
this.isNullable = false;
}
catch(Exception e) {
@@ -171,6 +168,7 @@ public class PlcBOOL extends PlcIECValue<Boolean> {
return (value != null) && value;
}
+ @JsonIgnore
public boolean getBOOL() {
return (value != null) && value;
}
@@ -283,6 +281,7 @@ public class PlcBOOL extends PlcIECValue<Boolean> {
return toString();
}
+ @JsonIgnore
public byte[] getBytes() {
return ((value != null) && value) ? new byte[] {0x01} : new byte[] {0x00};
}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcBoolean.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcBoolean.java
deleted file mode 100644
index 9f6164a..0000000
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcBoolean.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * 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.api.value;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
-public class PlcBoolean extends PlcSimpleValue<Boolean> {
-
- public PlcBoolean(Boolean value) {
- super(value, true);
- }
-
- @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
- public PlcBoolean(@JsonProperty("value") boolean value) {
- super(value, false);
- }
-
- @Override
- @JsonIgnore
- public boolean isBoolean() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public boolean getBoolean() {
- return (value != null) && value;
- }
-
- @Override
- @JsonIgnore
- public boolean isByte() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public byte getByte() {
- return (byte) (((value != null) && value) ? 1 : 0);
- }
-
- @Override
- @JsonIgnore
- public boolean isShort() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public short getShort() {
- return (short) (((value != null) && value) ? 1 : 0);
- }
-
- @Override
- @JsonIgnore
- public boolean isInteger() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public int getInteger() {
- return ((value != null) && value) ? 1 : 0;
- }
-
- @Override
- @JsonIgnore
- public boolean isLong() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public long getLong() {
- return ((value != null) && value) ? 1 : 0;
- }
-
- @Override
- @JsonIgnore
- public boolean isBigInteger() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public BigInteger getBigInteger() {
- return value ? BigInteger.ONE : BigInteger.ZERO;
- }
-
- @Override
- @JsonIgnore
- public boolean isFloat() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public float getFloat() {
- return ((value != null) && value) ? 1.0f : 0.0f;
- }
-
- @Override
- @JsonIgnore
- public boolean isDouble() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public double getDouble() {
- return ((value != null) && value) ? 1.0 : 0.0;
- }
-
- @Override
- @JsonIgnore
- public boolean isBigDecimal() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public BigDecimal getBigDecimal() {
- return value ? BigDecimal.ONE : BigDecimal.ZERO;
- }
-
- @Override
- @JsonIgnore
- public boolean isString() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public String getString() {
- return toString();
- }
-
- @Override
- @JsonIgnore
- public String toString() {
- return Boolean.toString(value);
- }
-
-}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcByte.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcByte.java
index ac215c3..00475ef 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcByte.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcByte.java
@@ -23,44 +23,150 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
import java.math.BigDecimal;
import java.math.BigInteger;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
-public class PlcByte extends PlcSimpleValue<Byte> {
-
- public PlcByte(Byte value) {
- super(value, true);
+public class PlcBYTE extends PlcIECValue<Short> {
+
+ static Short minValue = 0;
+ static Short maxValue = (short) Byte.MAX_VALUE * 2 + 1;
+
+ public PlcBYTE(Boolean value) {
+ super();
+ this.value = value ? Short.valueOf((short) 1) : Short.valueOf((short) 0);
+ this.isNullable = false;
+ }
+
+ public PlcBYTE(Byte value) {
+ super();
+ if ((value >= minValue) && (value <= maxValue)) {
+ this.value = value.shortValue();
+ this.isNullable = false;
+ } else {
+ throw new PlcInvalidFieldException("Value of type " + value +
+ " is out of range " + minValue + " - " + maxValue + " for a " +
+ this.getClass().getSimpleName() + " Value");
+ }
+ }
+
+ public PlcBYTE(Short value) {
+ super();
+ if ((value >= minValue) && (value <= maxValue)) {
+ this.value = value;
+ this.isNullable = false;
+ } else {
+ throw new PlcInvalidFieldException("Value of type " + value +
+ " is out of range " + minValue + " - " + maxValue + " for a " +
+ this.getClass().getSimpleName() + " Value");
+ }
+ }
+
+ public PlcBYTE(Integer value) {
+ super();
+ if ((value >= minValue) && (value <= maxValue)) {
+ this.value = value.shortValue();
+ this.isNullable = false;
+ } else {
+ throw new PlcInvalidFieldException("Value of type " + value +
+ " is out of range " + minValue + " - " + maxValue + " for a " +
+ this.getClass().getSimpleName() + " Value");
+ }
+ }
+
+ public PlcBYTE(Long value) {
+ super();
+ if ((value >= minValue) && (value <= maxValue)) {
+ this.value = value.shortValue();
+ this.isNullable = false;
+ } else {
+ throw new PlcInvalidFieldException("Value of type " + value +
+ " is out of range " + minValue + " - " + maxValue + " for a " +
+ this.getClass().getSimpleName() + " Value");
+ }
+ }
+
+ public PlcBYTE(Float value) {
+ super();
+ if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
+ this.value = value.shortValue();
+ this.isNullable = false;
+ } else {
+ throw new PlcInvalidFieldException("Value of type " + value +
+ " is out of range " + minValue + " - " + maxValue + " or has decimal places for a " +
+ this.getClass().getSimpleName() + " Value");
+ }
+ }
+
+ public PlcBYTE(Double value) {
+ super();
+ if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
+ this.value = value.shortValue();
+ this.isNullable = false;
+ } else {
+ throw new PlcInvalidFieldException("Value of type " + value +
+ " is out of range " + minValue + " - " + maxValue + " or has decimal places for a " +
+ this.getClass().getSimpleName() + " Value");
+ }
+ }
+
+ public PlcBYTE(BigInteger value) {
+ super();
+ if ((value.compareTo(BigInteger.valueOf(minValue)) >= 0) && (value.compareTo(BigInteger.valueOf(maxValue)) <= 0)) {
+ this.value = value.shortValue();
+ this.isNullable = true;
+ } else {
+ throw new PlcInvalidFieldException("Value of type " + value +
+ " is out of range " + minValue + " - " + maxValue + " for a " +
+ this.getClass().getSimpleName() + " Value");
+ }
+ }
+
+ public PlcBYTE(BigDecimal value) {
+ super();
+ if ((value.compareTo(BigDecimal.valueOf(minValue)) >= 0) && (value.compareTo(BigDecimal.valueOf(maxValue)) <= 0) && (value.scale() <= 0)) {
+ this.value = value.shortValue();
+ this.isNullable = true;
+ } else {
+ throw new PlcInvalidFieldException("Value of type " + value +
+ " is out of range " + minValue + " - " + maxValue + " for a " +
+ this.getClass().getSimpleName() + " Value");
+ }
+ }
+
+ public PlcBYTE(String value) {
+ super();
+ try {
+ short val = Short.parseShort(value);
+ if ((val >= minValue) && (val <= maxValue)) {
+ this.value = val;
+ this.isNullable = false;
+ } else {
+ throw new PlcInvalidFieldException("Value of type " + value +
+ " is out of range " + minValue + " - " + maxValue + " for a " +
+ this.getClass().getSimpleName() + " Value");
+ }
+ }
+ catch(Exception e) {
+ throw new PlcInvalidFieldException("Value of type " + value +
+ " is out of range " + minValue + " - " + maxValue + " for a " +
+ this.getClass().getSimpleName() + " Value");
+ }
}
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
- public PlcByte(@JsonProperty("value") byte value) {
- super(value, false);
- }
-
- @Override
- @JsonIgnore
- public boolean isBoolean() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public boolean getBoolean() {
- return (value != null) && !value.equals((byte) 0);
- }
-
- @Override
- @JsonIgnore
- public boolean isByte() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public byte getByte() {
- return value;
+ public PlcBYTE(@JsonProperty("value") short value) {
+ super();
+ if ((value >= minValue) && (value <= maxValue)) {
+ this.value = value;
+ this.isNullable = false;
+ } else {
+ throw new PlcInvalidFieldException("Value of type " + value +
+ " is out of range " + minValue + " - " + maxValue + " for a " +
+ this.getClass().getSimpleName() + " Value");
+ }
}
@Override
@@ -72,97 +178,25 @@ public class PlcByte extends PlcSimpleValue<Byte> {
@Override
@JsonIgnore
public short getShort() {
- return value.shortValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isInteger() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public int getInteger() {
- return value.intValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isLong() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public long getLong() {
- return value.longValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isBigInteger() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public BigInteger getBigInteger() {
- return BigInteger.valueOf((long) value);
- }
-
- @Override
- @JsonIgnore
- public boolean isFloat() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public float getFloat() {
- return value.floatValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isDouble() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public double getDouble() {
- return value.doubleValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isBigDecimal() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public BigDecimal getBigDecimal() {
- return new BigDecimal(value);
+ return value;
}
- @Override
@JsonIgnore
- public boolean isString() {
- return true;
+ public short getBYTE() {
+ return value;
}
@Override
@JsonIgnore
- public String getString() {
- return toString();
+ public String toString() {
+ return Short.toString(value);
}
- @Override
@JsonIgnore
- public String toString() {
- return Integer.toString(value);
+ public byte[] getBytes() {
+ byte[] bytes = new byte[1];
+ bytes[0] = (byte)(value & 0xff);
+ return bytes;
}
}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcCHAR.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcCHAR.java
index b39a63e..52e5ff7 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcCHAR.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcCHAR.java
@@ -40,7 +40,7 @@ public class PlcCHAR extends PlcIECValue<Short> {
public PlcCHAR(Boolean value) {
super();
- this.value = value ? new Short((short) 1) : new Short((short) 0);
+ this.value = value ? Short.valueOf((short) 1) : Short.valueOf((short) 0);
this.isNullable = false;
}
@@ -48,7 +48,7 @@ public class PlcCHAR extends PlcIECValue<Short> {
super();
Integer val = (int) value;
if ((val >= minValue) && (val <= maxValue)) {
- this.value = (Short) val.shortValue();
+ this.value = val.shortValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Character '" + Character.toString(value) + "', Value " + val +
@@ -198,6 +198,7 @@ public class PlcCHAR extends PlcIECValue<Short> {
return Character.toString(Character.valueOf((char) ((short) value)));
}
+ @JsonIgnore
public short getCHAR() {
return value;
}
@@ -213,6 +214,7 @@ public class PlcCHAR extends PlcIECValue<Short> {
return Character.toString(Character.valueOf((char) ((short) value)));
}
+ @JsonIgnore
public byte[] getBytes() {
byte[] bytes = new byte[1];
bytes[0] = (byte)(value & 0xff);
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcDINT.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcDINT.java
index e10a475..009a5c5 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcDINT.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcDINT.java
@@ -25,12 +25,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
-import org.apache.plc4x.java.api.value.*;
-
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.LinkedList;
-import java.util.List;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
public class PlcDINT extends PlcIECValue<Integer> {
@@ -46,13 +42,13 @@ public class PlcDINT extends PlcIECValue<Integer> {
public PlcDINT(Byte value) {
super();
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = false;
}
public PlcDINT(Short value) {
super();
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = false;
}
@@ -65,7 +61,7 @@ public class PlcDINT extends PlcIECValue<Integer> {
public PlcDINT(Long value) {
super();
if (value >= minValue && value <= maxValue) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -77,7 +73,7 @@ public class PlcDINT extends PlcIECValue<Integer> {
public PlcDINT(Float value) {
super();
if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -89,7 +85,7 @@ public class PlcDINT extends PlcIECValue<Integer> {
public PlcDINT(Double value) {
super();
if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -101,7 +97,7 @@ public class PlcDINT extends PlcIECValue<Integer> {
public PlcDINT(BigInteger value) {
super();
if ((value.compareTo(BigInteger.valueOf(minValue)) >= 0) && (value.compareTo(BigInteger.valueOf(maxValue)) <= 0)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -113,7 +109,7 @@ public class PlcDINT extends PlcIECValue<Integer> {
public PlcDINT(BigDecimal value) {
super();
if ((value.compareTo(BigDecimal.valueOf(minValue)) >= 0) && (value.compareTo(BigDecimal.valueOf(maxValue)) <= 0) && (value.scale() <= 0)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -125,8 +121,7 @@ public class PlcDINT extends PlcIECValue<Integer> {
public PlcDINT(String value) {
super();
try {
- Integer val = Integer.parseInt(value);
- this.value = val;
+ this.value = Integer.parseInt(value);
this.isNullable = false;
}
catch(Exception e) {
@@ -143,6 +138,43 @@ public class PlcDINT extends PlcIECValue<Integer> {
this.isNullable = false;
}
+
+ @Override
+ @JsonIgnore
+ public boolean isBoolean() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean getBoolean() {
+ return (value != null) && !value.equals(0);
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isByte() {
+ return (value != null) && (value <= Byte.MAX_VALUE) && (value >= Byte.MIN_VALUE);
+ }
+
+ @Override
+ @JsonIgnore
+ public byte getByte() {
+ return value.byteValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isShort() {
+ return (value != null) && (value <= Short.MAX_VALUE) && (value >= Short.MIN_VALUE);
+ }
+
+ @Override
+ @JsonIgnore
+ public short getShort() {
+ return value.shortValue();
+ }
+
@Override
@JsonIgnore
public boolean isInteger() {
@@ -155,8 +187,76 @@ public class PlcDINT extends PlcIECValue<Integer> {
return value;
}
- public int getDINT() {
- return value;
+ @Override
+ @JsonIgnore
+ public boolean isLong() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public long getLong() {
+ return value.longValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isBigInteger() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public BigInteger getBigInteger() {
+ return BigInteger.valueOf(getLong());
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isFloat() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public float getFloat() {
+ return value.floatValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isDouble() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public double getDouble() {
+ return value.doubleValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isBigDecimal() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public BigDecimal getBigDecimal() {
+ return BigDecimal.valueOf(getFloat());
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isString() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public String getString() {
+ return toString();
}
@Override
@@ -165,6 +265,12 @@ public class PlcDINT extends PlcIECValue<Integer> {
return Integer.toString(value);
}
+ @JsonIgnore
+ public int getDINT() {
+ return value;
+ }
+
+ @JsonIgnore
public byte[] getBytes() {
byte[] bytes = new byte[4];
bytes[0] = (byte)((value >> 24) & 0xff);
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcDWORD.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcDWORD.java
index 0f00d1d..ac10274 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcDWORD.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcDWORD.java
@@ -25,12 +25,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
-import org.apache.plc4x.java.api.value.*;
-
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.LinkedList;
-import java.util.List;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
public class PlcDWORD extends PlcIECValue<Long> {
@@ -47,7 +43,7 @@ public class PlcDWORD extends PlcIECValue<Long> {
public PlcDWORD(Byte value) {
super();
if (value >= minValue && value <= maxValue) {
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -59,7 +55,7 @@ public class PlcDWORD extends PlcIECValue<Long> {
public PlcDWORD(Short value) {
super();
if (value >= minValue && value <= maxValue) {
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -71,7 +67,7 @@ public class PlcDWORD extends PlcIECValue<Long> {
public PlcDWORD(Integer value) {
super();
if (value >= minValue && value <= maxValue) {
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -83,7 +79,7 @@ public class PlcDWORD extends PlcIECValue<Long> {
public PlcDWORD(Long value) {
super();
if (value >= minValue && value <= maxValue) {
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -95,7 +91,7 @@ public class PlcDWORD extends PlcIECValue<Long> {
public PlcDWORD(Float value) {
super();
if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -107,7 +103,7 @@ public class PlcDWORD extends PlcIECValue<Long> {
public PlcDWORD(Double value) {
super();
if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -119,7 +115,7 @@ public class PlcDWORD extends PlcIECValue<Long> {
public PlcDWORD(BigInteger value) {
super();
if ((value.compareTo(BigInteger.valueOf(minValue)) >= 0) && (value.compareTo(BigInteger.valueOf(maxValue)) <= 0)) {
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -131,7 +127,7 @@ public class PlcDWORD extends PlcIECValue<Long> {
public PlcDWORD(BigDecimal value) {
super();
if ((value.compareTo(BigDecimal.valueOf(minValue)) >= 0) && (value.compareTo(BigDecimal.valueOf(maxValue)) <= 0) && (value.scale() <= 0)) {
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -143,7 +139,7 @@ public class PlcDWORD extends PlcIECValue<Long> {
public PlcDWORD(String value) {
super();
try {
- Long val = Long.parseLong(value);
+ long val = Long.parseLong(value);
if (val >= minValue && val <= maxValue) {
this.value = val;
this.isNullable = false;
@@ -185,6 +181,7 @@ public class PlcDWORD extends PlcIECValue<Long> {
return value;
}
+ @JsonIgnore
public long getDWORD() {
return value;
}
@@ -195,6 +192,7 @@ public class PlcDWORD extends PlcIECValue<Long> {
return Long.toString(value);
}
+ @JsonIgnore
public byte[] getBytes() {
byte[] bytes = new byte[4];
bytes[0] = (byte)((value >> 24) & 0xff);
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcDouble.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcDouble.java
deleted file mode 100644
index 1ba0990..0000000
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcDouble.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * 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.api.value;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
-public class PlcDouble extends PlcSimpleValue<Double> {
-
- public PlcDouble(Double value) {
- super(value, true);
- }
-
- @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
- public PlcDouble(@JsonProperty("value") double value) {
- super(value, false);
- }
-
- @Override
- @JsonIgnore
- public boolean isBoolean() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public boolean getBoolean() {
- return (value != null) && !value.equals(0.0);
- }
-
- @Override
- @JsonIgnore
- public boolean isByte() {
- return (value != null) && (value <= Byte.MAX_VALUE) && (value >= Byte.MIN_VALUE);
- }
-
- @Override
- @JsonIgnore
- public byte getByte() {
- return value.byteValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isShort() {
- return (value != null) && (value <= Short.MAX_VALUE) && (value >= Short.MIN_VALUE);
- }
-
- @Override
- @JsonIgnore
- public short getShort() {
- return value.shortValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isInteger() {
- return (value != null) && (value <= Integer.MAX_VALUE) && (value >= Integer.MIN_VALUE);
- }
-
- @Override
- @JsonIgnore
- public int getInteger() {
- return value.intValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isLong() {
- return (value != null) && (value <= Long.MAX_VALUE) && (value >= Long.MIN_VALUE);
- }
-
- @Override
- @JsonIgnore
- public long getLong() {
- return value.longValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isBigInteger() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public BigInteger getBigInteger() {
- return BigInteger.valueOf(value.longValue());
- }
-
- @Override
- @JsonIgnore
- public boolean isFloat() {
- return (value != null) && (value <= Float.MAX_VALUE) && (value >= -Float.MAX_VALUE);
- }
-
- @Override
- @JsonIgnore
- public float getFloat() {
- return value.floatValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isDouble() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public double getDouble() {
- return value;
- }
-
- @Override
- @JsonIgnore
- public boolean isBigDecimal() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public BigDecimal getBigDecimal() {
- return new BigDecimal(value);
- }
-
- @Override
- @JsonIgnore
- public boolean isString() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public String getString() {
- return toString();
- }
-
- @Override
- @JsonIgnore
- public String toString() {
- return Double.toString(value);
- }
-
-}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcFloat.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcFloat.java
deleted file mode 100644
index 6e126f3..0000000
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcFloat.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * 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.api.value;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
-public class PlcFloat extends PlcSimpleValue<Float> {
-
- public PlcFloat(Float value) {
- super(value, true);
- }
-
- @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
- public PlcFloat(@JsonProperty("value") float value) {
- super(value, false);
- }
-
- @Override
- @JsonIgnore
- public boolean isBoolean() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public boolean getBoolean() {
- return (value != null) && !value.equals(0.0F);
- }
-
- @Override
- @JsonIgnore
- public boolean isByte() {
- return (value != null) && (value <= Byte.MAX_VALUE) && (value >= Byte.MIN_VALUE);
- }
-
- @Override
- @JsonIgnore
- public byte getByte() {
- return value.byteValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isShort() {
- return (value != null) && (value <= Short.MAX_VALUE) && (value >= Short.MIN_VALUE);
- }
-
- @Override
- @JsonIgnore
- public short getShort() {
- return value.shortValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isInteger() {
- return (value != null) && (value <= Integer.MAX_VALUE) && (value >= Integer.MIN_VALUE);
- }
-
- @Override
- @JsonIgnore
- public int getInteger() {
- return value.intValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isLong() {
- return (value != null) && (value <= Long.MAX_VALUE) && (value >= Long.MIN_VALUE);
- }
-
- @Override
- @JsonIgnore
- public long getLong() {
- return value.longValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isBigInteger() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public BigInteger getBigInteger() {
- return BigInteger.valueOf(value.longValue());
- }
-
- @Override
- @JsonIgnore
- public boolean isFloat() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public float getFloat() {
- return value;
- }
-
- @Override
- @JsonIgnore
- public boolean isDouble() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public double getDouble() {
- return value.doubleValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isBigDecimal() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public BigDecimal getBigDecimal() {
- return new BigDecimal(value);
- }
-
- @Override
- @JsonIgnore
- public boolean isString() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public String getString() {
- return toString();
- }
-
- @Override
- @JsonIgnore
- public String toString() {
- return Float.toString(value);
- }
-
-}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcIECValue.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcIECValue.java
index 3a01dca..9eeb1a7 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcIECValue.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcIECValue.java
@@ -20,7 +20,6 @@
package org.apache.plc4x.java.api.value;
import com.fasterxml.jackson.annotation.JsonIgnore;
-import org.apache.plc4x.java.api.value.*;
public abstract class PlcIECValue<T> extends PlcValueAdapter {
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcINT.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcINT.java
index a5f540d..b270260 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcINT.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcINT.java
@@ -25,12 +25,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
-import org.apache.plc4x.java.api.value.*;
-
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.LinkedList;
-import java.util.List;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
public class PlcINT extends PlcIECValue<Short> {
@@ -40,13 +36,13 @@ public class PlcINT extends PlcIECValue<Short> {
public PlcINT(Boolean value) {
super();
- this.value = value ? new Short((short) 1) : new Short((short) 0);
+ this.value = value ? Short.valueOf((short) 1) : Short.valueOf((short) 0);
this.isNullable = false;
}
public PlcINT(Byte value) {
super();
- this.value = (Short) value.shortValue();
+ this.value = value.shortValue();
this.isNullable = false;
}
@@ -59,7 +55,7 @@ public class PlcINT extends PlcIECValue<Short> {
public PlcINT(Integer value) {
super();
if ((value >= minValue) && (value <= maxValue)) {
- this.value = (Short) value.shortValue();
+ this.value = value.shortValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -71,7 +67,7 @@ public class PlcINT extends PlcIECValue<Short> {
public PlcINT(Long value) {
super();
if ((value >= minValue) && (value <= maxValue)) {
- this.value = (Short) value.shortValue();
+ this.value = value.shortValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -83,7 +79,7 @@ public class PlcINT extends PlcIECValue<Short> {
public PlcINT(Float value) {
super();
if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = (Short) value.shortValue();
+ this.value = value.shortValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -95,7 +91,7 @@ public class PlcINT extends PlcIECValue<Short> {
public PlcINT(Double value) {
super();
if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = (Short) value.shortValue();
+ this.value = value.shortValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -107,7 +103,7 @@ public class PlcINT extends PlcIECValue<Short> {
public PlcINT(BigInteger value) {
super();
if ((value.compareTo(BigInteger.valueOf(minValue)) >= 0) && (value.compareTo(BigInteger.valueOf(maxValue)) <= 0)) {
- this.value = (Short) value.shortValue();
+ this.value = value.shortValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -119,7 +115,7 @@ public class PlcINT extends PlcIECValue<Short> {
public PlcINT(BigDecimal value) {
super();
if ((value.compareTo(BigDecimal.valueOf(minValue)) >= 0) && (value.compareTo(BigDecimal.valueOf(maxValue)) <= 0) && (value.scale() <= 0)) {
- this.value = (Short) value.shortValue();
+ this.value = value.shortValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -131,8 +127,7 @@ public class PlcINT extends PlcIECValue<Short> {
public PlcINT(String value) {
super();
try {
- Short val = Short.valueOf(value).shortValue();
- this.value = val;
+ this.value = Short.valueOf(value);
this.isNullable = false;
}
catch(Exception e) {
@@ -150,6 +145,30 @@ public class PlcINT extends PlcIECValue<Short> {
@Override
@JsonIgnore
+ public boolean isBoolean() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean getBoolean() {
+ return (value != null) && !value.equals(0);
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isByte() {
+ return (value != null) && (value <= Byte.MAX_VALUE) && (value >= Byte.MIN_VALUE);
+ }
+
+ @Override
+ @JsonIgnore
+ public byte getByte() {
+ return value.byteValue();
+ }
+
+ @Override
+ @JsonIgnore
public boolean isShort() {
return true;
}
@@ -160,16 +179,102 @@ public class PlcINT extends PlcIECValue<Short> {
return value;
}
- public short getINT() {
- return value;
+ @Override
+ @JsonIgnore
+ public boolean isInteger() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public int getInteger() {
+ return value.intValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isLong() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public long getLong() {
+ return value.longValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isBigInteger() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public BigInteger getBigInteger() {
+ return BigInteger.valueOf(getLong());
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isFloat() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public float getFloat() {
+ return value.floatValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isDouble() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public double getDouble() {
+ return value.doubleValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isBigDecimal() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public BigDecimal getBigDecimal() {
+ return BigDecimal.valueOf(getFloat());
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isString() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public String getString() {
+ return toString();
}
@Override
@JsonIgnore
public String toString() {
- return Short.toString(value);
+ return Integer.toString(value);
+ }
+
+ @JsonIgnore
+ public short getINT() {
+ return value;
}
+ @JsonIgnore
public byte[] getBytes() {
byte[] bytes = new byte[2];
bytes[0] = (byte)((value >> 8) & 0xff);
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcInteger.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcInteger.java
deleted file mode 100644
index 5b6fd02..0000000
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcInteger.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * 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.api.value;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
-public class PlcInteger extends PlcSimpleValue<Integer> {
-
- public PlcInteger(Integer value) {
- super(value, true);
- }
-
- @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
- public PlcInteger(@JsonProperty("value") int value) {
- super(value, false);
- }
-
- @Override
- @JsonIgnore
- public boolean isBoolean() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public boolean getBoolean() {
- return (value != null) && !value.equals(0);
- }
-
- @Override
- @JsonIgnore
- public boolean isByte() {
- return (value != null) && (value <= Byte.MAX_VALUE) && (value >= Byte.MIN_VALUE);
- }
-
- @Override
- @JsonIgnore
- public byte getByte() {
- return value.byteValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isShort() {
- return (value != null) && (value <= Short.MAX_VALUE) && (value >= Short.MIN_VALUE);
- }
-
- @Override
- @JsonIgnore
- public short getShort() {
- return value.shortValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isInteger() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public int getInteger() {
- return value;
- }
-
- @Override
- @JsonIgnore
- public boolean isLong() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public long getLong() {
- return value.longValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isBigInteger() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public BigInteger getBigInteger() {
- return BigInteger.valueOf((long) value);
- }
-
- @Override
- @JsonIgnore
- public boolean isFloat() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public float getFloat() {
- return value.floatValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isDouble() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public double getDouble() {
- return value.doubleValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isBigDecimal() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public BigDecimal getBigDecimal() {
- return new BigDecimal(value);
- }
-
- @Override
- @JsonIgnore
- public boolean isString() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public String getString() {
- return toString();
- }
-
- @Override
- @JsonIgnore
- public String toString() {
- return Integer.toString(value);
- }
-
-}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcLINT.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcLINT.java
index 33605f4..2aaf5de 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcLINT.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcLINT.java
@@ -25,18 +25,14 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
-import org.apache.plc4x.java.api.value.*;
-
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.LinkedList;
-import java.util.List;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
public class PlcLINT extends PlcIECValue<Long> {
static Long minValue = (long) 0;
- static Long maxValue = (long) Long.MAX_VALUE;
+ static Long maxValue = Long.MAX_VALUE;
public PlcLINT(Boolean value) {
super();
@@ -46,19 +42,19 @@ public class PlcLINT extends PlcIECValue<Long> {
public PlcLINT(Byte value) {
super();
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = false;
}
public PlcLINT(Short value) {
super();
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = false;
}
public PlcLINT(Integer value) {
super();
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = false;
}
@@ -71,7 +67,7 @@ public class PlcLINT extends PlcIECValue<Long> {
public PlcLINT(Float value) {
super();
if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -83,7 +79,7 @@ public class PlcLINT extends PlcIECValue<Long> {
public PlcLINT(Double value) {
super();
if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -95,7 +91,7 @@ public class PlcLINT extends PlcIECValue<Long> {
public PlcLINT(BigInteger value) {
super();
if ((value.compareTo(BigInteger.valueOf(minValue)) >= 0) && (value.compareTo(BigInteger.valueOf(maxValue)) <= 0)) {
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -107,7 +103,7 @@ public class PlcLINT extends PlcIECValue<Long> {
public PlcLINT(BigDecimal value) {
super();
if ((value.compareTo(BigDecimal.valueOf(minValue)) >= 0) && (value.compareTo(BigDecimal.valueOf(maxValue)) <= 0) && (value.scale() <= 0)) {
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -119,8 +115,7 @@ public class PlcLINT extends PlcIECValue<Long> {
public PlcLINT(String value) {
super();
try {
- Long val = Long.parseLong(value);
- this.value = val;
+ this.value = Long.parseLong(value);
this.isNullable = false;
}
catch(Exception e) {
@@ -137,6 +132,55 @@ public class PlcLINT extends PlcIECValue<Long> {
this.isNullable = false;
}
+
+ @Override
+ @JsonIgnore
+ public boolean isBoolean() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean getBoolean() {
+ return (value != null) && !value.equals(0);
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isByte() {
+ return (value != null) && (value <= Byte.MAX_VALUE) && (value >= Byte.MIN_VALUE);
+ }
+
+ @Override
+ @JsonIgnore
+ public byte getByte() {
+ return value.byteValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isShort() {
+ return (value != null) && (value <= Short.MAX_VALUE) && (value >= Short.MIN_VALUE);
+ }
+
+ @Override
+ @JsonIgnore
+ public short getShort() {
+ return value.shortValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isInteger() {
+ return (value != null) && (value <= Integer.MAX_VALUE) && (value >= Integer.MIN_VALUE);
+ }
+
+ @Override
+ @JsonIgnore
+ public int getInteger() {
+ return value.intValue();
+ }
+
@Override
@JsonIgnore
public boolean isLong() {
@@ -149,8 +193,64 @@ public class PlcLINT extends PlcIECValue<Long> {
return value;
}
- public long getLINT() {
- return value;
+ @Override
+ @JsonIgnore
+ public boolean isBigInteger() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public BigInteger getBigInteger() {
+ return BigInteger.valueOf(value);
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isFloat() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public float getFloat() {
+ return value.floatValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isDouble() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public double getDouble() {
+ return value.doubleValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isBigDecimal() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public BigDecimal getBigDecimal() {
+ return BigDecimal.valueOf(getDouble());
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isString() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public String getString() {
+ return toString();
}
@Override
@@ -159,6 +259,12 @@ public class PlcLINT extends PlcIECValue<Long> {
return Long.toString(value);
}
+ @JsonIgnore
+ public long getLINT() {
+ return value;
+ }
+
+ @JsonIgnore
public byte[] getBytes() {
byte[] bytes = new byte[8];
bytes[0] = (byte)((value >> 56) & 0xff);
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcLREAL.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcLREAL.java
index f2b44ee..3bc90f5 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcLREAL.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcLREAL.java
@@ -25,12 +25,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
-import org.apache.plc4x.java.api.value.*;
-
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.LinkedList;
-import java.util.List;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
public class PlcLREAL extends PlcIECValue<Double> {
@@ -46,25 +42,25 @@ public class PlcLREAL extends PlcIECValue<Double> {
public PlcLREAL(Byte value) {
super();
- this.value = (Double) value.doubleValue();
+ this.value = value.doubleValue();
this.isNullable = false;
}
public PlcLREAL(Short value) {
super();
- this.value = (Double) value.doubleValue();
+ this.value = value.doubleValue();
this.isNullable = false;
}
public PlcLREAL(Integer value) {
super();
- this.value = (Double) value.doubleValue();
+ this.value = value.doubleValue();
this.isNullable = false;
}
public PlcLREAL(Float value) {
super();
- this.value = (Double) value.doubleValue();
+ this.value = value.doubleValue();
this.isNullable = false;
}
@@ -78,7 +74,7 @@ public class PlcLREAL extends PlcIECValue<Double> {
super();
BigDecimal val = new BigDecimal(value);
if ((val.compareTo(BigDecimal.valueOf(minValue)) >= 0) && (val.compareTo(BigDecimal.valueOf(maxValue)) <= 0)) {
- this.value = (Double) val.doubleValue();
+ this.value = val.doubleValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -90,7 +86,7 @@ public class PlcLREAL extends PlcIECValue<Double> {
public PlcLREAL(BigDecimal value) {
super();
if ((value.compareTo(BigDecimal.valueOf(minValue)) >= 0) && (value.compareTo(BigDecimal.valueOf(maxValue)) <= 0) && (value.scale() <= 0)) {
- this.value = (Double) value.doubleValue();
+ this.value = value.doubleValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -102,8 +98,7 @@ public class PlcLREAL extends PlcIECValue<Double> {
public PlcLREAL(String value) {
super();
try {
- Double val = Double.parseDouble(value);
- this.value = val;
+ this.value = Double.parseDouble(value);
this.isNullable = false;
}
catch(Exception e) {
@@ -116,12 +111,96 @@ public class PlcLREAL extends PlcIECValue<Double> {
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public PlcLREAL(@JsonProperty("value") double value) {
super();
- this.value = new Double(value);
+ this.value = value;
this.isNullable = false;
}
@Override
@JsonIgnore
+ public boolean isBoolean() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean getBoolean() {
+ return (value != null) && !value.equals(0);
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isByte() {
+ return (value != null) && (value <= Byte.MAX_VALUE) && (value >= Byte.MIN_VALUE);
+ }
+
+ @Override
+ @JsonIgnore
+ public byte getByte() {
+ return value.byteValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isShort() {
+ return (value != null) && (value <= Short.MAX_VALUE) && (value >= Short.MIN_VALUE);
+ }
+
+ @Override
+ @JsonIgnore
+ public short getShort() {
+ return value.shortValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isInteger() {
+ return (value != null) && (value <= Integer.MAX_VALUE) && (value >= Integer.MIN_VALUE);
+ }
+
+ @Override
+ @JsonIgnore
+ public int getInteger() {
+ return value.intValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isLong() {
+ return (value != null) && (value <= Long.MAX_VALUE) && (value >= Long.MIN_VALUE);
+ }
+
+ @Override
+ @JsonIgnore
+ public long getLong() {
+ return value.longValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isBigInteger() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public BigInteger getBigInteger() {
+ return BigInteger.valueOf(getLong());
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isFloat() {
+ return (value != null) && (value <= Float.MAX_VALUE) && (value >= -Float.MAX_VALUE);
+ }
+
+ @Override
+ @JsonIgnore
+ public float getFloat() {
+ return value.floatValue();
+ }
+
+ @Override
+ @JsonIgnore
public boolean isDouble() {
return true;
}
@@ -132,8 +211,28 @@ public class PlcLREAL extends PlcIECValue<Double> {
return value;
}
- public double getLREAL() {
- return value;
+ @Override
+ @JsonIgnore
+ public boolean isBigDecimal() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public BigDecimal getBigDecimal() {
+ return new BigDecimal(value);
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isString() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public String getString() {
+ return toString();
}
@Override
@@ -142,6 +241,12 @@ public class PlcLREAL extends PlcIECValue<Double> {
return Double.toString(value);
}
+ @JsonIgnore
+ public double getLREAL() {
+ return value;
+ }
+
+ @JsonIgnore
public byte[] getBytes() {
long longBits = Double.doubleToRawLongBits(value);
byte[] bytes = new byte[8];
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcLWORD.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcLWORD.java
index 00ef191..63d0552 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcLWORD.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcLWORD.java
@@ -19,18 +19,12 @@
package org.apache.plc4x.java.api.value;
-import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
-import org.apache.plc4x.java.api.value.*;
-
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.LinkedList;
-import java.util.List;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
public class PlcLWORD extends PlcIECValue<BigInteger> {
@@ -196,6 +190,7 @@ public class PlcLWORD extends PlcIECValue<BigInteger> {
return value;
}
+ @JsonIgnore
public BigInteger getLWORD() {
return value;
}
@@ -206,6 +201,7 @@ public class PlcLWORD extends PlcIECValue<BigInteger> {
return value.toString();
}
+ @JsonIgnore
public byte[] getBytes() {
byte[] tmp = value.toByteArray();
byte[] bytes = new byte[8];
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcLong.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcLong.java
deleted file mode 100644
index af2cf1e..0000000
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcLong.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * 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.api.value;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
-public class PlcLong extends PlcSimpleValue<Long> {
-
- public PlcLong(Long value) {
- super(value, true);
- }
-
- @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
- public PlcLong(@JsonProperty("value") long value) {
- super(value, false);
- }
-
- @Override
- @JsonIgnore
- public boolean isBoolean() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public boolean getBoolean() {
- return (value != null) && !value.equals(0L);
- }
-
- @Override
- @JsonIgnore
- public boolean isByte() {
- return (value != null) && (value <= Byte.MAX_VALUE) && (value >= Byte.MIN_VALUE);
- }
-
- @Override
- @JsonIgnore
- public byte getByte() {
- return value.byteValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isShort() {
- return (value != null) && (value <= Short.MAX_VALUE) && (value >= Short.MIN_VALUE);
- }
-
- @Override
- @JsonIgnore
- public short getShort() {
- return value.shortValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isInteger() {
- return (value != null) && (value <= Integer.MAX_VALUE) && (value >= Integer.MIN_VALUE);
- }
-
- @Override
- @JsonIgnore
- public int getInteger() {
- return value.intValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isLong() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public long getLong() {
- return value;
- }
-
- @Override
- @JsonIgnore
- public boolean isBigInteger() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public BigInteger getBigInteger() {
- return BigInteger.valueOf(value);
- }
-
- @Override
- @JsonIgnore
- public boolean isFloat() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public float getFloat() {
- return value.floatValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isDouble() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public double getDouble() {
- return value.doubleValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isBigDecimal() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public BigDecimal getBigDecimal() {
- return new BigDecimal(value);
- }
-
- @Override
- @JsonIgnore
- public boolean isString() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public String getString() {
- return toString();
- }
-
- @Override
- @JsonIgnore
- public String toString() {
- return Long.toString(value);
- }
-
-}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcREAL.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcREAL.java
index a54ba52..9e2a668 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcREAL.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcREAL.java
@@ -25,12 +25,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
-import org.apache.plc4x.java.api.value.*;
-
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.LinkedList;
-import java.util.List;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
public class PlcREAL extends PlcIECValue<Float> {
@@ -46,19 +42,19 @@ public class PlcREAL extends PlcIECValue<Float> {
public PlcREAL(Byte value) {
super();
- this.value = (Float) value.floatValue();
+ this.value = value.floatValue();
this.isNullable = false;
}
public PlcREAL(Short value) {
super();
- this.value = (Float) value.floatValue();
+ this.value = value.floatValue();
this.isNullable = false;
}
public PlcREAL(Integer value) {
super();
- this.value = (Float) value.floatValue();
+ this.value = value.floatValue();
this.isNullable = false;
}
@@ -71,7 +67,7 @@ public class PlcREAL extends PlcIECValue<Float> {
public PlcREAL(Double value) {
super();
if ((value >= minValue) && (value <= maxValue)) {
- this.value = (Float) value.floatValue();
+ this.value = value.floatValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -84,7 +80,7 @@ public class PlcREAL extends PlcIECValue<Float> {
super();
BigDecimal val = new BigDecimal(value);
if ((val.compareTo(BigDecimal.valueOf(minValue)) >= 0) && (val.compareTo(BigDecimal.valueOf(maxValue)) <= 0)) {
- this.value = (Float) val.floatValue();
+ this.value = val.floatValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -96,7 +92,7 @@ public class PlcREAL extends PlcIECValue<Float> {
public PlcREAL(BigDecimal value) {
super();
if ((value.compareTo(BigDecimal.valueOf(minValue)) >= 0) && (value.compareTo(BigDecimal.valueOf(maxValue)) <= 0) && (value.scale() <= 0)) {
- this.value = (Float) value.floatValue();
+ this.value = value.floatValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -108,8 +104,7 @@ public class PlcREAL extends PlcIECValue<Float> {
public PlcREAL(String value) {
super();
try {
- Float val = Float.parseFloat(value);
- this.value = val;
+ this.value = Float.parseFloat(value);
this.isNullable = false;
}
catch(Exception e) {
@@ -122,12 +117,84 @@ public class PlcREAL extends PlcIECValue<Float> {
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public PlcREAL(@JsonProperty("value") float value) {
super();
- this.value = new Float(value);
+ this.value = value;
this.isNullable = false;
}
@Override
@JsonIgnore
+ public boolean isBoolean() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean getBoolean() {
+ return (value != null) && !value.equals(0);
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isByte() {
+ return (value != null) && (value <= Byte.MAX_VALUE) && (value >= Byte.MIN_VALUE);
+ }
+
+ @Override
+ @JsonIgnore
+ public byte getByte() {
+ return value.byteValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isShort() {
+ return (value != null) && (value <= Short.MAX_VALUE) && (value >= Short.MIN_VALUE);
+ }
+
+ @Override
+ @JsonIgnore
+ public short getShort() {
+ return value.shortValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isInteger() {
+ return (value != null) && (value <= Integer.MAX_VALUE) && (value >= Integer.MIN_VALUE);
+ }
+
+ @Override
+ @JsonIgnore
+ public int getInteger() {
+ return value.intValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isLong() {
+ return (value != null) && (value <= Long.MAX_VALUE) && (value >= Long.MIN_VALUE);
+ }
+
+ @Override
+ @JsonIgnore
+ public long getLong() {
+ return value.longValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isBigInteger() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public BigInteger getBigInteger() {
+ return BigInteger.valueOf(getLong());
+ }
+
+ @Override
+ @JsonIgnore
public boolean isFloat() {
return true;
}
@@ -138,8 +205,40 @@ public class PlcREAL extends PlcIECValue<Float> {
return value;
}
- public float getREAL() {
- return value;
+ @Override
+ @JsonIgnore
+ public boolean isDouble() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public double getDouble() {
+ return value.doubleValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isBigDecimal() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public BigDecimal getBigDecimal() {
+ return BigDecimal.valueOf(getDouble());
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isString() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public String getString() {
+ return toString();
}
@Override
@@ -148,6 +247,12 @@ public class PlcREAL extends PlcIECValue<Float> {
return Float.toString(value);
}
+ @JsonIgnore
+ public float getREAL() {
+ return value;
+ }
+
+ @JsonIgnore
public byte[] getBytes() {
int intBits = Float.floatToIntBits(value);
return new byte[] { (byte) (intBits >> 24), (byte) (intBits >> 16), (byte) (intBits >> 8), (byte) (intBits) };
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcSINT.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcSINT.java
index 7b87ad4..0e2fe98 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcSINT.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcSINT.java
@@ -25,12 +25,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
-import org.apache.plc4x.java.api.value.*;
-
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.LinkedList;
-import java.util.List;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
public class PlcSINT extends PlcIECValue<Byte> {
@@ -40,7 +36,7 @@ public class PlcSINT extends PlcIECValue<Byte> {
public PlcSINT(Boolean value) {
super();
- this.value = value ? new Byte((byte) 1) : new Byte((byte) 0);
+ this.value = value ? Byte.valueOf((byte) 1) : Byte.valueOf((byte) 0);
this.isNullable = false;
}
@@ -53,7 +49,7 @@ public class PlcSINT extends PlcIECValue<Byte> {
public PlcSINT(Short value) {
super();
if ((value >= minValue) && (value <= maxValue)) {
- this.value = (Byte) value.byteValue();
+ this.value = value.byteValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -65,7 +61,7 @@ public class PlcSINT extends PlcIECValue<Byte> {
public PlcSINT(Integer value) {
super();
if ((value >= minValue) && (value <= maxValue)) {
- this.value = (Byte) value.byteValue();
+ this.value = value.byteValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -77,7 +73,7 @@ public class PlcSINT extends PlcIECValue<Byte> {
public PlcSINT(Long value) {
super();
if ((value >= minValue) && (value <= maxValue)) {
- this.value = (Byte) value.byteValue();
+ this.value = value.byteValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -89,7 +85,7 @@ public class PlcSINT extends PlcIECValue<Byte> {
public PlcSINT(Float value) {
super();
if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = (Byte) value.byteValue();
+ this.value = value.byteValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -101,7 +97,7 @@ public class PlcSINT extends PlcIECValue<Byte> {
public PlcSINT(Double value) {
super();
if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = (Byte) value.byteValue();
+ this.value = value.byteValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -113,7 +109,7 @@ public class PlcSINT extends PlcIECValue<Byte> {
public PlcSINT(BigInteger value) {
super();
if ((value.compareTo(BigInteger.valueOf(minValue)) >= 0) && (value.compareTo(BigInteger.valueOf(maxValue)) <= 0)) {
- this.value = (Byte) value.byteValue();
+ this.value = value.byteValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -125,7 +121,7 @@ public class PlcSINT extends PlcIECValue<Byte> {
public PlcSINT(BigDecimal value) {
super();
if ((value.compareTo(BigDecimal.valueOf(minValue)) >= 0) && (value.compareTo(BigDecimal.valueOf(maxValue)) <= 0) && (value.scale() <= 0)) {
- this.value = (Byte) value.byteValue();
+ this.value = value.byteValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -137,8 +133,7 @@ public class PlcSINT extends PlcIECValue<Byte> {
public PlcSINT(String value) {
super();
try {
- Byte val = Byte.valueOf(value).byteValue();
- this.value = val;
+ this.value = Byte.valueOf(value);
this.isNullable = false;
}
catch(Exception e) {
@@ -156,6 +151,18 @@ public class PlcSINT extends PlcIECValue<Byte> {
@Override
@JsonIgnore
+ public boolean isBoolean() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean getBoolean() {
+ return (value != null) && !value.equals(0);
+ }
+
+ @Override
+ @JsonIgnore
public boolean isByte() {
return true;
}
@@ -166,8 +173,100 @@ public class PlcSINT extends PlcIECValue<Byte> {
return value;
}
- public byte getSINT() {
- return value;
+ @Override
+ @JsonIgnore
+ public boolean isShort() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public short getShort() {
+ return value.shortValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isInteger() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public int getInteger() {
+ return value.intValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isLong() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public long getLong() {
+ return value.longValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isBigInteger() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public BigInteger getBigInteger() {
+ return BigInteger.valueOf(getLong());
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isFloat() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public float getFloat() {
+ return value.floatValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isDouble() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public double getDouble() {
+ return value.doubleValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isBigDecimal() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public BigDecimal getBigDecimal() {
+ return BigDecimal.valueOf(getFloat());
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isString() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public String getString() {
+ return toString();
}
@Override
@@ -176,6 +275,12 @@ public class PlcSINT extends PlcIECValue<Byte> {
return Byte.toString(value);
}
+ @JsonIgnore
+ public byte getSINT() {
+ return value;
+ }
+
+ @JsonIgnore
public byte[] getBytes() {
byte[] bytes = new byte[1];
bytes[0] = (byte)(value & 0xff);
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcShort.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcShort.java
deleted file mode 100644
index c4f7dc1..0000000
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcShort.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * 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.api.value;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
-public class PlcShort extends PlcSimpleValue<Short> {
-
- public PlcShort(Short value) {
- super(value, true);
- }
-
- @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
- public PlcShort(@JsonProperty("value") short value) {
- super(value, false);
- }
-
- @Override
- @JsonIgnore
- public boolean isBoolean() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public boolean getBoolean() {
- return (value != null) && !value.equals((short) 0);
- }
-
- @Override
- @JsonIgnore
- public boolean isByte() {
- return (value != null) && (value <= Byte.MAX_VALUE) && (value >= Byte.MIN_VALUE);
- }
-
- @Override
- @JsonIgnore
- public byte getByte() {
- return value.byteValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isShort() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public short getShort() {
- return value;
- }
-
- @Override
- @JsonIgnore
- public boolean isInteger() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public int getInteger() {
- return value.intValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isLong() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public long getLong() {
- return value.longValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isBigInteger() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public BigInteger getBigInteger() {
- return BigInteger.valueOf((long) value);
- }
-
- @Override
- @JsonIgnore
- public boolean isFloat() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public float getFloat() {
- return value.floatValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isDouble() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public double getDouble() {
- return value.doubleValue();
- }
-
- @Override
- @JsonIgnore
- public boolean isBigDecimal() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public BigDecimal getBigDecimal() {
- return new BigDecimal(value);
- }
-
- @Override
- @JsonIgnore
- public boolean isString() {
- return true;
- }
-
- @Override
- @JsonIgnore
- public String getString() {
- return toString();
- }
-
- @Override
- @JsonIgnore
- public String toString() {
- return Integer.toString(value);
- }
-
-}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcUDINT.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcUDINT.java
index ea3c53a..3ad65ca 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcUDINT.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcUDINT.java
@@ -25,12 +25,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
-import org.apache.plc4x.java.api.value.*;
-
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.LinkedList;
-import java.util.List;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
public class PlcUDINT extends PlcIECValue<Long> {
@@ -47,7 +43,7 @@ public class PlcUDINT extends PlcIECValue<Long> {
public PlcUDINT(Byte value) {
super();
if (value >= minValue && value <= maxValue) {
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -59,7 +55,7 @@ public class PlcUDINT extends PlcIECValue<Long> {
public PlcUDINT(Short value) {
super();
if (value >= minValue && value <= maxValue) {
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -71,7 +67,7 @@ public class PlcUDINT extends PlcIECValue<Long> {
public PlcUDINT(Integer value) {
super();
if (value >= minValue && value <= maxValue) {
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -83,7 +79,7 @@ public class PlcUDINT extends PlcIECValue<Long> {
public PlcUDINT(Long value) {
super();
if (value >= minValue && value <= maxValue) {
- this.value = (Long) value.longValue();
+ this.value = value;
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -95,7 +91,7 @@ public class PlcUDINT extends PlcIECValue<Long> {
public PlcUDINT(Float value) {
super();
if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -107,7 +103,7 @@ public class PlcUDINT extends PlcIECValue<Long> {
public PlcUDINT(Double value) {
super();
if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -119,7 +115,7 @@ public class PlcUDINT extends PlcIECValue<Long> {
public PlcUDINT(BigInteger value) {
super();
if ((value.compareTo(BigInteger.valueOf(minValue)) >= 0) && (value.compareTo(BigInteger.valueOf(maxValue)) <= 0)) {
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -131,7 +127,7 @@ public class PlcUDINT extends PlcIECValue<Long> {
public PlcUDINT(BigDecimal value) {
super();
if ((value.compareTo(BigDecimal.valueOf(minValue)) >= 0) && (value.compareTo(BigDecimal.valueOf(maxValue)) <= 0) && (value.scale() <= 0)) {
- this.value = (Long) value.longValue();
+ this.value = value.longValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -143,7 +139,7 @@ public class PlcUDINT extends PlcIECValue<Long> {
public PlcUDINT(String value) {
super();
try {
- Long val = Long.parseLong(value);
+ long val = Long.parseLong(value);
if (val >= minValue && val <= maxValue) {
this.value = val;
this.isNullable = false;
@@ -173,6 +169,55 @@ public class PlcUDINT extends PlcIECValue<Long> {
}
}
+
+ @Override
+ @JsonIgnore
+ public boolean isBoolean() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean getBoolean() {
+ return (value != null) && !value.equals(0);
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isByte() {
+ return (value != null) && (value <= Byte.MAX_VALUE) && (value >= Byte.MIN_VALUE);
+ }
+
+ @Override
+ @JsonIgnore
+ public byte getByte() {
+ return value.byteValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isShort() {
+ return (value != null) && (value <= Short.MAX_VALUE) && (value >= Short.MIN_VALUE);
+ }
+
+ @Override
+ @JsonIgnore
+ public short getShort() {
+ return value.shortValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isInteger() {
+ return (value != null) && (value <= Integer.MAX_VALUE) && (value >= Integer.MIN_VALUE);
+ }
+
+ @Override
+ @JsonIgnore
+ public int getInteger() {
+ return value.intValue();
+ }
+
@Override
@JsonIgnore
public boolean isLong() {
@@ -185,8 +230,64 @@ public class PlcUDINT extends PlcIECValue<Long> {
return value;
}
- public long getUDINT() {
- return value;
+ @Override
+ @JsonIgnore
+ public boolean isBigInteger() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public BigInteger getBigInteger() {
+ return BigInteger.valueOf(value);
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isFloat() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public float getFloat() {
+ return value.floatValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isDouble() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public double getDouble() {
+ return value.doubleValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isBigDecimal() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public BigDecimal getBigDecimal() {
+ return BigDecimal.valueOf(getDouble());
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isString() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public String getString() {
+ return toString();
}
@Override
@@ -195,6 +296,12 @@ public class PlcUDINT extends PlcIECValue<Long> {
return Long.toString(value);
}
+ @JsonIgnore
+ public long getUDINT() {
+ return value;
+ }
+
+ @JsonIgnore
public byte[] getBytes() {
byte[] bytes = new byte[4];
bytes[0] = (byte)((value >> 24) & 0xff);
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcUINT.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcUINT.java
index 02a65d1..cae28b6 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcUINT.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcUINT.java
@@ -25,12 +25,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
-import org.apache.plc4x.java.api.value.*;
-
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.LinkedList;
-import java.util.List;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
public class PlcUINT extends PlcIECValue<Integer> {
@@ -53,7 +49,7 @@ public class PlcUINT extends PlcIECValue<Integer> {
public PlcUINT(Short value) {
super();
if ((value >= minValue) && (value <= maxValue)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = false;
} else {
throw new IllegalArgumentException("Value of type " + value + " is out of range " + minValue + " - " + maxValue + " for a PLCUINT Value");
@@ -73,7 +69,7 @@ public class PlcUINT extends PlcIECValue<Integer> {
public PlcUINT(Long value) {
super();
if ((value >= minValue) && (value <= maxValue)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -85,7 +81,7 @@ public class PlcUINT extends PlcIECValue<Integer> {
public PlcUINT(Float value) {
super();
if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -97,7 +93,7 @@ public class PlcUINT extends PlcIECValue<Integer> {
public PlcUINT(Double value) {
super();
if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -109,7 +105,7 @@ public class PlcUINT extends PlcIECValue<Integer> {
public PlcUINT(BigInteger value) {
super();
if ((value.compareTo(BigInteger.valueOf(minValue)) >= 0) && (value.compareTo(BigInteger.valueOf(maxValue)) <= 0)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -121,7 +117,7 @@ public class PlcUINT extends PlcIECValue<Integer> {
public PlcUINT(BigDecimal value) {
super();
if ((value.compareTo(BigDecimal.valueOf(minValue)) >= 0) && (value.compareTo(BigDecimal.valueOf(maxValue)) <= 0) && (value.scale() <= 0)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -133,7 +129,7 @@ public class PlcUINT extends PlcIECValue<Integer> {
public PlcUINT(String value) {
super();
try {
- Integer val = Integer.parseInt(value);
+ int val = Integer.parseInt(value);
if ((val >= minValue) && (val <= maxValue)) {
this.value = val;
this.isNullable = false;
@@ -159,6 +155,42 @@ public class PlcUINT extends PlcIECValue<Integer> {
@Override
@JsonIgnore
+ public boolean isBoolean() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean getBoolean() {
+ return (value != null) && !value.equals(0);
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isByte() {
+ return (value != null) && (value <= Byte.MAX_VALUE) && (value >= Byte.MIN_VALUE);
+ }
+
+ @Override
+ @JsonIgnore
+ public byte getByte() {
+ return value.byteValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isShort() {
+ return (value != null) && (value <= Short.MAX_VALUE) && (value >= Short.MIN_VALUE);
+ }
+
+ @Override
+ @JsonIgnore
+ public short getShort() {
+ return value.shortValue();
+ }
+
+ @Override
+ @JsonIgnore
public boolean isInteger() {
return true;
}
@@ -169,8 +201,76 @@ public class PlcUINT extends PlcIECValue<Integer> {
return value;
}
- public int getUINT() {
- return value;
+ @Override
+ @JsonIgnore
+ public boolean isLong() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public long getLong() {
+ return value.longValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isBigInteger() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public BigInteger getBigInteger() {
+ return BigInteger.valueOf(getLong());
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isFloat() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public float getFloat() {
+ return value.floatValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isDouble() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public double getDouble() {
+ return value.doubleValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isBigDecimal() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public BigDecimal getBigDecimal() {
+ return BigDecimal.valueOf(getFloat());
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isString() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public String getString() {
+ return toString();
}
@Override
@@ -179,6 +279,12 @@ public class PlcUINT extends PlcIECValue<Integer> {
return Integer.toString(value);
}
+ @JsonIgnore
+ public int getUINT() {
+ return value;
+ }
+
+ @JsonIgnore
public byte[] getBytes() {
byte[] bytes = new byte[2];
bytes[0] = (byte)((value >> 8) & 0xff);
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcULINT.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcULINT.java
index 628f016..74b19e6 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcULINT.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcULINT.java
@@ -19,18 +19,12 @@
package org.apache.plc4x.java.api.value;
-import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
-import org.apache.plc4x.java.api.value.*;
-
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.LinkedList;
-import java.util.List;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
public class PlcULINT extends PlcIECValue<BigInteger> {
@@ -186,6 +180,66 @@ public class PlcULINT extends PlcIECValue<BigInteger> {
@Override
@JsonIgnore
+ public boolean isBoolean() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean getBoolean() {
+ return (value != null) && !value.equals(0);
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isByte() {
+ return (value != null) && (value.compareTo(BigInteger.valueOf(Byte.MAX_VALUE)) <= 0) && (value.compareTo(BigInteger.valueOf(Byte.MIN_VALUE)) >= 0);
+ }
+
+ @Override
+ @JsonIgnore
+ public byte getByte() {
+ return value.byteValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isShort() {
+ return (value != null) && (value.compareTo(BigInteger.valueOf(Short.MAX_VALUE)) <= 0) && (value.compareTo(BigInteger.valueOf(Short.MIN_VALUE)) >= 0);
+ }
+
+ @Override
+ @JsonIgnore
+ public short getShort() {
+ return value.shortValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isInteger() {
+ return (value != null) && (value.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) <= 0) && (value.compareTo(BigInteger.valueOf(Integer.MIN_VALUE)) >= 0);
+ }
+
+ @Override
+ @JsonIgnore
+ public int getInteger() {
+ return value.intValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isLong() {
+ return (value != null) && (value.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) <= 0) && (value.compareTo(BigInteger.valueOf(Long.MIN_VALUE)) >= 0);
+ }
+
+ @Override
+ @JsonIgnore
+ public long getLong() {
+ return value.longValue();
+ }
+
+ @Override
+ @JsonIgnore
public boolean isBigInteger() {
return true;
}
@@ -196,8 +250,52 @@ public class PlcULINT extends PlcIECValue<BigInteger> {
return value;
}
- public BigInteger getULINT() {
- return value;
+ @Override
+ @JsonIgnore
+ public boolean isFloat() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public float getFloat() {
+ return value.floatValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isDouble() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public double getDouble() {
+ return value.doubleValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isBigDecimal() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public BigDecimal getBigDecimal() {
+ return new BigDecimal(value);
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isString() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public String getString() {
+ return toString();
}
@Override
@@ -206,6 +304,12 @@ public class PlcULINT extends PlcIECValue<BigInteger> {
return value.toString();
}
+ @JsonIgnore
+ public BigInteger getULINT() {
+ return value;
+ }
+
+ @JsonIgnore
public byte[] getBytes() {
byte[] tmp = value.toByteArray();
byte[] bytes = new byte[8];
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcUSINT.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcUSINT.java
index c992859..aa8cba6 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcUSINT.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcUSINT.java
@@ -25,12 +25,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
-import org.apache.plc4x.java.api.value.*;
-
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.LinkedList;
-import java.util.List;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
public class PlcUSINT extends PlcIECValue<Short> {
@@ -40,7 +36,7 @@ public class PlcUSINT extends PlcIECValue<Short> {
public PlcUSINT(Boolean value) {
super();
- this.value = value ? new Short((short) 1) : new Short((short) 0);
+ this.value = value ? Short.valueOf((short) 1) : Short.valueOf((short) 0);
this.isNullable = false;
}
@@ -59,7 +55,7 @@ public class PlcUSINT extends PlcIECValue<Short> {
public PlcUSINT(Short value) {
super();
if ((value >= minValue) && (value <= maxValue)) {
- this.value = (Short) value.shortValue();
+ this.value = value;
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -71,7 +67,7 @@ public class PlcUSINT extends PlcIECValue<Short> {
public PlcUSINT(Integer value) {
super();
if ((value >= minValue) && (value <= maxValue)) {
- this.value = (Short) value.shortValue();
+ this.value = value.shortValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -83,7 +79,7 @@ public class PlcUSINT extends PlcIECValue<Short> {
public PlcUSINT(Long value) {
super();
if ((value >= minValue) && (value <= maxValue)) {
- this.value = (Short) value.shortValue();
+ this.value = value.shortValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -95,7 +91,7 @@ public class PlcUSINT extends PlcIECValue<Short> {
public PlcUSINT(Float value) {
super();
if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = (Short) value.shortValue();
+ this.value = value.shortValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -107,7 +103,7 @@ public class PlcUSINT extends PlcIECValue<Short> {
public PlcUSINT(Double value) {
super();
if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = (Short) value.shortValue();
+ this.value = value.shortValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -119,7 +115,7 @@ public class PlcUSINT extends PlcIECValue<Short> {
public PlcUSINT(BigInteger value) {
super();
if ((value.compareTo(BigInteger.valueOf(minValue)) >= 0) && (value.compareTo(BigInteger.valueOf(maxValue)) <= 0)) {
- this.value = (Short) value.shortValue();
+ this.value = value.shortValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -131,7 +127,7 @@ public class PlcUSINT extends PlcIECValue<Short> {
public PlcUSINT(BigDecimal value) {
super();
if ((value.compareTo(BigDecimal.valueOf(minValue)) >= 0) && (value.compareTo(BigDecimal.valueOf(maxValue)) <= 0) && (value.scale() <= 0)) {
- this.value = (Short) value.shortValue();
+ this.value = value.shortValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -143,7 +139,7 @@ public class PlcUSINT extends PlcIECValue<Short> {
public PlcUSINT(String value) {
super();
try {
- Short val = Short.valueOf(value).shortValue();
+ short val = Short.parseShort(value);
if ((val >= minValue) && (val <= maxValue)) {
this.value = val;
this.isNullable = false;
@@ -175,6 +171,30 @@ public class PlcUSINT extends PlcIECValue<Short> {
@Override
@JsonIgnore
+ public boolean isBoolean() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean getBoolean() {
+ return (value != null) && !value.equals(0);
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isByte() {
+ return (value != null) && (value <= Byte.MAX_VALUE) && (value >= Byte.MIN_VALUE);
+ }
+
+ @Override
+ @JsonIgnore
+ public byte getByte() {
+ return value.byteValue();
+ }
+
+ @Override
+ @JsonIgnore
public boolean isShort() {
return true;
}
@@ -185,8 +205,88 @@ public class PlcUSINT extends PlcIECValue<Short> {
return value;
}
- public short getUSINT() {
- return value;
+ @Override
+ @JsonIgnore
+ public boolean isInteger() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public int getInteger() {
+ return value.intValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isLong() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public long getLong() {
+ return value.longValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isBigInteger() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public BigInteger getBigInteger() {
+ return BigInteger.valueOf(getLong());
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isFloat() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public float getFloat() {
+ return value.floatValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isDouble() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public double getDouble() {
+ return value.doubleValue();
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isBigDecimal() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public BigDecimal getBigDecimal() {
+ return BigDecimal.valueOf(getFloat());
+ }
+
+ @Override
+ @JsonIgnore
+ public boolean isString() {
+ return true;
+ }
+
+ @Override
+ @JsonIgnore
+ public String getString() {
+ return toString();
}
@Override
@@ -195,6 +295,12 @@ public class PlcUSINT extends PlcIECValue<Short> {
return Short.toString(value);
}
+ @JsonIgnore
+ public short getUSINT() {
+ return value;
+ }
+
+ @JsonIgnore
public byte[] getBytes() {
byte[] bytes = new byte[1];
bytes[0] = (byte)(value & 0xff);
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcValues.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcValues.java
index 599402d..f746245 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcValues.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcValues.java
@@ -40,17 +40,17 @@ public class PlcValues {
private static final Logger LOGGER = LoggerFactory.getLogger(PlcValues.class);
public static PlcValue of(Boolean b) {
- return new PlcBoolean(b);
+ return new PlcBOOL(b);
}
public static PlcValue of(boolean b) {
- return new PlcBoolean(b);
+ return new PlcBOOL(b);
}
public static PlcValue of(Boolean[] b) {
if(b != null) {
if(b.length == 1) {
- return new PlcBoolean(b[0]);
+ return new PlcBOOL(b[0]);
} else if(b.length > 1) {
return new PlcList(Arrays.asList(b));
}
@@ -61,7 +61,7 @@ public class PlcValues {
public static PlcValue of(boolean[] b) {
if(b != null) {
if(b.length == 1) {
- return new PlcBoolean(b[0]);
+ return new PlcBOOL(b[0]);
} else if(b.length > 1) {
return new PlcList(Arrays.asList(b));
}
@@ -70,17 +70,17 @@ public class PlcValues {
}
public static PlcValue of(Byte i) {
- return new PlcInteger(i);
+ return new PlcSINT(i);
}
public static PlcValue of(byte i) {
- return new PlcInteger(i);
+ return new PlcSINT(i);
}
public static PlcValue of(Byte[] i) {
if(i != null) {
if(i.length == 1) {
- return new PlcInteger(i[0]);
+ return new PlcSINT(i[0]);
} else if(i.length > 1) {
return new PlcList(Arrays.asList(i));
}
@@ -91,7 +91,7 @@ public class PlcValues {
public static PlcValue of(byte[] i) {
if(i != null) {
if(i.length == 1) {
- return new PlcInteger(i[0]);
+ return new PlcSINT(i[0]);
} else if(i.length > 1) {
return new PlcList(Arrays.asList(i));
}
@@ -100,17 +100,17 @@ public class PlcValues {
}
public static PlcValue of(Short i) {
- return new PlcInteger(i);
+ return new PlcINT(i);
}
public static PlcValue of(short i) {
- return new PlcInteger(i);
+ return new PlcINT(i);
}
public static PlcValue of(Short[] i) {
if(i != null) {
if(i.length == 1) {
- return new PlcInteger(i[0]);
+ return new PlcINT(i[0]);
} else if(i.length > 1) {
return new PlcList(Arrays.asList(i));
}
@@ -121,7 +121,7 @@ public class PlcValues {
public static PlcValue of(short[] i) {
if(i != null) {
if(i.length == 1) {
- return new PlcInteger(i[0]);
+ return new PlcINT(i[0]);
} else if(i.length > 1) {
return new PlcList(Arrays.asList(i));
}
@@ -130,17 +130,17 @@ public class PlcValues {
}
public static PlcValue of(Integer i) {
- return new PlcInteger(i);
+ return new PlcDINT(i);
}
public static PlcValue of(int i) {
- return new PlcInteger(i);
+ return new PlcDINT(i);
}
public static PlcValue of(Integer[] i) {
if(i != null) {
if(i.length == 1) {
- return new PlcInteger(i[0]);
+ return new PlcDINT(i[0]);
} else if(i.length > 1) {
return new PlcList(Arrays.asList(i));
}
@@ -151,7 +151,7 @@ public class PlcValues {
public static PlcValue of(int[] i) {
if(i != null) {
if(i.length == 1) {
- return new PlcInteger(i[0]);
+ return new PlcDINT(i[0]);
} else if(i.length > 1) {
return new PlcList(Arrays.asList(i));
}
@@ -160,17 +160,17 @@ public class PlcValues {
}
public static PlcValue of(Long i) {
- return new PlcLong(i);
+ return new PlcLINT(i);
}
public static PlcValue of(long i) {
- return new PlcLong(i);
+ return new PlcLINT(i);
}
public static PlcValue of(Long[] i) {
if(i != null) {
if(i.length == 1) {
- return new PlcLong(i[0]);
+ return new PlcLINT(i[0]);
} else if(i.length > 1) {
return new PlcList(Arrays.asList(i));
}
@@ -181,7 +181,7 @@ public class PlcValues {
public static PlcValue of(long[] i) {
if(i != null) {
if(i.length == 1) {
- return new PlcLong(i[0]);
+ return new PlcLINT(i[0]);
} else if(i.length > 1) {
return new PlcList(Arrays.asList(i));
}
@@ -205,17 +205,17 @@ public class PlcValues {
}
public static PlcValue of(Float i) {
- return new PlcFloat(i);
+ return new PlcREAL(i);
}
public static PlcValue of(float i) {
- return new PlcFloat(i);
+ return new PlcREAL(i);
}
public static PlcValue of(Float[] i) {
if(i != null) {
if(i.length == 1) {
- return new PlcFloat(i[0]);
+ return new PlcREAL(i[0]);
} else if(i.length > 1) {
return new PlcList(Arrays.asList(i));
}
@@ -226,7 +226,7 @@ public class PlcValues {
public static PlcValue of(float[] i) {
if(i != null) {
if(i.length == 1) {
- return new PlcFloat(i[0]);
+ return new PlcREAL(i[0]);
} else if(i.length > 1) {
return new PlcList(Arrays.asList(i));
}
@@ -235,17 +235,17 @@ public class PlcValues {
}
public static PlcValue of(Double i) {
- return new PlcDouble(i);
+ return new PlcLREAL(i);
}
public static PlcValue of(double i) {
- return new PlcDouble(i);
+ return new PlcLREAL(i);
}
public static PlcValue of(Double[] i) {
if(i != null) {
if(i.length == 1) {
- return new PlcDouble(i[0]);
+ return new PlcLREAL(i[0]);
} else if(i.length > 1) {
return new PlcList(Arrays.asList(i));
}
@@ -256,7 +256,7 @@ public class PlcValues {
public static PlcValue of(double[] i) {
if(i != null) {
if(i.length == 1) {
- return new PlcDouble(i[0]);
+ return new PlcLREAL(i[0]);
} else if(i.length > 1) {
return new PlcList(Arrays.asList(i));
}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcWCHAR.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcWCHAR.java
index 3c44e9d..44d8e6d 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcWCHAR.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcWCHAR.java
@@ -25,12 +25,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
-import org.apache.plc4x.java.api.value.*;
-
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.LinkedList;
-import java.util.List;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
public class PlcWCHAR extends PlcIECValue<Integer> {
@@ -52,7 +48,7 @@ public class PlcWCHAR extends PlcIECValue<Integer> {
public PlcWCHAR(Character value) {
super();
- Integer val = (int) value;
+ int val = (int) value;
if ((val >= minValue) && (val <= maxValue)) {
this.value = val;
this.isNullable = false;
@@ -66,7 +62,7 @@ public class PlcWCHAR extends PlcIECValue<Integer> {
public PlcWCHAR(Short value) {
super();
if ((value >= minValue) && (value <= maxValue)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = false;
} else {
throw new IllegalArgumentException("Value of type " + value + " is out of range " + minValue + " - " + maxValue + " for a PLCWCHAR Value");
@@ -86,7 +82,7 @@ public class PlcWCHAR extends PlcIECValue<Integer> {
public PlcWCHAR(Long value) {
super();
if ((value >= minValue) && (value <= maxValue)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -98,7 +94,7 @@ public class PlcWCHAR extends PlcIECValue<Integer> {
public PlcWCHAR(Float value) {
super();
if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -110,7 +106,7 @@ public class PlcWCHAR extends PlcIECValue<Integer> {
public PlcWCHAR(Double value) {
super();
if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -122,7 +118,7 @@ public class PlcWCHAR extends PlcIECValue<Integer> {
public PlcWCHAR(BigInteger value) {
super();
if ((value.compareTo(BigInteger.valueOf(minValue)) >= 0) && (value.compareTo(BigInteger.valueOf(maxValue)) <= 0)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -134,7 +130,7 @@ public class PlcWCHAR extends PlcIECValue<Integer> {
public PlcWCHAR(BigDecimal value) {
super();
if ((value.compareTo(BigDecimal.valueOf(minValue)) >= 0) && (value.compareTo(BigDecimal.valueOf(maxValue)) <= 0) && (value.scale() <= 0)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -146,7 +142,7 @@ public class PlcWCHAR extends PlcIECValue<Integer> {
public PlcWCHAR(String value) {
super();
try {
- Integer val = Integer.parseInt(value);
+ int val = Integer.parseInt(value);
if ((val >= minValue) && (val <= maxValue)) {
this.value = val;
this.isNullable = false;
@@ -182,21 +178,23 @@ public class PlcWCHAR extends PlcIECValue<Integer> {
return value;
}
+ @JsonIgnore
public int getWCHAR() {
return value;
}
@Override
public Object getObject() {
- return Character.toString(Character.valueOf((char) ((int) value)));
+ return Character.toString((char) ((int) value));
}
@Override
@JsonIgnore
public String toString() {
- return Character.toString(Character.valueOf((char) ((int) value)));
+ return Character.toString((char) ((int) value));
}
+ @JsonIgnore
public byte[] getBytes() {
byte[] bytes = new byte[2];
bytes[0] = (byte)((value >> 8) & 0xff);
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcWORD.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcWORD.java
index 8597b60..c243495 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcWORD.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcWORD.java
@@ -25,12 +25,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
-import org.apache.plc4x.java.api.value.*;
-
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.LinkedList;
-import java.util.List;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
public class PlcWORD extends PlcIECValue<Integer> {
@@ -46,14 +42,14 @@ public class PlcWORD extends PlcIECValue<Integer> {
public PlcWORD(Byte value) {
super();
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = false;
}
public PlcWORD(Short value) {
super();
if ((value >= minValue) && (value <= maxValue)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = false;
} else {
throw new IllegalArgumentException("Value of type " + value + " is out of range " + minValue + " - " + maxValue + " for a PLCUINT Value");
@@ -73,7 +69,7 @@ public class PlcWORD extends PlcIECValue<Integer> {
public PlcWORD(Long value) {
super();
if ((value >= minValue) && (value <= maxValue)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -85,7 +81,7 @@ public class PlcWORD extends PlcIECValue<Integer> {
public PlcWORD(Float value) {
super();
if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -97,7 +93,7 @@ public class PlcWORD extends PlcIECValue<Integer> {
public PlcWORD(Double value) {
super();
if ((value >= minValue) && (value <= maxValue) && (value % 1 == 0)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = false;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -109,7 +105,7 @@ public class PlcWORD extends PlcIECValue<Integer> {
public PlcWORD(BigInteger value) {
super();
if ((value.compareTo(BigInteger.valueOf(minValue)) >= 0) && (value.compareTo(BigInteger.valueOf(maxValue)) <= 0)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -121,7 +117,7 @@ public class PlcWORD extends PlcIECValue<Integer> {
public PlcWORD(BigDecimal value) {
super();
if ((value.compareTo(BigDecimal.valueOf(minValue)) >= 0) && (value.compareTo(BigDecimal.valueOf(maxValue)) <= 0) && (value.scale() <= 0)) {
- this.value = (Integer) value.intValue();
+ this.value = value.intValue();
this.isNullable = true;
} else {
throw new PlcInvalidFieldException("Value of type " + value +
@@ -133,7 +129,7 @@ public class PlcWORD extends PlcIECValue<Integer> {
public PlcWORD(String value) {
super();
try {
- Integer val = Integer.parseInt(value);
+ int val = Integer.parseInt(value);
if ((val >= minValue) && (val <= maxValue)) {
this.value = val;
this.isNullable = false;
@@ -169,6 +165,7 @@ public class PlcWORD extends PlcIECValue<Integer> {
return value;
}
+ @JsonIgnore
public int getWORD() {
return value;
}
@@ -179,6 +176,7 @@ public class PlcWORD extends PlcIECValue<Integer> {
return Integer.toString(value);
}
+ @JsonIgnore
public byte[] getBytes() {
byte[] bytes = new byte[2];
bytes[0] = (byte)((value >> 8) & 0xff);
diff --git a/plc4j/drivers/ab-eth/src/main/java/org/apache/plc4x/java/abeth/protocol/AbEthProtocolLogic.java b/plc4j/drivers/ab-eth/src/main/java/org/apache/plc4x/java/abeth/protocol/AbEthProtocolLogic.java
index d9e38b6..0583e96 100644
--- a/plc4j/drivers/ab-eth/src/main/java/org/apache/plc4x/java/abeth/protocol/AbEthProtocolLogic.java
+++ b/plc4j/drivers/ab-eth/src/main/java/org/apache/plc4x/java/abeth/protocol/AbEthProtocolLogic.java
@@ -26,10 +26,7 @@ import org.apache.plc4x.java.api.messages.PlcReadResponse;
import org.apache.plc4x.java.api.messages.PlcResponse;
import org.apache.plc4x.java.api.model.PlcField;
import org.apache.plc4x.java.api.types.PlcResponseCode;
-import org.apache.plc4x.java.api.value.PlcInteger;
-import org.apache.plc4x.java.api.value.PlcList;
-import org.apache.plc4x.java.api.value.PlcValue;
-import org.apache.plc4x.java.api.value.PlcValues;
+import org.apache.plc4x.java.api.value.*;
import org.apache.plc4x.java.spi.ConversationContext;
import org.apache.plc4x.java.spi.Plc4xProtocolBase;
import org.apache.plc4x.java.spi.configuration.HasConfiguration;
@@ -158,7 +155,7 @@ public class AbEthProtocolLogic extends Plc4xProtocolBase<CIPEncapsulationPacket
DF1CommandResponseMessageProtectedTypedLogicalRead df1PTLR = (DF1CommandResponseMessageProtectedTypedLogicalRead) plcReadResponse.getResponse();
short[] data = df1PTLR.getData();
if(data.length == 1) {
- plcValue = new PlcInteger(data[0]);
+ plcValue = new PlcINT(data[0]);
} else {
plcValue = new PlcList(Arrays.asList(data));
}
diff --git a/plc4j/drivers/ab-eth/src/main/java/org/apache/plc4x/java/abeth/protocol/Plc4xAbEthProtocol.java b/plc4j/drivers/ab-eth/src/main/java/org/apache/plc4x/java/abeth/protocol/Plc4xAbEthProtocol.java
index 24391c4..3658ec8 100644
--- a/plc4j/drivers/ab-eth/src/main/java/org/apache/plc4x/java/abeth/protocol/Plc4xAbEthProtocol.java
+++ b/plc4j/drivers/ab-eth/src/main/java/org/apache/plc4x/java/abeth/protocol/Plc4xAbEthProtocol.java
@@ -179,7 +179,7 @@ public class Plc4xAbEthProtocol extends PlcMessageToMessageCodec<CIPEncapsulatio
DF1CommandResponseMessageProtectedTypedLogicalRead df1PTLR = (DF1CommandResponseMessageProtectedTypedLogicalRead) plcReadResponse.getResponse();
short[] data = df1PTLR.getData();
if(data.length == 1) {
- plcValue = new PlcInteger(data[0]);
+ plcValue = new PlcINT(data[0]);
} else {
plcValue = new PlcList(Arrays.asList(data));
}
@@ -243,7 +243,7 @@ public class Plc4xAbEthProtocol extends PlcMessageToMessageCodec<CIPEncapsulatio
private PlcValue decodeReadResponseUnsignedBytePlcValue(AbEthField field, ByteBuf data) {
Short[] shorts = null;//readAllValues(Short.class, field, i -> data.readUnsignedByte());
- return new PlcInteger(1/*shorts*/);
+ return new PlcSINT(1/*shorts*/);
}
}
diff --git a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/field/AdsFieldHandler.java b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/field/AdsFieldHandler.java
index 82b19f8..cb022dd 100644
--- a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/field/AdsFieldHandler.java
+++ b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/field/AdsFieldHandler.java
@@ -464,9 +464,9 @@ public class AdsFieldHandler extends DefaultPlcFieldHandler {
case BIT:
case BIT8: {
if (values.length == 1) {
- return new PlcBoolean(Boolean.valueOf(stringValues[0]));
+ return new PlcBOOL(Boolean.valueOf(stringValues[0]));
} else {
- return new PlcList(Arrays.stream(stringValues).map(s -> new PlcBoolean(Boolean.valueOf(s))).collect(Collectors.toList()));
+ return new PlcList(Arrays.stream(stringValues).map(s -> new PlcBOOL(Boolean.valueOf(s))).collect(Collectors.toList()));
}
}
case BYTE:
@@ -484,9 +484,9 @@ public class AdsFieldHandler extends DefaultPlcFieldHandler {
case SINT:
case INT8: {
if (values.length == 1) {
- return new PlcByte(Byte.valueOf(stringValues[0]));
+ return new PlcSINT(Byte.valueOf(stringValues[0]));
} else {
- return new PlcList(Arrays.stream(stringValues).map(s -> new PlcByte(Byte.valueOf(s))).collect(Collectors.toList()));
+ return new PlcList(Arrays.stream(stringValues).map(s -> new PlcSINT(Byte.valueOf(s))).collect(Collectors.toList()));
}
}
@@ -495,9 +495,9 @@ public class AdsFieldHandler extends DefaultPlcFieldHandler {
case INT:
case INT16: {
if (values.length == 1) {
- return new PlcShort(Short.valueOf(stringValues[0]));
+ return new PlcINT(Short.valueOf(stringValues[0]));
} else {
- return new PlcList(Arrays.stream(stringValues).map(s -> new PlcShort(Short.valueOf(s))).collect(Collectors.toList()));
+ return new PlcList(Arrays.stream(stringValues).map(s -> new PlcINT(Short.valueOf(s))).collect(Collectors.toList()));
}
}
@@ -506,9 +506,9 @@ public class AdsFieldHandler extends DefaultPlcFieldHandler {
case DINT:
case INT32: {
if (values.length == 1) {
- return new PlcInteger(Integer.valueOf(stringValues[0]));
+ return new PlcDINT(Integer.valueOf(stringValues[0]));
} else {
- return new PlcList(Arrays.stream(stringValues).map(s -> new PlcInteger(Integer.valueOf(s))).collect(Collectors.toList()));
+ return new PlcList(Arrays.stream(stringValues).map(s -> new PlcDINT(Integer.valueOf(s))).collect(Collectors.toList()));
}
}
@@ -517,36 +517,36 @@ public class AdsFieldHandler extends DefaultPlcFieldHandler {
case LINT:
case INT64: {
if (values.length == 1) {
- return new PlcLong(Long.valueOf(stringValues[0]));
+ return new PlcLINT(Long.valueOf(stringValues[0]));
} else {
- return new PlcList(Arrays.stream(stringValues).map(s -> new PlcLong(Long.valueOf(s))).collect(Collectors.toList()));
+ return new PlcList(Arrays.stream(stringValues).map(s -> new PlcLINT(Long.valueOf(s))).collect(Collectors.toList()));
}
}
case ULINT:
case UINT64: {
if (values.length == 1) {
- return new PlcBigInteger(new BigInteger(stringValues[0]));
+ return new PlcULINT(new BigInteger(stringValues[0]));
} else {
- return new PlcList(Arrays.stream(stringValues).map(s -> new PlcBigInteger(new BigInteger(s))).collect(Collectors.toList()));
+ return new PlcList(Arrays.stream(stringValues).map(s -> new PlcULINT(new BigInteger(s))).collect(Collectors.toList()));
}
}
case REAL:
case FLOAT: {
if (values.length == 1) {
- return new PlcFloat(Float.valueOf(stringValues[0]));
+ return new PlcREAL(Float.valueOf(stringValues[0]));
} else {
- return new PlcList(Arrays.stream(stringValues).map(s -> new PlcFloat(Float.valueOf(s))).collect(Collectors.toList()));
+ return new PlcList(Arrays.stream(stringValues).map(s -> new PlcREAL(Float.valueOf(s))).collect(Collectors.toList()));
}
}
case LREAL:
case DOUBLE: {
if (values.length == 1) {
- return new PlcDouble(Double.valueOf(stringValues[0]));
+ return new PlcLREAL(Double.valueOf(stringValues[0]));
} else {
- return new PlcList(Arrays.stream(stringValues).map(s -> new PlcDouble(Double.valueOf(s))).collect(Collectors.toList()));
+ return new PlcList(Arrays.stream(stringValues).map(s -> new PlcLREAL(Double.valueOf(s))).collect(Collectors.toList()));
}
}
@@ -775,60 +775,63 @@ public class AdsFieldHandler extends DefaultPlcFieldHandler {
}
}
if(booleanValues.size() == 1) {
- return new PlcBoolean(booleanValues.get(0));
+ return new PlcBOOL(booleanValues.get(0));
} else {
return new PlcList(booleanValues);
}
}
private PlcValue internalEncodeInteger(PlcField field, Object[] values) {
+ // TODO: Review and double check this method.
AdsField adsField = (AdsField) field;
Class<? extends PlcValue> fieldType;
switch (adsField.getAdsDataType()) {
case BYTE:
- fieldType = PlcInteger.class;
- break;
case WORD:
- fieldType = PlcList.class;
- break;
case DWORD:
- fieldType = PlcList.class;
+ fieldType = PlcBOOL.class;
break;
case SINT:
- fieldType = PlcInteger.class;
+ fieldType = PlcSINT.class;
break;
case USINT:
- fieldType = PlcLong.class;
+ fieldType = PlcUSINT.class;
break;
case INT:
- fieldType = PlcInteger.class;
+ fieldType = PlcINT.class;
break;
case UINT:
- fieldType = PlcInteger.class;
+ fieldType = PlcUINT.class;
break;
case DINT:
- fieldType = PlcInteger.class;
+ fieldType = PlcDINT.class;
break;
case UDINT:
- fieldType = PlcLong.class;
+ fieldType = PlcUDINT.class;
break;
case LINT:
- fieldType = PlcLong.class;
+ fieldType = PlcLINT.class;
break;
case ULINT:
- fieldType = PlcBigInteger.class;
+ fieldType = PlcULINT.class;
break;
case INT32:
- fieldType = PlcInteger.class;
+ fieldType = PlcDINT.class;
break;
case INT64:
- fieldType = PlcLong.class;
+ fieldType = PlcLINT.class;
+ break;
+ case FLOAT:
+ fieldType = PlcREAL.class;
+ break;
+ case DOUBLE:
+ fieldType = PlcLREAL.class;
break;
default:
throw new IllegalArgumentException(
"Cannot assign integer values to " + adsField.getAdsDataType().name() + " fields.");
}
- if (fieldType == PlcLong.class) {
+ if (fieldType == PlcREAL.class) {
Long[] longValues = new Long[values.length];
for (int i = 0; i < values.length; i++) {
if (!((values[i] instanceof Byte) || (values[i] instanceof Short) ||
@@ -845,7 +848,7 @@ public class AdsFieldHandler extends DefaultPlcFieldHandler {
longValues[i] = value.longValue();
}
if(longValues.length == 1) {
- return new PlcLong(longValues[0]);
+ return new PlcREAL(longValues[0]);
} else {
return new PlcList(Arrays.asList(longValues));
}
@@ -882,16 +885,16 @@ public class AdsFieldHandler extends DefaultPlcFieldHandler {
AdsDataType adsDataType = adsField.getAdsDataType();
switch (adsDataType) {
case REAL:
- fieldType = PlcFloat.class;
+ fieldType = PlcREAL.class;
break;
case LREAL:
- fieldType = PlcDouble.class;
+ fieldType = PlcLREAL.class;
break;
default:
throw new IllegalArgumentException(
"Cannot assign floating point values to " + adsDataType.name() + " fields.");
}
- if (fieldType == PlcDouble.class) {
+ if (fieldType == PlcLREAL.class) {
Double[] floatingPointValues = new Double[values.length];
for (int i = 0; i < values.length; i++) {
if (values[i] instanceof Float) {
@@ -910,7 +913,7 @@ public class AdsFieldHandler extends DefaultPlcFieldHandler {
}*/
}
if(floatingPointValues.length == 1) {
- return new PlcDouble(floatingPointValues[0]);
+ return new PlcLREAL(floatingPointValues[0]);
} else {
return new PlcList(Arrays.asList(floatingPointValues));
}
@@ -939,7 +942,7 @@ public class AdsFieldHandler extends DefaultPlcFieldHandler {
}*/
}
if(floatingPointValues.length == 1) {
- return new PlcFloat(floatingPointValues[0]);
+ return new PlcREAL(floatingPointValues[0]);
} else {
return new PlcList(Arrays.asList(floatingPointValues));
}
diff --git a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/amsads/attic/protocol/util/LittleEndianDecoder.java b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/amsads/attic/protocol/util/LittleEndianDecoder.java
index 24858fe..49d86e4 100644
--- a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/amsads/attic/protocol/util/LittleEndianDecoder.java
+++ b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/amsads/attic/protocol/util/LittleEndianDecoder.java
@@ -53,7 +53,7 @@ public class LittleEndianDecoder {
values.offer(aByte != 0);
}
if(values.size() == 1) {
- return new PlcBoolean(values.get(0));
+ return new PlcBOOL(values.get(0));
} else {
return new PlcList(values);
}
@@ -65,7 +65,7 @@ public class LittleEndianDecoder {
values.offer(aByte != 0);
}
if(values.size() == 1) {
- return new PlcBoolean(values.get(0));
+ return new PlcBOOL(values.get(0));
} else {
return new PlcList(values);
}
@@ -77,7 +77,8 @@ public class LittleEndianDecoder {
values.offer(aByte);
}
if(values.size() == 1) {
- return new PlcInteger(values.get(0));
+ // TODO: Double-Check this ...
+ return new PlcBOOL(values.get(0));
} else {
return new PlcList(values);
}
@@ -89,7 +90,8 @@ public class LittleEndianDecoder {
values.offer(aLong);
}
if(values.size() == 1) {
- return new PlcInteger(values.get(0));
+ // TODO: Double-Check this ...
+ return new PlcBOOL(values.get(0));
} else {
return new PlcList(values);
}
@@ -101,7 +103,8 @@ public class LittleEndianDecoder {
values.offer(aLong);
}
if(values.size() == 1) {
- return new PlcLong(values.get(0));
+ // TODO: Double-Check this ...
+ return new PlcBOOL(values.get(0));
} else {
return new PlcList(values);
}
@@ -113,7 +116,7 @@ public class LittleEndianDecoder {
values.offer(aLong);
}
if(values.size() == 1) {
- return new PlcInteger(values.get(0));
+ return new PlcSINT(values.get(0));
} else {
return new PlcList(values);
}
@@ -125,7 +128,7 @@ public class LittleEndianDecoder {
values.offer(aLong);
}
if(values.size() == 1) {
- return new PlcInteger(values.get(0));
+ return new PlcINT(values.get(0));
} else {
return new PlcList(values);
}
@@ -137,7 +140,7 @@ public class LittleEndianDecoder {
values.offer(intLE);
}
if(values.size() == 1) {
- return new PlcInteger(values.get(0));
+ return new PlcDINT(values.get(0));
} else {
return new PlcList(values);
}
@@ -149,7 +152,7 @@ public class LittleEndianDecoder {
values.offer(longLE);
}
if(values.size() == 1) {
- return new PlcLong(values.get(0));
+ return new PlcLINT(values.get(0));
} else {
return new PlcList(values);
}
@@ -161,7 +164,7 @@ public class LittleEndianDecoder {
values.offer(aLong);
}
if(values.size() == 1) {
- return new PlcInteger(values.get(0));
+ return new PlcUSINT(values.get(0));
} else {
return new PlcList(values);
}
@@ -173,7 +176,7 @@ public class LittleEndianDecoder {
values.offer(aLong);
}
if(values.size() == 1) {
- return new PlcInteger(values.get(0));
+ return new PlcUINT(values.get(0));
} else {
return new PlcList(values);
}
@@ -185,7 +188,7 @@ public class LittleEndianDecoder {
values.offer(aLong);
}
if(values.size() == 1) {
- return new PlcLong(values.get(0));
+ return new PlcUDINT(values.get(0));
} else {
return new PlcList(values);
}
@@ -201,7 +204,7 @@ public class LittleEndianDecoder {
values.offer(bigInteger);
}
if(values.size() == 1) {
- return new PlcBigInteger(values.get(0));
+ return new PlcULINT(values.get(0));
} else {
return new PlcList(values);
}
@@ -215,7 +218,7 @@ public class LittleEndianDecoder {
values.offer(aLong);
}
if(values.size() == 1) {
- return new PlcFloat(values.get(0));
+ return new PlcREAL(values.get(0));
} else {
return new PlcList(values);
}
@@ -229,7 +232,7 @@ public class LittleEndianDecoder {
values.offer(aLong);
}
if(values.size() == 1) {
- return new PlcDouble(values.get(0));
+ return new PlcLREAL(values.get(0));
} else {
return new PlcList(values);
}
@@ -241,7 +244,7 @@ public class LittleEndianDecoder {
values.offer(aByte != 0);
}
if(values.size() == 1) {
- return new PlcBoolean(values.get(0));
+ return new PlcBOOL(values.get(0));
} else {
return new PlcList(values);
}
@@ -253,7 +256,8 @@ public class LittleEndianDecoder {
values.offer(aByte);
}
if(values.size() == 1) {
- return new PlcInteger(values.get(0));
+ // TODO: Double-Check this ...
+ return new PlcBOOL(values.get(0));
} else {
return new PlcList(values);
}
@@ -265,7 +269,8 @@ public class LittleEndianDecoder {
values.offer(aByte);
}
if(values.size() == 1) {
- return new PlcInteger(values.get(0));
+ // TODO: Double-Check this ...
+ return new PlcBOOL(values.get(0));
} else {
return new PlcList(values);
}
@@ -277,7 +282,8 @@ public class LittleEndianDecoder {
values.offer(aByte);
}
if(values.size() == 1) {
- return new PlcLong(values.get(0));
+ // TODO: Double-Check this ...
+ return new PlcBOOL(values.get(0));
} else {
return new PlcList(values);
}
@@ -289,7 +295,7 @@ public class LittleEndianDecoder {
values.offer(aByte);
}
if(values.size() == 1) {
- return new PlcInteger(values.get(0));
+ return new PlcSINT(values.get(0));
} else {
return new PlcList(values);
}
@@ -301,7 +307,7 @@ public class LittleEndianDecoder {
values.offer(aByte);
}
if(values.size() == 1) {
- return new PlcInteger(values.get(0));
+ return new PlcUSINT(values.get(0));
} else {
return new PlcList(values);
}
@@ -313,7 +319,7 @@ public class LittleEndianDecoder {
values.offer(aByte);
}
if(values.size() == 1) {
- return new PlcInteger(values.get(0));
+ return new PlcINT(values.get(0));
} else {
return new PlcList(values);
}
@@ -325,7 +331,7 @@ public class LittleEndianDecoder {
values.offer(aByte);
}
if(values.size() == 1) {
- return new PlcInteger(values.get(0));
+ return new PlcUINT(values.get(0));
} else {
return new PlcList(values);
}
@@ -337,7 +343,7 @@ public class LittleEndianDecoder {
values.offer(aByte);
}
if(values.size() == 1) {
- return new PlcInteger(values.get(0));
+ return new PlcDINT(values.get(0));
} else {
return new PlcList(values);
}
@@ -349,7 +355,7 @@ public class LittleEndianDecoder {
values.offer(aByte);
}
if(values.size() == 1) {
- return new PlcLong(values.get(0));
+ return new PlcUDINT(values.get(0));
} else {
return new PlcList(values);
}
@@ -361,7 +367,7 @@ public class LittleEndianDecoder {
values.offer(aByte);
}
if(values.size() == 1) {
- return new PlcLong(values.get(0));
+ return new PlcLINT(values.get(0));
} else {
return new PlcList(values);
}
@@ -375,7 +381,7 @@ public class LittleEndianDecoder {
values.offer(aByte);
}
if(values.size() == 1) {
- return new PlcFloat(values.get(0));
+ return new PlcREAL(values.get(0));
} else {
return new PlcList(values);
}
@@ -389,7 +395,7 @@ public class LittleEndianDecoder {
values.offer(aByte);
}
if(values.size() == 1) {
- return new PlcDouble(values.get(0));
+ return new PlcLREAL(values.get(0));
} else {
return new PlcList(values);
}
diff --git a/plc4j/drivers/ads/src/test/resources/testsuite/AdsDriverIT.xml b/plc4j/drivers/ads/src/test/resources/testsuite/AdsDriverIT.xml
index 6eb1f65..b1f91f8 100644
--- a/plc4j/drivers/ads/src/test/resources/testsuite/AdsDriverIT.xml
+++ b/plc4j/drivers/ads/src/test/resources/testsuite/AdsDriverIT.xml
@@ -156,7 +156,7 @@
</request>
<hurz>
<code>OK</code>
- <value className="org.apache.plc4x.java.api.value.PlcBoolean">
+ <value className="org.apache.plc4x.java.api.value.PlcBOOL">
<object>true</object>
</value>
</hurz>
@@ -303,13 +303,13 @@
</request>
<hurz1>
<code>OK</code>
- <value className="org.apache.plc4x.java.api.value.PlcBoolean">
+ <value className="org.apache.plc4x.java.api.value.PlcBOOL">
<object>true</object>
</value>
</hurz1>
<hurz2>
<code>OK</code>
- <value className="org.apache.plc4x.java.api.value.PlcBoolean">
+ <value className="org.apache.plc4x.java.api.value.PlcBOOL">
<object>true</object>
</value>
</hurz2>
@@ -520,7 +520,7 @@
</request>
<hurz1>
<code>OK</code>
- <value className="org.apache.plc4x.java.api.value.PlcBoolean">
+ <value className="org.apache.plc4x.java.api.value.PlcBOOL">
<object>false</object>
</value>
</hurz1>
@@ -730,7 +730,7 @@
</request>
<hurz1>
<code>OK</code>
- <value className="org.apache.plc4x.java.api.value.PlcBoolean">
+ <value className="org.apache.plc4x.java.api.value.PlcBOOL">
<object>false</object>
</value>
</hurz1>
@@ -843,7 +843,7 @@
</request>
<hurz1>
<code>OK</code>
- <value className="org.apache.plc4x.java.api.value.PlcBoolean">
+ <value className="org.apache.plc4x.java.api.value.PlcBOOL">
<object>false</object>
</value>
</hurz1>
diff --git a/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/readwrite/field/EipFieldHandler.java b/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/readwrite/field/EipFieldHandler.java
index 3afffbf..f3bd99b 100644
--- a/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/readwrite/field/EipFieldHandler.java
+++ b/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/readwrite/field/EipFieldHandler.java
@@ -192,7 +192,7 @@ public class EipFieldHandler implements PlcFieldHandler {
}
}
if(booleanValues.size() == 1) {
- return new PlcBoolean(booleanValues.get(0));
+ return new PlcBOOL(booleanValues.get(0));
} else {
return new PlcList(booleanValues);
}
@@ -210,28 +210,28 @@ public class EipFieldHandler implements PlcFieldHandler {
case SINT:
minValue = BigInteger.valueOf(Byte.MIN_VALUE);
maxValue = BigInteger.valueOf(Byte.MAX_VALUE);
- fieldType = PlcByte.class;
+ fieldType = PlcSINT.class;
valueType = Byte.class;
castedValues = new Byte[values.length];
break;
case INT:
minValue = BigInteger.valueOf(Short.MIN_VALUE);
maxValue = BigInteger.valueOf(Short.MAX_VALUE);
- fieldType = PlcShort.class;
+ fieldType = PlcINT.class;
valueType = Short.class;
castedValues = new Short[values.length];
break;
case DINT:
minValue = BigInteger.valueOf(Integer.MIN_VALUE);
maxValue = BigInteger.valueOf(Integer.MAX_VALUE);
- fieldType = PlcInteger.class;
+ fieldType = PlcDINT.class;
valueType= Integer.class;
castedValues = new Integer[values.length];
break;
case LINT:
minValue = BigInteger.valueOf(Long.MIN_VALUE);
maxValue = BigInteger.valueOf(Long.MAX_VALUE);
- fieldType = PlcLong.class;
+ fieldType = PlcLINT.class;
valueType= Long.class;
castedValues = new Long[values.length];
break;
@@ -292,7 +292,7 @@ public class EipFieldHandler implements PlcFieldHandler {
if (eipField.getType() == CIPDataTypeCode.REAL) {
minValue = (double) -Float.MAX_VALUE;
maxValue = (double) Float.MAX_VALUE;
- fieldType = PlcFloat.class;
+ fieldType = PlcREAL.class;
valueType = Float.class;
castedValues = new Float[values.length];
} else {
diff --git a/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/readwrite/protocol/EipProtocolLogic.java b/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/readwrite/protocol/EipProtocolLogic.java
index 7516160..d811314 100644
--- a/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/readwrite/protocol/EipProtocolLogic.java
+++ b/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/readwrite/protocol/EipProtocolLogic.java
@@ -326,17 +326,23 @@ public class EipProtocolLogic extends Plc4xProtocolBase<EipPacket> implements Ha
for (int i = 0; i < nb; i++) {
switch (type) {
case DINT:
+ list.add(new PlcDINT(Integer.reverseBytes(data.getInt(index))));
+ index += type.getSize();
+ break;
case INT:
+ list.add(new PlcINT(Integer.reverseBytes(data.getInt(index))));
+ index += type.getSize();
+ break;
case SINT:
- list.add(new PlcInteger(Integer.reverseBytes(data.getInt(index))));
+ list.add(new PlcSINT(Integer.reverseBytes(data.getInt(index))));
index += type.getSize();
break;
case REAL:
- list.add(new PlcDouble(swap(data.getFloat(index))));
+ list.add(new PlcLREAL(swap(data.getFloat(index))));
index += type.getSize();
break;
case BOOL:
- list.add(new PlcBoolean(data.getBoolean(index)));
+ list.add(new PlcBOOL(data.getBoolean(index)));
index += type.getSize();
default:
return null;
@@ -346,15 +352,15 @@ public class EipProtocolLogic extends Plc4xProtocolBase<EipPacket> implements Ha
} else {
switch (type) {
case SINT:
- return new PlcByte(data.getByte(0));
+ return new PlcSINT(data.getByte(0));
case INT:
- return new PlcInteger(Short.reverseBytes(data.getShort(0)));
+ return new PlcINT(Short.reverseBytes(data.getShort(0)));
case DINT:
- return new PlcInteger(Integer.reverseBytes(data.getInt(0)));
+ return new PlcDINT(Integer.reverseBytes(data.getInt(0)));
case REAL:
- return new PlcDouble(swap(data.getFloat(0)));
+ return new PlcREAL(swap(data.getFloat(0)));
case BOOL:
- return new PlcBoolean(data.getBoolean(0));
+ return new PlcBOOL(data.getBoolean(0));
default:
return null;
}
diff --git a/plc4j/drivers/eip/src/test/resources/testsuite/EIPDriverTestsuite.xml b/plc4j/drivers/eip/src/test/resources/testsuite/EIPDriverTestsuite.xml
index f7593ef..67884fc 100644
--- a/plc4j/drivers/eip/src/test/resources/testsuite/EIPDriverTestsuite.xml
+++ b/plc4j/drivers/eip/src/test/resources/testsuite/EIPDriverTestsuite.xml
@@ -140,7 +140,7 @@
</request>
<hurz>
<code>OK</code>
- <value className="org.apache.plc4x.java.api.value.PlcInteger">
+ <value className="org.apache.plc4x.java.api.value.PlcDINT">
<object>369229824</object>
</value>
</hurz>
diff --git a/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/field/FirmataFieldHandler.java b/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/field/FirmataFieldHandler.java
index d84781a..af9d697 100644
--- a/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/field/FirmataFieldHandler.java
+++ b/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/field/FirmataFieldHandler.java
@@ -20,10 +20,7 @@ package org.apache.plc4x.java.firmata.readwrite.field;
import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
import org.apache.plc4x.java.api.model.PlcField;
-import org.apache.plc4x.java.api.value.PlcBoolean;
-import org.apache.plc4x.java.api.value.PlcList;
-import org.apache.plc4x.java.api.value.PlcShort;
-import org.apache.plc4x.java.api.value.PlcValue;
+import org.apache.plc4x.java.api.value.*;
import org.apache.plc4x.java.spi.connection.DefaultPlcFieldHandler;
import java.util.ArrayList;
@@ -82,7 +79,7 @@ public class FirmataFieldHandler extends DefaultPlcFieldHandler {
}
}
if(booleanValues.size() == 1) {
- return new PlcBoolean(booleanValues.get(0));
+ return new PlcBOOL(booleanValues.get(0));
} else {
return new PlcList(booleanValues);
}
@@ -101,16 +98,16 @@ public class FirmataFieldHandler extends DefaultPlcFieldHandler {
if((numberValue.intValue() < Short.MIN_VALUE) || (numberValue.intValue() > Short.MAX_VALUE)) {
throw new PlcInvalidFieldException("Value of " + numberValue.toString() + " exceeds the boundaries of a short value.");
}
- return new PlcShort(numberValue.shortValue());
+ return new PlcINT(numberValue.shortValue());
} else {
- List<PlcShort> shorts = new ArrayList<>(values.length);
+ List<PlcINT> shorts = new ArrayList<>(values.length);
for (Object value : values) {
Number numberValue = (Number) value;
// Intentionally checking the next larger type.
if((numberValue.intValue() < Short.MIN_VALUE) || (numberValue.intValue() > Short.MAX_VALUE)) {
throw new PlcInvalidFieldException("Value of " + numberValue.toString() + " exceeds the boundaries of a short value.");
}
- shorts.add(new PlcShort(((Number) value).shortValue()));
+ shorts.add(new PlcINT(((Number) value).shortValue()));
}
return new PlcList(shorts);
}
diff --git a/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/protocol/FirmataProtocolLogic.java b/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/protocol/FirmataProtocolLogic.java
index 5a60ee7..9651aea 100644
--- a/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/protocol/FirmataProtocolLogic.java
+++ b/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/protocol/FirmataProtocolLogic.java
@@ -24,10 +24,7 @@ import org.apache.plc4x.java.api.messages.*;
import org.apache.plc4x.java.api.model.PlcConsumerRegistration;
import org.apache.plc4x.java.api.model.PlcSubscriptionHandle;
import org.apache.plc4x.java.api.types.PlcResponseCode;
-import org.apache.plc4x.java.api.value.PlcBoolean;
-import org.apache.plc4x.java.api.value.PlcInteger;
-import org.apache.plc4x.java.api.value.PlcList;
-import org.apache.plc4x.java.api.value.PlcValue;
+import org.apache.plc4x.java.api.value.*;
import org.apache.plc4x.java.firmata.readwrite.*;
import org.apache.plc4x.java.firmata.readwrite.context.FirmataDriverContext;
import org.apache.plc4x.java.firmata.readwrite.field.FirmataField;
@@ -214,11 +211,11 @@ public class FirmataProtocolLogic extends Plc4xProtocolBase<FirmataMessage> impl
List<PlcValue> values = new ArrayList<>(analogField.getQuantity());
for(int i = analogField.getAddress(); i < analogField.getAddress() + analogField.getQuantity(); i++) {
if(analogValues.containsKey(i)) {
- values.add(new PlcInteger(analogValues.get(i).intValue()));
+ values.add(new PlcDINT(analogValues.get(i).intValue()));
}
// This could be the case if only some of the requested array values are available
else {
- values.add(new PlcInteger(-1));
+ values.add(new PlcDINT(-1));
}
}
sendUpdateEvents(consumer, subscriptionHandle.getName(), values);
@@ -251,7 +248,7 @@ public class FirmataProtocolLogic extends Plc4xProtocolBase<FirmataMessage> impl
if(digitalField.getBitSet().intersects(changedBits)) {
List<PlcValue> values = new ArrayList<>(digitalField.getBitSet().cardinality());
for(int i = 0; i < digitalField.getBitSet().length(); i++) {
- values.add(new PlcBoolean(bitValues.get(i)));
+ values.add(new PlcBOOL(bitValues.get(i)));
}
sendUpdateEvents(consumer, subscriptionHandle.getName(), values);
}
diff --git a/plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/field/KnxNetIpFieldHandler.java b/plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/field/KnxNetIpFieldHandler.java
index 2a49fd0..2bcb443 100644
--- a/plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/field/KnxNetIpFieldHandler.java
+++ b/plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/field/KnxNetIpFieldHandler.java
@@ -20,7 +20,6 @@ package org.apache.plc4x.java.knxnetip.field;
import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
import org.apache.plc4x.java.api.model.PlcField;
-import org.apache.plc4x.java.api.value.PlcBoolean;
import org.apache.plc4x.java.api.value.PlcValue;
import org.apache.plc4x.java.api.value.PlcValues;
import org.apache.plc4x.java.spi.connection.DefaultPlcFieldHandler;
diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/field/ModbusField.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/field/ModbusField.java
index bf6d933..117f014 100644
--- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/field/ModbusField.java
+++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/field/ModbusField.java
@@ -32,8 +32,8 @@ import java.lang.*;
public abstract class ModbusField implements PlcField {
- public static final Pattern ADDRESS_PATTERN = Pattern.compile("(?<address>\\d+):?(?<datatype>[a-zA-Z_]+)?(\\[(?<quantity>\\d+)])?");
- public static final Pattern FIXED_DIGIT_MODBUS_PATTERN = Pattern.compile("(?<address>\\d{4,5}):?(?<datatype>[a-zA-Z_]+)?(\\[(?<quantity>\\d+)])?");
+ public static final Pattern ADDRESS_PATTERN = Pattern.compile("(?<address>\\d+)(\\[(?<quantity>\\d+)])?(:(?<datatype>[a-zA-Z_]+))?");
+ public static final Pattern FIXED_DIGIT_MODBUS_PATTERN = Pattern.compile("(?<address>\\d{4,5})?(\\[(?<quantity>\\d+)])?(:(?<datatype>[a-zA-Z_]+))?");
protected static final int PROTOCOL_ADDRESS_OFFSET = 1;
diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/field/ModbusFieldDiscreteInput.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/field/ModbusFieldDiscreteInput.java
index 0f390d1..551be36 100644
--- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/field/ModbusFieldDiscreteInput.java
+++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/field/ModbusFieldDiscreteInput.java
@@ -29,7 +29,7 @@ public class ModbusFieldDiscreteInput extends ModbusField {
public static final Pattern ADDRESS_SHORTER_PATTERN = Pattern.compile("1" + ModbusField.FIXED_DIGIT_MODBUS_PATTERN);
public static final Pattern ADDRESS_SHORT_PATTERN = Pattern.compile("1x" + ModbusField.FIXED_DIGIT_MODBUS_PATTERN);
- protected static final int REGISTER_MAXADDRESS = 65535;
+ protected static final int REGISTER_MAX_ADDRESS = 65535;
public ModbusFieldDiscreteInput(int address, Integer quantity, String datatype) {
super(address, quantity, datatype.toUpperCase());
@@ -61,14 +61,14 @@ public class ModbusFieldDiscreteInput extends ModbusField {
public static ModbusFieldDiscreteInput of(String addressString) {
Matcher matcher = getMatcher(addressString);
int address = Integer.parseInt(matcher.group("address")) - PROTOCOL_ADDRESS_OFFSET;
- if (address > REGISTER_MAXADDRESS) {
- throw new IllegalArgumentException("Address must be less than or equal to " + REGISTER_MAXADDRESS + ". Was " + (address + PROTOCOL_ADDRESS_OFFSET));
+ if (address > REGISTER_MAX_ADDRESS) {
+ throw new IllegalArgumentException("Address must be less than or equal to " + REGISTER_MAX_ADDRESS + ". Was " + (address + PROTOCOL_ADDRESS_OFFSET));
}
String quantityString = matcher.group("quantity");
Integer quantity = quantityString != null ? Integer.valueOf(quantityString) : 1;
- if ((address + quantity) > REGISTER_MAXADDRESS) {
- throw new IllegalArgumentException("Last requested address is out of range, should be between " + PROTOCOL_ADDRESS_OFFSET + " and " + REGISTER_MAXADDRESS + ". Was " + (address + PROTOCOL_ADDRESS_OFFSET + (quantity - 1)));
+ if ((address + quantity) > REGISTER_MAX_ADDRESS) {
+ throw new IllegalArgumentException("Last requested address is out of range, should be between " + PROTOCOL_ADDRESS_OFFSET + " and " + REGISTER_MAX_ADDRESS + ". Was " + (address + PROTOCOL_ADDRESS_OFFSET + (quantity - 1)));
}
String datatypeTemp = matcher.group("datatype");
diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/connection/OpcuaTcpPlcConnection.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/connection/OpcuaTcpPlcConnection.java
index 7eefcb3..d2f52c7 100644
--- a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/connection/OpcuaTcpPlcConnection.java
+++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/connection/OpcuaTcpPlcConnection.java
@@ -116,7 +116,7 @@ public class OpcuaTcpPlcConnection extends BaseOpcuaPlcConnection {
Object objValue = value.getValue().getValue();
if (typeNode.equals(Identifiers.Boolean)) {
- return new PlcBoolean((Boolean) objValue);
+ return new PlcBOOL((Boolean) objValue);
/*} else if (typeNode.equals(Identifiers.ByteString)) {
byte[] array = ((ByteString) objValue).bytes();
Byte[] byteArry = new Byte[array.length];
@@ -128,29 +128,29 @@ public class OpcuaTcpPlcConnection extends BaseOpcuaPlcConnection {
}
return new DefaultByteArrayPlcValue(byteArry);*/
} else if (typeNode.equals(Identifiers.Integer)) {
- return new PlcInteger((Integer) objValue);
+ return new PlcDINT((Integer) objValue);
} else if (typeNode.equals(Identifiers.Int16)) {
- return new PlcInteger((Short) objValue);
+ return new PlcINT((Short) objValue);
} else if (typeNode.equals(Identifiers.Int32)) {
- return new PlcInteger((Integer) objValue);
+ return new PlcDINT((Integer) objValue);
} else if (typeNode.equals(Identifiers.Int64)) {
- return new PlcLong((Long) objValue);
+ return new PlcLINT((Long) objValue);
} else if (typeNode.equals(Identifiers.UInteger)) {
- return new PlcLong((Long) objValue);
+ return new PlcLINT((Long) objValue);
} else if (typeNode.equals(Identifiers.UInt16)) {
- return new PlcInteger(((UShort) objValue).intValue());
+ return new PlcUINT(((UShort) objValue).intValue());
} else if (typeNode.equals(Identifiers.UInt32)) {
- return new PlcLong(((UInteger) objValue).longValue());
+ return new PlcUDINT(((UInteger) objValue).longValue());
} else if (typeNode.equals(Identifiers.UInt64)) {
- return new PlcBigInteger(new BigInteger(objValue.toString()));
+ return new PlcULINT(new BigInteger(objValue.toString()));
} else if (typeNode.equals(Identifiers.Byte)) {
- return new PlcInteger(Short.valueOf(objValue.toString()));
+ return new PlcINT(Short.valueOf(objValue.toString()));
} else if (typeNode.equals(Identifiers.Float)) {
- return new PlcFloat((Float) objValue);
+ return new PlcREAL((Float) objValue);
} else if (typeNode.equals(Identifiers.Double)) {
- return new PlcDouble((Double) objValue);
+ return new PlcLREAL((Double) objValue);
} else if (typeNode.equals(Identifiers.SByte)) {
- return new PlcInteger((Byte) objValue);
+ return new PlcSINT((Byte) objValue);
} else {
return new PlcString(objValue.toString());
}
diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaPlcFieldHandler.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaPlcFieldHandler.java
index b9ccd8b..848f0c0 100644
--- a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaPlcFieldHandler.java
+++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaPlcFieldHandler.java
@@ -61,7 +61,7 @@ public class OpcuaPlcFieldHandler extends DefaultPlcFieldHandler {
resultSet.add((Boolean) item);
}
if(resultSet.size() == 1) {
- return new PlcBoolean(resultSet.get(0));
+ return new PlcBOOL(resultSet.get(0));
} else {
return new PlcList(resultSet);
}
@@ -75,7 +75,7 @@ public class OpcuaPlcFieldHandler extends DefaultPlcFieldHandler {
resultSet.add((Byte) item);
}
if(resultSet.size() == 1) {
- return new PlcInteger(resultSet.get(0));
+ return new PlcSINT(resultSet.get(0));
} else {
return new PlcList(resultSet);
}
@@ -89,7 +89,7 @@ public class OpcuaPlcFieldHandler extends DefaultPlcFieldHandler {
resultSet.add((Short) item);
}
if(resultSet.size() == 1) {
- return new PlcInteger(resultSet.get(0));
+ return new PlcINT(resultSet.get(0));
} else {
return new PlcList(resultSet);
}
@@ -103,7 +103,7 @@ public class OpcuaPlcFieldHandler extends DefaultPlcFieldHandler {
resultSet.add((Integer) item);
}
if(resultSet.size() == 1) {
- return new PlcInteger(resultSet.get(0));
+ return new PlcDINT(resultSet.get(0));
} else {
return new PlcList(resultSet);
}
@@ -131,7 +131,7 @@ public class OpcuaPlcFieldHandler extends DefaultPlcFieldHandler {
resultSet.add((Long) item);
}
if(resultSet.size() == 1) {
- return new PlcLong(resultSet.get(0));
+ return new PlcLINT(resultSet.get(0));
} else {
return new PlcList(resultSet);
}
@@ -145,7 +145,7 @@ public class OpcuaPlcFieldHandler extends DefaultPlcFieldHandler {
resultSet.add((Float) item);
}
if(resultSet.size() == 1) {
- return new PlcFloat(resultSet.get(0));
+ return new PlcREAL(resultSet.get(0));
} else {
return new PlcList(resultSet);
}
@@ -160,7 +160,7 @@ public class OpcuaPlcFieldHandler extends DefaultPlcFieldHandler {
resultSet.add((Double) item);
}
if(resultSet.size() == 1) {
- return new PlcDouble(resultSet.get(0));
+ return new PlcLREAL(resultSet.get(0));
} else {
return new PlcList(resultSet);
}
diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/field/S7Field.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/field/S7Field.java
index c0d15b2..f118c03 100644
--- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/field/S7Field.java
+++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/field/S7Field.java
@@ -55,10 +55,10 @@ public class S7Field implements PlcField {
Pattern.compile("^%DB(?<blockNumber>\\d{1,5}):(?<byteOffset>\\d{1,7})(.(?<bitOffset>[0-7]))?:(?<dataType>[a-zA-Z_]+)(\\[(?<numElements>\\d+)])?");
private static final Pattern DATA_BLOCK_STRING_ADDRESS_PATTERN =
- Pattern.compile("^%DB(?<blockNumber>\\d{1,5}).DB(?<transferSizeCode>[XBWD]?)(?<byteOffset>\\d{1,7}):STRING\\((?<stringLength>\\d{1,3})\\)(\\[(?<numElements>\\d+)])?");
+ Pattern.compile("^%DB(?<blockNumber>\\d{1,5}).DB(?<transferSizeCode>[XBWD]?)(?<byteOffset>\\d{1,7})(.(?<bitOffset>[0-7]))?:STRING\\((?<stringLength>\\d{1,3})\\)(\\[(?<numElements>\\d+)])?");
private static final Pattern DATA_BLOCK_STRING_SHORT_PATTERN =
- Pattern.compile("^%DB(?<blockNumber>\\d{1,5}):(?<byteOffset>\\d{1,7}):STRING\\((?<stringLength>\\d{1,3})\\)(\\[(?<numElements>\\d+)])?");
+ Pattern.compile("^%DB(?<blockNumber>\\d{1,5}):(?<byteOffset>\\d{1,7})(.(?<bitOffset>[0-7]))?:STRING\\((?<stringLength>\\d{1,3})\\)(\\[(?<numElements>\\d+)])?");
private static final Pattern PLC_PROXY_ADDRESS_PATTERN =
Pattern.compile("[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}");
diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/field/S7PlcFieldHandler.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/field/S7PlcFieldHandler.java
index a233bed..745d67c 100644
--- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/field/S7PlcFieldHandler.java
+++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/field/S7PlcFieldHandler.java
@@ -284,7 +284,7 @@ public class S7PlcFieldHandler extends DefaultPlcFieldHandler {
}
}
if(booleanValues.size() == 1) {
- return new PlcBoolean(booleanValues.get(0));
+ return new PlcBOOL(booleanValues.get(0));
} else {
return new PlcList(booleanValues);
}
@@ -403,13 +403,13 @@ public class S7PlcFieldHandler extends DefaultPlcFieldHandler {
// Create the field item.
if(integerValues.size() == 1) {
if (valueType == Byte.class) {
- return new PlcByte((Byte) integerValues.get(0));
+ return new PlcSINT((Byte) integerValues.get(0));
} else if (valueType == Short.class) {
- return new PlcShort((Short) integerValues.get(0));
+ return new PlcINT((Short) integerValues.get(0));
} else if (valueType == Integer.class) {
- return new PlcInteger((Integer) integerValues.get(0));
+ return new PlcDINT((Integer) integerValues.get(0));
} else if (valueType == Long.class) {
- return new PlcLong((Long) integerValues.get(0));
+ return new PlcLINT((Long) integerValues.get(0));
} else {
return new PlcBigInteger((BigInteger) integerValues.get(0));
}
@@ -478,9 +478,9 @@ public class S7PlcFieldHandler extends DefaultPlcFieldHandler {
// Create the field item.
if(floatingPointValues.size() == 1) {
if (valueType == Float.class) {
- return new PlcFloat((Float) floatingPointValues.get(0));
+ return new PlcREAL((Float) floatingPointValues.get(0));
} else {
- return new PlcDouble((Double) floatingPointValues.get(0));
+ return new PlcLREAL((Double) floatingPointValues.get(0));
}
} else {
return new PlcList(floatingPointValues);
diff --git a/plc4j/drivers/s7/src/test/resources/testsuite/S7DriverIT.xml b/plc4j/drivers/s7/src/test/resources/testsuite/S7DriverIT.xml
index f4ab523..baa2eb0 100644
--- a/plc4j/drivers/s7/src/test/resources/testsuite/S7DriverIT.xml
+++ b/plc4j/drivers/s7/src/test/resources/testsuite/S7DriverIT.xml
@@ -296,7 +296,7 @@
</request>
<hurz>
<code>OK</code>
- <value className="org.apache.plc4x.java.api.value.PlcBoolean">
+ <value className="org.apache.plc4x.java.api.value.PlcBOOL">
<object>true</object>
</value>
</hurz>
diff --git a/plc4j/drivers/simulated/src/main/java/org/apache/plc4x/java/simulated/field/SimulatedFieldHandler.java b/plc4j/drivers/simulated/src/main/java/org/apache/plc4x/java/simulated/field/SimulatedFieldHandler.java
index fccd057..205f7d8 100644
--- a/plc4j/drivers/simulated/src/main/java/org/apache/plc4x/java/simulated/field/SimulatedFieldHandler.java
+++ b/plc4j/drivers/simulated/src/main/java/org/apache/plc4x/java/simulated/field/SimulatedFieldHandler.java
@@ -47,7 +47,7 @@ public class SimulatedFieldHandler implements PlcFieldHandler {
SimulatedField testField = (SimulatedField) field;
if (testField.getDataType() == Boolean.class) {
if(values.length == 1) {
- return new PlcBoolean((Boolean) values[0]);
+ return new PlcBOOL((Boolean) values[0]);
} else {
return new PlcList(Arrays.asList(values));
}
@@ -60,7 +60,7 @@ public class SimulatedFieldHandler implements PlcFieldHandler {
SimulatedField testField = (SimulatedField) field;
if (testField.getDataType() == Byte.class) {
if(values.length == 1) {
- return new PlcInteger((Byte) values[0]);
+ return new PlcSINT((Byte) values[0]);
} else {
return new PlcList(Arrays.asList(values));
}
@@ -73,7 +73,7 @@ public class SimulatedFieldHandler implements PlcFieldHandler {
SimulatedField testField = (SimulatedField) field;
if (testField.getDataType() == Short.class) {
if(values.length == 1) {
- return new PlcInteger((Short) values[0]);
+ return new PlcINT((Short) values[0]);
} else {
return new PlcList(Arrays.asList(values));
}
@@ -86,7 +86,7 @@ public class SimulatedFieldHandler implements PlcFieldHandler {
SimulatedField testField = (SimulatedField) field;
if (testField.getDataType() == Integer.class) {
if(values.length == 1) {
- return new PlcInteger((Integer) values[0]);
+ return new PlcDINT((Integer) values[0]);
} else {
return new PlcList(Arrays.asList(values));
}
@@ -112,7 +112,7 @@ public class SimulatedFieldHandler implements PlcFieldHandler {
SimulatedField testField = (SimulatedField) field;
if (testField.getDataType() == Long.class) {
if(values.length == 1) {
- return new PlcLong((Long) values[0]);
+ return new PlcLINT((Long) values[0]);
} else {
return new PlcList(Arrays.asList(values));
}
@@ -125,7 +125,7 @@ public class SimulatedFieldHandler implements PlcFieldHandler {
SimulatedField testField = (SimulatedField) field;
if (testField.getDataType() == Float.class) {
if(values.length == 1) {
- return new PlcFloat((Float) values[0]);
+ return new PlcREAL((Float) values[0]);
} else {
return new PlcList(Arrays.asList(values));
}
@@ -151,7 +151,7 @@ public class SimulatedFieldHandler implements PlcFieldHandler {
SimulatedField testField = (SimulatedField) field;
if (testField.getDataType() == Double.class) {
if(values.length == 1) {
- return new PlcDouble((Double) values[0]);
+ return new PlcLREAL((Double) values[0]);
} else {
return new PlcList(Arrays.asList(values));
}
diff --git a/plc4j/drivers/simulated/src/test/java/org/apache/plc4x/java/simulated/connection/SimulatedDeviceTest.java b/plc4j/drivers/simulated/src/test/java/org/apache/plc4x/java/simulated/connection/SimulatedDeviceTest.java
index a3262d5..268660d 100644
--- a/plc4j/drivers/simulated/src/test/java/org/apache/plc4x/java/simulated/connection/SimulatedDeviceTest.java
+++ b/plc4j/drivers/simulated/src/test/java/org/apache/plc4x/java/simulated/connection/SimulatedDeviceTest.java
@@ -18,7 +18,7 @@
*/
package org.apache.plc4x.java.simulated.connection;
-import org.apache.plc4x.java.api.value.PlcLong;
+import org.apache.plc4x.java.api.value.PlcLINT;
import org.apache.plc4x.java.api.value.PlcValue;
import org.apache.plc4x.java.simulated.field.SimulatedField;
import org.junit.jupiter.api.Test;
@@ -47,7 +47,7 @@ public class SimulatedDeviceTest {
Optional<PlcValue> value = device.get(field);
assertFalse(value.isPresent());
- device.set(field, new PlcLong(42));
+ device.set(field, new PlcLINT(42));
value = device.get(field);
assertTrue(value.isPresent());
PlcValue plcValue = value.get();
diff --git a/plc4j/examples/hello-webapp/webapp/src/main/java/org/apache/plc4x/examples/watertank/service/WaterTankService.java b/plc4j/examples/hello-webapp/webapp/src/main/java/org/apache/plc4x/examples/watertank/service/WaterTankService.java
index e56a4f6..e013216 100644
--- a/plc4j/examples/hello-webapp/webapp/src/main/java/org/apache/plc4x/examples/watertank/service/WaterTankService.java
+++ b/plc4j/examples/hello-webapp/webapp/src/main/java/org/apache/plc4x/examples/watertank/service/WaterTankService.java
@@ -32,7 +32,7 @@ import org.apache.plc4x.java.api.messages.PlcSubscriptionRequest;
import org.apache.plc4x.java.api.messages.PlcSubscriptionResponse;
import org.apache.plc4x.java.api.model.PlcSubscriptionHandle;
import org.apache.plc4x.java.api.types.PlcResponseCode;
-import org.apache.plc4x.java.api.value.PlcShort;
+import org.apache.plc4x.java.api.value.PlcINT;
import org.apache.plc4x.java.api.value.PlcValue;
import org.apache.plc4x.java.spi.messages.DefaultPlcSubscriptionEvent;
import org.apache.plc4x.java.spi.messages.utils.ResponseItem;
@@ -136,7 +136,7 @@ public class WaterTankService {
short value = (short) new Random().nextInt(1024);
Map<String, ResponseItem<PlcValue>> values = new HashMap<>();
- values.put("waterLevel", new ResponseItem<>(PlcResponseCode.OK, new PlcShort(value)));
+ values.put("waterLevel", new ResponseItem<>(PlcResponseCode.OK, new PlcINT(value)));
DefaultPlcSubscriptionEvent event = new DefaultPlcSubscriptionEvent(Instant.now(), values);
handler.accept(event);
diff --git a/plc4j/integrations/apache-edgent/src/test/java.sav/org/apache/plc4x/edgent/PlcConnectionAdapterTest.java b/plc4j/integrations/apache-edgent/src/test/java.sav/org/apache/plc4x/edgent/PlcConnectionAdapterTest.java
index 951d2f3..b8da3b2 100644
--- a/plc4j/integrations/apache-edgent/src/test/java.sav/org/apache/plc4x/edgent/PlcConnectionAdapterTest.java
+++ b/plc4j/integrations/apache-edgent/src/test/java.sav/org/apache/plc4x/edgent/PlcConnectionAdapterTest.java
@@ -29,7 +29,6 @@ import org.apache.plc4x.java.api.messages.PlcReadResponse;
import org.apache.plc4x.java.api.messages.PlcWriteRequest;
import org.apache.plc4x.java.api.messages.PlcWriteResponse;
import org.apache.plc4x.java.api.model.PlcField;
-import org.apache.plc4x.java.api.value.PlcLong;
import org.apache.plc4x.java.mock.connection.MockConnection;
import org.apache.plc4x.java.mock.field.MockField;
import org.apache.plc4x.test.FastTests;
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcReadResponse.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcReadResponse.java
index 2d4dae0..e048cf4 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcReadResponse.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcReadResponse.java
@@ -60,7 +60,7 @@ public class DefaultPlcReadResponse implements InternalPlcReadResponse, PlcReadR
@JsonIgnore
public PlcValue getAsPlcValue() {
return PlcValues.of(request.getFieldNames().stream()
- .collect(Collectors.toMap(Function.identity(), name -> PlcValues.of(getObject(name)))));
+ .collect(Collectors.toMap(Function.identity(), this::getPlcValue)));
}
@Override
diff --git a/plc4j/tools/opm/src/test/java/org/apache/plc4x/java/opm/PlcEntityManagerComplexTest.java b/plc4j/tools/opm/src/test/java/org/apache/plc4x/java/opm/PlcEntityManagerComplexTest.java
index a96ff8d..078dee8 100644
--- a/plc4j/tools/opm/src/test/java/org/apache/plc4x/java/opm/PlcEntityManagerComplexTest.java
+++ b/plc4j/tools/opm/src/test/java/org/apache/plc4x/java/opm/PlcEntityManagerComplexTest.java
@@ -84,8 +84,8 @@ public class PlcEntityManagerComplexTest implements WithAssertions {
public void read() throws OPMException, PlcConnectionException {
Map<String, PlcValue> results = new HashMap<>();
String prefix = MyEntity.class.getName() + ".";
- results.put(prefix + "counter", new PlcInteger(1));
- results.put(prefix + "counter2", new PlcLong(1L));
+ results.put(prefix + "counter", new PlcDINT(1));
+ results.put(prefix + "counter2", new PlcLINT(1L));
PlcEntityManager manager = getPlcEntityManager(results);
MyEntity myEntity = manager.read(MyEntity.class, "s7://localhost:5555/0/0");
diff --git a/plc4j/tools/scraper/src/test/java/org/apache/plc4x/java/scraper/ScraperTest.java b/plc4j/tools/scraper/src/test/java/org/apache/plc4x/java/scraper/ScraperTest.java
index 92b8ab8..2d5fe4a 100644
--- a/plc4j/tools/scraper/src/test/java/org/apache/plc4x/java/scraper/ScraperTest.java
+++ b/plc4j/tools/scraper/src/test/java/org/apache/plc4x/java/scraper/ScraperTest.java
@@ -25,7 +25,7 @@ import org.apache.plc4x.java.PlcDriverManager;
import org.apache.plc4x.java.api.PlcConnection;
import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
import org.apache.plc4x.java.api.types.PlcResponseCode;
-import org.apache.plc4x.java.api.value.PlcInteger;
+import org.apache.plc4x.java.api.value.PlcDINT;
import org.apache.plc4x.java.mock.connection.MockConnection;
import org.apache.plc4x.java.mock.connection.MockDevice;
import org.apache.plc4x.java.spi.messages.utils.ResponseItem;
@@ -96,7 +96,7 @@ class ScraperTest implements WithAssertions {
MockConnection connection = (MockConnection) driverManager.getConnection("mock:m1");
connection.setDevice(mockDevice);
- when(mockDevice.read(any())).thenReturn(new ResponseItem<>(PlcResponseCode.OK, new PlcInteger(1)));
+ when(mockDevice.read(any())).thenReturn(new ResponseItem<>(PlcResponseCode.OK, new PlcDINT(1)));
ScraperImpl scraper = new ScraperImpl((j, a, m) -> {}, driverManager, Collections.singletonList(
new ScrapeJobImpl("job1",
@@ -147,7 +147,7 @@ class ScraperTest implements WithAssertions {
MockConnection connection = (MockConnection) driverManager.getConnection("mock:m1");
connection.setDevice(mockDevice);
- when(mockDevice.read(any())).thenReturn(new ResponseItem<>(PlcResponseCode.OK, new PlcInteger(1)));
+ when(mockDevice.read(any())).thenReturn(new ResponseItem<>(PlcResponseCode.OK, new PlcDINT(1)));
Scraper scraper = new ScraperImpl((j, a, m) -> {}, driverManager, Collections.singletonList(
new ScrapeJobImpl("job1",
diff --git a/plc4j/tools/scraper/src/test/java/org/apache/plc4x/java/scraper/triggeredscraper/TriggeredScraperImplTest.java b/plc4j/tools/scraper/src/test/java/org/apache/plc4x/java/scraper/triggeredscraper/TriggeredScraperImplTest.java
index 691fd7f..7f222bd 100644
--- a/plc4j/tools/scraper/src/test/java/org/apache/plc4x/java/scraper/triggeredscraper/TriggeredScraperImplTest.java
+++ b/plc4j/tools/scraper/src/test/java/org/apache/plc4x/java/scraper/triggeredscraper/TriggeredScraperImplTest.java
@@ -21,8 +21,8 @@ package org.apache.plc4x.java.scraper.triggeredscraper;
import org.apache.plc4x.java.PlcDriverManager;
import org.apache.plc4x.java.api.types.PlcResponseCode;
-import org.apache.plc4x.java.api.value.PlcBoolean;
-import org.apache.plc4x.java.api.value.PlcLong;
+import org.apache.plc4x.java.api.value.PlcBOOL;
+import org.apache.plc4x.java.api.value.PlcLINT;
import org.apache.plc4x.java.mock.connection.MockConnection;
import org.apache.plc4x.java.mock.connection.MockDevice;
import org.apache.plc4x.java.scraper.config.ScraperConfiguration;
@@ -78,8 +78,8 @@ public class TriggeredScraperImplTest {
public void scrapeMultipleTargets() throws ScraperException, IOException, InterruptedException {
// Prepare the Mocking
// Scrate Jobs 1 and 2
- when(mockDevice1.read(eq("%DB810:DBB0:USINT"))).thenReturn(new ResponseItem<>(PlcResponseCode.OK, new PlcLong(1L)));
- when(mockDevice2.read(eq("%DB810:DBB0:USINT"))).thenReturn(new ResponseItem<>(PlcResponseCode.OK, new PlcLong(2L)));
+ when(mockDevice1.read(eq("%DB810:DBB0:USINT"))).thenReturn(new ResponseItem<>(PlcResponseCode.OK, new PlcLINT(1L)));
+ when(mockDevice2.read(eq("%DB810:DBB0:USINT"))).thenReturn(new ResponseItem<>(PlcResponseCode.OK, new PlcLINT(2L)));
// Trigger Jobs
// Trigger var
Random rand = new Random();
@@ -88,7 +88,7 @@ public class TriggeredScraperImplTest {
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
boolean trigger = rand.nextBoolean();
System.out.println(trigger);
- return new ResponseItem<>(PlcResponseCode.OK, new PlcBoolean(trigger));
+ return new ResponseItem<>(PlcResponseCode.OK, new PlcBOOL(trigger));
}
});
when(mockDevice2.read(eq("%M0.3:BOOL"))).thenAnswer(new Answer<Object>() {
@@ -96,12 +96,12 @@ public class TriggeredScraperImplTest {
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
boolean trigger = rand.nextBoolean();
System.out.println("\t\t" + trigger);
- return new ResponseItem<>(PlcResponseCode.OK, new PlcBoolean(trigger));
+ return new ResponseItem<>(PlcResponseCode.OK, new PlcBOOL(trigger));
}
});
// Read var
- when(mockDevice1.read(eq("%DB810:DBW0:INT"))).thenReturn(new ResponseItem<>(PlcResponseCode.OK, new PlcLong(3L)));
- when(mockDevice2.read(eq("%DB810:DBW0:INT"))).thenReturn(new ResponseItem<>(PlcResponseCode.OK, new PlcLong(4L)));
+ when(mockDevice1.read(eq("%DB810:DBW0:INT"))).thenReturn(new ResponseItem<>(PlcResponseCode.OK, new PlcLINT(3L)));
+ when(mockDevice2.read(eq("%DB810:DBW0:INT"))).thenReturn(new ResponseItem<>(PlcResponseCode.OK, new PlcLINT(4L)));
ScraperConfiguration configuration = ScraperConfiguration.fromFile("src/test/resources/mock-scraper-config.yml", ScraperConfigurationClassicImpl.class);
TriggerCollector triggerCollector = new TriggerCollectorImpl(driverManager);
diff --git a/protocols/ads/src/main/resources/protocols/ads/ads.mspec b/protocols/ads/src/main/resources/protocols/ads/ads.mspec
index f766190..3f28e00 100644
--- a/protocols/ads/src/main/resources/protocols/ads/ads.mspec
+++ b/protocols/ads/src/main/resources/protocols/ads/ads.mspec
@@ -391,15 +391,15 @@
// -----------------------------------------
// Bit
// -----------------------------------------
- ['AdsDataType.BOOL' Boolean
+ ['AdsDataType.BOOL' BOOL
[reserved uint 7 '0x00']
[simple bit 'value']
]
- ['AdsDataType.BIT' Boolean
+ ['AdsDataType.BIT' BOOL
[reserved uint 7 '0x00']
[simple bit 'value']
]
- ['AdsDataType.BIT8' Boolean
+ ['AdsDataType.BIT8' BOOL
[reserved uint 7 '0x00']
[simple bit 'value']
]
@@ -408,24 +408,24 @@
// Bit-strings
// -----------------------------------------
// 1 byte
- ['AdsDataType.BYTE' Boolean
+ ['AdsDataType.BYTE' BOOL
[array bit 'value' count '8']
]
- ['AdsDataType.BITARR8' Boolean
+ ['AdsDataType.BITARR8' BOOL
[array bit 'value' count '8']
]
// 2 byte (16 bit)
- ['AdsDataType.WORD' Boolean
+ ['AdsDataType.WORD' BOOL
[array bit 'value' count '16']
]
- ['AdsDataType.BITARR16' Boolean
+ ['AdsDataType.BITARR16' BOOL
[array bit 'value' count '16']
]
// 4 byte (32 bit)
- ['AdsDataType.DWORD' Boolean
+ ['AdsDataType.DWORD' BOOL
[array bit 'value' count '32']
]
- ['AdsDataType.BITARR32' Boolean
+ ['AdsDataType.BITARR32' BOOL
[array bit 'value' count '32']
]
@@ -433,71 +433,71 @@
// Integers
// -----------------------------------------
// 8 bit:
- ['AdsDataType.SINT' Integer
+ ['AdsDataType.SINT' SINT
[simple int 8 'value']
]
- ['AdsDataType.INT8' Integer
+ ['AdsDataType.INT8' SINT
[simple int 8 'value']
]
- ['AdsDataType.USINT' Integer
+ ['AdsDataType.USINT' USINT
[simple uint 8 'value']
]
- ['AdsDataType.UINT8' Integer
+ ['AdsDataType.UINT8' USINT
[simple uint 8 'value']
]
// 16 bit:
- ['AdsDataType.INT' Integer
+ ['AdsDataType.INT' INT
[simple int 16 'value']
]
- ['AdsDataType.INT16' Integer
+ ['AdsDataType.INT16' INT
[simple int 16 'value']
]
- ['AdsDataType.UINT' Integer
+ ['AdsDataType.UINT' UINT
[simple uint 16 'value']
]
- ['AdsDataType.UINT16' Integer
+ ['AdsDataType.UINT16' UINT
[simple uint 16 'value']
]
// 32 bit:
- ['AdsDataType.DINT' Integer
+ ['AdsDataType.DINT' DINT
[simple int 32 'value']
]
- ['AdsDataType.INT32' Integer
+ ['AdsDataType.INT32' DINT
[simple int 32 'value']
]
- ['AdsDataType.UDINT' Long
+ ['AdsDataType.UDINT' UDINT
[simple uint 32 'value']
]
- ['AdsDataType.UINT32' Long
+ ['AdsDataType.UINT32' UDINT
[simple uint 32 'value']
]
// 64 bit:
- ['AdsDataType.LINT' Long
+ ['AdsDataType.LINT' LINT
[simple int 64 'value']
]
- ['AdsDataType.INT64' Long
+ ['AdsDataType.INT64' LINT
[simple int 64 'value']
]
- ['AdsDataType.ULINT' BigInteger
+ ['AdsDataType.ULINT' ULINT
[simple uint 64 'value']
]
- ['AdsDataType.UINT64' BigInteger
+ ['AdsDataType.UINT64' ULINT
[simple uint 64 'value']
]
// -----------------------------------------
// Floating point values
// -----------------------------------------
- ['AdsDataType.REAL' Float
+ ['AdsDataType.REAL' REAL
[simple float 8.23 'value']
]
- ['AdsDataType.FLOAT' Float
+ ['AdsDataType.FLOAT' REAL
[simple float 8.23 'value']
]
- ['AdsDataType.LREAL' Double
+ ['AdsDataType.LREAL' LREAL
[simple float 11.52 'value']
]
- ['AdsDataType.DOUBLE' Double
+ ['AdsDataType.DOUBLE' LREAL
[simple float 11.52 'value']
]
diff --git a/protocols/knxnetip/src/main/resources/protocols/knxnetip/knxnetip.mspec b/protocols/knxnetip/src/main/resources/protocols/knxnetip/knxnetip.mspec
index 3b454ce..220a8db 100644
--- a/protocols/knxnetip/src/main/resources/protocols/knxnetip/knxnetip.mspec
+++ b/protocols/knxnetip/src/main/resources/protocols/knxnetip/knxnetip.mspec
@@ -396,11 +396,11 @@
[dataIo 'KnxDatapoint' [uint 10 'mainNumber', uint 10 'subNumber']
[typeSwitch 'mainNumber','subNumber'
- ['1' Boolean
+ ['1' BOOL
[reserved uint 7 '0x0']
[simple bit 'value']
]
- ['2' Boolean
+ ['2' BOOL
[reserved uint 6 '0x0']
[simple bit 'control']
[simple bit 'value']
@@ -415,33 +415,33 @@
[simple bit 'b1']
[simple bit 'b0']
]
- ['3' Integer
+ ['3' USINT
[reserved uint 4 '0x0']
[simple bit 'control']
[simple uint 3 'value']
]
- ['18' Integer
+ ['18' USINT
[simple bit 'control']
[reserved uint 1 '0x0']
[simple uint 6 'value']
]
- ['17' Integer
+ ['17' USINT
[reserved uint 2 '0x0']
[simple uint 6 'value']
]
- ['5' Integer
+ ['5' USINT
[reserved uint 8 '0x0']
[simple uint 8 'value']
]
- ['7' Integer
+ ['7' UINT
[reserved uint 8 '0x0']
[simple uint 16 'value']
]
- ['12' Long
+ ['12' UDINT
[reserved uint 8 '0x0']
[simple uint 32 'value']
]
- ['6','20' Integer
+ ['6','20' SINT
[simple bit 'a']
[simple bit 'b']
[simple bit 'c']
@@ -449,23 +449,23 @@
[simple bit 'e']
[simple int 8 'value']
]
- ['6' Integer
+ ['6' SINT
[reserved uint 8 '0x0']
[simple int 8 'value']
]
- ['8' Integer
+ ['8' INT
[reserved uint 8 '0x0']
[simple int 16 'value']
]
- ['13' Integer
+ ['13' DINT
[reserved uint 8 '0x0']
[simple int 32 'value']
]
- ['9' Float
+ ['9' REAL
[reserved uint 8 '0x0']
[manual float 4.11 'value' 'STATIC_CALL("org.apache.plc4x.java.knxnetip.utils.KnxHelper.bytesToF16", io)' 'STATIC_CALL("org.apache.plc4x.java.knxnetip.utils.KnxHelper.f16toBytes", io, object)' '16']
]
- ['14' Float
+ ['14' REAL
[reserved uint 8 '0x0']
[simple float 8.23 'value']
]
diff --git a/protocols/modbus/src/main/resources/protocols/modbus/modbus.mspec b/protocols/modbus/src/main/resources/protocols/modbus/modbus.mspec
index 0f1573c..ad6a75b 100644
--- a/protocols/modbus/src/main/resources/protocols/modbus/modbus.mspec
+++ b/protocols/modbus/src/main/resources/protocols/modbus/modbus.mspec
@@ -270,11 +270,11 @@
[dataIo 'DataItem' [uint 8 'dataType', uint 8 'numberOfValues']
[typeSwitch 'dataType','numberOfValues'
- ['1','1' Boolean
+ ['1','1' BOOL
[reserved uint 7 '0x00']
[simple bit 'value']
]
- ['1' Boolean
+ ['1' BOOL
[array bit 'value' count 'numberOfValues']
]
['10','1' BYTE
diff --git a/protocols/s7/src/main/resources/protocols/s7/s7.mspec b/protocols/s7/src/main/resources/protocols/s7/s7.mspec
index 5a27863..5128e71 100644
--- a/protocols/s7/src/main/resources/protocols/s7/s7.mspec
+++ b/protocols/s7/src/main/resources/protocols/s7/s7.mspec
@@ -263,7 +263,7 @@
// -----------------------------------------
// Bit
// -----------------------------------------
- ['01' Boolean
+ ['01' BOOL
[reserved uint 7 '0x00']
[simple bit 'value']
]
@@ -272,19 +272,19 @@
// Bit-strings
// -----------------------------------------
// 1 byte
- ['11' Boolean
+ ['11' BOOL
[array bit 'value' count '8']
]
// 2 byte (16 bit)
- ['12' Boolean
+ ['12' BOOL
[array bit 'value' count '16']
]
// 4 byte (32 bit)
- ['13' Boolean
+ ['13' BOOL
[array bit 'value' count '32']
]
// 8 byte (64 bit)
- ['14' Boolean
+ ['14' BOOL
[array bit 'value' count '64']
]
@@ -292,41 +292,41 @@
// Integers
// -----------------------------------------
// 8 bit:
- ['21' Integer
+ ['21' SINT
[simple int 8 'value']
]
- ['22' Integer
+ ['22' USINT
[simple uint 8 'value']
]
// 16 bit:
- ['23' Integer
+ ['23' INT
[simple int 16 'value']
]
- ['24' Integer
+ ['24' UINT
[simple uint 16 'value']
]
// 32 bit:
- ['25' Integer
+ ['25' DINT
[simple int 32 'value']
]
- ['26' Long
+ ['26' UDINT
[simple uint 32 'value']
]
// 64 bit:
- ['27' Long
+ ['27' LINT
[simple int 64 'value']
]
- ['28' BigInteger
+ ['28' ULINT
[simple uint 64 'value']
]
// -----------------------------------------
// Floating point values
// -----------------------------------------
- ['31' Float
+ ['31' REAL
[simple float 8.23 'value']
]
- ['32' Double
+ ['32' LREAL
[simple float 11.52 'value']
]
diff --git a/sandbox/hello-influx-data-collection/src/main/java/org/apache/plc4x/java/examples/helloinflux/HelloInflux.java b/sandbox/hello-influx-data-collection/src/main/java/org/apache/plc4x/java/examples/helloinflux/HelloInflux.java
index f80d22b..cecd2c4 100644
--- a/sandbox/hello-influx-data-collection/src/main/java/org/apache/plc4x/java/examples/helloinflux/HelloInflux.java
+++ b/sandbox/hello-influx-data-collection/src/main/java/org/apache/plc4x/java/examples/helloinflux/HelloInflux.java
@@ -99,13 +99,27 @@ public class HelloInflux {
if (contextName.equals("address")) {
point.addTag(contextName, plcValue.getString());
} else {
- if (plcValue instanceof PlcBoolean) {
+ if (plcValue instanceof PlcBOOL) {
point.addField(contextName, plcValue.getBoolean());
- } else if (plcValue instanceof PlcInteger) {
+ } else if (plcValue instanceof PlcSINT) {
+ point.addField(contextName, plcValue.getByte());
+ } else if (plcValue instanceof PlcUSINT) {
+ point.addField(contextName, plcValue.getShort());
+ } else if (plcValue instanceof PlcINT) {
+ point.addField(contextName, plcValue.getShort());
+ } else if (plcValue instanceof PlcUINT) {
+ point.addField(contextName, plcValue.getInteger());
+ } else if (plcValue instanceof PlcDINT) {
+ point.addField(contextName, plcValue.getInteger());
+ } else if (plcValue instanceof PlcUDINT) {
point.addField(contextName, plcValue.getLong());
- } else if (plcValue instanceof PlcFloat) {
+ } else if (plcValue instanceof PlcLINT) {
+ point.addField(contextName, plcValue.getLong());
+ } else if (plcValue instanceof PlcULINT) {
+ point.addField(contextName, plcValue.getBigInteger());
+ } else if (plcValue instanceof PlcREAL) {
point.addField(contextName, plcValue.getFloat());
- } else if (plcValue instanceof PlcDouble) {
+ } else if (plcValue instanceof PlcLREAL) {
point.addField(contextName, plcValue.getDouble());
} else if (plcValue instanceof PlcString) {
point.addField(contextName, plcValue.getString());
diff --git a/sandbox/plc4c/generated-sources/modbus/src/data_item.c b/sandbox/plc4c/generated-sources/modbus/src/data_item.c
index a825905..ff8d068 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/data_item.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/data_item.c
@@ -30,7 +30,7 @@ plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4c_spi_read_buffer*
uint16_t curPos;
plc4c_return_code _res = OK;
- if((dataType == 1) && (numberOfValues == 1)) { /* Boolean */
+ if((dataType == 1) && (numberOfValues == 1)) { /* BOOL */
// Reserved Field (Compartmentalized so the "reserved" variable can't leak)
{
@@ -54,11 +54,91 @@ plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4c_spi_read_buffer*
*data_item = plc4c_data_create_bool_data(value);
} else
- if(dataType == 1) { /* List */
+ if(dataType == 1) { /* BOOL */
// Array field (value)
} else
- if((dataType == 2) && (numberOfValues == 1)) { /* Integer */
+ if((dataType == 10) && (numberOfValues == 1)) { /* BYTE */
+
+ // Simple Field (value)
+ uint8_t value = 0;
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_uint8_t_data(value);
+
+ } else
+ if(dataType == 10) { /* BYTE */
+
+ // Array field (value)
+ } else
+ if((dataType == 11) && (numberOfValues == 1)) { /* WORD */
+
+ // Simple Field (value)
+ uint16_t value = 0;
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_uint16_t_data(value);
+
+ } else
+ if(dataType == 11) { /* WORD */
+
+ // Array field (value)
+ } else
+ if((dataType == 12) && (numberOfValues == 1)) { /* DWORD */
+
+ // Simple Field (value)
+ uint32_t value = 0;
+ _res = plc4c_spi_read_unsigned_int(io, 32, (uint32_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_uint32_t_data(value);
+
+ } else
+ if(dataType == 12) { /* DWORD */
+
+ // Array field (value)
+ } else
+ if((dataType == 13) && (numberOfValues == 1)) { /* LWORD */
+
+ // Simple Field (value)
+ uint64_t value = 0;
+ _res = plc4c_spi_read_unsigned_long(io, 64, (uint64_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_uint64_t_data(value);
+
+ } else
+ if(dataType == 13) { /* LWORD */
+
+ // Array field (value)
+ } else
+ if((dataType == 20) && (numberOfValues == 1)) { /* SINT */
+
+ // Simple Field (value)
+ int8_t value = 0;
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_int8_t_data(value);
+
+ } else
+ if(dataType == 20) { /* SINT */
+
+ // Array field (value)
+ } else
+ if((dataType == 21) && (numberOfValues == 1)) { /* INT */
// Simple Field (value)
int16_t value = 0;
@@ -70,7 +150,167 @@ plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4c_spi_read_buffer*
*data_item = plc4c_data_create_int16_t_data(value);
} else
- if(dataType == 2) { /* List */
+ if(dataType == 21) { /* INT */
+
+ // Array field (value)
+ } else
+ if((dataType == 22) && (numberOfValues == 1)) { /* DINT */
+
+ // Simple Field (value)
+ int32_t value = 0;
+ _res = plc4c_spi_read_signed_int(io, 32, (int32_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_int32_t_data(value);
+
+ } else
+ if(dataType == 22) { /* DINT */
+
+ // Array field (value)
+ } else
+ if((dataType == 23) && (numberOfValues == 1)) { /* LINT */
+
+ // Simple Field (value)
+ int64_t value = 0;
+ _res = plc4c_spi_read_signed_long(io, 64, (int64_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_int64_t_data(value);
+
+ } else
+ if(dataType == 23) { /* LINT */
+
+ // Array field (value)
+ } else
+ if((dataType == 24) && (numberOfValues == 1)) { /* USINT */
+
+ // Simple Field (value)
+ uint8_t value = 0;
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_uint8_t_data(value);
+
+ } else
+ if(dataType == 24) { /* USINT */
+
+ // Array field (value)
+ } else
+ if((dataType == 25) && (numberOfValues == 1)) { /* UINT */
+
+ // Simple Field (value)
+ uint16_t value = 0;
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_uint16_t_data(value);
+
+ } else
+ if(dataType == 25) { /* UINT */
+
+ // Array field (value)
+ } else
+ if((dataType == 26) && (numberOfValues == 1)) { /* UDINT */
+
+ // Simple Field (value)
+ uint32_t value = 0;
+ _res = plc4c_spi_read_unsigned_int(io, 32, (uint32_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_uint32_t_data(value);
+
+ } else
+ if(dataType == 26) { /* UDINT */
+
+ // Array field (value)
+ } else
+ if((dataType == 27) && (numberOfValues == 1)) { /* ULINT */
+
+ // Simple Field (value)
+ uint64_t value = 0;
+ _res = plc4c_spi_read_unsigned_long(io, 64, (uint64_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_uint64_t_data(value);
+
+ } else
+ if(dataType == 27) { /* ULINT */
+
+ // Array field (value)
+ } else
+ if((dataType == 30) && (numberOfValues == 1)) { /* REAL */
+
+ // Simple Field (value)
+ float value = 0.0;
+ _res = plc4c_spi_read_float(io, 32, (float*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_float_data(value);
+
+ } else
+ if(dataType == 30) { /* REAL */
+
+ // Array field (value)
+ } else
+ if((dataType == 31) && (numberOfValues == 1)) { /* LREAL */
+
+ // Simple Field (value)
+ double value = 0.0;
+ _res = plc4c_spi_read_double(io, 64, (double*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_double_data(value);
+
+ } else
+ if(dataType == 31) { /* LREAL */
+
+ // Array field (value)
+ } else
+ if((dataType == 80) && (numberOfValues == 1)) { /* CHAR */
+
+ // Simple Field (value)
+ uint8_t value = 0;
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_uint8_t_data(value);
+
+ } else
+ if(dataType == 80) { /* CHAR */
+
+ // Array field (value)
+ } else
+ if((dataType == 81) && (numberOfValues == 1)) { /* WCHAR */
+
+ // Simple Field (value)
+ uint16_t value = 0;
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_uint16_t_data(value);
+
+ } else
+ if(dataType == 81) { /* WCHAR */
// Array field (value)
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_request_item.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_request_item.c
index 9855f70..a14596d 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_request_item.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_request_item.c
@@ -76,8 +76,8 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_request_i
uint8_t _recordDataLength = (recordLength) * (2);
uint8_t recordDataEndPos = plc4c_spi_read_get_pos(io) + _recordDataLength;
while(plc4c_spi_read_get_pos(io) < recordDataEndPos) {
- uint16_t _value = 0;
- _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &_value);
+ int8_t _value = 0;
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &_value);
if(_res != OK) {
return _res;
}
@@ -111,7 +111,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_request_i
}
// Implicit Field (recordLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_short(io, 16, (((plc4c_spi_evaluation_helper_count(_message->record_data)) * (2))) / (2));
+ _res = plc4c_spi_write_unsigned_short(io, 16, (plc4c_spi_evaluation_helper_count(_message->record_data)) / (2));
if(_res != OK) {
return _res;
}
@@ -121,8 +121,8 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_request_i
uint8_t itemCount = plc4c_utils_list_size(_message->record_data);
for(int curItem = 0; curItem < itemCount; curItem++) {
- uint16_t* _value = (uint16_t*) plc4c_utils_list_get_value(_message->record_data, curItem);
- plc4c_spi_write_unsigned_short(io, 16, *_value);
+ int8_t* _value = (int8_t*) plc4c_utils_list_get_value(_message->record_data, curItem);
+ plc4c_spi_write_signed_byte(io, 8, *_value);
}
}
@@ -149,7 +149,7 @@ uint16_t plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item_lengt
lengthInBits += 16;
// Array field
- lengthInBits += 16 * plc4c_utils_list_size(_message->record_data);
+ lengthInBits += 8 * plc4c_utils_list_size(_message->record_data);
return lengthInBits;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_response_item.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_response_item.c
index 906650e..e8252a9 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_response_item.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_response_item.c
@@ -73,11 +73,11 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_response_
}
{
// Length array
- uint8_t _recordDataLength = (recordLength) * (2);
+ uint8_t _recordDataLength = recordLength;
uint8_t recordDataEndPos = plc4c_spi_read_get_pos(io) + _recordDataLength;
while(plc4c_spi_read_get_pos(io) < recordDataEndPos) {
- uint16_t _value = 0;
- _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &_value);
+ int8_t _value = 0;
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &_value);
if(_res != OK) {
return _res;
}
@@ -111,7 +111,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_response_
}
// Implicit Field (recordLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_short(io, 16, (((plc4c_spi_evaluation_helper_count(_message->record_data)) * (2))) / (2));
+ _res = plc4c_spi_write_unsigned_short(io, 16, (plc4c_spi_evaluation_helper_count(_message->record_data)) / (2));
if(_res != OK) {
return _res;
}
@@ -121,8 +121,8 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_response_
uint8_t itemCount = plc4c_utils_list_size(_message->record_data);
for(int curItem = 0; curItem < itemCount; curItem++) {
- uint16_t* _value = (uint16_t*) plc4c_utils_list_get_value(_message->record_data, curItem);
- plc4c_spi_write_unsigned_short(io, 16, *_value);
+ int8_t* _value = (int8_t*) plc4c_utils_list_get_value(_message->record_data, curItem);
+ plc4c_spi_write_signed_byte(io, 8, *_value);
}
}
@@ -149,7 +149,7 @@ uint16_t plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item_leng
lengthInBits += 16;
// Array field
- lengthInBits += 16 * plc4c_utils_list_size(_message->record_data);
+ lengthInBits += 8 * plc4c_utils_list_size(_message->record_data);
return lengthInBits;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/data_item.c b/sandbox/plc4c/generated-sources/s7/src/data_item.c
index 1d0f20d..68bd07c 100644
--- a/sandbox/plc4c/generated-sources/s7/src/data_item.c
+++ b/sandbox/plc4c/generated-sources/s7/src/data_item.c
@@ -30,7 +30,7 @@ plc4c_return_code plc4c_s7_read_write_data_item_parse(plc4c_spi_read_buffer* io,
uint16_t curPos;
plc4c_return_code _res = OK;
- if(dataProtocolId == 01) { /* Boolean */
+ if(dataProtocolId == 01) { /* BOOL */
// Reserved Field (Compartmentalized so the "reserved" variable can't leak)
{
@@ -54,23 +54,23 @@ plc4c_return_code plc4c_s7_read_write_data_item_parse(plc4c_spi_read_buffer* io,
*data_item = plc4c_data_create_bool_data(value);
} else
- if(dataProtocolId == 11) { /* List */
+ if(dataProtocolId == 11) { /* BOOL */
// Array field (value)
} else
- if(dataProtocolId == 12) { /* List */
+ if(dataProtocolId == 12) { /* BOOL */
// Array field (value)
} else
- if(dataProtocolId == 13) { /* List */
+ if(dataProtocolId == 13) { /* BOOL */
// Array field (value)
} else
- if(dataProtocolId == 14) { /* List */
+ if(dataProtocolId == 14) { /* BOOL */
// Array field (value)
} else
- if(dataProtocolId == 21) { /* Integer */
+ if(dataProtocolId == 21) { /* SINT */
// Simple Field (value)
int8_t value = 0;
@@ -82,7 +82,7 @@ plc4c_return_code plc4c_s7_read_write_data_item_parse(plc4c_spi_read_buffer* io,
*data_item = plc4c_data_create_int8_t_data(value);
} else
- if(dataProtocolId == 22) { /* Integer */
+ if(dataProtocolId == 22) { /* USINT */
// Simple Field (value)
uint8_t value = 0;
@@ -94,7 +94,7 @@ plc4c_return_code plc4c_s7_read_write_data_item_parse(plc4c_spi_read_buffer* io,
*data_item = plc4c_data_create_uint8_t_data(value);
} else
- if(dataProtocolId == 23) { /* Integer */
+ if(dataProtocolId == 23) { /* INT */
// Simple Field (value)
int16_t value = 0;
@@ -106,7 +106,7 @@ plc4c_return_code plc4c_s7_read_write_data_item_parse(plc4c_spi_read_buffer* io,
*data_item = plc4c_data_create_int16_t_data(value);
} else
- if(dataProtocolId == 24) { /* Integer */
+ if(dataProtocolId == 24) { /* UINT */
// Simple Field (value)
uint16_t value = 0;
@@ -118,7 +118,7 @@ plc4c_return_code plc4c_s7_read_write_data_item_parse(plc4c_spi_read_buffer* io,
*data_item = plc4c_data_create_uint16_t_data(value);
} else
- if(dataProtocolId == 25) { /* Integer */
+ if(dataProtocolId == 25) { /* DINT */
// Simple Field (value)
int32_t value = 0;
@@ -130,7 +130,7 @@ plc4c_return_code plc4c_s7_read_write_data_item_parse(plc4c_spi_read_buffer* io,
*data_item = plc4c_data_create_int32_t_data(value);
} else
- if(dataProtocolId == 26) { /* Long */
+ if(dataProtocolId == 26) { /* UDINT */
// Simple Field (value)
uint32_t value = 0;
@@ -142,7 +142,7 @@ plc4c_return_code plc4c_s7_read_write_data_item_parse(plc4c_spi_read_buffer* io,
*data_item = plc4c_data_create_uint32_t_data(value);
} else
- if(dataProtocolId == 27) { /* Long */
+ if(dataProtocolId == 27) { /* LINT */
// Simple Field (value)
int64_t value = 0;
@@ -154,7 +154,7 @@ plc4c_return_code plc4c_s7_read_write_data_item_parse(plc4c_spi_read_buffer* io,
*data_item = plc4c_data_create_int64_t_data(value);
} else
- if(dataProtocolId == 28) { /* BigInteger */
+ if(dataProtocolId == 28) { /* ULINT */
// Simple Field (value)
uint64_t value = 0;
@@ -166,7 +166,7 @@ plc4c_return_code plc4c_s7_read_write_data_item_parse(plc4c_spi_read_buffer* io,
*data_item = plc4c_data_create_uint64_t_data(value);
} else
- if(dataProtocolId == 31) { /* Float */
+ if(dataProtocolId == 31) { /* REAL */
// Simple Field (value)
float value = 0.0;
@@ -178,7 +178,7 @@ plc4c_return_code plc4c_s7_read_write_data_item_parse(plc4c_spi_read_buffer* io,
*data_item = plc4c_data_create_float_data(value);
} else
- if(dataProtocolId == 32) { /* Double */
+ if(dataProtocolId == 32) { /* LREAL */
// Simple Field (value)
double value = 0.0;
diff --git a/sandbox/test-java-bacnetip-driver/src/main/java/org/apache/plc4x/java/bacnetip/ede/model/Datapoint.java b/sandbox/test-java-bacnetip-driver/src/main/java/org/apache/plc4x/java/bacnetip/ede/model/Datapoint.java
index e05231d..ab5f241 100644
--- a/sandbox/test-java-bacnetip-driver/src/main/java/org/apache/plc4x/java/bacnetip/ede/model/Datapoint.java
+++ b/sandbox/test-java-bacnetip-driver/src/main/java/org/apache/plc4x/java/bacnetip/ede/model/Datapoint.java
@@ -125,17 +125,17 @@ public class Datapoint {
values.put("keyName", (keyName == null) ? null : new PlcString(keyName));
values.put("objectName", (objectName == null) ? null : new PlcString(objectName));
values.put("description", (description == null) ? null : new PlcString(description));
- values.put("defaultValue", (defaultValue == null) ? null : new PlcDouble(defaultValue));
- values.put("minValue", (minValue == null) ? null : new PlcDouble(minValue));
- values.put("maxValue", (maxValue == null) ? null : new PlcDouble(maxValue));
- values.put("commandable", (commandable == null) ? null : new PlcBoolean(commandable));
- values.put("supportsCov", (supportsCov == null) ? null : new PlcBoolean(supportsCov));
- values.put("hiLimit", (hiLimit == null) ? null : new PlcDouble(hiLimit));
- values.put("lowLimit", (lowLimit == null) ? null : new PlcDouble(lowLimit));
+ values.put("defaultValue", (defaultValue == null) ? null : new PlcLREAL(defaultValue));
+ values.put("minValue", (minValue == null) ? null : new PlcLREAL(minValue));
+ values.put("maxValue", (maxValue == null) ? null : new PlcLREAL(maxValue));
+ values.put("commandable", (commandable == null) ? null : new PlcBOOL(commandable));
+ values.put("supportsCov", (supportsCov == null) ? null : new PlcBOOL(supportsCov));
+ values.put("hiLimit", (hiLimit == null) ? null : new PlcLREAL(hiLimit));
+ values.put("lowLimit", (lowLimit == null) ? null : new PlcLREAL(lowLimit));
values.put("stateTextReference", (stateTextReference == null) ? null : new PlcString(stateTextReference));
- values.put("unitCode", (unitCode == null) ? null : new PlcInteger(unitCode));
- values.put("vendorSpecificAddress", (vendorSpecificAddress == null) ? null : new PlcInteger(vendorSpecificAddress));
- values.put("notificationClass", (notificationClass == null) ? null : new PlcInteger(notificationClass));
+ values.put("unitCode", (unitCode == null) ? null : new PlcDINT(unitCode));
+ values.put("vendorSpecificAddress", (vendorSpecificAddress == null) ? null : new PlcDINT(vendorSpecificAddress));
+ values.put("notificationClass", (notificationClass == null) ? null : new PlcDINT(notificationClass));
return values;
}
diff --git a/sandbox/test-java-bacnetip-driver/src/main/java/org/apache/plc4x/java/bacnetip/protocol/BacNetIpProtocolLogic.java b/sandbox/test-java-bacnetip-driver/src/main/java/org/apache/plc4x/java/bacnetip/protocol/BacNetIpProtocolLogic.java
index 7f03cf9..4e3992e 100644
--- a/sandbox/test-java-bacnetip-driver/src/main/java/org/apache/plc4x/java/bacnetip/protocol/BacNetIpProtocolLogic.java
+++ b/sandbox/test-java-bacnetip-driver/src/main/java/org/apache/plc4x/java/bacnetip/protocol/BacNetIpProtocolLogic.java
@@ -140,9 +140,9 @@ public class BacNetIpProtocolLogic extends Plc4xProtocolBase<BVLC> implements Ha
// Initialize an enriched version of the PlcStruct.
final Map<String, PlcValue> enrichedPlcValue = new HashMap<>();
- enrichedPlcValue.put("deviceIdentifier", new PlcLong(deviceIdentifier));
- enrichedPlcValue.put("objectType", new PlcInteger(objectType));
- enrichedPlcValue.put("objectInstance", new PlcLong(objectInstance));
+ enrichedPlcValue.put("deviceIdentifier", new PlcUDINT(deviceIdentifier));
+ enrichedPlcValue.put("objectType", new PlcDINT(objectType));
+ enrichedPlcValue.put("objectInstance", new PlcUDINT(objectInstance));
enrichedPlcValue.put("address", new PlcString(toString(curField)));
// Add all of the existing attributes.
enrichedPlcValue.putAll(plcValue.getStruct());
diff --git a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/protocol/Plc4XDf1Protocol.java b/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/protocol/Plc4XDf1Protocol.java
index 2208df5..0f1f16f 100644
--- a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/protocol/Plc4XDf1Protocol.java
+++ b/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/protocol/Plc4XDf1Protocol.java
@@ -26,7 +26,7 @@ import org.apache.plc4x.java.api.messages.PlcResponse;
import org.apache.plc4x.java.api.messages.PlcWriteRequest;
import org.apache.plc4x.java.api.model.PlcField;
import org.apache.plc4x.java.api.types.PlcResponseCode;
-import org.apache.plc4x.java.api.value.PlcInteger;
+import org.apache.plc4x.java.api.value.PlcDINT;
import org.apache.plc4x.java.api.value.PlcValue;
import org.apache.plc4x.java.df1.field.Df1Field;
import org.apache.plc4x.java.spi.PlcMessageToMessageCodec;
@@ -98,7 +98,7 @@ public class Plc4XDf1Protocol extends PlcMessageToMessageCodec<DF1Symbol, PlcReq
new DefaultPlcReadResponse(
((InternalPlcReadRequest) entry.getValue().getRequest()),
Collections.singletonMap("erster",
- new ResponseItem<>(PlcResponseCode.INTERNAL_ERROR, new PlcInteger(-1)))
+ new ResponseItem<>(PlcResponseCode.INTERNAL_ERROR, new PlcDINT(-1)))
));
}
return;
@@ -144,7 +144,7 @@ public class Plc4XDf1Protocol extends PlcMessageToMessageCodec<DF1Symbol, PlcReq
break;
case INTEGER:
// TODO: type conversion is untested
- responseItem = new PlcInteger((int)data[0] + ((int) data[1] << 8));
+ responseItem = new PlcDINT((int)data[0] + ((int) data[1] << 8));
break;
case FLOAT:
break;