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 2022/02/21 20:01:18 UTC
[incubator-streampipes] branch dev updated: [hotfix] Fix problem with type guessing in opc ua 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.git
The following commit(s) were added to refs/heads/dev by this push:
new e8f51ca [hotfix] Fix problem with type guessing in opc ua adapter
e8f51ca is described below
commit e8f51ca7432473109854eed5836f4ac051ca6c42
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Mon Feb 21 21:01:04 2022 +0100
[hotfix] Fix problem with type guessing in opc ua adapter
---
.../connect/iiot/adapters/opcua/OpcUaNodeBrowser.java | 2 +-
.../connect/iiot/adapters/opcua/utils/OpcUaTypes.java | 10 ++++++++--
ui/cypress/tests/adapter/opcAdapter.ts | 4 ++--
ui/src/app/connect/services/data-type.service.ts | 10 +++++++++-
4 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/adapters/opcua/OpcUaNodeBrowser.java b/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/adapters/opcua/OpcUaNodeBrowser.java
index 6429aa4..5a9f2fb 100644
--- a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/adapters/opcua/OpcUaNodeBrowser.java
+++ b/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/adapters/opcua/OpcUaNodeBrowser.java
@@ -81,7 +81,7 @@ public class OpcUaNodeBrowser {
UaNode node = addressSpace.getNode(nodeId);
if (node instanceof BaseDataVariableTypeNode) {
- UInteger value = UInteger.valueOf(((BaseDataVariableTypeNode) node).getDataType().getType().getValue());
+ UInteger value = (UInteger) ((BaseDataVariableTypeNode) node).getDataType().getIdentifier();
return new OpcNode(node.getDisplayName().getText(), OpcUaTypes.getType(value), node.getNodeId());
}
diff --git a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/adapters/opcua/utils/OpcUaTypes.java b/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/adapters/opcua/utils/OpcUaTypes.java
index ec3c068..0dc1efc 100644
--- a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/adapters/opcua/utils/OpcUaTypes.java
+++ b/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/adapters/opcua/utils/OpcUaTypes.java
@@ -30,13 +30,19 @@ public class OpcUaTypes {
* @return StreamPipes internal data type
*/
public static Datatypes getType(UInteger o) {
- if (UInteger.valueOf(4).equals(o) | UInteger.valueOf(6).equals(o) | UInteger.valueOf(27).equals(o)) {
+ if (UInteger.valueOf(4).equals(o) |
+ UInteger.valueOf(5).equals(o) |
+ UInteger.valueOf(6).equals(o) |
+ UInteger.valueOf(7).equals(o) |
+ UInteger.valueOf(8).equals(o) |
+ UInteger.valueOf(9).equals(o) |
+ UInteger.valueOf(27).equals(o)) {
return Datatypes.Integer;
} else if (UInteger.valueOf(8).equals(o) ) {
return Datatypes.Long;
} else if (UInteger.valueOf(11).equals(o)) {
return Datatypes.Double;
- } else if (UInteger.valueOf(10).equals(o) | UInteger.valueOf(26).equals(o)) {
+ } else if (UInteger.valueOf(10).equals(o) | UInteger.valueOf(26).equals(o) | UInteger.valueOf(50).equals(o)) {
return Datatypes.Float;
} else if (UInteger.valueOf(1).equals(o)) {
return Datatypes.Boolean;
diff --git a/ui/cypress/tests/adapter/opcAdapter.ts b/ui/cypress/tests/adapter/opcAdapter.ts
index a4190b3..74ad8ba 100644
--- a/ui/cypress/tests/adapter/opcAdapter.ts
+++ b/ui/cypress/tests/adapter/opcAdapter.ts
@@ -47,11 +47,11 @@ describe('Test OPC-UA Adapter Subscription Mode', () => {
const getAdapterBuilder = (pullMode: boolean) => {
- const host: string = ParameterUtils.getEnvOrDefault('OPC_HOST', 'opcua');
+ const host: string = ParameterUtils.get('ipe-girlitz.fzi.de', 'opcua');
const builder = SpecificAdapterBuilder
.create('OPC_UA')
- .setName('OPC UA Test' + pullMode ? '(Pull)' : '(Subscription');
+ .setName('OPC UA Test ' + (pullMode ? '(Pull)' : '(Subscription)'));
if (pullMode) {
builder.addInput('select', 'adapter_type-pull_mode', 'check');
diff --git a/ui/src/app/connect/services/data-type.service.ts b/ui/src/app/connect/services/data-type.service.ts
index 649e7e7..44165a0 100644
--- a/ui/src/app/connect/services/data-type.service.ts
+++ b/ui/src/app/connect/services/data-type.service.ts
@@ -30,6 +30,10 @@ export class DataTypesService {
url: 'http://www.w3.org/2001/XMLSchema#boolean'
},
{
+ label: 'Double - A number, e.g., \'1.25\'',
+ url: 'http://www.w3.org/2001/XMLSchema#double'
+ },
+ {
label: 'Float - A number, e.g., \'1.25\'',
url: 'http://www.w3.org/2001/XMLSchema#float'
}, {
@@ -74,7 +78,11 @@ export class DataTypesService {
}
isNumeric(uri: string) {
- const numericDataTypes = ['http://www.w3.org/2001/XMLSchema#float', 'http://www.w3.org/2001/XMLSchema#integer', 'http://www.w3.org/2001/XMLSchema#long'];
+ const numericDataTypes = [
+ 'http://www.w3.org/2001/XMLSchema#float',
+ 'http://www.w3.org/2001/XMLSchema#double',
+ 'http://www.w3.org/2001/XMLSchema#integer',
+ 'http://www.w3.org/2001/XMLSchema#long'];
return numericDataTypes.includes(uri);
}