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/03/25 14:40:17 UTC
[plc4x] branch develop updated: - Made the usage of real or fake
device a config option in the application.properties
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 f120d94 - Made the usage of real or fake device a config option in the application.properties
f120d94 is described below
commit f120d941b454663b53956540b5a9172efdf124f5
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Wed Mar 25 15:40:10 2020 +0100
- Made the usage of real or fake device a config option in the application.properties
---
.../plc4x/examples/watertank/service/WaterTankService.java | 9 ++++++++-
.../webapp/src/main/resources/application.properties | 5 ++++-
2 files changed, 12 insertions(+), 2 deletions(-)
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 4fb36a0..e56a4f6 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
@@ -67,13 +67,20 @@ public class WaterTankService {
@Value("${plc4x.watertank.address-string.waterlevel}")
private String addressStringWaterLevel;
+ @Value("${plc4x.watertank.simulation}")
+ private boolean simulation;
+
@PostConstruct
protected void connectAndSubscribe() {
// Create the BlazeDS destinations the clients can subscribe to.
createDestinations();
// Connect to the remote and subscribe to the values.
- connectToFakeDevice();
+ if(simulation) {
+ connectToFakeDevice();
+ } else {
+ connectToDevice();
+ }
}
@PreDestroy
diff --git a/plc4j/examples/hello-webapp/webapp/src/main/resources/application.properties b/plc4j/examples/hello-webapp/webapp/src/main/resources/application.properties
index b0b11d7..5d3d105 100644
--- a/plc4j/examples/hello-webapp/webapp/src/main/resources/application.properties
+++ b/plc4j/examples/hello-webapp/webapp/src/main/resources/application.properties
@@ -23,5 +23,8 @@ spring.mvc.view.suffix= .html
logging.level.root=INFO
-plc4x.watertank.connection-string=firmata://cu.usbmodem146101
+# Comment in to use a random number generator instead of a real device.
+#plc4x.watertank.simulation=true
+
+plc4x.watertank.connection-string=firmata://cu.usbmodem1412201
plc4x.watertank.address-string.waterlevel=analog:0