You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2020/06/05 07:30:26 UTC
[incubator-streampipes-extensions] branch dev updated: Integrate
modbus adapter
This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git
The following commit(s) were added to refs/heads/dev by this push:
new 3614b2a Integrate modbus adapter
3614b2a is described below
commit 3614b2a71d531087880bda2457c825305835430d
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Fri Jun 5 09:30:02 2020 +0200
Integrate modbus adapter
---
.../streampipes/connect/ConnectAdapterInit.java | 2 +
.../adapters/plc4x/modbus/Plc4xModbusAdapter.java | 40 +++++++++++---------
.../documentation.md | 33 +++++++++++++++++
.../icon.png | Bin 0 -> 46022 bytes
.../strings.en | 41 +++++++++++++++++++++
5 files changed, 99 insertions(+), 17 deletions(-)
diff --git a/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/ConnectAdapterInit.java b/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/ConnectAdapterInit.java
index c8ec37c..d347247 100644
--- a/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/ConnectAdapterInit.java
+++ b/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/ConnectAdapterInit.java
@@ -23,6 +23,7 @@ import org.apache.streampipes.connect.adapters.image.stream.ImageStreamAdapter;
import org.apache.streampipes.connect.adapters.iss.IssAdapter;
import org.apache.streampipes.connect.adapters.netio.NetioMQTTAdapter;
import org.apache.streampipes.connect.adapters.netio.NetioRestAdapter;
+import org.apache.streampipes.connect.adapters.plc4x.modbus.Plc4xModbusAdapter;
import org.apache.streampipes.connect.adapters.ti.TISensorTag;
import org.apache.streampipes.connect.protocol.set.HttpProtocol;
import org.apache.streampipes.connect.adapters.coindesk.CoindeskBitcoinAdapter;
@@ -88,6 +89,7 @@ public class ConnectAdapterInit extends AdapterWorkerContainer {
.add(new NetioRestAdapter())
.add(new NetioMQTTAdapter())
.add(new Plc4xS7Adapter())
+ .add(new Plc4xModbusAdapter())
.add(new ImageStreamAdapter())
.add(new ImageSetAdapter())
.add(new IssAdapter());
diff --git a/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/plc4x/modbus/Plc4xModbusAdapter.java b/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/plc4x/modbus/Plc4xModbusAdapter.java
index 3e17fc7..92cdaef 100644
--- a/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/plc4x/modbus/Plc4xModbusAdapter.java
+++ b/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/plc4x/modbus/Plc4xModbusAdapter.java
@@ -65,9 +65,10 @@ public class Plc4xModbusAdapter extends PullAdapter{
/**
* Keys of user configuration parameters
*/
- private static final String PLC_IP = "plc_ip";
-
- private static final String PLC_NODES = "plc_nodes";
+ private static final String PLC_IP = "plc_ip";
+ private static final String PLC_PORT = "plc_port";
+
+ private static final String PLC_NODES = "plc_nodes";
private static final String PLC_NODE_NAME = "plc_node_name";
private static final String PLC_NODE_RUNTIME_NAME = "plc_node_runtime_name";
private static final String PLC_NODE_ADDRESS = "plc_node_address";
@@ -78,7 +79,8 @@ public class Plc4xModbusAdapter extends PullAdapter{
* Values of user configuration parameters
*/
private String ip;
- private List<Map<String, String>> nodes;
+ private int port;
+ private List<Map<String, String>> nodes;
/**
* Connection to the PLC
@@ -105,14 +107,16 @@ public class Plc4xModbusAdapter extends PullAdapter{
.withLocales(Locales.EN)
.withAssets(Assets.DOCUMENTATION, Assets.ICON)
.category(AdapterType.Manufacturing)
- .requiredTextParameter(Labels.from(PLC_IP, "PLC Address", "Example: 192.168.34.56"))
- .requiredCollection(Labels.from(PLC_NODES, "Nodes", "The PLC Nodes"),
- StaticProperties.collection(Labels.withId(PLC_NODES),
+ .requiredTextParameter(Labels.withId(PLC_IP))
+ .requiredTextParameter(Labels.withId(PLC_PORT))
+ .requiredCollection(Labels.withId(PLC_NODES),
+// StaticProperties.collection(Labels.withId(PLC_NODES),
StaticProperties.stringFreeTextProperty(Labels.withId(PLC_NODE_RUNTIME_NAME)),
StaticProperties.stringFreeTextProperty(Labels.withId(PLC_NODE_NAME)),
StaticProperties.integerFreeTextProperty(Labels.withId(PLC_NODE_ADDRESS)),
- StaticProperties.singleValueSelection(Labels.withId(PLC_NODE_TYPE),
- Options.from("Coil", "HoldingRegister"))))
+ StaticProperties.singleValueSelection(Labels.withId(PLC_NODE_TYPE),
+ Options.from("Coil", "HoldingRegister")))
+// )
.build();
description.setAppId(ID);
@@ -129,9 +133,10 @@ public class Plc4xModbusAdapter extends PullAdapter{
StaticPropertyExtractor extractor = StaticPropertyExtractor.from(adapterDescription.getConfig(), new ArrayList<>());
- this.ip = extractor.singleValueParameter(PLC_IP, String.class);
-
- this.nodes = new ArrayList<>();
+ this.ip = extractor.singleValueParameter(PLC_IP, String.class);
+ this.port = extractor.singleValueParameter(PLC_PORT, Integer.class);
+
+ this.nodes = new ArrayList<>();
CollectionStaticProperty sp = (CollectionStaticProperty) extractor.getStaticPropertyByName(PLC_NODES);
for (StaticProperty member : sp.getMembers()) {
@@ -140,11 +145,12 @@ public class Plc4xModbusAdapter extends PullAdapter{
Map map = new HashMap();
map.put(PLC_NODE_RUNTIME_NAME, memberExtractor.textParameter(PLC_NODE_RUNTIME_NAME));
map.put(PLC_NODE_NAME, memberExtractor.textParameter(PLC_NODE_NAME));
- map.put(PLC_NODE_ADDRESS, memberExtractor.selectedSingleValue(PLC_NODE_ADDRESS, Integer.class));
+ map.put(PLC_NODE_ADDRESS, memberExtractor.singleValueParameter(PLC_NODE_ADDRESS, Integer.class));
map.put(PLC_NODE_TYPE, memberExtractor.selectedSingleValue(PLC_NODE_TYPE, String.class));
+
this.nodes.add(map);
}
-
+
}
@@ -169,7 +175,7 @@ public class Plc4xModbusAdapter extends PullAdapter{
/**
* Takes the user input and creates the event schema. The event schema describes the properties of the event stream.
- * @param adapaterDescription
+ * @param
* @return
* @throws AdapterException, ParseException
*/
@@ -192,7 +198,7 @@ public class Plc4xModbusAdapter extends PullAdapter{
PrimitivePropertyBuilder
.create(datatype, node.get(PLC_NODE_RUNTIME_NAME))
.label(node.get(PLC_NODE_RUNTIME_NAME))
- .description("FieldAdress: " + node.get(PLC_NODE_TYPE) + " " + node.get(PLC_NODE_ADDRESS))
+ .description("FieldAdress: " + node.get(PLC_NODE_TYPE) + " " + String.valueOf(node.get(PLC_NODE_ADDRESS)))
.build());
}
@@ -214,7 +220,7 @@ public class Plc4xModbusAdapter extends PullAdapter{
getConfigurations(adapterDescription);
try {
- this.plcConnection = new PlcDriverManager().getConnection("modbus:tcp://" + this.ip);
+ this.plcConnection = new PlcDriverManager().getConnection("modbus:tcp://" + this.ip + ":" + this.port);
if (!this.plcConnection.getMetadata().canRead()) {
throw new AdapterException("The Modbus device on IP: " + this.ip + " does not support reading data");
diff --git a/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.modbus/documentation.md b/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.modbus/documentation.md
new file mode 100644
index 0000000..c3da505
--- /dev/null
+++ b/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.modbus/documentation.md
@@ -0,0 +1,33 @@
+<!--
+ ~ 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.
+ ~
+ -->
+
+## ISS Adapter
+
+<p align="center">
+ <img src="icon.png" width="150px;" class="pe-image-documentation"/>
+</p>
+
+***
+
+## Description
+
+Shows the live position of the International Space Station (ISS), updated every two seconds.
+
+
+***
+
diff --git a/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.modbus/icon.png b/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.modbus/icon.png
new file mode 100644
index 0000000..cfb6339
Binary files /dev/null and b/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.modbus/icon.png differ
diff --git a/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.modbus/strings.en b/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.modbus/strings.en
new file mode 100644
index 0000000..d7aff3b
--- /dev/null
+++ b/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.modbus/strings.en
@@ -0,0 +1,41 @@
+org.apache.streampipes.connect.adapters.plc4x.modbus.title=PLC4X MODBUS
+org.apache.streampipes.connect.adapters.plc4x.modbus.description=Connect directly to your MODBUS PLC
+
+plc_ip.title=PLC Address
+plc_ip.description=Example: 192.168.34.56
+
+plc_port.title=PLC Port
+plc_port.description=Example: 502
+
+configure.title=Configuration
+configure.description=
+
+manually.title=Enter Manually
+manually.description=Enter the addresses to read the data from manually
+
+plc_nodes.title=Nodes
+plc_nodes.description=Define the nodes of the PLC
+
+plc_node_runtime_name.title=Runtime Name
+plc_node_runtime_name.description=example: temperature
+
+plc_node_name.title=Node Name
+plc_node_name.description=example: %Q0.4
+
+plc_node_type.title=Data Type
+plc_node_type.description=example: bool
+
+csv_import.title=Import from CSV
+csv_import.description=Import a CSV file with the configurations from the TIA portal
+
+excel_import.title= Import from Excel file
+excel_import.description=Import a Excel file with the configurations from the TIA portal
+
+plc_nodes_csv_file.title=CSV File
+plc_nodes_csv_file.description=Contains three columns 'Name', 'Data Type', 'Logical Address'
+
+plc_nodes_excel_file.title=Excel File
+plc_nodes_excel_file.description=Contains three columns 'Name', 'Data Type', 'Logical Address'
+
+plc_node_address.title=Node Address
+plc_node_address.description=