1
zhang
2025-07-10 b8feb2880cc44d8408627db431eb9cf31967f393
src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -47,7 +47,8 @@
//
//    }};
    public static final ArrayList<Integer> staNos1 = new ArrayList<Integer>() {{
        add(101);add(102);
        add(101);
        add(102);
    }};
@@ -116,6 +117,7 @@
        }
    }
    /**
     * 初始化站点状态
     */
@@ -192,20 +194,7 @@
                staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result4.Content, i*2));   // 目标站
            }
        }
//        Thread.sleep(200);
//        OperateResultExOne<byte[]> result0 = siemensS7Net.Read("DB101.0", (short) 186);
//        if (result0.IsSuccess) {
//            for (int i = 0; i < 93; i++) {
//                Integer siteId = staNos.get(i); // 站点编号
//                StaProtocol staProtocol = station.get(siteId);
//                if (null == staProtocol) {
//                    staProtocol = new StaProtocol();
//                    staProtocol.setSiteId(siteId);
//                    station.put(siteId, staProtocol);
//                }
//                staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result0.Content, i*2));   // 目标站
//            }
//        }
        //条码扫描器
        Thread.sleep(200);
        OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB100.200",(short)(barcodeSize*8));
@@ -218,7 +207,20 @@
                    barcodeThread.setBarcode(barcode);
                }
            }
        }
        //外形检测
        OperateResultExOne<byte[]> resultErr = siemensS7Net.Read("DB101.42", (short) 8);
        if (resultErr.IsSuccess) {
            boolean[] status = siemensS7Net.getByteTransform().TransBool(resultErr.Content, 0, 1);
            StaProtocol staProtocol = station.get(304);
            staProtocol.setFrontErr(status[0]);
            staProtocol.setBackErr(status[1]);
            staProtocol.setHighErr(status[2]);
            staProtocol.setLeftErr(status[3]);
            staProtocol.setRightErr(status[4]);
            staProtocol.setWeightErr(status[5]);
            staProtocol.setBarcodeErr(status[6]);
        }
        Thread.sleep(200);
@@ -240,21 +242,12 @@
                if (!staProtocol.isPakMk() && !staProtocol.isLoading()) {
                    staProtocol.setPakMk(true);
                }
                if (staProtocol.getStamp()>=2 && !staProtocol.isLoading()){
                    staProtocol.setStamp(0);
                }else if (staProtocol.getStamp()<2 && staProtocol.isLoading()){
                    //lfd入库印记  当stamp>=2时才入库
                    staProtocol.setStamp(staProtocol.getStamp()+1);
                }
            }
        }
        if (result.IsSuccess && result1.IsSuccess) {
            OutputQueue.DEVP.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), slave.getId()));
            // 根据实时信息更新数据库
            try {
                List<BasDevp> basDevps = new ArrayList<>();
@@ -320,8 +313,7 @@
                    writeCount++;
                    log.error("写入输送线命令后读取失败。输送线plc编号={},站点数据={},写入次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
                }
            }
            else {
            } else {
                writeCount++;
                log.error("写入输送线命令后读取失败。输送线plc编号={},站点数据={},写入次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
            }