Junjie
2023-07-19 13b93182b70c276996b2d00de9497eb6843b072e
src/main/java/com/zy/core/thread/ShuttleThread.java
@@ -292,15 +292,34 @@
        }
        command.setShuttleNo(slave.getId().shortValue());
        short[] array = getCommandArr(command);//获取命令报文
        OperateResult result = modbusTcpNet.Write("0", array);;
        OperateResult result = modbusTcpNet.Write("0", array);
        if (result != null && result.IsSuccess) {
            News.info("四向穿梭车命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command));
            OutputQueue.SHUTTLE.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command)));
            try {
                Thread.sleep(3000);//命令下发后休眠1s
                Thread.sleep(3000);//命令下发后休眠
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            News.info("四向穿梭车命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command));
            OutputQueue.SHUTTLE.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command)));
            for (int i = 0; i < 5; i++) {
                readStatus();//重新读取状态
                if (shuttleProtocol.getBusyStatusType().equals(ShuttleStatusType.BUSY)) {
                    break;
                }
                //判断是否运行中,如不运行,重新下发命令
                result = modbusTcpNet.Write("0", array);
                News.info("四向穿梭车命令下发[id:{}] >>>>> {},次数:{}", slave.getId(), JSON.toJSON(command), i);
                OutputQueue.SHUTTLE.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2},次数:{}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command), i));
                try {
                    Thread.sleep(3000);//命令下发后休眠
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            return true;
        } else {
            OutputQueue.SHUTTLE.offer(MessageFormat.format("【{0}】写入四向穿梭车plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));