|
|
@ -207,6 +207,7 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
if (mode == 2) { |
|
|
|
inst = null; |
|
|
|
this.setRequireSucess1(false); |
|
|
|
log.info("任务复位完成"); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "模式变待机,复位前工位请求标记requireSucess1:" + requireSucess1); |
|
|
|
} |
|
|
|
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); |
|
|
@ -227,6 +228,7 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
if (move1 != last_move1) { |
|
|
|
if (move1 == 0) { |
|
|
|
this.setRequireSucess1(false); |
|
|
|
log.info("任务复位完成"); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "前工位有货变无货,复位前工位请求标记requireSucess1:" + requireSucess1); |
|
|
|
} |
|
|
|
logServer.deviceItemValue(this.device_code, "move1", String.valueOf(move1)); |
|
|
@ -302,7 +304,7 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
} |
|
|
|
|
|
|
|
//前工位取货时判断取货位光电信号
|
|
|
|
if (mode == 3 && error == 0 && status != 3 && action1 == 0 && move1 == 0 && task1 > 0 && action2 != 1) { |
|
|
|
if (mode == 3 && error == 0 && status != 3 && action1 == 0 && move1 == 0 && task1 > 0 && action2 == 2) { |
|
|
|
Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); |
|
|
|
String start_device_code = inst1.getStart_device_code(); |
|
|
|
Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); |
|
|
@ -342,7 +344,7 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
} |
|
|
|
|
|
|
|
//前工位放货时判断放货位光电信号
|
|
|
|
if (mode == 3 && error == 0 && status != 3 && action1 == 2 && move1 != 0 && task1 > 0 && action2 == 3) { |
|
|
|
if (mode == 3 && error == 0 && status != 3 && action1 == 2 && move1 != 0 && task1 > 0 && action2 != 1) { |
|
|
|
Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); |
|
|
|
String next_device_code = inst1.getNext_device_code(); |
|
|
|
Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); |
|
|
@ -464,10 +466,14 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
} |
|
|
|
|
|
|
|
//后工位放货时判断放货位光电信号
|
|
|
|
if (mode == 3 && error == 0 && status != 3 && action2 == 2 && move2 != 0 && task2 > 0 && action1 == 2) { |
|
|
|
if (mode == 3 && error == 0 && status != 3 && action2 == 2 && move2 != 0 && task2 > 0 && action1 != 1) { |
|
|
|
Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task2)); |
|
|
|
String next_device_code = inst1.getNext_device_code2(); |
|
|
|
Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); |
|
|
|
String next_parent_code = inst1.getNext_parent_code(); |
|
|
|
String start_device_code=inst1.getStart_device_code(); |
|
|
|
//后工位单任务
|
|
|
|
Device nextDevice = deviceAppservice.findDeviceByCode(next_parent_code); |
|
|
|
//双工位
|
|
|
|
Device nextDevice1 = deviceAppservice.findDeviceByCode(start_device_code); |
|
|
|
if (nextDevice.getDeviceDriver() instanceof LnshPalletizingManipulatorSiteDeviceDriver) { |
|
|
|
LnshPalletizingManipulatorSiteDeviceDriver driver = (LnshPalletizingManipulatorSiteDeviceDriver) nextDevice.getDeviceDriver(); |
|
|
|
if (driver.getMode() != 0 |
|
|
@ -476,6 +482,7 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
// && (driver.getAction() == 2 || driver.getAction() == 3)
|
|
|
|
) { |
|
|
|
this.writing("to_command2", "2"); |
|
|
|
this.requireSucess1 = false; |
|
|
|
driver.setMessage(""); |
|
|
|
logServer.deviceExecuteLog(nextDevice.getDevice_code(), "", "", "允许RGV后工位放货。"); |
|
|
|
} else { |
|
|
@ -497,11 +504,21 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
driver.setMessage(msg); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", msg); |
|
|
|
} |
|
|
|
} else if (nextDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { |
|
|
|
} |
|
|
|
if(nextDevice1.getDeviceDriver() instanceof LnshPalletizingManipulatorSiteDeviceDriver){ |
|
|
|
LnshPalletizingManipulatorSiteDeviceDriver driver = (LnshPalletizingManipulatorSiteDeviceDriver) nextDevice1.getDeviceDriver(); |
|
|
|
if (driver.getMode() != 0 |
|
|
|
&& driver.getMove() == 0 |
|
|
|
// && (driver.getIo_action() == 1 || driver.getIo_action() == 3)
|
|
|
|
// && (driver.getAction() == 2 || driver.getAction() == 3)
|
|
|
|
) { |
|
|
|
this.writing("to_command2", "2"); |
|
|
|
this.requireSucess1 = false; |
|
|
|
driver.setMessage(""); |
|
|
|
logServer.deviceExecuteLog(nextDevice.getDevice_code(), "", "", "允许RGV后工位放货。"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception var17) { |
|
|
@ -529,7 +546,9 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
log.debug("设备运转模式:等待工作"); |
|
|
|
return; |
|
|
|
case 2: |
|
|
|
// 申请任务
|
|
|
|
if (move1 == 0 && move2 == 0 && action1 == 0 && action2 == 0 && task1 == 0 && task2 == 0 && requireSucess1) { |
|
|
|
log.info("没有复位"); |
|
|
|
} |
|
|
|
if (move1 == 0 && move2 == 0 && action1 == 0 && action2 == 0 && task1 == 0 && task2 == 0 && !requireSucess1) { |
|
|
|
instruction_require(); |
|
|
|
} |
|
|
@ -579,10 +598,11 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
last_to_target2 = to_target2; |
|
|
|
last_to_task2 = to_task2; |
|
|
|
last_to_container_type = to_container_type; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//申请前工位任务
|
|
|
|
//任务申请
|
|
|
|
public synchronized boolean instruction_require() throws Exception { |
|
|
|
Date date = new Date(); |
|
|
|
if (date.getTime() - this.instruction_apply_time2.getTime() < (long) this.instruction_require_time_out) { |
|
|
@ -669,6 +689,7 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
//下发4个点任务
|
|
|
|
if (ObjectUtil.isNotEmpty(start_device_code2) && ObjectUtil.isNotEmpty(next_device_code2)) { |
|
|
|
sendHeadBackSignalType(instdto); |
|
|
|
log.info("下发五点任务,指令信息()",instdto); |
|
|
|
requireSucess1 = true; |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "申请前后工位任务成功,requireSucess1" + requireSucess1 + ",指令号:" + instdto.getInstruction_code()); |
|
|
|
if(ObjectUtil.isNotEmpty(start_device_code)){ |
|
|
@ -680,13 +701,8 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
} else { |
|
|
|
sendHeadSignalType(instdto); |
|
|
|
requireSucess1 = true; |
|
|
|
log.info("申请前工位任务成功,{}",requireSucess1); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "申请后工位任务成功,requireSucess1" + requireSucess1 + ",指令号:" + instdto.getInstruction_code()); |
|
|
|
if(ObjectUtil.isNotEmpty(start_device_code)){ |
|
|
|
if (addressdevice.getDeviceDriver() instanceof LnshLaminatingMachineDeviceDriver) { |
|
|
|
lnshLaminatingMachineDeviceDriver = (LnshLaminatingMachineDeviceDriver) addressdevice.getDeviceDriver(); |
|
|
|
lnshLaminatingMachineDeviceDriver.writing("to_command", "1"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
//申请后工位任务
|
|
|
@ -694,7 +710,7 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
List<String> getDeviceCodeList2 = this.getExtraDeviceCodes("get_device_code2"); |
|
|
|
//前工位放货关联设备
|
|
|
|
List<String> putDeviceCodeList2 = this.getExtraDeviceCodes("put_device_code2"); |
|
|
|
for (int i = 0; i < putDeviceCodeList.size(); i++) { |
|
|
|
for (int i = 0; i < putDeviceCodeList2.size(); i++) { |
|
|
|
if (ObjectUtil.isNotEmpty(taskserver.queryTaskByDeviceCode(getDeviceCodeList2.get(i).replace("\"", "")))) { |
|
|
|
task2 = taskserver.queryTaskByDeviceCode(getDeviceCodeList2.get(i).replace("\"", "")).get(0); |
|
|
|
} |
|
|
@ -712,6 +728,7 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
String next_point_code = task2.getNext_point_code(); |
|
|
|
String next_device_code = task2.getNext_device_code(); |
|
|
|
String next_device_code2 = task2.getNext_device_code2(); |
|
|
|
String put_device_code=task2.getPut_device_code(); |
|
|
|
Device startdevice = deviceAppservice.findDeviceByCode(start_device_code); |
|
|
|
Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code); |
|
|
|
Device startdevice2 = null; |
|
|
@ -761,6 +778,15 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
taskserver.update(task2); |
|
|
|
sendBackSignalType(instdto); |
|
|
|
requireSucess1 = true; |
|
|
|
LnshLaminatingMachineDeviceDriver lnshLaminatingMachineDeviceDriver; |
|
|
|
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); |
|
|
|
Device addressdevice = appService.findDeviceByCode(put_device_code); |
|
|
|
if(ObjectUtil.isNotEmpty(start_device_code)){ |
|
|
|
if (addressdevice.getDeviceDriver() instanceof LnshLaminatingMachineDeviceDriver) { |
|
|
|
lnshLaminatingMachineDeviceDriver = (LnshLaminatingMachineDeviceDriver) addressdevice.getDeviceDriver(); |
|
|
|
lnshLaminatingMachineDeviceDriver.writing("to_command", "1"); |
|
|
|
} |
|
|
|
} |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "申请后工位任务成功,requireSucess1" + requireSucess1 + ",指令号:" + instdto.getInstruction_code()); |
|
|
|
} |
|
|
|
} |
|
|
@ -1005,21 +1031,31 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
try { |
|
|
|
finish_instruction(inst1); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("RGV 前工位完成指令异常", e); |
|
|
|
log.error("RGV 双工位完成指令异常", e); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "前工位指令" + task1 + "完成异常,异常原因:" + e.getMessage()); |
|
|
|
} |
|
|
|
log.info("五点任务完成"); |
|
|
|
writing("to_command1", "0"); |
|
|
|
writing("to_command1", "0"); |
|
|
|
writing("to_onset1", "0"); |
|
|
|
writing("to_onset1", "0"); |
|
|
|
writing("to_target1", "0"); |
|
|
|
writing("to_target1", "0"); |
|
|
|
writing("to_task1", "0"); |
|
|
|
writing("to_task1", "0"); |
|
|
|
writing("to_command2", "0"); |
|
|
|
writing("to_command2", "0"); |
|
|
|
writing("to_onset2", "0"); |
|
|
|
writing("to_onset2", "0"); |
|
|
|
writing("to_target2", "0"); |
|
|
|
writing("to_target2", "0"); |
|
|
|
writing("to_task2", "0"); |
|
|
|
writing("to_task2", "0"); |
|
|
|
writing("to_container_type", "0"); |
|
|
|
requireSucess1 = false; |
|
|
|
writing("to_container_type", "0"); |
|
|
|
} |
|
|
|
this.requireSucess1 = false; |
|
|
|
log.info("前后工位任务完成复位"); |
|
|
|
//单独的后工位任务
|
|
|
|
} else if (action2 == 4 && move2 == 0 && task2 > 0 && action1 == 0 && move2 == 0 && task1 == 0) { |
|
|
|
//inst_message
|
|
|
@ -1028,16 +1064,21 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
try { |
|
|
|
finish_instruction(inst2); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("RGV 前工位完成指令异常", e); |
|
|
|
log.error("RGV 后工位完成指令异常", e); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "后工位指令" + task1 + "完成异常,异常原因:" + e.getMessage()); |
|
|
|
} |
|
|
|
log.info("后工位任务完成"); |
|
|
|
writing("to_command2", "0"); |
|
|
|
writing("to_command2", "0"); |
|
|
|
writing("to_onset2", "0"); |
|
|
|
writing("to_onset2", "0"); |
|
|
|
writing("to_target2", "0"); |
|
|
|
writing("to_target2", "0"); |
|
|
|
writing("to_task2", "0"); |
|
|
|
writing("to_task2", "0"); |
|
|
|
requireSucess1 = false; |
|
|
|
} |
|
|
|
this.requireSucess1 = false; |
|
|
|
log.info("后工位任务完成复位"); |
|
|
|
} else if (action1 == 4 && move1 == 0 && task1 > 0 && action2 == 0 && move2 == 0 && task2 == 0) { |
|
|
|
inst1 = checkInst(); |
|
|
|
if (inst1 != null) { |
|
|
@ -1047,14 +1088,20 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
log.error("RGV 前工位完成指令异常", e); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "前工位指令" + task1 + "完成异常,异常原因:" + e.getMessage()); |
|
|
|
} |
|
|
|
log.info("前工位任务完成"); |
|
|
|
writing("to_command1", "0"); |
|
|
|
writing("to_command1", "0"); |
|
|
|
writing("to_onset1", "0"); |
|
|
|
writing("to_onset1", "0"); |
|
|
|
writing("to_target1", "0"); |
|
|
|
writing("to_target1", "0"); |
|
|
|
writing("to_task1", "0"); |
|
|
|
writing("to_task1", "0"); |
|
|
|
writing("to_container_type", "0"); |
|
|
|
requireSucess1 = false; |
|
|
|
writing("to_container_type", "0"); |
|
|
|
} |
|
|
|
this.requireSucess1 = false; |
|
|
|
log.info("前工位任务完成复位"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1130,9 +1177,13 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
String start_addr = startDevice.getExtraValue().get("OPCServer").toString(); |
|
|
|
String next_addr = nextDevice.getExtraValue().get("OPCServer").toString(); |
|
|
|
this.writing("to_onset1", start_addr); |
|
|
|
this.writing("to_onset1", start_addr); |
|
|
|
this.writing("to_target1", next_addr); |
|
|
|
this.writing("to_target1", next_addr); |
|
|
|
this.writing("to_task1", dto.getInstruction_code()); |
|
|
|
this.writing("to_task1", dto.getInstruction_code()); |
|
|
|
this.writing("to_command1", "1"); |
|
|
|
this.writing("to_command1", "1"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -1149,9 +1200,13 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
String start_addr = startDevice.getExtraValue().get("OPCServer").toString(); |
|
|
|
String next_addr = nextDevice.getExtraValue().get("OPCServer").toString(); |
|
|
|
this.writing("to_onset2", start_addr); |
|
|
|
this.writing("to_onset2", start_addr); |
|
|
|
this.writing("to_target2", next_addr); |
|
|
|
this.writing("to_target2", next_addr); |
|
|
|
this.writing("to_task2", dto.getInstruction_code()); |
|
|
|
this.writing("to_task2", dto.getInstruction_code()); |
|
|
|
this.writing("to_command2", "1"); |
|
|
|
this.writing("to_command2", "1"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -1176,12 +1231,19 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi |
|
|
|
String start_addr2 = startDevice2.getExtraValue().get("OPCServer").toString(); |
|
|
|
String next_addr2 = nextDevice2.getExtraValue().get("OPCServer").toString(); |
|
|
|
this.writing("to_onset1", start_addr); |
|
|
|
this.writing("to_onset1", start_addr); |
|
|
|
this.writing("to_target1", next_addr); |
|
|
|
this.writing("to_target1", next_addr); |
|
|
|
this.writing("to_task1", dto.getInstruction_code()); |
|
|
|
this.writing("to_task1", dto.getInstruction_code()); |
|
|
|
//this.writing("to_command1", "1");
|
|
|
|
this.writing("to_onset2", start_addr2); |
|
|
|
this.writing("to_onset2", start_addr2); |
|
|
|
this.writing("to_target2", next_addr2); |
|
|
|
this.writing("to_target2", next_addr2); |
|
|
|
this.writing("to_task2", dto.getInstruction_code()); |
|
|
|
this.writing("to_task2", dto.getInstruction_code()); |
|
|
|
this.writing("to_command2", "1"); |
|
|
|
this.writing("to_command2", "1"); |
|
|
|
} |
|
|
|
|
|
|
|