From e17213427dd8000e5cac6ebcaaf1dca5b1327e88 Mon Sep 17 00:00:00 2001 From: psh Date: Tue, 27 Feb 2024 16:40:10 +0800 Subject: [PATCH] fix --- .../hf_rgv_two/HfRGVTwoDeviceDriver.java | 73 +++++++++++++------ 1 file changed, 49 insertions(+), 24 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_rgv_two/HfRGVTwoDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_rgv_two/HfRGVTwoDeviceDriver.java index 07e3da7..5a40393 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_rgv_two/HfRGVTwoDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_rgv_two/HfRGVTwoDeviceDriver.java @@ -33,6 +33,7 @@ import org.openscada.opc.lib.da.Server; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -197,14 +198,12 @@ public class HfRGVTwoDeviceDriver extends AbstractOpcDeviceDriver implements Dev // } // } logServer.deviceInfo("反馈电气信号", this.getDevice_code(), "RGV前工位任务完成,开始反馈电气信号"); - this.writing("to_command1", "0"); - this.writing("to_onset1", "0"); - this.writing("to_target1", "0"); - this.writing("to_task1", "0"); - this.writing("to_command1", "0"); - this.writing("to_onset1", "0"); - this.writing("to_target1", "0"); - this.writing("to_task1", "0"); + Map map = new LinkedHashMap<>(); + map.put("to_onset1","0"); + map.put("to_target1", "0"); + map.put("to_task1","0"); + map.put("to_command1", "0"); + this.writing(map); this.setRequireHeadSucess(false); } } @@ -524,14 +523,12 @@ public class HfRGVTwoDeviceDriver extends AbstractOpcDeviceDriver implements Dev this.isSetAddress(nextDevice); String start_addr = startDevice.getExtraValue().get("address").toString(); String next_addr = nextDevice.getExtraValue().get("address").toString(); - this.writing("to_onset1", start_addr); - this.writing("to_target1", next_addr); - this.writing("to_task1", dto.getInstruction_code()); - this.writing("to_command1", "1"); - this.writing("to_onset1", start_addr); - this.writing("to_target1", next_addr); - this.writing("to_task1", dto.getInstruction_code()); - this.writing("to_command1", "1"); + Map map = new LinkedHashMap<>(); + map.put("to_onset1",start_addr); + map.put("to_target1", next_addr); + map.put("to_task1", dto.getInstruction_code()); + map.put("to_command1", "1"); + this.writing(map); logServer.deviceInfo("RGV申请前工位任务", this.getDevice_code(), "RGV前工位任务指令创建成功,信号写入成功"); } @@ -545,14 +542,12 @@ public class HfRGVTwoDeviceDriver extends AbstractOpcDeviceDriver implements Dev this.isSetAddress(nextDevice); String start_addr = startDevice.getExtraValue().get("address").toString(); String next_addr = nextDevice.getExtraValue().get("address").toString(); - this.writing("to_onset2", start_addr); - this.writing("to_target2", next_addr); - this.writing("to_task2", dto.getInstruction_code()); - this.writing("to_command2", "1"); - this.writing("to_onset2", start_addr); - this.writing("to_target2", next_addr); - this.writing("to_task2", dto.getInstruction_code()); - this.writing("to_command2", "1"); + Map map = new LinkedHashMap<>(); + map.put("to_onset2",start_addr); + map.put("to_target2", next_addr); + map.put("to_task2", dto.getInstruction_code()); + map.put("to_command2", "1"); + this.writing(map); logServer.deviceInfo("RGV申请后工位任务", this.getDevice_code(), "RGV后工位任务指令创建成功,信号写入成功"); } @@ -572,6 +567,36 @@ public class HfRGVTwoDeviceDriver extends AbstractOpcDeviceDriver implements Dev return false; } } + public void writing(Map map) { + Map itemMap = new LinkedHashMap<>(); + map.forEach((key, value) -> { + if (ObjectUtil.isNotEmpty(value)) { + itemMap.put(getToParam() + key, value); + } + }); + if (ObjectUtil.isNotEmpty(itemMap)) { + try { + this.checkcontrol(itemMap); + } catch (Exception e) { + e.printStackTrace(); + try{ + this.checkcontrol(itemMap); + } catch (Exception e1){ + e1.printStackTrace(); + } + } + logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap); + } + } + + /** + * 抽取统一下发电气信号前缀 + * + * @return + */ + public String getToParam() { + return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; + } public void writing(String param, String value) {