*
L
2 天以前 e2a14112a81740481623dc16bbd1301432ce34b0
src/main/java/com/zy/core/thread/SiemensCrnThread.java
@@ -105,7 +105,7 @@
                    default:
                        break;
                }
                Thread.sleep(500);
                Thread.sleep(200);
            } catch (Exception e) {
//                e.printStackTrace();
            }
@@ -282,16 +282,20 @@
            log.error("堆垛机写入命令为空");
            return false;
        }
        CrnErrCache.updateCrnErr(slave.getId(), "-");
//        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){
//        }
//        convertRow(command);
        try{
            DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
            deviceErrorService.addDeviceError("crnWriteIng", slave.getId(), "巷道号"+command.getLaneNo()+";堆垛机待下发指令:"+JSON.toJSONString(command.getNowTask()));
        } catch (Exception e){
            log.error("crnWriteIng新增异常");
        }
        try{
            CrnErrCache.updateCrnErr(slave.getId(), "-");
        } catch (Exception e){
            log.error(JSON.toJSONString(e));
            log.error("堆垛机任务写异常:异常定位值:crnWrite-294行");
        }
        command.setCrnNo(slave.getId());
        short[] array = new short[10];
        array[0] = command.getAckFinish();
@@ -305,24 +309,32 @@
        array[8] = command.getDestinationPosZ();
//        array[9] = command.getCommand();
        array[9] = (short)0;
        log.info("堆垛机任务写100.18:值:0 crnWrite-313行");
        OperateResult result18 = siemensNet.Write("DB100.18", (short)0);
        if (command.getAckFinish() == 0) {
            log.info("堆垛机任务写100.0:值:0 crnWrite-317行");
            OperateResult result100 = siemensNet.Write("DB100.0", (short)0);
        }
        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);
        int i=0;
        do{
            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();
@@ -343,7 +355,6 @@
                        || !command.getDestinationPosY().equals(one.getDestinationPosY())
                        || !command.getDestinationPosZ().equals(one.getDestinationPosZ())
                ){
                    i++;
                    CrnErrCache.updateCrnErr(slave.getId(), "堆垛机命令地址写入后回读失败");
                    log.error("堆垛机命令地址写入后回读失败[id:{}]>>>>重写[{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), i,JSON.toJSON(command),JSON.toJSON(one));
@@ -370,6 +381,16 @@
                    }
                    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){
                }
            }
        }while(i<5);
@@ -381,6 +402,7 @@
            result = siemensNet.Write("DB100.18", commandFinish);
            int signFinish = 1;
            while (signFinish<5){
                signFinish++;
                OperateResultExOne<byte[]> result10018 = siemensNet.Read("DB100.18", (short) 2);
                short transInt16 = siemensNet.getByteTransform().TransInt16(result10018.Content, 0);
                if (transInt16 != commandFinish){
@@ -401,7 +423,6 @@
                    } catch (Exception e3){
                    }
                    result = siemensNet.Write("DB100.18", commandFinish);
                    signFinish++;
                }else {
                    log.info("下发DB100.18" + "commandFinish:"+commandFinish);
                    log.info("下发DB100.18" + "array:"+ JSON.toJSONString(array));