|
|
@ -66,11 +66,9 @@ public class MaGangConveyorDeviceDriver extends AbstractOpcDeviceDriver implemen |
|
|
|
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class); |
|
|
|
|
|
|
|
private Date instruction_require_time = new Date(); |
|
|
|
private Date instruction_finished_time = new Date(); |
|
|
|
private Date instruction_apply_time = new Date(); |
|
|
|
private Date feedHeartBeatTime = new Date(); |
|
|
|
private int feedHeartBeatTimeOut = 30000; |
|
|
|
private int instruction_require_time_out = 3000; |
|
|
|
private int instruction_require_time_out = 5000; |
|
|
|
|
|
|
|
int feedHeartbeat = 0; |
|
|
|
int last_feedHeartbeat = 0; |
|
|
@ -132,7 +130,7 @@ public class MaGangConveyorDeviceDriver extends AbstractOpcDeviceDriver implemen |
|
|
|
} |
|
|
|
} |
|
|
|
if (mode != last_mode) { |
|
|
|
if (mode == 3 || mode == 4) { |
|
|
|
if (mode == 3) { |
|
|
|
this.setRequireSucess(false); |
|
|
|
} |
|
|
|
} |
|
|
@ -160,11 +158,6 @@ public class MaGangConveyorDeviceDriver extends AbstractOpcDeviceDriver implemen |
|
|
|
if (mode == 3 && !requireSucess) { |
|
|
|
instruction_require(); |
|
|
|
} |
|
|
|
|
|
|
|
//3#彩涂机组申请任务
|
|
|
|
if (mode == 4 && !requireSucess) { |
|
|
|
instruction_require2(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
last_mode = mode; |
|
|
@ -173,78 +166,18 @@ public class MaGangConveyorDeviceDriver extends AbstractOpcDeviceDriver implemen |
|
|
|
last_action = action; |
|
|
|
} |
|
|
|
|
|
|
|
public synchronized boolean instruction_require2() throws Exception { |
|
|
|
Date date = new Date(); |
|
|
|
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { |
|
|
|
public synchronized boolean instruction_require() throws Exception { |
|
|
|
if (System.currentTimeMillis() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { |
|
|
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); |
|
|
|
return false; |
|
|
|
} else { |
|
|
|
this.instruction_require_time = date; |
|
|
|
List<String> link_device_codes = this.getExtraDeviceCodes("link_device_code"); |
|
|
|
String next_device_code = ""; |
|
|
|
MaGangConveyorDeviceDriver maGangConveyorDeviceDriver; |
|
|
|
Device device = null; |
|
|
|
|
|
|
|
for (int i = 0; i < link_device_codes.size(); i++) { |
|
|
|
String link_device_code = link_device_codes.get(i); |
|
|
|
device = deviceAppservice.findDeviceByCode(link_device_code); |
|
|
|
if (device.getDeviceDriver() instanceof MaGangConveyorDeviceDriver && !link_device_code.startsWith("D")) { |
|
|
|
maGangConveyorDeviceDriver = (MaGangConveyorDeviceDriver) device.getDeviceDriver(); |
|
|
|
if (maGangConveyorDeviceDriver.getMove() == 0) { |
|
|
|
next_device_code = link_device_code; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//查询任务表中是否有同一起点和终点的任务
|
|
|
|
List<TaskDto> taskDtos = taskserver.queryTaskByStartAndNextDeviceCode(this.getDevice_code(), next_device_code); |
|
|
|
this.instruction_require_time = new Date(); |
|
|
|
//查询任务表中是否有同一起点任务
|
|
|
|
List<TaskDto> taskDtos = taskserver.queryTaskByStartDeviceCode(this.getDevice_code()); |
|
|
|
//如果有就不生成任务
|
|
|
|
if (ObjectUtil.isNotEmpty(taskDtos)) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
String taskType = String.valueOf(device.getExtraValue().get("taskType")); |
|
|
|
String start_device_code = this.getDevice().getDevice_code(); |
|
|
|
if (StrUtil.isEmpty(next_device_code)) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
if (StrUtil.equals(taskType, "null") || StrUtil.isEmpty(taskType)) { |
|
|
|
taskType = "0"; |
|
|
|
} |
|
|
|
TaskDto taskDto = new TaskDto(); |
|
|
|
String now = DateUtil.now(); |
|
|
|
taskDto.setTask_id(IdUtil.simpleUUID()); |
|
|
|
taskDto.setTask_code("-" + CodeUtil.getNewCode("TASK_NO")); |
|
|
|
taskDto.setTask_type(taskType); |
|
|
|
taskDto.setRoute_plan_code("normal"); |
|
|
|
taskDto.setTask_status("0"); |
|
|
|
taskDto.setPriority("101"); |
|
|
|
taskDto.setAgv_system_type("1"); |
|
|
|
taskDto.setStart_device_code(start_device_code); |
|
|
|
taskDto.setStart_point_code(start_device_code); |
|
|
|
taskDto.setNext_point_code(next_device_code); |
|
|
|
taskDto.setNext_point_code(next_device_code); |
|
|
|
taskDto.setCreate_by(start_device_code); |
|
|
|
taskDto.setUpdate_by(start_device_code); |
|
|
|
taskDto.setUpdate_time(now); |
|
|
|
taskDto.setCreate_time(now); |
|
|
|
try { |
|
|
|
taskserver.create(taskDto); |
|
|
|
this.writing(1); |
|
|
|
this.setRequireSucess(true); |
|
|
|
} catch (Exception e) { |
|
|
|
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "任务创建失败,原因:" + e.getMessage())); |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public synchronized boolean instruction_require() 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 { |
|
|
|
this.instruction_require_time = date; |
|
|
|
List<String> link_device_codes = this.getExtraDeviceCodes("link_device_code"); |
|
|
|
String next_device_code = ""; |
|
|
|
MaGangConveyorDeviceDriver maGangConveyorDeviceDriver; |
|
|
@ -259,12 +192,7 @@ public class MaGangConveyorDeviceDriver extends AbstractOpcDeviceDriver implemen |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//查询任务表中是否有同一起点和终点的任务
|
|
|
|
List<TaskDto> taskDtos = taskserver.queryTaskByStartAndNextDeviceCode(this.getDevice_code(), next_device_code); |
|
|
|
//如果有就不生成任务
|
|
|
|
if (ObjectUtil.isNotEmpty(taskDtos)) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
String taskType = String.valueOf(this.getExtraValue().get("taskType")); |
|
|
|
String start_device_code = this.getDevice().getDevice_code(); |
|
|
|
if (StrUtil.isEmpty(next_device_code)) { |
|
|
|