@Test public void readVariables() { try { PlcConnection opcuaConnection = new PlcDriverManager().getConnection(tcpConnectionAddress); assert opcuaConnection.isConnected(); PlcReadRequest.Builder builder = opcuaConnection.readRequestBuilder(); builder.addItem("Bool", BOOL_IDENTIFIER_READ_WRITE); builder.addItem("Byte", BYTE_IDENTIFIER_READ_WRITE); builder.addItem("Double", DOUBLE_IDENTIFIER_READ_WRITE); builder.addItem("Float", FLOAT_IDENTIFIER_READ_WRITE); builder.addItem("Int16", INT16_IDENTIFIER_READ_WRITE); builder.addItem("Int32", INT32_IDENTIFIER_READ_WRITE); builder.addItem("Int64", INT64_IDENTIFIER_READ_WRITE); builder.addItem("Integer", INTEGER_IDENTIFIER_READ_WRITE); builder.addItem("SByte", SBYTE_IDENTIFIER_READ_WRITE); builder.addItem("String", STRING_IDENTIFIER_READ_WRITE); builder.addItem("UInt16", UINT16_IDENTIFIER_READ_WRITE); builder.addItem("UInt32", UINT32_IDENTIFIER_READ_WRITE); builder.addItem("UInt64", UINT64_IDENTIFIER_READ_WRITE); builder.addItem("UInteger", UINTEGER_IDENTIFIER_READ_WRITE); builder.addItem("DoesNotExists", DOES_NOT_EXIST_IDENTIFIER_READ_WRITE); PlcReadRequest request = builder.build(); PlcReadResponse response = request.execute().get(); assert response.getResponseCode("Bool").equals(PlcResponseCode.OK); assert response.getResponseCode("Byte").equals(PlcResponseCode.OK); assert response.getResponseCode("Double").equals(PlcResponseCode.OK); assert response.getResponseCode("Float").equals(PlcResponseCode.OK); assert response.getResponseCode("Int16").equals(PlcResponseCode.OK); assert response.getResponseCode("Int32").equals(PlcResponseCode.OK); assert response.getResponseCode("Int64").equals(PlcResponseCode.OK); assert response.getResponseCode("Integer").equals(PlcResponseCode.OK); assert response.getResponseCode("SByte").equals(PlcResponseCode.OK); assert response.getResponseCode("String").equals(PlcResponseCode.OK); assert response.getResponseCode("UInt16").equals(PlcResponseCode.OK); assert response.getResponseCode("UInt32").equals(PlcResponseCode.OK); assert response.getResponseCode("UInt64").equals(PlcResponseCode.OK); assert response.getResponseCode("UInteger").equals(PlcResponseCode.OK); assert response.getResponseCode("DoesNotExists").equals(PlcResponseCode.NOT_FOUND); opcuaConnection.close(); assert !opcuaConnection.isConnected(); } catch (Exception e) { fail("Exception during readVariables Test EXCEPTION: " + e.getMessage()); } }
@Override public PlcConnection getConnection(String url) throws PlcConnectionException { Matcher matcher = OPCUA_URI_PATTERN.matcher(url); if (!matcher.matches()) { throw new PlcConnectionException( "Connection url doesn't match the format 'opcua:{type} } String host = matcher.group("host"); String portString = matcher.group("port"); Integer port = StringUtils.isNotBlank(portString) ? Integer.parseInt(portString) : null; String params = matcher.group("params") != null ? matcher.group("params").substring(1) : null; try { return opcuaConnectionFactory.opcuaTcpPlcConnectionOf(InetAddress.getByName(host), port, params, requestTimeout); } catch (UnknownHostException e) { throw new PlcConnectionException(e); } }
OpcuaPlcDriver implements PlcDriver { @Override public PlcConnection getConnection(String url) throws PlcConnectionException { Matcher matcher = OPCUA_URI_PATTERN.matcher(url); if (!matcher.matches()) { throw new PlcConnectionException( "Connection url doesn't match the format 'opcua:{type} } String host = matcher.group("host"); String portString = matcher.group("port"); Integer port = StringUtils.isNotBlank(portString) ? Integer.parseInt(portString) : null; String params = matcher.group("params") != null ? matcher.group("params").substring(1) : null; try { return opcuaConnectionFactory.opcuaTcpPlcConnectionOf(InetAddress.getByName(host), port, params, requestTimeout); } catch (UnknownHostException e) { throw new PlcConnectionException(e); } } }
OpcuaPlcDriver implements PlcDriver { @Override public PlcConnection getConnection(String url) throws PlcConnectionException { Matcher matcher = OPCUA_URI_PATTERN.matcher(url); if (!matcher.matches()) { throw new PlcConnectionException( "Connection url doesn't match the format 'opcua:{type} } String host = matcher.group("host"); String portString = matcher.group("port"); Integer port = StringUtils.isNotBlank(portString) ? Integer.parseInt(portString) : null; String params = matcher.group("params") != null ? matcher.group("params").substring(1) : null; try { return opcuaConnectionFactory.opcuaTcpPlcConnectionOf(InetAddress.getByName(host), port, params, requestTimeout); } catch (UnknownHostException e) { throw new PlcConnectionException(e); } }  }
OpcuaPlcDriver implements PlcDriver { @Override public PlcConnection getConnection(String url) throws PlcConnectionException { Matcher matcher = OPCUA_URI_PATTERN.matcher(url); if (!matcher.matches()) { throw new PlcConnectionException( "Connection url doesn't match the format 'opcua:{type} } String host = matcher.group("host"); String portString = matcher.group("port"); Integer port = StringUtils.isNotBlank(portString) ? Integer.parseInt(portString) : null; String params = matcher.group("params") != null ? matcher.group("params").substring(1) : null; try { return opcuaConnectionFactory.opcuaTcpPlcConnectionOf(InetAddress.getByName(host), port, params, requestTimeout); } catch (UnknownHostException e) { throw new PlcConnectionException(e); } }  @Override String getProtocolCode(); @Override String getProtocolName(); @Override PlcConnection getConnection(String url); @Override PlcConnection getConnection(String url, PlcAuthentication authentication); @Override OpcuaField prepareField(String query); }
OpcuaPlcDriver implements PlcDriver { @Override public PlcConnection getConnection(String url) throws PlcConnectionException { Matcher matcher = OPCUA_URI_PATTERN.matcher(url); if (!matcher.matches()) { throw new PlcConnectionException( "Connection url doesn't match the format 'opcua:{type} } String host = matcher.group("host"); String portString = matcher.group("port"); Integer port = StringUtils.isNotBlank(portString) ? Integer.parseInt(portString) : null; String params = matcher.group("params") != null ? matcher.group("params").substring(1) : null; try { return opcuaConnectionFactory.opcuaTcpPlcConnectionOf(InetAddress.getByName(host), port, params, requestTimeout); } catch (UnknownHostException e) { throw new PlcConnectionException(e); } }  @Override String getProtocolCode(); @Override String getProtocolName(); @Override PlcConnection getConnection(String url); @Override PlcConnection getConnection(String url, PlcAuthentication authentication); @Override OpcuaField prepareField(String query); static final Pattern INET_ADDRESS_PATTERN; static final Pattern OPCUA_URI_PARAM_PATTERN; static final Pattern OPCUA_URI_PATTERN; }