自动化立体仓库 - WCS系统
lty
2025-03-29 8e7bafc2ef250baf2989d0584a0d3812d4113ff3
#输送线循环覆写由plc执行
4个文件已修改
85 ■■■■ 已修改文件
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 35 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/MainProcess.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/SiemensDevpThread.java 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -164,10 +164,12 @@
                                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, staProtocol5));
                            }
                        } else {
                            short workNo = staProtocol.getWorkNo();
                            staProtocol.setWorkNo(workNo);
                            staProtocol.setStaNo((short) 112);
                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, staProtocol));
                            if(staProtocol.isLoading() && (staProtocol.getStaNo() == 105 || staProtocol.getStaNo() == 110 ||  staProtocol.getStaNo() == 111)){
                                short workNo = staProtocol.getWorkNo();
                                staProtocol.setWorkNo(workNo);
                                staProtocol.setStaNo((short) 112);
                                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, staProtocol));
                            }
                        }
                    }
                }
@@ -195,21 +197,7 @@
                }
                StaProtocol staProtocol = devpThread.getStation().get(112);
                StaProtocol staProtocol2 = devpThread.getStation().get(116);
//                StaProtocol staProtocol3 = devpThread.getStation().get(117);
//                if(Objects.equals(staProtocol3.getWorkNo(), staProtocol.getWorkNo()) && staProtocol.getWorkNo() != 0){
//                    staProtocol.setWorkNo((short) 0);
//                    staProtocol.setStaNo((short) 0);
//                    MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
//                    Thread.sleep(100); // 让 PLC 识别变化
//                }
                if (staProtocol == null || staProtocol.getWorkNo() == 0 || !staProtocol.isLoading() ) {
                    continue;
                }
                if(staProtocol.getStaNo() != 112){
                    continue;
                }
                if(staProtocol.getWorkNo() == staProtocol2.getWorkNo()) {
                if (staProtocol.getStaNo() != 112 || staProtocol.getWorkNo() == 0 || !staProtocol.isLoading() || staProtocol.getWorkNo() > 9000 || staProtocol.getWorkNo() < 6000) {
                    continue;
                }
                // 查询任务信息
@@ -218,14 +206,7 @@
                    continue;
                }
//                 先清零
                short workNo = staProtocol.getWorkNo();
                short oldStaNo = staProtocol.getStaNo();
//                staProtocol.setWorkNo((short) 0);
//                staProtocol.setStaNo((short) 0);
//                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
//                Thread.sleep(100); // 让 PLC 识别变化
                // 再写入目标站点
                staProtocol.setWorkNo(workNo);
                staProtocol.setStaNo(Short.valueOf(taskWrk.getTargetPoint()));
@@ -984,7 +965,7 @@
                        }
                        int storeCount = basDevpService.getStoreCount();
                        if(storeCount >= maxCount){
                            log.error("输送线暂存数达到上限");
                            log.error("输送线暂存数达到上限{}",storeCount);
                            break;
                        }
src/main/java/com/zy/core/MainProcess.java
@@ -66,15 +66,15 @@
                    // 其他  ===>> // 入出库模式切换函数
                    //环形循环函数
                    mainService.shiftTargetToCyclePoint();
                    mainService.shiftCyclePointToTarget();
//                    i++;
//                    if (i > maxCount) {
//                        //环形循环函数
//                        mainService.shiftTargetToCyclePoint();
//                        mainService.shiftCyclePointToTarget();
//                        i = 0;
//                    }
//                    mainService.shiftTargetToCyclePoint();
//                    mainService.shiftCyclePointToTarget();
                    i++;
                    if (i > maxCount) {
                        //环形循环函数
                        mainService.shiftTargetToCyclePoint();
                        mainService.shiftCyclePointToTarget();
                        i = 0;
                    }
                    //自动派发任务
   //                 mainService.autoDistribute();
src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -584,33 +584,11 @@
                plcAddressStaNo = "DB73." + (4 * 6 + 4);
                break;
        }
//        String plcAddressWorkNo = "DB100." + index * 6;
//        String plcAddressStaNo = "DB100." + (index * 6 + 4);
        while (writeCount < 5) {
            // **读取当前PLC状态,避免不必要的写入**
            OperateResultExOne<byte[]> readResult = siemensS7Net.Read(plcAddressWorkNo, (short) 6);
            if (readResult.IsSuccess) {
                int currentWorkNo = siemensS7Net.getByteTransform().TransInt32(readResult.Content, 0);
                short currentStaNo = siemensS7Net.getByteTransform().TransInt16(readResult.Content, 4);
                if (currentWorkNo == staProtocol.getWorkNo().intValue() && currentStaNo == staProtocol.getStaNo()) {
                    log.info("站点 {} 当前状态已匹配,无需重复写入", staProtocol.getSiteId());
                    return;
                }
            }
            // **写入新任务**
            if (writeTaskToPLC(plcAddressWorkNo, plcAddressStaNo, staProtocol)) {
                writeFlag = true;
                log.info("输送线命令写入成功,PLC编号={},站点数据={},尝试次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
                break;
            }
            log.warn("输送线命令写入失败,PLC编号={},站点数据={},尝试次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
            writeCount++;
        // **写入新任务**
        if (writeTaskToPLC(plcAddressWorkNo, plcAddressStaNo, staProtocol)) {
            writeFlag = true;
            log.info("输送线命令写入成功,PLC编号={},站点数据={},尝试次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
        }
        // **写入失败处理**
        handleWriteFailure(staProtocol, writeFlag);
    }
src/main/resources/application.yml
@@ -46,7 +46,7 @@
wms:
  #输送线暂存数
  count: 8
  maxCirle: 5
  maxCirle: 3
  # 是否开启上报
  start: true
  # WMS系统ip