From d2894bd7c44dc902140c95a72ab740b6db253fbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E4=BF=8A=E6=9D=B0?= <9463626+zhou-junjiezjj@user.noreply.gitee.com> Date: Wed, 27 Sep 2023 08:47:46 +0800 Subject: [PATCH] =?UTF-8?q?add=20RGV=E9=A9=B1=E5=8A=A8=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E8=B5=B7=E7=82=B9=E5=92=8C=E4=BB=BB=E5=8A=A1=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E5=8E=9F=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lnsh/lnsh_rgv/LnshRGVDeviceDriver.java | 220 ++++++++++++++++-- 1 file changed, 197 insertions(+), 23 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java index f9396f5..92e9635 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java @@ -12,8 +12,13 @@ import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; import org.nl.acs.device.service.DeviceService; import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.device_driver.lnsh.lnsh_Laminating_machine.LnshLaminatingMachineDeviceDriver; +import org.nl.acs.device_driver.lnsh.lnsh_package_site.LnshPackageSiteDeviceDriver; +import org.nl.acs.device_driver.lnsh.lnsh_palletizing_manipulator_site.LnshPalletizingManipulatorSiteDeviceDriver; +import org.nl.acs.device_driver.lnsh.lnsh_station.LnshStationDeviceDriver; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.log.service.DeviceExecuteLogService; @@ -296,38 +301,201 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi update_instruction_status(); } - //双任务下 后工位取货完成,然后给前工位下发取满盘任务取货命令 - if (mode == 3 && action_2 == 2 && action_1 == 0 && move_2 != 0 && move_1 == 0 && task2 > 0 && to_task1 > 0 && to_task2 > 0) { - if (to_command1 != 1) { - writing("to_command1", "1"); - } - } - - //双任务下发 前后工位取货完成 给后工位放货命令 - if (mode == 3 && action_2 == 2 && action_1 == 2 && move_2 != 0 && move_1 != 0 && task2 > 0 && task1 > 0) { - if (to_command2 != 2) { - writing("to_command2", "2"); + //前工位取货时判断取货位光电信号 + if (mode == 3 && error == 0 && status != 3 && action_1 == 1 && move_1 == 0 && task1 > 0 && action_2 != 1) { + Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); + String start_device_code = inst1.getStart_device_code(); + Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); + if (startDevice.getDeviceDriver() instanceof LnshPalletizingManipulatorSiteDeviceDriver) { + LnshPalletizingManipulatorSiteDeviceDriver driver = (LnshPalletizingManipulatorSiteDeviceDriver) startDevice.getDeviceDriver(); + if (driver.getMode() != 0 + && driver.getMove() != 0 + && (driver.getIo_action() == 3 || driver.getIo_action() == 1) + && (driver.getAction() == 3 || driver.getAction() == 1)) { + this.writing("to_command1", "2"); + driver.setMessage(""); + logServer.deviceExecuteLog(startDevice.getDevice_code(), "", "", "允许RGV前工位取货。"); + } else { + String msg = ""; + if (driver.getMode() == 0) { + msg += "站点未联机,"; + } else { + if (driver.getMove() == 0) { + msg += "站点无货,"; + } + if (driver.getIo_action() != 3 && driver.getIo_action() != 1) { + msg += "站点不允许进入,"; + } + if (driver.getAction() != 3 && driver.getAction() != 1) { + msg += "站点不允许取货,"; + } + } + msg += "不允许RGV前工位取货。"; + driver.setMessage(msg); + logServer.deviceExecuteLog(startDevice.getDevice_code(), "", "", msg); + } + } else if (startDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + this.writing("to_command1", "2"); + logServer.deviceExecuteLog(startDevice.getDevice_code(), "", "", "允许RGV前工位取货。"); } } - //双任务下发 后工位放货完成 给前工位下发放货 - if (mode == 3 && action_2 == 4 && action_1 == 2 && move_2 == 0 && move_1 != 0 && task2 > 0 && task1 > 0) { - if (to_command1 != 2) { - writing("to_command1", "2"); + //前工位放货时判断放货位光电信号 + if (mode == 3 && error == 0 && status != 3 && action_1 == 3 && move_1 != 0 && task1 > 0 && action_2 != 3) { + Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); + String next_device_code = inst1.getNext_device_code(); + Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); + if (nextDevice.getDeviceDriver() instanceof LnshStationDeviceDriver) { + LnshStationDeviceDriver driver = (LnshStationDeviceDriver) nextDevice.getDeviceDriver(); + if (driver.getMode() != 0 + && driver.getMove() == 0 + && (driver.getAction() == 2 || driver.getAction() == 3) + && (driver.getIo_action() == 1 || driver.getIo_action() == 3)) { + this.writing("to_command1", "3"); + driver.setMessage(""); + logServer.deviceExecuteLog(nextDevice.getDevice_code(), "", "", "允许RGV前工位放货。"); + } else { + String msg = ""; + if (driver.getMode() == 0) { + msg += "站点未联机,"; + } else { + if (driver.getMove() != 0) { + msg += "站点有货,"; + } + if (driver.getIo_action() != 1 && driver.getIo_action() != 3) { + msg += "站点不允许进入,"; + } + if (driver.getAction() != 2 && driver.getAction() != 3) { + msg += "站点不允许放货,"; + } + } + msg += "不允许RGV前工位放货。"; + driver.setMessage(msg); + logServer.deviceExecuteLog(nextDevice.getDevice_code(), "", "", msg); + } + } else if (nextDevice.getDeviceDriver() instanceof LnshPackageSiteDeviceDriver) { + LnshPackageSiteDeviceDriver driver = (LnshPackageSiteDeviceDriver) nextDevice.getDeviceDriver(); + if (driver.getMode() != 0 + && driver.getMove() == 0 + && (driver.getAction() == 2 || driver.getAction() == 3) + && (driver.getIoaction() == 1 || driver.getIoaction() == 3)) { + this.writing("to_command1", "3"); + driver.setMessage(""); + logServer.deviceExecuteLog(nextDevice.getDevice_code(), "", "", "允许RGV前工位放货。"); + } else { + String msg = ""; + if (driver.getMode() == 0) { + msg += "站点未联机,"; + } else { + if (driver.getMove() != 0) { + msg += "站点有货,"; + } + if (driver.getIoaction() != 1 && driver.getIoaction() != 3) { + msg += "站点不允许进入,"; + } + if (driver.getAction() != 2 && driver.getAction() != 3) { + msg += "站点不允许放货,"; + } + } + msg += "不允许RGV前工位放货。"; + driver.setMessage(msg); + logServer.deviceExecuteLog(nextDevice.getDevice_code(), "", "", msg); + } } } - //后工位单任务下发 空托或者半托缓存任务 - if (mode == 3 && action_2 == 2 && action_1 == 0 && move_2 > 0 && move_1 == 0 && task2 > 0 && task1 == 0 && to_task1 == 0) { - if (to_command2 != 2) { - writing("to_command2", "2"); + //后工位取货时判断取货位光电信号 + if (mode == 3 && error == 0 && status != 3 && action_2 == 1 && move_2 == 0 && task2 > 0) { + Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task2)); + String start_device_code = inst1.getStart_device_code(); + Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); + if (startDevice.getDeviceDriver() instanceof LnshLaminatingMachineDeviceDriver) { + LnshLaminatingMachineDeviceDriver driver = (LnshLaminatingMachineDeviceDriver) startDevice.getDeviceDriver(); + if (driver.getMode() != 0 + && driver.getMove() != 0) { + this.writing("to_command2", "2"); + driver.setMessage(""); + logServer.deviceExecuteLog(startDevice.getDevice_code(), "", "", "允许RGV后工位取货。"); + } else { + String msg = ""; + if (driver.getMode() == 0) { + msg += "站点未联机,"; + } else { + if (driver.getMove() == 0) { + msg += "站点无货,"; + } + } + msg += "不允许RGV后工位取货。"; + driver.setMessage(msg); + logServer.deviceExecuteLog(startDevice.getDevice_code(), "", "", msg); + } + } else if (startDevice.getDeviceDriver() instanceof LnshStationDeviceDriver) { + LnshStationDeviceDriver driver = (LnshStationDeviceDriver) startDevice.getDeviceDriver(); + if (driver.getMode() != 0 + && driver.getMove() != 0 + && (driver.getIo_action() == 3 || driver.getIo_action() == 1) + && (driver.getAction() == 3 || driver.getAction() == 1)) { + this.writing("to_command2", "2"); + driver.setMessage(""); + logServer.deviceExecuteLog(startDevice.getDevice_code(), "", "", "允许RGV后工位取货。"); + } else { + String msg = ""; + if (driver.getMode() == 0) { + msg += "站点未联机,"; + } else { + if (driver.getMove() == 0) { + msg += "站点无货,"; + } + if (driver.getIo_action() != 3 && driver.getIo_action() != 1) { + msg += "站点不允许进入,"; + } + if (driver.getAction() != 3 && driver.getAction() != 1) { + msg += "站点不允许取货,"; + } + } + msg += "不允许RGV后工位取货。"; + driver.setMessage(msg); + logServer.deviceExecuteLog(startDevice.getDevice_code(), "", "", msg); + } } } - //前工位单任务下发 强制包装的任务 - if (mode == 3 && action_1 == 2 && action_2 == 0 && move_1 > 0 && move_2 == 0 && task1 > 0 && task2 == 0 && to_task2 == 0) { - if (to_command1 != 2) { - writing("to_command1", "2"); + //后工位放货时判断放货位光电信号 + if (mode == 3 && error == 0 && status != 3 && action_2 == 3 && move_2 != 0 && task2 > 0 && action_1 != 1) { + Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task2)); + String next_device_code = inst1.getNext_device_code(); + Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); + if (nextDevice.getDeviceDriver() instanceof LnshPalletizingManipulatorSiteDeviceDriver) { + LnshPalletizingManipulatorSiteDeviceDriver driver = (LnshPalletizingManipulatorSiteDeviceDriver) nextDevice.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", "3"); + driver.setMessage(""); + logServer.deviceExecuteLog(nextDevice.getDevice_code(), "", "", "允许RGV后工位放货。"); + } else { + String msg = ""; + if (driver.getMode() == 0) { + msg += "站点未联机,"; + } else { + if (driver.getMove() != 0) { + msg += "站点有货,"; + } + if (driver.getIo_action() != 1 && driver.getIo_action() != 3) { + msg += "站点不允许进入,"; + } + if (driver.getAction() != 2 && driver.getAction() != 3) { + msg += "站点不允许放货,"; + } + } + msg += "不允许RGV后工位放货。"; + driver.setMessage(msg); + logServer.deviceExecuteLog(device_code, "", "", msg); + } + } else if (nextDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + this.writing("to_command2", "3"); + logServer.deviceExecuteLog(nextDevice.getDevice_code(), "", "", "允许RGV后工位放货。"); } } @@ -496,10 +664,16 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi sendHeadBackSignalType(instdto); requireSucess1 = true; logServer.deviceExecuteLog(this.device_code, "", "", "申请前后工位任务成功,requireSucess1" + requireSucess1 + ",指令号:" + instdto.getInstruction_code()); + if(ObjectUtil.isNotEmpty(start_device_code)){ + writing("to_command1", "1"); + } } else { sendHeadSignalType(instdto); requireSucess1 = true; logServer.deviceExecuteLog(this.device_code, "", "", "申请后工位任务成功,requireSucess1" + requireSucess1 + ",指令号:" + instdto.getInstruction_code()); + if(ObjectUtil.isNotEmpty(start_device_code)){ + writing("to_command1", "1"); + } } } else { //申请后工位任务