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 2022/09/02 07:44:39 UTC
[plc4x] branch develop updated: chore(plc4j/examples): Updated the HelloPlc4xDiscoverAndBrowse example to utilize the added PlcBrowseItem fields.
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
The following commit(s) were added to refs/heads/develop by this push:
new 1c9c69999 chore(plc4j/examples): Updated the HelloPlc4xDiscoverAndBrowse example to utilize the added PlcBrowseItem fields.
1c9c69999 is described below
commit 1c9c69999d7cfa2625bd159509219ed826485595
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Fri Sep 2 09:44:32 2022 +0200
chore(plc4j/examples): Updated the HelloPlc4xDiscoverAndBrowse example to utilize the added PlcBrowseItem fields.
---
.../discoverandbrowse/HelloPlc4xDiscoverAndBrowse.java | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/plc4j/examples/hello-world-plc4x-discover-and-browse/src/main/java/org/apache/plc4x/java/examples/helloplc4x/discoverandbrowse/HelloPlc4xDiscoverAndBrowse.java b/plc4j/examples/hello-world-plc4x-discover-and-browse/src/main/java/org/apache/plc4x/java/examples/helloplc4x/discoverandbrowse/HelloPlc4xDiscoverAndBrowse.java
index 6db390e06..f91a9c32a 100644
--- a/plc4j/examples/hello-world-plc4x-discover-and-browse/src/main/java/org/apache/plc4x/java/examples/helloplc4x/discoverandbrowse/HelloPlc4xDiscoverAndBrowse.java
+++ b/plc4j/examples/hello-world-plc4x-discover-and-browse/src/main/java/org/apache/plc4x/java/examples/helloplc4x/discoverandbrowse/HelloPlc4xDiscoverAndBrowse.java
@@ -52,7 +52,7 @@ public class HelloPlc4xDiscoverAndBrowse {
throwable.printStackTrace();
} else {
for (PlcBrowseItem value : browseResponse.getValues()) {
- System.out.println(String.format("%60s : %60s", value.getAddress(), value.getPlcValueType().name()));
+ outputBrowseItem(value, 0);
}
}
});
@@ -67,4 +67,19 @@ public class HelloPlc4xDiscoverAndBrowse {
}
}
+ protected static void outputBrowseItem(PlcBrowseItem browseItem, int indent) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(" ".repeat(Math.max(0, indent)));
+ System.out.println(String.format(sb + "%s : %s (%s %s %s)", browseItem.getAddress(),
+ browseItem.getPlcValueType().name(),
+ browseItem.isReadable() ? "R" : " ",
+ browseItem.isReadable() ? "W" : " ",
+ browseItem.isReadable() ? "S" : " "));
+ if(!browseItem.getChildren().isEmpty()) {
+ for (PlcBrowseItem child : browseItem.getChildren()) {
+ outputBrowseItem(child, indent + 1);
+ }
+ }
+ }
+
}