自动化立体仓库 - WCS系统
#
luxiaotao1123
2022-03-17 9a10da7c920e5b926ad1278672b1dab7e604edb4
#
1个文件已修改
128 ■■■■ 已修改文件
src/main/java/com/zy/core/thread/MelsecCrnThread.java 128 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/MelsecCrnThread.java
@@ -230,73 +230,73 @@
            return false;
        }
        OperateResult result = null;
        try{
            Integer exeCount=0;
            do{
                command.setCrnNo(slave.getId());
                short[] array = new short[10];
                array[0] = command.getAckFinish();
                array[1] = command.getTaskNo();
                array[2] = command.getTaskMode();
                array[3] = command.getSourcePosX();
                array[4] = command.getSourcePosY();
                array[5] = command.getSourcePosZ();
                array[6] = command.getDestinationPosX();
                array[7] = command.getDestinationPosY();
                array[8] = command.getDestinationPosZ();
                array[9] = command.getCommand();
                result = melsecMcNet.Write("D0", array);
                if(result.IsSuccess) {
                    if (command.getAckFinish() == 0) {
                        short commandFinish = 1;
                        result = melsecMcNet.Write("D9", commandFinish);
                        if(result.IsSuccess){
                            //写任务确认返回成功后,查询确认一次
                            Thread.sleep(200);
                            OperateResultExOne<byte[]> result1 = melsecMcNet.Read("D9", (short)2);
                            if(result1.IsSuccess){
                                short commandVal = melsecMcNet.getByteTransform().TransInt16(result1.Content,2);
                                if(commandVal==1){
                                    break;
                                } else {
                                    exeCount++;
                                }
                            } else{
                                exeCount++;
                            }
                        }else{
                            exeCount++;
                        }
                    }
                }else{
                    exeCount++;
                }
                Thread.sleep(200);
            }while(exeCount>3);
        }catch (Exception e){
        }
//        command.setCrnNo(slave.getId());
//        short[] array = new short[10];
//        array[0] = command.getAckFinish();
//        array[1] = command.getTaskNo();
//        array[2] = command.getTaskMode();
//        array[3] = command.getSourcePosX();
//        array[4] = command.getSourcePosY();
//        array[5] = command.getSourcePosZ();
//        array[6] = command.getDestinationPosX();
//        array[7] = command.getDestinationPosY();
//        array[8] = command.getDestinationPosZ();
//        array[9] = command.getCommand();
//        OperateResult result = melsecMcNet.Write("D0", array);
//        OperateResult result = null;
//        try{
//            Integer exeCount=0;
//            do{
//                command.setCrnNo(slave.getId());
//                short[] array = new short[10];
//                array[0] = command.getAckFinish();
//                array[1] = command.getTaskNo();
//                array[2] = command.getTaskMode();
//                array[3] = command.getSourcePosX();
//                array[4] = command.getSourcePosY();
//                array[5] = command.getSourcePosZ();
//                array[6] = command.getDestinationPosX();
//                array[7] = command.getDestinationPosY();
//                array[8] = command.getDestinationPosZ();
//                array[9] = command.getCommand();
//                result = melsecMcNet.Write("D0", array);
//                if(result.IsSuccess) {
//                    if (command.getAckFinish() == 0) {
//                        short commandFinish = 1;
//                        result = melsecMcNet.Write("D9", commandFinish);
//                        if(result.IsSuccess){
//                            //写任务确认返回成功后,查询确认一次
//                            Thread.sleep(200);
//                            OperateResultExOne<byte[]> result1 = melsecMcNet.Read("D9", (short)2);
//                            if(result1.IsSuccess){
//                                short commandVal = melsecMcNet.getByteTransform().TransInt16(result1.Content,2);
//                                if(commandVal==1){
//                                    break;
//                                } else {
//                                    exeCount++;
//                                }
//                            } else{
//                                exeCount++;
//                            }
//                        }else{
//                            exeCount++;
//                        }
//                    }
//                }else{
//                    exeCount++;
//                }
//                Thread.sleep(200);
//            }while(exeCount>3);
//        }catch (Exception e){
//
//        if (command.getAckFinish() == 0) {
//            short commandFinish = 1;
//            result = melsecMcNet.Write("D9", commandFinish);
//        }
        command.setCrnNo(slave.getId());
        short[] array = new short[10];
        array[0] = command.getAckFinish();
        array[1] = command.getTaskNo();
        array[2] = command.getTaskMode();
        array[3] = command.getSourcePosX();
        array[4] = command.getSourcePosY();
        array[5] = command.getSourcePosZ();
        array[6] = command.getDestinationPosX();
        array[7] = command.getDestinationPosY();
        array[8] = command.getDestinationPosZ();
        array[9] = command.getCommand();
        OperateResult result = melsecMcNet.Write("D0", array);
        if (command.getAckFinish() == 0) {
            short commandFinish = 1;
            result = melsecMcNet.Write("D9", commandFinish);
        }
        try {
            // 日志记录
            BasCrnOptService bean = SpringUtils.getBean(BasCrnOptService.class);