This is an automated email from the ASF dual-hosted git repository. bossenti pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git
commit 302af04782400ec80ec6aca6fe7c81584cb73c6c Author: bossenti <[email protected]> AuthorDate: Tue Apr 20 14:43:05 2021 +0200 [STREAMPIPES-344] change polling interval to milliseconds --- .../streampipes/connect/adapters/opcua/OpcUa.java | 36 +++++++++++----------- .../connect/adapters/opcua/OpcUaAdapter.java | 6 ++-- .../strings.en | 2 +- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/opcua/OpcUa.java b/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/opcua/OpcUa.java index efc84a0..0f09f5d 100644 --- a/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/opcua/OpcUa.java +++ b/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/opcua/OpcUa.java @@ -72,7 +72,7 @@ public class OpcUa { private String opcServerURL; private OpcUaClient client; private boolean unauthenticated; - private Double pullIntervalSeconds; + private Integer pullIntervalMilliSeconds; private String user; private String password; private List<Map<String, Integer>> unitIDs = new ArrayList<>(); @@ -95,14 +95,14 @@ public class OpcUa { * @param opcServerURL complete OPC UA server url * @param namespaceIndex namespace index of the given node * @param nodeId node identifier - * @param pullIntervalSeconds duration of pull interval in seconds, {@code null} if in subscription mode + * @param pullIntervalMilliSeconds duration of pull interval in milliseconds, {@code null} if in subscription mode * @param selectedNodeNames list of node names provided from {@link OpcUaUtil#resolveOptions(String, StaticPropertyExtractor)} */ - public OpcUa(String opcServerURL, int namespaceIndex, String nodeId, Double pullIntervalSeconds, List<String> selectedNodeNames) { + public OpcUa(String opcServerURL, int namespaceIndex, String nodeId, int pullIntervalMilliSeconds, List<String> selectedNodeNames) { this.opcServerURL = opcServerURL; this.unauthenticated = true; - this.pullIntervalSeconds = pullIntervalSeconds; + this.pullIntervalMilliSeconds = pullIntervalMilliSeconds; this.selectedNodeNames = selectedNodeNames; if (isInteger(nodeId)) { @@ -120,11 +120,11 @@ public class OpcUa { * @param opcServerPort OPC UA port number * @param namespaceIndex namespace index of the given node * @param nodeId node identifier - * @param pullIntervalSeconds duration of pull interval in seconds, {@code null} if in subscription mode + * @param pullIntervalMilliSeconds duration of pull interval in milliseconds, {@code null} if in subscription mode * @param selectedNodeNames list of node names provided from {@link OpcUaUtil#resolveOptions(String, StaticPropertyExtractor)} */ - public OpcUa(String opcServer, int opcServerPort, int namespaceIndex, String nodeId, Double pullIntervalSeconds, List<String> selectedNodeNames) { - this( opcServer + ":" + opcServerPort, namespaceIndex, nodeId, pullIntervalSeconds, selectedNodeNames); + public OpcUa(String opcServer, int opcServerPort, int namespaceIndex, String nodeId, int pullIntervalMilliSeconds, List<String> selectedNodeNames) { + this( opcServer + ":" + opcServerPort, namespaceIndex, nodeId, pullIntervalMilliSeconds, selectedNodeNames); } /** @@ -135,11 +135,11 @@ public class OpcUa { * @param nodeId node identifier * @param username username to authenticate at the OPC UA server * @param password corresponding password to given user name - * @param pullIntervalSeconds duration of pull interval in seconds, {@code null} if in subscription mode + * @param pullIntervalMilliSeconds duration of pull interval in milliseconds, {@code null} if in subscription mode * @param selectedNodeNames list of node names provided from {@link OpcUaUtil#resolveOptions(String, StaticPropertyExtractor)} */ - public OpcUa(String opcServerURL, int namespaceIndex, String nodeId, String username, String password, Double pullIntervalSeconds, List<String> selectedNodeNames) { - this(opcServerURL, namespaceIndex, nodeId, pullIntervalSeconds, selectedNodeNames); + public OpcUa(String opcServerURL, int namespaceIndex, String nodeId, String username, String password, int pullIntervalMilliSeconds, List<String> selectedNodeNames) { + this(opcServerURL, namespaceIndex, nodeId, pullIntervalMilliSeconds, selectedNodeNames); this.unauthenticated = false; this.user = username; this.password = password; @@ -154,11 +154,11 @@ public class OpcUa { * @param nodeId node identifier * @param username username to authenticate at the OPC UA server * @param password corresponding password to given user name - * @param pullIntervalSeconds duration of pull interval in seconds, {@code null} if in subscription mode + * @param pullIntervalMilliSeconds duration of pull interval in milliseconds, {@code null} if in subscription mode * @param selectedNodeNames list of node names provided from {@link OpcUaUtil#resolveOptions(String, StaticPropertyExtractor)} */ - public OpcUa(String opcServer, int opcServerPort, int namespaceIndex, String nodeId, String username, String password, Double pullIntervalSeconds, List<String> selectedNodeNames) { - this (opcServer, opcServerPort, namespaceIndex, nodeId, pullIntervalSeconds, selectedNodeNames); + public OpcUa(String opcServer, int opcServerPort, int namespaceIndex, String nodeId, String username, String password, int pullIntervalMilliSeconds, List<String> selectedNodeNames) { + this (opcServer, opcServerPort, namespaceIndex, nodeId, pullIntervalMilliSeconds, selectedNodeNames); this.unauthenticated = false; this.user = username; this.password = password; @@ -181,9 +181,9 @@ public class OpcUa { boolean useURL = selectedAlternativeConnection.equals(OpcUaLabels.OPC_URL.name()); boolean unauthenticated = selectedAlternativeAuthentication.equals(OpcUaLabels.UNAUTHENTICATED.name()); - Double pullIntervalSeconds = null; + Integer pullIntervalSeconds = null; if (usePullMode) { - pullIntervalSeconds = extractor.singleValueParameter(OpcUaLabels.PULLING_INTERVAL.name(), Double.class); + pullIntervalSeconds = extractor.singleValueParameter(OpcUaLabels.PULLING_INTERVAL.name(), Integer.class); } List<String> selectedNodeNames = extractor.selectedMultiValues(OpcUaLabels.AVAILABLE_NODES.name(), String.class); @@ -564,10 +564,10 @@ public class OpcUa { } public boolean inPullMode() { - return !(this.pullIntervalSeconds == null); + return !(this.pullIntervalMilliSeconds == null); } - public double getPullIntervalSeconds() { - return this.pullIntervalSeconds; + public int getPullIntervalMilliSeconds() { + return this.pullIntervalMilliSeconds; } } diff --git a/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/opcua/OpcUaAdapter.java b/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/opcua/OpcUaAdapter.java index 85d7a36..38aba15 100644 --- a/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/opcua/OpcUaAdapter.java +++ b/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/opcua/OpcUaAdapter.java @@ -33,7 +33,7 @@ public class OpcUaAdapter extends PullAdapter implements ResolvesContainerProvid public static final String ID = "org.apache.streampipes.connect.adapters.opcua"; - private double pullingIntervalInSeconds; + private int pullingIntervalMilliSeconds; private OpcUa opcUa; private List<OpcNode> allNodes; private List<NodeId> allNodeIds; @@ -66,7 +66,7 @@ public class OpcUaAdapter extends PullAdapter implements ResolvesContainerProvid } if (opcUa.inPullMode()) { - this.pullingIntervalInSeconds = opcUa.getPullIntervalSeconds(); + this.pullingIntervalMilliSeconds = opcUa.getPullIntervalMilliSeconds(); } else { this.numberProperties = this.allNodeIds.size(); this.opcUa.createListSubscription(this.allNodeIds, this); @@ -145,7 +145,7 @@ public class OpcUaAdapter extends PullAdapter implements ResolvesContainerProvid @Override protected PollingSettings getPollingInterval() { - return PollingSettings.from(TimeUnit.MILLISECONDS, (int) this.pullingIntervalInSeconds * 1000); + return PollingSettings.from(TimeUnit.MILLISECONDS, this.pullingIntervalMilliSeconds); } @Override diff --git a/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.opcua/strings.en b/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.opcua/strings.en index 240ffdb..006543d 100644 --- a/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.opcua/strings.en +++ b/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.opcua/strings.en @@ -46,7 +46,7 @@ AVAILABLE_NODES.title=Available Nodes AVAILABLE_NODES.description=Select the nodes that are relevant for you. Please ensure to select one option each for access mode and OPC UA server and to specify the polling interval PULLING_INTERVAL.title=Pull Interval -PULLING_INTERVAL.description=Timespan between data are pulled, in seconds +PULLING_INTERVAL.description=Timespan between data retrieval, in milliseconds ADAPTER_TYPE.title=Adapter Type ADAPTER_TYPE.description=Select whether the adapter pulls data regularly or listens to subscriptions
