自动化立体仓库 - WCS系统
Junjie
2023-12-20 ca6062762cf95a074635626ce185d2fd14512e76
src/main/java/com/zy/core/thread/LiftThread.java
@@ -272,6 +272,13 @@
                }
            }
            Thread.sleep(100);
            //获取提升机异常数据
            OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB82.22.0", (short) 2);
            if (result3.IsSuccess) {
                liftProtocol.setErrorCode(siemensS7Net.getByteTransform().TransInt16(result3.Content, 0));//错误码
            }
        } catch (Exception e) {
            OutputQueue.LIFT.offer(MessageFormat.format("【{0}】提升机plc状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
        }
@@ -288,6 +295,7 @@
        OperateResult result = siemensS7Net.Write("DB83.0", array);
        if (result != null && result.IsSuccess) {
            liftProtocol.setSendTime(System.currentTimeMillis());//指令下发时间
            News.info("提升机命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command));
            OutputQueue.LIFT.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command)));
            return true;
@@ -329,7 +337,7 @@
        redisCommand.setCommandStep(0);//命令执行步序
        redisCommand.setAssignCommand(assignCommand);//命令
        //任务数据保存到redis
        redisUtil.set("lift_wrk_no_" + assignCommand.getTaskNo(), JSON.toJSONString(redisCommand));
        redisUtil.set(RedisKeyType.LIFT.key + assignCommand.getTaskNo(), JSON.toJSONString(redisCommand));
        liftProtocol.setAssignCommand(assignCommand);
        liftProtocol.setProtocolStatus(LiftProtocolStatusType.WORKING);
        //执行下发任务
@@ -344,7 +352,7 @@
        }
        WrkMastMapper wrkMastMapper = SpringUtils.getBean(WrkMastMapper.class);
        Object o = redisUtil.get("lift_wrk_no_" + wrkNo);
        Object o = redisUtil.get(RedisKeyType.LIFT.key + wrkNo);
        if (o == null) {
            return false;
        }
@@ -357,6 +365,10 @@
        //取出命令
        NyLiftCommand command = commands.get(commandStep);
        if (!redisCommand.getLiftNo().equals(liftProtocol.getLiftNo())) {
            return false;
        }
        //下发命令
        if (!write(command)) {
@@ -376,7 +388,7 @@
            short[] commandArr = getCommandArr(command);//获取命令报文
            BasLiftOpt opt = new BasLiftOpt(
                    redisCommand.getWrkNo().intValue(),
                    redisCommand.getLiftNo().intValue(),
                    liftProtocol.getLiftNo().intValue(),
                    new Date(),
                    null,
                    null,
@@ -395,11 +407,11 @@
            commandStep++;
            redisCommand.setCommandStep(commandStep);
            //任务数据保存到redis
            redisUtil.set("lift_wrk_no_" + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand));
            redisUtil.set(RedisKeyType.LIFT.key + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand));
        }else {
            //已执行完成
            //删除redis
            redisUtil.del("lift_wrk_no_" + redisCommand.getWrkNo());
            redisUtil.del(RedisKeyType.LIFT.key + redisCommand.getWrkNo());
            //对主线程抛出等待确认状态waiting
            liftProtocol.setProtocolStatus(LiftProtocolStatusType.WAITING);