You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2018/06/13 08:10:35 UTC
[incubator-plc4x] branch master updated: smaller cleanups
This is an automated email from the ASF dual-hosted git repository.
sruehl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git
The following commit(s) were added to refs/heads/master by this push:
new aaad9ce smaller cleanups
aaad9ce is described below
commit aaad9ce502129220bbd65a260ad3dee18cca0f63
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Wed Jun 13 10:10:31 2018 +0200
smaller cleanups
---
.../plc4x/java/ads/api/serial/types/ReceiverAddress.java | 14 ++++++++++++++
.../java/ads/api/serial/types/TransmitterAddress.java | 14 ++++++++++++++
.../plc4x/java/ads/api/serial/types/UserDataLength.java | 11 +++++++++++
3 files changed, 39 insertions(+)
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/types/ReceiverAddress.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/types/ReceiverAddress.java
index f1809f3..b6ec0aa 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/types/ReceiverAddress.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/types/ReceiverAddress.java
@@ -21,6 +21,9 @@ package org.apache.plc4x.java.ads.api.serial.types;
import io.netty.buffer.ByteBuf;
import org.apache.plc4x.java.ads.api.util.ByteValue;
+import static java.lang.Integer.toHexString;
+import static org.apache.commons.lang3.StringUtils.leftPad;
+
public class ReceiverAddress extends ByteValue {
public static final int NUM_BYTES = 1;
@@ -43,4 +46,15 @@ public class ReceiverAddress extends ByteValue {
return new ReceiverAddress(byteBuf);
}
+ public byte getAsByte() {
+ return value[0];
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "{" +
+ "byteValue=" + (getAsByte() & 0xFF) +
+ ",hexValue=0x" + leftPad(toHexString(getAsByte() & 0xFF), NUM_BYTES * 2, "0") +
+ "}";
+ }
}
\ No newline at end of file
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/types/TransmitterAddress.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/types/TransmitterAddress.java
index 1c90591..f447b76 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/types/TransmitterAddress.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/types/TransmitterAddress.java
@@ -21,6 +21,9 @@ package org.apache.plc4x.java.ads.api.serial.types;
import io.netty.buffer.ByteBuf;
import org.apache.plc4x.java.ads.api.util.ByteValue;
+import static java.lang.Integer.toHexString;
+import static org.apache.commons.lang3.StringUtils.leftPad;
+
public class TransmitterAddress extends ByteValue {
public static final int NUM_BYTES = 1;
@@ -43,4 +46,15 @@ public class TransmitterAddress extends ByteValue {
return new TransmitterAddress(byteBuf);
}
+ public byte getAsByte() {
+ return value[0];
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "{" +
+ "byteValue=" + (getAsByte() & 0xFF) +
+ ",hexValue=0x" + leftPad(toHexString(getAsByte() & 0xFF), NUM_BYTES * 2, "0") +
+ "}";
+ }
}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/types/UserDataLength.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/types/UserDataLength.java
index 851cf91..e432885 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/types/UserDataLength.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/types/UserDataLength.java
@@ -21,6 +21,9 @@ package org.apache.plc4x.java.ads.api.serial.types;
import io.netty.buffer.ByteBuf;
import org.apache.plc4x.java.ads.api.util.ByteValue;
+import static java.lang.Integer.toHexString;
+import static org.apache.commons.lang3.StringUtils.leftPad;
+
public class UserDataLength extends ByteValue {
public static final int NUM_BYTES = 1;
@@ -44,4 +47,12 @@ public class UserDataLength extends ByteValue {
public byte getAsByte() {
return value[0];
}
+
+ @Override
+ public String toString() {
+ return super.toString() + "{" +
+ "byteValue=" + (getAsByte() & 0xFF) +
+ ",hexValue=0x" + leftPad(toHexString(getAsByte() & 0xFF), NUM_BYTES * 2, "0") +
+ "}";
+ }
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
sruehl@apache.org.