|
|
@ -71,11 +71,14 @@ public class AgvConveyorDeviceDriver extends AbstractOpcDeviceDriver implements |
|
|
|
int heartbeat = 0; |
|
|
|
int error = 0; |
|
|
|
int task = 0; |
|
|
|
String on_off_site; |
|
|
|
String tray_Information; |
|
|
|
int on_off_site; |
|
|
|
int tray_Information; |
|
|
|
int down_request; |
|
|
|
int up_request; |
|
|
|
|
|
|
|
String on_off_site_str; |
|
|
|
String tray_Information_str; |
|
|
|
|
|
|
|
Boolean isonline = true; |
|
|
|
|
|
|
|
Boolean iserror = false; |
|
|
@ -99,12 +102,12 @@ public class AgvConveyorDeviceDriver extends AbstractOpcDeviceDriver implements |
|
|
|
String message = null; |
|
|
|
|
|
|
|
device_code = this.getDeviceCode(); |
|
|
|
heartbeat = this.itemProtocol.getItem_heartbeat(); |
|
|
|
on_off_site = this.itemProtocol.getItem_on_off_site(); |
|
|
|
tray_Information = this.itemProtocol.getItem_tray_Information(); |
|
|
|
down_request = this.itemProtocol.getItem_down_request(); |
|
|
|
up_request = this.itemProtocol.getItem_up_request(); |
|
|
|
|
|
|
|
on_off_site_str = String.valueOf(on_off_site); |
|
|
|
tray_Information_str = String.valueOf(tray_Information); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -116,10 +119,12 @@ public class AgvConveyorDeviceDriver extends AbstractOpcDeviceDriver implements |
|
|
|
this.setIsonline(false); |
|
|
|
this.setIserror(true); |
|
|
|
//未联机
|
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "未联机"); |
|
|
|
|
|
|
|
} else { |
|
|
|
this.setIsonline(true); |
|
|
|
this.setIserror(false); |
|
|
|
if ((down_request == 1 || up_request == 1) && StringUtils.isNoneEmpty(on_off_site)){ |
|
|
|
if ((down_request == 1 || up_request == 1) && StringUtils.isNoneEmpty(on_off_site_str)){ |
|
|
|
task_apply(); |
|
|
|
} |
|
|
|
} |
|
|
@ -135,42 +140,88 @@ public class AgvConveyorDeviceDriver extends AbstractOpcDeviceDriver implements |
|
|
|
} else { |
|
|
|
this.instruction_require_time = date; |
|
|
|
WQLObject wo = WQLObject.getWQLObject("acs_device_runpoint"); |
|
|
|
JSONObject json = wo.query("device_code ='" + on_off_site + "'").uniqueResult(0); |
|
|
|
if (MapUtil.isNotEmpty(json) && "0".equals(json.get("hasgoods"))){ |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", on_off_site + "无上下料货物"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
//上料设备
|
|
|
|
List<String> putDeviceCodeList = this.getExtraDeviceCodes("put_device_code"); |
|
|
|
//下料设备
|
|
|
|
List<String> getDeviceCodeList = this.getExtraDeviceCodes("get_device_code"); |
|
|
|
|
|
|
|
//请求下料
|
|
|
|
if (down_request == 1){ |
|
|
|
List<RouteLineDto> routeLineDtos = routeLineService.getsByCode(on_off_site,"normal"); |
|
|
|
if (CollUtil.isEmpty(routeLineDtos) || routeLineDtos.size() < 1) { |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "没有"+ on_off_site + "的路由"); |
|
|
|
String nextCode = null; |
|
|
|
//下料点要有货,终点要无货
|
|
|
|
JSONObject json = wo.query("device_code ='" + on_off_site_str + "'").uniqueResult(0); |
|
|
|
if (MapUtil.isNotEmpty(json) && "0".equals(json.get("hasgoods"))){ |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", on_off_site_str + "下料点无货物"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
RouteLineDto routeLineDto = routeLineDtos.get(0); |
|
|
|
if (CollUtil.isNotEmpty(getDeviceCodeList)){ |
|
|
|
//查找无货的防货点
|
|
|
|
for (String deviceCode : getDeviceCodeList) { |
|
|
|
JSONObject jsonEnd = wo.query("device_code ='" + deviceCode + "'").uniqueResult(0); |
|
|
|
if (MapUtil.isNotEmpty(jsonEnd) && "0".equals(jsonEnd.get("hasgoods"))){ |
|
|
|
nextCode = deviceCode; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (nextCode == null){ |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "终点货物占满"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
List<TaskDto> taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(on_off_site_str); |
|
|
|
if (CollUtil.isNotEmpty(taskDtos)){ |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "已存在"+on_off_site_str+"为起点就绪或执行的任务"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
TaskDto taskDto = new TaskDto(); |
|
|
|
taskDto.setStart_device_code(on_off_site); |
|
|
|
taskDto.setNext_device_code(routeLineDto.getNext_device_code()); |
|
|
|
taskDto.setStart_point_code(on_off_site); |
|
|
|
taskDto.setNext_point_code(routeLineDto.getNext_device_code()); |
|
|
|
taskDto.setStart_device_code(on_off_site_str); |
|
|
|
taskDto.setNext_device_code(nextCode); |
|
|
|
taskDto.setStart_point_code(on_off_site_str); |
|
|
|
taskDto.setNext_point_code(nextCode); |
|
|
|
taskDto.setExecute_code(this.device_code); |
|
|
|
taskDto.setExecute_message("down"); |
|
|
|
taskDto.setTask_type("3"); |
|
|
|
taskserver.create(taskDto); |
|
|
|
} |
|
|
|
//请求上料
|
|
|
|
if (up_request == 1){ |
|
|
|
List<RouteLineDto> routeLineDtos = routeLineService.getPathLinesByCode(on_off_site,"normal"); |
|
|
|
if (CollUtil.isEmpty(routeLineDtos) || routeLineDtos.size() < 1) { |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "没有"+ on_off_site + "的路由"); |
|
|
|
String startCode = null; |
|
|
|
//起点要有货,上料点要无货
|
|
|
|
JSONObject json = wo.query("device_code ='" + on_off_site_str + "'").uniqueResult(0); |
|
|
|
if (MapUtil.isNotEmpty(json) && "1".equals(json.get("hasgoods"))){ |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", on_off_site_str + "上料点存在货物"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(putDeviceCodeList)){ |
|
|
|
//查找无货的防货点
|
|
|
|
for (String deviceCode : putDeviceCodeList) { |
|
|
|
JSONObject jsonStar = wo.query("device_code ='" + deviceCode + "'").uniqueResult(0); |
|
|
|
if (MapUtil.isNotEmpty(jsonStar) && "1".equals(jsonStar.get("hasgoods")) && tray_Information_str.equals(jsonStar.get("material_type"))){ |
|
|
|
startCode = deviceCode; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (startCode == null){ |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "起点无货物可取或者物料类型不匹配"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
List<TaskDto> taskDtos = taskserver.queryTaskByEndDeviceCodeAndStatus(on_off_site_str); |
|
|
|
if (CollUtil.isNotEmpty(taskDtos)){ |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "已存在"+startCode+"为终点就绪或执行的任务"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
RouteLineDto routeLineDto = routeLineDtos.get(0); |
|
|
|
TaskDto taskDto = new TaskDto(); |
|
|
|
taskDto.setStart_device_code(routeLineDto.getDevice_code()); |
|
|
|
taskDto.setNext_device_code(on_off_site); |
|
|
|
taskDto.setStart_point_code(routeLineDto.getDevice_code()); |
|
|
|
taskDto.setNext_point_code(on_off_site); |
|
|
|
taskDto.setStart_device_code(startCode); |
|
|
|
taskDto.setNext_device_code(on_off_site_str); |
|
|
|
taskDto.setStart_point_code(startCode); |
|
|
|
taskDto.setNext_point_code(on_off_site_str); |
|
|
|
taskDto.setExecute_code(this.device_code); |
|
|
|
taskDto.setExecute_message("up"); |
|
|
|
taskDto.setTask_type("3"); |
|
|
|
taskserver.create(taskDto); |
|
|
|
} |
|
|
|
return true; |
|
|
|