hutcheb commented on a change in pull request #210: URL: https://github.com/apache/plc4x/pull/210#discussion_r543293832
########## File path: plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaField.java ########## @@ -30,30 +30,34 @@ Licensed to the Apache Software Foundation (ASF) under one */ public class OpcuaField implements PlcField { - public static final Pattern ADDRESS_PATTERN = Pattern.compile("^ns=(?<namespace>\\d+);(?<identifierType>[isgb])=((?<identifier>.+))?"); + public static final Pattern ADDRESS_PATTERN = Pattern.compile("^ns=(?<namespace>\\d+);(?<identifierType>[isgb])=((?<identifier>[^:]+))?(:(?<datatype>[a-zA-Z_]+))?"); private final OpcuaIdentifierType identifierType; private final int namespace; private final String identifier; - protected OpcuaField(int namespace, OpcuaIdentifierType identifierType, String identifier) { + private final String dataType; + + protected OpcuaField(int namespace, OpcuaIdentifierType identifierType, String identifier, String dataType) { this.namespace = namespace; this.identifier = identifier; this.identifierType = identifierType; if (this.identifier == null || this.namespace < 0) { throw new IllegalArgumentException("Identifier can not be null or Namespace can not be lower then 0."); } + this.dataType = dataType != null ? dataType.toUpperCase() : null; } Review comment: At the moment I have to explicitly map between PlcValue types and OPC UA data types when writing data. There's a bunch of if statements in there checking what datatype it is. If people want to extend it and add datatypes they would have to change this logic to take care of the new data type anyway. If we used an enum we could possibly (I'd have to check to see if we would end up using a class lookup) include the OPC UA data type to map it to. This way if people wanted to extend it they would only need to update the mspec as well as add whatever PlcValue class they want. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org