|  |  | 
 |  |  |     @SuppressWarnings("InfiniteLoopStatement") | 
 |  |  |     public void run() { | 
 |  |  |         this.connect(); | 
 |  |  | //        try { | 
 |  |  | //            Thread.sleep(2000); | 
 |  |  | //        } catch (InterruptedException e) { | 
 |  |  | //            e.printStackTrace(); | 
 |  |  | //        } | 
 |  |  |         while (true) { | 
 |  |  |             try { | 
 |  |  |                 int step = 1; | 
 |  |  | 
 |  |  |         if (null == crnProtocol) { | 
 |  |  |             crnProtocol = new CrnProtocol(); | 
 |  |  |         } | 
 |  |  |         crnProtocol.setCrnNo(slave.getId()); | 
 |  |  |         crnProtocol.setMode((short) -1); | 
 |  |  | //        crnProtocol.setTaskNo((short)0); | 
 |  |  |         crnProtocol.setStatus((short)-1); | 
 |  |  | 
 |  |  |             log.error("堆垛机plc连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); | 
 |  |  |             initCrn(); | 
 |  |  |         } | 
 |  |  |         melsecMcNet.ConnectClose(); | 
 |  |  | //        melsecMcNet.ConnectClose(); | 
 |  |  |         return result; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     private void readStatus(){ | 
 |  |  |         try { | 
 |  |  | //            if (this.slave.getId() == 1 && flag1.equals(0)) { | 
 |  |  | //                Thread.sleep(3000); | 
 |  |  | //                flag1=1; | 
 |  |  | //                System.out.println("==="); | 
 |  |  | //            } | 
 |  |  |             OperateResultExOne<byte[]> result = melsecMcNet.Read("D20", (short) 70); | 
 |  |  |             if (result.IsSuccess) { | 
 |  |  |                 if (null == crnProtocol) { | 
 |  |  |                     crnProtocol = new CrnProtocol(); | 
 |  |  |                 } | 
 |  |  |                 crnProtocol.setCrnNo(slave.getId()); | 
 |  |  |                 crnProtocol.setMode(melsecMcNet.getByteTransform().TransInt16(result.Content, 0)); | 
 |  |  |                 crnProtocol.setTaskNo(melsecMcNet.getByteTransform().TransInt16(result.Content, 2)); | 
 |  |  |                 crnProtocol.setStatus(melsecMcNet.getByteTransform().TransInt16(result.Content, 4)); | 
 |  |  | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                 // 根据实时信息更新数据库 | 
 |  |  |                 BasCrnpService basCrnpService = SpringUtils.getBean(BasCrnpService.class); | 
 |  |  |                 BasCrnp basCrnp = new BasCrnp(); |