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/08/27 20:44:01 UTC
[incubator-streampipes-extensions] branch dev updated:
[STREAMPIPES-211] Add Polling interval for PLC4X S7 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 93dfc8b [STREAMPIPES-211] Add Polling interval for PLC4X S7 adapter
93dfc8b is described below
commit 93dfc8b7c529d7cf8f1b668e8687d5b85269638e
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Thu Aug 27 22:43:33 2020 +0200
[STREAMPIPES-211] Add Polling interval for PLC4X S7 adapter
---
.../streampipes/connect/adapters/plc4x/s7/Plc4xS7Adapter.java | 11 +++++++++--
.../strings.en | 3 +++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/plc4x/s7/Plc4xS7Adapter.java b/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/plc4x/s7/Plc4xS7Adapter.java
index ae06a59..e27cfaa 100644
--- a/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/plc4x/s7/Plc4xS7Adapter.java
+++ b/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/plc4x/s7/Plc4xS7Adapter.java
@@ -79,6 +79,7 @@ public class Plc4xS7Adapter extends PullAdapter {
* Keys of user configuration parameters
*/
private static final String PLC_IP = "plc_ip";
+ private static final String PLC_POLLING_INTERVAL = "plc_polling_interval";
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";
@@ -94,6 +95,7 @@ public class Plc4xS7Adapter extends PullAdapter {
* Values of user configuration parameters
*/
private String ip;
+ private int pollingInterval;
private List<Map<String, String>> nodes;
/**
@@ -125,6 +127,7 @@ public class Plc4xS7Adapter extends PullAdapter {
.withAssets(Assets.DOCUMENTATION, Assets.ICON)
.category(AdapterType.Manufacturing)
.requiredTextParameter(Labels.withId(PLC_IP))
+ .requiredIntegerParameter(Labels.withId(PLC_POLLING_INTERVAL), 1000)
.requiredAlternatives(Labels.withId(CONFIGURE),
Alternatives.from(Labels.withId(MANUALLY),
StaticProperties.collection(Labels.withId(PLC_NODES),
@@ -154,6 +157,10 @@ public class Plc4xS7Adapter extends PullAdapter {
// Extract user input
getConfigurations(adapterDescription);
+ if (this.pollingInterval < 10) {
+ throw new AdapterException("Polling interval must be higher then 10. Current value: " + this.pollingInterval);
+ }
+
// TODO add a validation to check if the user input is available in the PLC
GuessSchema guessSchema = new GuessSchema();
@@ -241,14 +248,13 @@ public class Plc4xS7Adapter extends PullAdapter {
}
-
/**
* Define the polling interval of this adapter. Default is to poll every second
* @return
*/
@Override
protected PollingSettings getPollingInterval() {
- return PollingSettings.from(TimeUnit.SECONDS, 1);
+ return PollingSettings.from(TimeUnit.MILLISECONDS, this.pollingInterval);
}
/**
@@ -280,6 +286,7 @@ public class Plc4xS7Adapter extends PullAdapter {
StaticPropertyExtractor.from(adapterDescription.getConfig(), new ArrayList<>());
this.ip = extractor.singleValueParameter(PLC_IP, String.class);
+ this.pollingInterval = extractor.singleValueParameter(PLC_POLLING_INTERVAL, Integer.class);
String selectedAlternative = extractor.selectedAlternativeInternalId(CONFIGURE);
if (selectedAlternative.equals(CSV_IMPORT)) {
diff --git a/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.s7/strings.en b/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.s7/strings.en
index c3fc57e..2a31187 100644
--- a/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.s7/strings.en
+++ b/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.s7/strings.en
@@ -4,6 +4,9 @@ org.apache.streampipes.connect.adapters.plc4x.s7.description=Connect directly to
plc_ip.title=PLC Address
plc_ip.description=Example: 192.168.34.56
+plc_polling_interval.title=Polling Interval [ms]
+plc_polling_interval.description=Polling Interval of adapter in milliseconds. Minimum value is 10.
+
configure.title=Configuration
configure.description=