From 5316c506119ad056a5640650e5e79babe4194d38 Mon Sep 17 00:00:00 2001 From: admin <15939171744@163.com> Date: 星期四, 25 四月 2024 20:33:31 +0800 Subject: [PATCH] - --- jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java | 44 ++++++++++++++++++++++++++------------------ 1 files changed, 26 insertions(+), 18 deletions(-) diff --git a/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java b/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java index 5dd407c..dc802b1 100644 --- a/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java +++ b/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java @@ -34,11 +34,17 @@ public SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + //鏂拌嚜鍔ㄥ伐绔� + public List<String> automaticList = Arrays.asList("OP280", "OP320A","OP320B", "OP340A","OP340B", "OP350A","OP350B", "OP360","OP365","OP370", "OP390", "OP470"); + //鑷姩宸ヤ綅 - public List<String> automaticList = Arrays.asList("OP300","OP280", "OP320", "OP340", "OP350", "OP360","OP370", "OP390", "OP470", "OP530", "OP540"); +// public List<String> automaticList = Arrays.asList("OP300","OP280", "OP320A","OP320B", "OP340", "OP350", "OP360","OP370", "OP390", "OP470", "OP530", "OP540"); //閲囬泦妯$粍宸ヤ綅 - public List<String> moduleCodeList = Arrays.asList("OP300","OP310", "OP320", "OP340", "OP350", "OP330"); + public List<String> moduleCodeList = Arrays.asList("OP300","OP310", "OP340", "OP350", "OP330"); + + //鍖哄垎pack鍨嬪彿鐨勫伐浣� + public List<String> packIdList = Arrays.asList("OP280"); //绌虹殑 public List<String> nullList = Arrays.asList("OP250","OP260"); @@ -73,7 +79,7 @@ public void onSubscribe(String identifier, Object value) { try { - if(null != value) { + if(null != value && Integer.valueOf(value.toString())!= 0) { String[] nodes = identifier.split("[.]"); String thoroughfare = nodes[0];//閫氶亾 String device = nodes[1];//璁惧 @@ -104,24 +110,26 @@ // } //鑷姩宸ヤ綅 - //plc缁欐垜浠竴涓猵ack鐮侊紝鎷縫ack鐮佹牎楠屽嚭鍨嬪彿 - if(moduleCodeList.stream().anyMatch(s -> s.equals(device))){ - //璇绘ā缁勭爜 - String moduleCode = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue().toString(); - String productTye = thoroughfare + "." + device + ".ProductType"; - if(null!=moduleCode && moduleCode.length() == 24){ - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(productTye).value(Integer.valueOf(moduleCode.substring(7,8))).build()); - //杩涚珯淇濆瓨鏁版嵁 + if(automaticList.stream().anyMatch(s -> s.equals(device))){ + //plc缁欐垜浠竴涓ā缁勭爜锛屾嬁妯$粍鐮佹牎楠屽嚭鍨嬪彿 + if(moduleCodeList.stream().anyMatch(s -> s.equals(device))) { + //璇绘ā缁勭爜 + String moduleCode = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue().toString(); + String productTye = thoroughfare + "." + device + ".ProductType"; + if (null != moduleCode && moduleCode.length() == 24) { + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(productTye).value(Integer.valueOf(moduleCode.substring(7, 8))).build()); + //杩涚珯淇濆瓨鏁版嵁 // inSaveDate(thoroughfare,device) - //璁板綍鏁版嵁瀹屾垚 - String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; + //璁板綍鏁版嵁瀹屾垚 + String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build()); + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build()); - //璇锋眰宸ュ崟 - }else { - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); + //璇锋眰宸ュ崟 + } else { + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); + } } }else { //鎵嬪姩宸ヤ綅澶勭悊閫昏緫 @@ -143,7 +151,7 @@ recordDataDoneValue = outSaveDate(thoroughfare,device); //璁板綍鏁版嵁瀹屾垚 String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(Integer.valueOf(RecordDataDoneAddress)).build()); + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(Integer.valueOf(recordDataDoneValue)).build()); }else { //鎵嬪姩宸ヤ綅 WebSocketUsers.sendMessageToUserByText(map.get(device), "END"); -- Gitblit v1.9.3