|
|
@ -61,7 +61,7 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device |
|
|
|
|
|
|
|
String last_mode = "0"; |
|
|
|
private Date instruction_require_time = new Date(); |
|
|
|
private int instruction_require_time_out = 1000; |
|
|
|
private int instruction_require_time_out = 3000; |
|
|
|
int is_charging = 0; |
|
|
|
int stop = 0; |
|
|
|
int DI0 = 0; |
|
|
@ -186,6 +186,7 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device |
|
|
|
} |
|
|
|
|
|
|
|
if (address != last_address) { |
|
|
|
|
|
|
|
LuceneLogDto logDto = new LuceneLogDto(); |
|
|
|
logDto.setDevice_code(device_code); |
|
|
|
logDto.setContent("信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.address + "变更从" + this.last_address + "->" + this.address); |
|
|
@ -249,11 +250,11 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device |
|
|
|
if (ObjectUtil.isEmpty(inst)) { |
|
|
|
if (electricity != 0 && electricity < min_electric && address != charge_point && (navigation_status == 0 || navigation_status == 4)) { |
|
|
|
log.info("下发充电:{}", charge_point); |
|
|
|
writing("to_address", charge_point); |
|
|
|
feedAgvTaskStatus(inst, "5"); |
|
|
|
} |
|
|
|
if (electricity != 0 && electricity > cancle_electric && address == charge_point && (navigation_status == 0 || navigation_status == 4)) { |
|
|
|
log.info("下发回休息点:{}", relax_point); |
|
|
|
writing("to_address", relax_point); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
TaskDto task = taskserver.findByCodeFromCache(inst.getTask_code()); |
|
|
@ -268,40 +269,42 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device |
|
|
|
if (StrUtil.equals("0", inst.getInstruction_status())) { |
|
|
|
log.info("下发指令号{},起点{}", inst.getInstruction_code(), start_device); |
|
|
|
//判断指令起点与任务起点是否相同
|
|
|
|
if(StrUtil.equals(task.getStart_device_code(),inst.getStart_device_code())){ |
|
|
|
feedAgvTaskStatus(inst, "1"); |
|
|
|
} else { |
|
|
|
//不同的话是按照路由生成的指令
|
|
|
|
LuceneLogDto logDto = new LuceneLogDto(); |
|
|
|
logDto.setDevice_code(device_code); |
|
|
|
logDto.setInstruct_code(inst.getInstruction_code()); |
|
|
|
logDto.setTask_code(inst.getTask_code()); |
|
|
|
logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_address + " value:" + start_device_code); |
|
|
|
luceneExecuteLogService.deviceExecuteLog(logDto); |
|
|
|
writing("to_address", start_device_code); |
|
|
|
inst.setInstruction_status("1"); |
|
|
|
instructionService.update(inst); |
|
|
|
} |
|
|
|
feedAgvTaskStatus(inst, "1"); |
|
|
|
} |
|
|
|
|
|
|
|
//取货完成请求离开
|
|
|
|
if (StrUtil.equals("1", inst.getInstruction_status()) && address == start_device_code && stop == 1 && StrUtil.equals(inst.getExecute_status(),"1")) { |
|
|
|
if (StrUtil.equals("1", inst.getInstruction_status()) && address == 5 && stop == 1 && StrUtil.equals(inst.getExecute_status(),"1")) { |
|
|
|
//请求wms是否允许从取货点离开
|
|
|
|
feedAgvTaskStatus(inst, "2"); |
|
|
|
} |
|
|
|
|
|
|
|
//请求放货
|
|
|
|
if (StrUtil.equals("1", inst.getInstruction_status()) && address == next_device_code && stop == 1 && StrUtil.equals(inst.getExecute_status(),"2")) { |
|
|
|
if (StrUtil.equals("1", inst.getInstruction_status()) && address == 2 && stop == 1 && StrUtil.equals(inst.getExecute_status(),"2")) { |
|
|
|
//请求wms是否允许进入放货
|
|
|
|
feedAgvTaskStatus(inst, "3"); |
|
|
|
|
|
|
|
} |
|
|
|
//放货完成 完成任务回休息点
|
|
|
|
if (StrUtil.equals("1", inst.getInstruction_status()) && address == next_device_code && stop == 1 && StrUtil.equals(inst.getExecute_status(),"3")) { |
|
|
|
if (StrUtil.equals("1", inst.getInstruction_status()) && address == 1 && stop == 1 && StrUtil.equals(inst.getExecute_status(),"3")) { |
|
|
|
feedAgvTaskStatus(inst, "4"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//请求开门
|
|
|
|
if ( (address == 3 || address == 11 ) && stop == 1 ) { |
|
|
|
feedAgvAction("5"); |
|
|
|
} |
|
|
|
|
|
|
|
//请求关门
|
|
|
|
if ( (address == 9 || address == 10 ) && stop == 1 ) { |
|
|
|
feedAgvAction("6"); |
|
|
|
} |
|
|
|
|
|
|
|
//请求充电
|
|
|
|
if ( address == 4 && stop == 1 ) { |
|
|
|
feedAgvAction( "7"); |
|
|
|
} |
|
|
|
last_home_relocation = home_relocation; |
|
|
|
last_address = address; |
|
|
|
last_next_address = next_address; |
|
|
@ -326,9 +329,13 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
String mode = ""; |
|
|
|
jo.put("device_name", this.getDevice().getDevice_name()); |
|
|
|
jo.put("mode", mode); |
|
|
|
jo.put("message", this.getMessage()); |
|
|
|
jo.put("is_click", true); |
|
|
|
jo.put("address", address); |
|
|
|
jo.put("stop", stop); |
|
|
|
jo.put("electricity", electricity); |
|
|
|
jo.put("is_charging", is_charging); |
|
|
|
|
|
|
|
return jo; |
|
|
|
} |
|
|
|
|
|
|
@ -350,12 +357,13 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device |
|
|
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); |
|
|
|
return false; |
|
|
|
} else { |
|
|
|
Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code()); |
|
|
|
Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code()); |
|
|
|
int start_device_code = Integer.parseInt(start_device.getAddress()); |
|
|
|
int next_device_code = Integer.parseInt(next_device.getAddress()); |
|
|
|
|
|
|
|
//请求WMS允许取货
|
|
|
|
if (StrUtil.equals(type, "1")) { |
|
|
|
Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code()); |
|
|
|
Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code()); |
|
|
|
int start_device_code = Integer.parseInt(start_device.getAddress()); |
|
|
|
int next_device_code = Integer.parseInt(next_device.getAddress()); |
|
|
|
JSONArray ja = new JSONArray(); |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("vehicle_code", inst.getVehicle_code()); |
|
|
@ -364,22 +372,30 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device |
|
|
|
jo.put("task_code", inst.getTask_code()); |
|
|
|
ja.add(jo); |
|
|
|
HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); |
|
|
|
LuceneLogDto logDto = new LuceneLogDto(); |
|
|
|
|
|
|
|
logDto.setDevice_code(device_code); |
|
|
|
logDto.setContent("请求参数:" + ja.toString() ); |
|
|
|
luceneExecuteLogService.deviceExecuteLog(logDto); |
|
|
|
luceneExecuteLogService.deviceExecuteLog(logDto); |
|
|
|
|
|
|
|
if (resp.getStatus() ==200) { |
|
|
|
LuceneLogDto logDto = new LuceneLogDto(); |
|
|
|
logDto.setDevice_code(device_code); |
|
|
|
logDto.setInstruct_code(inst.getInstruction_code()); |
|
|
|
logDto.setTask_code(inst.getTask_code()); |
|
|
|
logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_address + " value:" + start_device_code); |
|
|
|
luceneExecuteLogService.deviceExecuteLog(logDto); |
|
|
|
writing("to_address", start_device_code); |
|
|
|
|
|
|
|
inst.setInstruction_status("1"); |
|
|
|
inst.setExecute_status("1"); |
|
|
|
instructionService.update(inst); |
|
|
|
writing("to_line", 1); |
|
|
|
|
|
|
|
} else { |
|
|
|
writing("to_line", 1); |
|
|
|
|
|
|
|
} |
|
|
|
//取货完成请求离开
|
|
|
|
} else if (StrUtil.equals(type, "2")) { |
|
|
|
Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code()); |
|
|
|
Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code()); |
|
|
|
int start_device_code = Integer.parseInt(start_device.getAddress()); |
|
|
|
int next_device_code = Integer.parseInt(next_device.getAddress()); |
|
|
|
JSONArray ja = new JSONArray(); |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("vehicle_code", inst.getVehicle_code()); |
|
|
@ -389,13 +405,7 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device |
|
|
|
ja.add(jo); |
|
|
|
HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); |
|
|
|
if (resp.getStatus() ==200) { |
|
|
|
LuceneLogDto logDto = new LuceneLogDto(); |
|
|
|
logDto.setDevice_code(device_code); |
|
|
|
logDto.setInstruct_code(inst.getInstruction_code()); |
|
|
|
logDto.setTask_code(inst.getTask_code()); |
|
|
|
logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_address + " value:" + start_device_code); |
|
|
|
luceneExecuteLogService.deviceExecuteLog(logDto); |
|
|
|
writing("to_address", next_device_code); |
|
|
|
|
|
|
|
inst.setInstruction_status("1"); |
|
|
|
inst.setExecute_status("2"); |
|
|
|
instructionService.update(inst); |
|
|
@ -404,6 +414,10 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device |
|
|
|
} |
|
|
|
//请求放货
|
|
|
|
} else if (StrUtil.equals(type, "3")) { |
|
|
|
Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code()); |
|
|
|
Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code()); |
|
|
|
int start_device_code = Integer.parseInt(start_device.getAddress()); |
|
|
|
int next_device_code = Integer.parseInt(next_device.getAddress()); |
|
|
|
JSONArray ja = new JSONArray(); |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("vehicle_code", inst.getVehicle_code()); |
|
|
@ -413,20 +427,17 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device |
|
|
|
ja.add(jo); |
|
|
|
HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); |
|
|
|
if (resp.getStatus() ==200) { |
|
|
|
LuceneLogDto logDto = new LuceneLogDto(); |
|
|
|
logDto.setDevice_code(device_code); |
|
|
|
logDto.setInstruct_code(inst.getInstruction_code()); |
|
|
|
logDto.setTask_code(inst.getTask_code()); |
|
|
|
logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_address + " value:" + start_device_code); |
|
|
|
luceneExecuteLogService.deviceExecuteLog(logDto); |
|
|
|
inst.setInstruction_status("1"); |
|
|
|
inst.setExecute_status("3"); |
|
|
|
instructionService.update(inst); |
|
|
|
writing("to_address", start_device_code); |
|
|
|
} else { |
|
|
|
|
|
|
|
} |
|
|
|
} else if (StrUtil.equals(type, "4")) { |
|
|
|
Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code()); |
|
|
|
Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code()); |
|
|
|
int start_device_code = Integer.parseInt(start_device.getAddress()); |
|
|
|
int next_device_code = Integer.parseInt(next_device.getAddress()); |
|
|
|
JSONArray ja = new JSONArray(); |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("vehicle_code", inst.getVehicle_code()); |
|
|
@ -440,16 +451,128 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device |
|
|
|
logDto.setDevice_code(device_code); |
|
|
|
logDto.setInstruct_code(inst.getInstruction_code()); |
|
|
|
logDto.setTask_code(inst.getTask_code()); |
|
|
|
logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_address + " value:" + start_device_code); |
|
|
|
logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_line + " value:" + 2); |
|
|
|
luceneExecuteLogService.deviceExecuteLog(logDto); |
|
|
|
writing("to_address", relax_point); |
|
|
|
writing("to_line", 2); |
|
|
|
inst.setInstruction_status("2"); |
|
|
|
inst.setInstruction_status("1"); |
|
|
|
inst.setExecute_status("4"); |
|
|
|
instructionService.finish(inst); |
|
|
|
} else { |
|
|
|
|
|
|
|
} |
|
|
|
} else if (StrUtil.equals(type, "5")) { |
|
|
|
JSONArray ja = new JSONArray(); |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("status", "5"); |
|
|
|
jo.put("device_code", this.address); |
|
|
|
ja.add(jo); |
|
|
|
HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); |
|
|
|
if (resp.getStatus() == 200) { |
|
|
|
LuceneLogDto logDto = new LuceneLogDto(); |
|
|
|
logDto.setDevice_code(device_code); |
|
|
|
logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_di_low + " value:" + 0); |
|
|
|
luceneExecuteLogService.deviceExecuteLog(logDto); |
|
|
|
writing("to_di_low", 0); |
|
|
|
writing("to_di_height", 0); |
|
|
|
} else { |
|
|
|
|
|
|
|
} |
|
|
|
} else if (StrUtil.equals(type, "6")) { |
|
|
|
JSONArray ja = new JSONArray(); |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("status", "6"); |
|
|
|
jo.put("device_code", this.device_code); |
|
|
|
ja.add(jo); |
|
|
|
HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); |
|
|
|
if (resp.getStatus() == 200) { |
|
|
|
LuceneLogDto logDto = new LuceneLogDto(); |
|
|
|
logDto.setDevice_code(device_code); |
|
|
|
logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_di_low + " value:" + 0); |
|
|
|
luceneExecuteLogService.deviceExecuteLog(logDto); |
|
|
|
writing("to_di_height", 0); |
|
|
|
writing("to_di_low", 0); |
|
|
|
} else { |
|
|
|
|
|
|
|
} |
|
|
|
} else if (StrUtil.equals(type, "7")) { |
|
|
|
JSONArray ja = new JSONArray(); |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("status", "7"); |
|
|
|
jo.put("device_code", this.device_code); |
|
|
|
ja.add(jo); |
|
|
|
HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); |
|
|
|
if (resp.getStatus() == 200) { |
|
|
|
LuceneLogDto logDto = new LuceneLogDto(); |
|
|
|
logDto.setDevice_code(device_code); |
|
|
|
logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_di_low + " value:" + 0); |
|
|
|
luceneExecuteLogService.deviceExecuteLog(logDto); |
|
|
|
writing("to_di_low", 0); |
|
|
|
} else { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
public boolean feedAgvAction(String type) throws Exception { |
|
|
|
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); |
|
|
|
return false; |
|
|
|
} else { |
|
|
|
if (StrUtil.equals(type, "5")) { |
|
|
|
JSONArray ja = new JSONArray(); |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("status", "5"); |
|
|
|
jo.put("device_code", "A4"); |
|
|
|
ja.add(jo); |
|
|
|
HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); |
|
|
|
if (resp.getStatus() == 200) { |
|
|
|
LuceneLogDto logDto = new LuceneLogDto(); |
|
|
|
logDto.setDevice_code(device_code); |
|
|
|
logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_di_low + " value:" + 0); |
|
|
|
luceneExecuteLogService.deviceExecuteLog(logDto); |
|
|
|
writing("to_di_low", 0); |
|
|
|
writing("to_di_height", 0); |
|
|
|
} else { |
|
|
|
writing("to_di_low", 0); |
|
|
|
writing("to_di_height", 0); |
|
|
|
} |
|
|
|
} else if (StrUtil.equals(type, "6")) { |
|
|
|
JSONArray ja = new JSONArray(); |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("status", "6"); |
|
|
|
jo.put("device_code", "A4"); |
|
|
|
ja.add(jo); |
|
|
|
HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); |
|
|
|
if (resp.getStatus() == 200) { |
|
|
|
LuceneLogDto logDto = new LuceneLogDto(); |
|
|
|
logDto.setDevice_code(device_code); |
|
|
|
logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_di_low + " value:" + 0); |
|
|
|
luceneExecuteLogService.deviceExecuteLog(logDto); |
|
|
|
writing("to_di_height", 0); |
|
|
|
writing("to_di_low", 0); |
|
|
|
} else { |
|
|
|
writing("to_di_height", 0); |
|
|
|
writing("to_di_low", 0); |
|
|
|
} |
|
|
|
} else if (StrUtil.equals(type, "7")) { |
|
|
|
JSONArray ja = new JSONArray(); |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("status", "7"); |
|
|
|
jo.put("device_code", "A4"); |
|
|
|
ja.add(jo); |
|
|
|
HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); |
|
|
|
if (resp.getStatus() == 200) { |
|
|
|
LuceneLogDto logDto = new LuceneLogDto(); |
|
|
|
logDto.setDevice_code(device_code); |
|
|
|
logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_di_low + " value:" + 0); |
|
|
|
luceneExecuteLogService.deviceExecuteLog(logDto); |
|
|
|
writing("to_di_height", 0); |
|
|
|
} else { |
|
|
|
writing("to_di_height", 0); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|