| | |
| | | //错误编号 |
| | | shuttleProtocol.setErrorCode(modbusTcpNet.getByteTransform().TransInt16(content,8)); |
| | | //Plc输出状态IO |
| | | boolean[] booleans = modbusTcpNet.getByteTransform().TransBool(content, 10, 2); |
| | | shuttleProtocol.setPlcOutputLift(booleans[1]); |
| | | shuttleProtocol.setPlcOutputTransfer(booleans[2]); |
| | | shuttleProtocol.setPlcOutputBrake(booleans[3]); |
| | | shuttleProtocol.setPlcOutputCharge(booleans[4]); |
| | | int plcOutIo = modbusTcpNet.getByteTransform().TransUInt16(content, 10); |
| | | int[] plcOutIos = CommonUtils.byteToBits((byte) plcOutIo); |
| | | shuttleProtocol.setPlcOutputLift(plcOutIos[1] == 1); |
| | | shuttleProtocol.setPlcOutputTransfer(plcOutIos[2] == 1); |
| | | shuttleProtocol.setPlcOutputBrake(plcOutIos[3] == 1); |
| | | shuttleProtocol.setPlcOutputCharge(plcOutIos[4] == 1); |
| | | shuttleProtocol.setPlcOutputStatusIO(modbusTcpNet.getByteTransform().TransInt16(content, 10)); |
| | | //错误信息码 |
| | | shuttleProtocol.setStatusErrorCode(modbusTcpNet.getByteTransform().TransInt16(content,12)); |
| | | int plcInIo = modbusTcpNet.getByteTransform().TransUInt16(content, 14); |
| | | int[] plcInIos = CommonUtils.byteToBits((byte) plcInIo); |
| | | //PLC输入状态 |
| | | shuttleProtocol.setPlcInputStatus(modbusTcpNet.getByteTransform().TransInt16(content,14)); |
| | | shuttleProtocol.setPlcInputStatus((short) plcInIos[6]); |
| | | //当前或者之前读到的二维码值 |
| | | shuttleProtocol.setCurrentOrBeforeCode(modbusTcpNet.getByteTransform().TransInt16(content,16)); |
| | | //读到的二维码X方向偏移量 |
| | |
| | | return false; |
| | | } |
| | | |
| | | //将标记置为false(防止重发) |
| | | shuttleProtocol.setPakMk(false); |
| | | |
| | | List<ShuttleCommand> errorCommands = redisCommand.getErrorCommands(); |
| | | if (errorCommands.size() > 0) { |
| | | //优先执行该指令 |
| | |
| | | int size = commands.size(); |
| | | ShuttleAssignCommand assignCommand = redisCommand.getAssignCommand(); |
| | | |
| | | if (commandStep != 0) { |
| | | //判断上一条指令是否完成 |
| | | ShuttleCommand command = commands.get(commandStep - 1); |
| | | if (command.getCommandWord().intValue() == 1) { |
| | | //移动命令 |
| | | if (command.getDistCodeNum().intValue() == shuttleProtocol.getCurrentCode().intValue()) { |
| | | //上一条指令的目标位置和当前小车位置相同,则认定上一条任务完成 |
| | | command.setComplete(true); |
| | | } |
| | | } else if (command.getCommandWord().intValue() == 2) { |
| | | //托盘顶升命令 |
| | | if (command.getPalletLift().intValue() == 1) { |
| | | //顶升 |
| | | //判断是否顶升到位 |
| | | if (shuttleProtocol.getPlcOutputLift()) { |
| | | //自动模式 |
| | | if (assignCommand.getAuto() && shuttleProtocol.getPlcInputStatus().intValue() == 1) { |
| | | //顶升到位,且托盘雷达有物,认定任务完成 |
| | | command.setComplete(true); |
| | | }else { |
| | | //手动模式,不判断托盘雷达 |
| | | //顶升到位,认定任务完成 |
| | | command.setComplete(true); |
| | | } |
| | | } |
| | | }else { |
| | | //下降 |
| | | //判断是否下降到位,判断托盘雷达是否无物 |
| | | if (!shuttleProtocol.getPlcOutputLift() && !shuttleProtocol.getPlcOutputTransfer()) { |
| | | //自动模式 |
| | | if (assignCommand.getAuto() && shuttleProtocol.getPlcInputStatus().intValue() == 0) { |
| | | //下降到位,且托盘雷达无物,认定任务完成 |
| | | command.setComplete(true); |
| | | }else { |
| | | //手动模式,不判断托盘雷达 |
| | | //下降到位,且托盘雷达无物,认定任务完成 |
| | | command.setComplete(true); |
| | | } |
| | | } |
| | | } |
| | | } else if (command.getCommandWord().intValue() == 5) { |
| | | //充电命令 |
| | | //判断小车充电开关 |
| | | if (shuttleProtocol.getPlcOutputCharge()) { |
| | | //正常充电,认定任务完成 |
| | | command.setComplete(true); |
| | | } |
| | | } |
| | | //任务数据保存到redis |
| | | redisUtil.set("shuttle_wrk_no_" + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand)); |
| | | |
| | | if (!command.getComplete()) { |
| | | //上一条任务未完成,禁止下发命令 |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | //取出命令 |
| | | ShuttleCommand command = commands.get(commandStep); |
| | | |
| | |
| | | //小车当前命令起始位置就是提升机二维码,说明小车需要向提升机外移动,则需要判断状态是否满足 |
| | | if (command.getStartCodeNum().intValue() == liftProtocol.getBarcode().intValue()){ |
| | | //提升机是否空闲,提升机是否到达目标楼层,目标楼层是否给出提升机到位信号位 |
| | | if (!liftProtocol.isIdle()) { |
| | | if (!liftProtocol.isIdleNoTask()) { |
| | | return false;//提升机忙,禁止下发命令 |
| | | } |
| | | if (liftProtocol.getTaskNo().intValue() != wrkNo) { |
| | | //提升机工作号和当前工作不相同,禁止下发命令 |
| | | return false; |
| | | } |
| | | |
| | | Short distCodeNum = command.getDistCodeNum();//目标二维码 |
| | |
| | | } else { |
| | | News.info("四向穿梭车命令下发成功,穿梭车号={},任务数据={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command)); |
| | | |
| | | //将标记置为false(防止重发) |
| | | shuttleProtocol.setPakMk(false); |
| | | |
| | | //保存数据到数据库做流水 |
| | | BasShuttleOptService shuttleOptService = SpringUtils.getBean(BasShuttleOptService.class); |
| | | if (shuttleOptService != null) { |