diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java index abc3185..e494b58 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java @@ -29,7 +29,7 @@ public interface NDCAgvService { */ public void sendAgvInstToNDC(String agv_system_type,Instruction inst) throws Exception; - public byte[] sendAgvOneModeInst(int phase, int index,int result); + public byte[] sendAgvOneModeInst(int phase, int index,int result,int pickup,int release); public byte[] sendAgvTwoModeInst(int phase, int index,int result); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java index 35209ec..e317808 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java @@ -83,15 +83,16 @@ public class NDCAgvServiceImpl implements NDCAgvService { int start_height = Integer.parseInt(task.getStart_height()); int next_height = Integer.parseInt(task.getNext_height()); int type; - if (start_height != 0 && next_height != 0) { - type = 1; - } else if (start_height != 0) { - type = 2; - } else if (next_height != 0) { - type = 3; - } else { - type = 4; - } +// if (start_height != 0 && next_height != 0) { +// type = 1; +// } else if (start_height != 0) { +// type = 2; +// } else if (next_height != 0) { +// type = 3; +// } else { +// type = 4; +// } + type = 1; int priority = Integer.parseInt(inst.getPriority()) + 128; DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); @@ -107,10 +108,10 @@ public class NDCAgvServiceImpl implements NDCAgvService { byte fhdhigh = (byte) IntToHexHigh(nextAddress); byte fhdlow = (byte) IntToHexLow(nextAddress); byte prioritylow = (byte) IntToHexLow(priority); - byte qhghigh = (byte) IntToHexHigh(start_height); - byte qhglow = (byte) IntToHexLow(start_height); - byte fhghigh = (byte) IntToHexHigh(next_height); - byte fhglow = (byte) IntToHexLow(next_height); +// byte qhghigh = (byte) IntToHexHigh(start_height); +// byte qhglow = (byte) IntToHexLow(start_height); +// byte fhghigh = (byte) IntToHexHigh(next_height); +// byte fhglow = (byte) IntToHexLow(next_height); String str = "十进制下发:"; String str1 = "十六进制下发:"; str += "ikey:" + (Integer.parseInt(instcode)); @@ -123,27 +124,25 @@ public class NDCAgvServiceImpl implements NDCAgvService { str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF); str += "/priority:" + (priority); str1 += "/priority:" + hexToString(prioritylow & 0xFF); - str += "/qhg:" + (start_height); - str1 += "/qhg:" + hexToString(qhghigh & 0XFF) + hexToString(qhglow & 0XFF); - str += "/fhg:" + (next_height); - str1 += "/fhg:" + hexToString(fhghigh & 0XFF) + hexToString(fhglow & 0XFF); +// str += "/qhg:" + (start_height); +// str1 += "/qhg:" + hexToString(qhghigh & 0XFF) + hexToString(qhglow & 0XFF); +// str += "/fhg:" + (next_height); +// str1 += "/fhg:" + hexToString(fhghigh & 0XFF) + hexToString(fhglow & 0XFF); System.out.println(str); System.out.println(str1); byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X16, + (byte) 0X00, (byte) 0X12, (byte) 0X00, (byte) 0X01, (byte) 0X00, (byte) 0X71, - (byte) 0X00, (byte) 0X12, + (byte) 0X00, (byte) 0X0E, (byte) 0X01, prioritylow, (byte) 0X00, (byte) 0X01, (byte) ikeyhigh, (byte) ikeylow, (byte) ikeyhigh, (byte) ikeylow, (byte) typehigh, (byte) typelow, (byte) qhdhigh, (byte) qhdlow, - (byte) fhdhigh, (byte) fhdlow, - (byte) qhghigh, (byte) qhglow, - (byte) fhghigh, (byte) fhglow + (byte) fhdhigh, (byte) fhdlow }; log.info("下发AGV作业指令--{}", str1); log.info("下发agv指令数据{}" ,Bytes2HexString(b)); @@ -153,22 +152,28 @@ public class NDCAgvServiceImpl implements NDCAgvService { } @Override - public byte[] sendAgvOneModeInst(int phase, int index, int result) { + public byte[] sendAgvOneModeInst(int phase, int index, int result,int pickup,int release) { if (phase < 0 || index < 0) return null; byte indexhigh = (byte) IntToHexHigh(index); byte indexlow = (byte) IntToHexLow(index); byte phasehigh = (byte) IntToHexHigh(phase); byte phaselow = (byte) IntToHexLow(phase); + byte pickuphigh = (byte) IntToHexHigh(pickup); + byte pickuplow = (byte) IntToHexLow(pickup); + byte releasehigh = (byte) IntToHexHigh(release); + byte releaselow = (byte) IntToHexLow(release); byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X0A, + (byte) 0X00, (byte) 0X0E, (byte) 0X00, (byte) 0X01, (byte) 0X00, (byte) 0X6D, - (byte) 0X00, (byte) 0X06, + (byte) 0X00, (byte) 0X0A, (byte) indexhigh, (byte) indexlow, (byte) 0X01, (byte) 0X14, + (byte) phasehigh, (byte) phaselow, + (byte) phasehigh, (byte) phaselow, (byte) phasehigh, (byte) phaselow }; diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java b/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java index cad902d..34ee596 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java @@ -166,7 +166,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { inst.setSend_status("1"); instructionService.update(inst); } - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0); } //任务完毕 //(无车id及状态) @@ -176,13 +176,13 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { } else { log.warn("指令号:{},未反馈wms任务完成,因为agv上报指令号查询指令为空!"); } - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0); log.info("指令号:{},已反馈agv任务完成!"); } //请求删除任务 //(需要WCS反馈) else if (phase == 0x30) { - data = NDCAgvService.sendAgvOneModeInst(0x8F, index, 0); + data = NDCAgvService.sendAgvOneModeInst(0x8F, index, 0,0,0); } //任务删除确认 //(需要WCS反馈) @@ -193,7 +193,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { taskService.cancel(inst.getTask_id()); } - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0); } else { //上报异常信息 diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java index bb85b4d..0a2aa15 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java @@ -27,6 +27,7 @@ import org.nl.acs.log.service.DeviceExecuteLogService; import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.task.service.TaskService; +import org.nl.acs.task.service.dto.TaskDto; import org.nl.acs.task.service.impl.TaskServiceImpl; import org.nl.modules.system.service.ParamService; import org.nl.modules.system.service.impl.ParamServiceImpl; @@ -118,7 +119,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic if (arr[18] * 256 + arr[19] == 0) { } - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0); } //普通站点 @@ -173,30 +174,40 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic return; } + + TaskDto task =taskService.findById(inst.getTask_id()); + int start_height= ObjectUtil.isNotEmpty(task.getStart_height())?Integer.parseInt(task.getStart_height()):0; + int next_height= ObjectUtil.isNotEmpty(task.getNext_height())?Integer.parseInt(task.getNext_height()):0; // Object reqWms = device.getExtraValue().get("reqWms"); // if (ObjectUtil.isNotEmpty(reqWms) && reqWms.toString().equals("true")) { -// JSONArray req = new JSONArray(); -// JSONObject map = new JSONObject(); -// map.put("vehicle_code", inst.getVehicle_code()); -// map.put("status", "1"); -// map.put("device_code", inst.getStart_point_code()); -// map.put("task_code", inst.getTask_code()); -// req.add(map); -// HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req); -// if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) { -// JSONObject resp = JSONObject.parseObject(httpResponse.body()); -// if (resp.getInteger("status") == 200) { -// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); -// log.info("指令号:{},acs请求wms取货申请成功,wms允许agv申请取货,已反馈agv允许取货", inst.getInstruction_code()); -// } else { -// log.warn("指令号:{},acs请求wms取货申请成功,wms不允许agv申请取货,未反馈agv允许取货", inst.getInstruction_code()); -// } -// } else { -// log.warn("指令号:{},acs请求wms取货申请失败,连接被拒绝,未反馈agv允许取货", inst.getInstruction_code()); -// } -// } else { - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); -// } + if(!StrUtil.startWith(task.getTask_code(), '-')){ + JSONArray req = new JSONArray(); + JSONObject map = new JSONObject(); + map.put("vehicle_code", inst.getVehicle_code()); + map.put("status", "1"); + map.put("device_code", inst.getStart_point_code()); + map.put("task_code", inst.getTask_code()); + req.add(map); + HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req); + if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) { + JSONObject resp = JSONObject.parseObject(httpResponse.body()); + if (resp.getInteger("status") == 200) { + start_height=resp.getInteger("start_height"); + next_height=resp.getInteger("next_height"); + task.setStart_height(String.valueOf(start_height)); + task.setNext_height(String.valueOf(next_height)); + taskService.update(task); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,start_height,next_height); + log.info("指令号:{},acs请求wms取货申请成功,wms允许agv申请取货,已反馈agv允许取货", inst.getInstruction_code()); + } else { + log.warn("指令号:{},acs请求wms取货申请成功,wms不允许agv申请取货,未反馈agv允许取货", inst.getInstruction_code()); + } + } else { + log.warn("指令号:{},acs请求wms取货申请失败,连接被拒绝,未反馈agv允许取货", inst.getInstruction_code()); + } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,start_height,next_height); + } //取货完毕 //(需要WCS反馈) } else if (phase == 0x05) { @@ -245,13 +256,13 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic req.add(map); HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req); if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) { - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0); log.info("指令号:{},acs反馈wms取货完成成功,wms允许agv取货完成,已反馈agv取货完成", inst.getInstruction_code()); } else { log.warn("指令号:{},acs反馈wms取货完成成功,wms不允许agv取货完成,未反馈agv取货完成", inst.getInstruction_code()); } // } else { -// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); +// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0); // } //到达放货点 //(需要WCS反馈) @@ -299,7 +310,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic // if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) { // JSONObject resp = JSONObject.parseObject(httpResponse.body()); // if (resp.getInteger("status") == 200) { -// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); +// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0); // log.info("指令号:{},acs请求wms放货申请成功,wms允许agv申请放货,已反馈agv允许放货", inst.getInstruction_code()); // } else { // log.warn("指令号:{},acs请求wms放货申请成功,wms不允许agv申请放货,未反馈agv允许放货", inst.getInstruction_code()); @@ -308,7 +319,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic // log.warn("指令号:{},acs请求wms放货申请失败,连接被拒绝,未反馈agv允许放货", inst.getInstruction_code()); // } // } else { - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0); // } //放货完毕 //(需要WCS反馈) @@ -355,13 +366,13 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic req.add(map); HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req); if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) { - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0); log.info("指令号:{},acs请求wms放货申请成功,wms允许agv申请放货,已反馈agv允许放货", inst.getInstruction_code()); } else { log.warn("指令号:{},acs请求wms放货申请失败,连接被拒绝,未反馈agv允许放货", inst.getInstruction_code()); } // } else { -// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); +// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0); // } } //到达位置点 @@ -370,13 +381,13 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic //1、根据货位id找到对应三工位设备,赋给agv属性地址对应的满料位设备 agvaddr = arr[18] * 256 + arr[19]; agvaddr_copy = agvaddr; - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0); logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); } else if (phase == 0x50) {//进入交通灯区域 - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0); logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); } else if (phase == 0x51) {//离开交通灯区域 - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0); logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); } else if (phase == 0x67) {//agv异常 // if (ikey == 0) { @@ -394,7 +405,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic // dto.setError_info(error_message); // deviceErrorLogService.create(dto); // } - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0); last_error = error; } else if (phase == 0x70) { //x坐标 diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java index 70654b0..cd5fd76 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java @@ -126,7 +126,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple if (ObjectUtil.isNotEmpty(inst)) { inst.setExecute_status("1"); instructionService.update(inst); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0); + byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0,0,0); agvphase = 0; index = 0; inst = null; @@ -141,7 +141,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple if (ObjectUtil.isNotEmpty(inst)) { inst.setExecute_status("2"); instructionService.update(inst); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0); + byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0,0,0); // OneNDCSocketConnectionAutoRun.write(data); agvphase = 0; index = 0; @@ -157,7 +157,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple if (ObjectUtil.isNotEmpty(inst)) { inst.setExecute_status("5"); instructionService.update(inst); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0); + byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0,0,0); // OneNDCSocketConnectionAutoRun.write(data); agvphase = 0; index = 0; @@ -172,7 +172,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple if (ObjectUtil.isNotEmpty(inst)) { inst.setExecute_status("6"); instructionService.update(inst); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0); + byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0,0,0); // OneNDCSocketConnectionAutoRun.write(data); agvphase = 0; index = 0;