From 327681cc3c4094e01aaab734b0d79afa4db32e48 Mon Sep 17 00:00:00 2001 From: gengby <858962040@qq.com> Date: Wed, 4 Jan 2023 15:23:26 +0800 Subject: [PATCH] GX --- .../HailiangSmartplcTestDeviceDriver.java | 91 +++++++++++++------ 1 file changed, 65 insertions(+), 26 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_smart_plc_test/HailiangSmartplcTestDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_smart_plc_test/HailiangSmartplcTestDeviceDriver.java index c18c2d9..141300b 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_smart_plc_test/HailiangSmartplcTestDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_smart_plc_test/HailiangSmartplcTestDeviceDriver.java @@ -80,6 +80,10 @@ public class HailiangSmartplcTestDeviceDriver extends AbstractOpcDeviceDriver im int last_mode = 0; int last_move = 0; int last_error = 0; + int last_action = 0; + int last_number = 0; + int last_container_type = 0; + int last_task = 0; String device_code; @@ -90,33 +94,64 @@ public class HailiangSmartplcTestDeviceDriver extends AbstractOpcDeviceDriver im //请求成功标记 Boolean requireSucess = false; + Boolean requireSucessFullIn = false; @Override public void execute() { String message = null; - device_code = this.getDeviceCode(); - heartbeat = this.itemProtocol.getItem_heartbeat(); - mode = this.itemProtocol.getItem_mode(); - move = this.itemProtocol.getItem_move(); - action = this.itemProtocol.getItem_action(); - error = this.itemProtocol.getItem_error(); - number = this.itemProtocol.getItem_number(); - container_type = this.itemProtocol.getItem_container_type(); - task = this.itemProtocol.getItem_task(); - - - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (move != last_move) { - if (move == 0) { - thingToNothing(); + try { + device_code = this.getDeviceCode(); + heartbeat = this.itemProtocol.getItem_heartbeat(); + mode = this.itemProtocol.getItem_mode(); + move = this.itemProtocol.getItem_move(); + action = this.itemProtocol.getItem_action(); + error = this.itemProtocol.getItem_error(); + number = this.itemProtocol.getItem_number(); + container_type = this.itemProtocol.getItem_container_type(); + task = this.itemProtocol.getItem_task(); + if (mode != last_mode) { + if (mode == 4) { + logServer.deviceExecuteLog(device_code, "", "", "请求标记变化前:requireSucess = " + requireSucess); + requireSucess = false; + logServer.deviceExecuteLog(device_code, "", "", "请求标记变化后:requireSucess = " + requireSucess); + } + if (mode == 5) { + logServer.deviceExecuteLog(device_code, "", "", "请求标记变化前:requireSucessFullIn = " + requireSucessFullIn); + requireSucessFullIn = false; + logServer.deviceExecuteLog(device_code, "", "", "请求标记变化前:requireSucessFullIn = " + requireSucessFullIn); + } + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); } + if (move != last_move) { + logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); + } + if (task != last_task) { + logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); + } + if (action != last_action) { + logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); + } + if (number != last_number) { + logServer.deviceItemValue(this.device_code, "number", String.valueOf(number)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号number:" + last_number + "->" + number); + } + if (container_type != last_container_type) { + logServer.deviceItemValue(this.device_code, "container_type", String.valueOf(container_type)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号container_type:" + last_container_type + "->" + container_type); + } + if (error != last_error) { + logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); + } + } catch (Exception e) { + logServer.deviceExecuteLog(device_code, "", "", "未执行到创建任务代码---" + e.getMessage()); + return; } - if (error != last_error) { - } - if (!this.itemProtocol.getIsonline()) { this.setIsonline(false); @@ -147,7 +182,8 @@ public class HailiangSmartplcTestDeviceDriver extends AbstractOpcDeviceDriver im Date date = new Date(); if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - }else { + } else { + logServer.deviceExecuteLog(device_code, "", "", "开始申请空盘任务-"); //向LMS发送请求,发送终点和托盘类型 jo.put("type", "1"); jo.put("point_code", device_code); @@ -155,7 +191,8 @@ public class HailiangSmartplcTestDeviceDriver extends AbstractOpcDeviceDriver im jo.put("vehicle_type", container_type); String result = acsToWmsService.applyTaskToWms(jo); JSONObject res_jo = JSONObject.parseObject(result); - if (res_jo.getString("status").equals("200")){ + if (res_jo.getString("status").equals("200")) { + logServer.deviceExecuteLog(device_code, "", "", "空盘任务申请成功-"); requireSucess = true; } } @@ -163,11 +200,12 @@ public class HailiangSmartplcTestDeviceDriver extends AbstractOpcDeviceDriver im break; case 5: //满托入库 - if (move == 1 && !requireSucess) { + if (move == 1 && !requireSucessFullIn) { Date date = new Date(); if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - }else { + } else { + logServer.deviceExecuteLog(device_code, "", "", "满托入库申请开始任务-"); //向LMS发送请求,发送起点 jo.put("type", "2"); jo.put("point_code", device_code); @@ -176,8 +214,9 @@ public class HailiangSmartplcTestDeviceDriver extends AbstractOpcDeviceDriver im jo.put("qty", number); String result = acsToWmsService.applyTaskToWms(jo); JSONObject res_jo = JSONObject.parseObject(result); - if (res_jo.getString("status").equals("200")){ - requireSucess = true; + if (res_jo.getString("status").equals("200")) { + requireSucessFullIn = true; + logServer.deviceExecuteLog(device_code, "", "", "满托入库任务申请成功-"); } } }