*
L
昨天 c3434b1fe0132372b34ff0a46d84e6129a094bfc
src/main/java/com/zy/core/thread/SiemensCrnThread.java
@@ -286,6 +286,7 @@
            DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
            deviceErrorService.addDeviceError("crnWriteIng", slave.getId(), "巷道号"+command.getLaneNo()+";堆垛机待下发指令:"+JSON.toJSONString(command.getNowTask()));
        } catch (Exception e){
            log.error("crnWriteIng新增异常");
        }
        try{
@@ -320,7 +321,7 @@
        try{
            Thread.sleep(50L);
        } catch (Exception e){}
        } catch (Exception e){log.error("延时异常324行");}
        log.info("堆垛机任务写100.0:值:array crnWrite-317行;array:"+JSON.toJSONString(array));
        OperateResult result = siemensNet.Write("DB100.0", array);
@@ -330,66 +331,70 @@
            i++;
            //堆垛机任务写入后,回读一次,看是否成功
            try{
                Thread.sleep(100L);
            } catch (Exception e){}
                Thread.sleep(50L);
            } catch (Exception e){log.error("延时异常335行");}
            log.info("堆垛机任务读100.0:值:20 crnWrite-317行;");
            OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 20);
            if (resultRead.IsSuccess) {
                CrnCommand one = new CrnCommand();
                one.setTaskNo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 2));
                one.setTaskMode(siemensNet.getByteTransform().TransInt16(resultRead.Content, 4));
                one.setSourcePosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 6));
                one.setSourcePosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 8));
                one.setSourcePosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 10));
                one.setDestinationPosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 12));
                one.setDestinationPosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 14));
                one.setDestinationPosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 16));
                if (!command.getTaskNo().equals(one.getTaskNo())
                        || !command.getTaskMode().equals(one.getTaskMode())
                        || !command.getSourcePosX().equals(one.getSourcePosX())
                        || !command.getSourcePosY().equals(one.getSourcePosY())
                        || !command.getSourcePosZ().equals(one.getSourcePosZ())
                        || !command.getDestinationPosX().equals(one.getDestinationPosX())
                        || !command.getDestinationPosY().equals(one.getDestinationPosY())
                        || !command.getDestinationPosZ().equals(one.getDestinationPosZ())
                ){
                    CrnErrCache.updateCrnErr(slave.getId(), "堆垛机命令地址写入后回读失败");
            try{
                OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 20);
                if (resultRead.IsSuccess) {
                    CrnCommand one = new CrnCommand();
                    one.setTaskNo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 2));
                    one.setTaskMode(siemensNet.getByteTransform().TransInt16(resultRead.Content, 4));
                    one.setSourcePosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 6));
                    one.setSourcePosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 8));
                    one.setSourcePosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 10));
                    one.setDestinationPosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 12));
                    one.setDestinationPosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 14));
                    one.setDestinationPosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 16));
                    if (!command.getTaskNo().equals(one.getTaskNo())
                            || !command.getTaskMode().equals(one.getTaskMode())
                            || !command.getSourcePosX().equals(one.getSourcePosX())
                            || !command.getSourcePosY().equals(one.getSourcePosY())
                            || !command.getSourcePosZ().equals(one.getSourcePosZ())
                            || !command.getDestinationPosX().equals(one.getDestinationPosX())
                            || !command.getDestinationPosY().equals(one.getDestinationPosY())
                            || !command.getDestinationPosZ().equals(one.getDestinationPosZ())
                    ){
                        CrnErrCache.updateCrnErr(slave.getId(), "堆垛机命令地址写入后回读失败");
                    log.error("堆垛机命令地址写入后回读失败[id:{}]>>>>重写[{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), i,JSON.toJSON(command),JSON.toJSON(one));
                        log.error("堆垛机命令地址写入后回读失败[id:{}]>>>>重写[{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), i,JSON.toJSON(command),JSON.toJSON(one));
                    try{
                        DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
                        deviceErrorService.addDeviceError("CrnErr", slave.getId(), "巷道号"+command.getLaneNo()+";写入次数"+i+";堆垛机命令地址写入后回读失败:"+JSON.toJSONString(command.getNowTask()));
                    } catch (Exception e2){
                    }
                    try{
                        BasErrLogService basErrLogService = SpringUtils.getBean(BasErrLogService.class);
                        BasErrLog basErrLog = new BasErrLog(command,"堆垛机命令地址写入后回读失败","");
                        if (!basErrLogService.insert(basErrLog)) {
                            log.error("堆垛机plc异常记录失败 ===>> [id:{}] [error:{}]", slave.getId(), "堆垛机命令地址写入后回读失败记录失败");
                        try{
                            DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
                            deviceErrorService.addDeviceError("CrnErr", slave.getId(), "巷道号"+command.getLaneNo()+";写入次数"+i+";堆垛机命令地址写入后回读失败:"+JSON.toJSONString(command.getNowTask()));
                        } catch (Exception e2){
                        }
                    } catch (Exception e3){
                        try{
                            BasErrLogService basErrLogService = SpringUtils.getBean(BasErrLogService.class);
                            BasErrLog basErrLog = new BasErrLog(command,"堆垛机命令地址写入后回读失败","");
                            if (!basErrLogService.insert(basErrLog)) {
                                log.error("堆垛机plc异常记录失败 ===>> [id:{}] [error:{}]", slave.getId(), "堆垛机命令地址写入后回读失败记录失败");
                            }
                        } catch (Exception e3){
                        }
                        result = siemensNet.Write("DB100.0", array);
                    }else{
                        try{
                            DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
                            deviceErrorService.addDeviceError("crnWrite", slave.getId(), "巷道号"+command.getLaneNo()+";堆垛机指令下发:"+JSON.toJSONString(command.getNowTask()));
                        } catch (Exception e2){
                        }
                        break;
                    }
                    result = siemensNet.Write("DB100.0", array);
                }else{
                } else {
                    CrnErrCache.updateCrnErr(slave.getId(), "堆垛机命令读取失败");
                    log.error("堆垛机命令读取失败[id:{}]>>>>重写[{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), i,JSON.toJSON(command),"");
                    try{
                        DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
                        deviceErrorService.addDeviceError("crnWrite", slave.getId(), "巷道号"+command.getLaneNo()+";堆垛机指令下发:"+JSON.toJSONString(command.getNowTask()));
                        deviceErrorService.addDeviceError("CrnErr", slave.getId(), "巷道号"+command.getLaneNo()+";写入次数"+i+";堆垛机命令读取失败:"+JSON.toJSONString(command.getNowTask()));
                    } catch (Exception e2){
                    }
                    break;
                }
            } else {
                CrnErrCache.updateCrnErr(slave.getId(), "堆垛机命令读取失败");
                log.error("堆垛机命令读取失败[id:{}]>>>>重写[{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), i,JSON.toJSON(command),"");
                try{
                    DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
                    deviceErrorService.addDeviceError("CrnErr", slave.getId(), "巷道号"+command.getLaneNo()+";写入次数"+i+";堆垛机命令读取失败:"+JSON.toJSONString(command.getNowTask()));
                } catch (Exception e2){
                }
            } catch (Exception e396){
                log.error("堆垛机任务读100.0:值:20 crnWrite-317行;异常"+e396.getMessage());
            }
        }while(i<5);