| | |
| | | public class ClientHandler { |
| | | |
| | | // 客户端实例 |
| | | private OpcUaClient client = null; |
| | | public static OpcUaClient client = null; |
| | | |
| | | public List<OpcuaConfResult> b = null; |
| | | |
| | |
| | | opcuaConfParam.setSubscribe(1); |
| | | b=opcuaConfController.mylist(opcuaConfParam); |
| | | } |
| | | String str1 = id.getIdentifier().toString()+":"+value.getValue().toString(); |
| | | //使用Stream API在List<T>中查找元素 |
| | | OpcuaConfResult opcuaConfResult = b.stream() |
| | | .filter(customer ->id.getIdentifier().toString().equals(customer.getNode())) |
| | |
| | | .orElse(null); |
| | | try { |
| | | Class<?> clazz = Class.forName(opcuaConfResult.getRModule()); |
| | | Method method = clazz.getMethod(opcuaConfResult.getRFunction(), String.class); |
| | | method.invoke(clazz.newInstance(), str1); |
| | | Method method = clazz.getMethod(opcuaConfResult.getRFunction(), new Class[] { String.class, |
| | | String.class }); |
| | | method.invoke(clazz.newInstance(),new Object[] { |
| | | new String(id.getIdentifier().toString()), new String(value.getValue().toString()) }); |
| | | } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InstantiationException | |
| | | InvocationTargetException e) { |
| | | e.printStackTrace(); |
| | |
| | | case "boolean": |
| | | value = new Variant(Boolean.parseBoolean(node.getValue().toString())); |
| | | break; |
| | | case "long": |
| | | value = new Variant(Long.parseLong(node.getValue().toString())); |
| | | break; |
| | | } |
| | | DataValue dataValue = new DataValue(value, null, null); |
| | | |