自动化立体仓库 - WCS系统
#
lsh
2024-06-25 f30358a20ae9a74ee7f6c604a8d102c1b9b24659
src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -197,6 +197,9 @@
                        Thread.sleep(400);
                        write((StaProtocol)task.getData());
                        break;
                    case 9:
                        write9((StaProtocol)task.getData());
                        break;
                    default:
                        break;
                }
@@ -316,27 +319,6 @@
                }
            }
        }
//        Thread.sleep(200);
//        OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB100.100", (short) (staNoSize * 2));
//        if (result1.IsSuccess) {
//            for (int i = 0; i < staNoSize; i++) {
//                Integer siteId = staNos.get(i); // 站点编号
//                boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, i*2, 1);
//                StaProtocol staProtocol = station.get(siteId);
//                staProtocol.setAutoing(status[0]);  // 自动
//                staProtocol.setLoading(status[1]);  // 有物
//                staProtocol.setInEnable(status[2]); // 可入
//                staProtocol.setOutEnable(status[3]);// 可出
//                staProtocol.setEmptyMk(status[4]);  // 空板信号
//                staProtocol.setFullPlt(status[5]);  // 满托盘
//                staProtocol.setHigh(status[6]);     // 高库位
//                staProtocol.setLow(status[7]);      // 低库位
//
//                if (!staProtocol.isPakMk() && !staProtocol.isLoading()) {
//                    staProtocol.setPakMk(true);
//                }
//            }
//        }
        //条码扫描器
        Thread.sleep(200);
@@ -555,6 +537,86 @@
            log.info("输送线命令下发码垛完成  给输送复位 [id:{}] >>>>> 命令下发: {}",  slave.getId(), JSON.toJSON(staProtocol));
        }
    }
    /**
     * 写入 ID+目标站 =====> 单站点写入
     */
    private void write9(StaProtocol staProtocol) throws InterruptedException {
        if (null == staProtocol) {
            return;
        }
        short resultS1 = staProtocol.getEndRow();
        OperateResult result1 = null;
        String resultV1 = "";
        switch (staProtocol.getSiteId()){
            case 623:
                resultV1 = "1800";
                break;
            case 624:
                resultV1 = "1806";
                break;
            case 625:
                resultV1 = "1812";
                break;
            case 626:
                resultV1 = "1818";
                break;
            default:
                return;
        }
        result1 = siemensS7Net.Write(resultV1, resultS1);
        //硫化罐任务写入后,回读一次,看是否成功
        try {
            Thread.sleep(200);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        int writeCount = 1;
        do {
            try{
                if(!result1.IsSuccess){
                    log.error("写入RGV数据失败,重新下发任务  写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(staProtocol),writeCount);
                    result1 = siemensS7Net.Write(resultV1, resultS1);
                    Thread.sleep(100);
                    writeCount++;
                    continue;
                }
                OperateResultExOne<byte[]> resultRead1 = siemensS7Net.Read(resultV1, (short) 2);
                if (resultRead1.IsSuccess) {
                    short transInt16 = siemensS7Net.getByteTransform().TransInt16(resultRead1.Content, 0);
                    if (transInt16 == resultS1 || transInt16 == (short) 2 || transInt16 == (short) 3){
                        break;
                    } else {
                        log.error("写入RGV数据失败,重新下发任务  写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(staProtocol),writeCount);
                        result1 = siemensS7Net.Write(resultV1, resultS1);
                        Thread.sleep(100);
                        writeCount++;
                        continue;
                    }
                } else {
                    log.error("写入RGV数据失败,重新下发任务  写入直接失败 ===>> [id:{}],{},[写入次数:{}]", slave.getId(), JSON.toJSON(staProtocol),writeCount);
                    result1 = siemensS7Net.Write(resultV1, resultS1);
                    Thread.sleep(100);
                    writeCount++;
                    continue;
                }
            }catch (Exception e){
                log.error("写入RGV数据后回读出错,异常:"+e);
            }
            writeCount++;
        } while (writeCount<6);
        if (!result1.IsSuccess) {
            staProtocol = station.get(staProtocol.getSiteId());
            OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线站点数据失败。输送线plc编号={1},站点数据={2}", slave.getId(), JSON.toJSON(staProtocol)));
            log.error("写入输送线站点数据失败。输送线plc编号={},站点数据={}", slave.getId(), JSON.toJSON(staProtocol));
        } else {
            OutputQueue.DEVP.offer(MessageFormat.format("【{0}】 输送线命令下发 [id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol)));
            log.info("输送线命令下发码垛完成  给输送复位 [id:{}] >>>>> 命令下发: {}",  slave.getId(), JSON.toJSON(staProtocol));
        }
    }
    // 更新入出库模式
    private void updateIoMode() throws InterruptedException {
        if (this.ioModeOf2F != IoModeType.NONE) {