|  |  | 
 |  |  |                 switch (step) { | 
 |  |  |                     // 读数据 | 
 |  |  |                     case 1: | 
 |  |  |                         readStatus(); | 
 |  |  |                         read(); | 
 |  |  |                         break; | 
 |  |  |                     // 写入数据 | 
 |  |  |                     case 2: | 
 |  |  | 
 |  |  |     @Override | 
 |  |  |     public void close() { | 
 |  |  |         modbusTcpNet.ConnectClose(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private void read() { | 
 |  |  |         try { | 
 |  |  |             readStatus(); | 
 |  |  |             //四向穿梭车空闲、有任务、标记为true、存在任务指令,需要执行任务的下一条指令 | 
 |  |  |             if (shuttleProtocol.getBusyStatusType() == ShuttleStatusType.IDLE | 
 |  |  |                     && shuttleProtocol.getTaskNo() != 0 | 
 |  |  |                     && shuttleProtocol.getPakMk()) { | 
 |  |  |                 //执行下一步指令 | 
 |  |  |                 executeWork(shuttleProtocol.getTaskNo()); | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |             OutputQueue.SHUTTLE.offer(MessageFormat.format("【{0}】四向穿梭车plc状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); | 
 |  |  |             initShuttle(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private void readStatus() { | 
 |  |  | 
 |  |  |                 if (shuttleProtocol.getBusyStatusType() == ShuttleStatusType.BUSY) { | 
 |  |  |                     shuttleProtocol.setPakMk(true); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  | //                if (shuttleProtocol.getErrorCode() != 0 && shuttleProtocol.getProtocolStatusType() == ShuttleProtocolStatusType.WORKING) { | 
 |  |  | //                    //出现错误 | 
 |  |  | //                    resetAndTryFix(shuttleProtocol.getTaskNo()); | 
 |  |  | //                } | 
 |  |  | // | 
 |  |  | //                if(shuttleProtocol.getProtocolStatusType() == ShuttleProtocolStatusType.FIXING | 
 |  |  | //                        && shuttleProtocol.getTaskNo() != 0 | 
 |  |  | //                        && shuttleProtocol.getBusyStatusType() == ShuttleStatusType.IDLE){ | 
 |  |  | //                    //处于故障修复状态 | 
 |  |  | //                    //执行下一步指令 | 
 |  |  | //                    executeWork(shuttleProtocol.getTaskNo()); | 
 |  |  | //                } | 
 |  |  |  | 
 |  |  |                 //四向穿梭车空闲、有任务、标记为true、存在任务指令,需要执行任务的下一条指令 | 
 |  |  |                 if (shuttleProtocol.getBusyStatusType() == ShuttleStatusType.IDLE | 
 |  |  |                         && shuttleProtocol.getTaskNo() != 0 | 
 |  |  |                         && shuttleProtocol.getPakMk()) { | 
 |  |  |                     //执行下一步指令 | 
 |  |  |                     executeWork(shuttleProtocol.getTaskNo()); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  | //                //检测是否有提升机锁定标记,有则检测提升机是否到位,是否能走下一步命令 | 
 |  |  | //                if (shuttleProtocol.getBusyStatusType() == ShuttleStatusType.IDLE | 
 |  |  | //                        && shuttleProtocol.getTaskNo() != 0) { | 
 |  |  | //                    Object o = redisUtil.get("shuttle_wrk_no_" + shuttleProtocol.getTaskNo()); | 
 |  |  | //                    if (o != null) { | 
 |  |  | //                        ShuttleRedisCommand redisCommand = JSON.parseObject(o.toString(), ShuttleRedisCommand.class); | 
 |  |  | //                        if (redisCommand.getLiftSecurityMk()) { | 
 |  |  | //                            //执行下一步指令 | 
 |  |  | //                            executeWork(shuttleProtocol.getTaskNo()); | 
 |  |  | //                        } | 
 |  |  | //                    } | 
 |  |  | //                } | 
 |  |  |  | 
 |  |  |                 //将四向穿梭车状态保存至数据库 | 
 |  |  |                 BasShuttleService shuttleService = SpringUtils.getBean(BasShuttleService.class); | 
 |  |  | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             for (int i = 0; i < 5; i++) { | 
 |  |  |                 if (command.getCommandWord().intValue() == 5 || command.getCommandWord().intValue() == 6) { | 
 |  |  |                     break;//充电开关和系统复位不需要重发机制 | 
 |  |  |                 } | 
 |  |  |                 readStatus();//重新读取状态 | 
 |  |  |                 if (shuttleProtocol.getBusyStatusType().equals(ShuttleStatusType.BUSY)) { | 
 |  |  |                     break; |