1
zhangchao
2024-08-30 b89f1b9ab0efaea721d7d05b9dc7555e18d12b13
src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -194,8 +194,8 @@
//        updateIoMode();
        ArrayList<Integer> staNos = getStaNo();
        int staNoSize = staNos.size();
        OperateResultExOne<byte[]> result = siemensS7Net.Read("DB101.0", (short) (staNoSize * 8));
//       OperateResultExOne<byte[]> result4 = siemensS7Net.Read("DB100.2", (short) (staNoSize*2));
        OperateResultExOne<byte[]> result = siemensS7Net.Read("DB101.0", (short) (staNoSize * 4));
//        OperateResultExOne<byte[]> result4 = siemensS7Net.Read("DB100.2", (short) (staNoSize*2));
        if (result.IsSuccess) {
            for (int i = 0; i < staNoSize; i++) {
                Integer siteId = staNos.get(i); // 站点编号
@@ -205,9 +205,19 @@
                    staProtocol.setSiteId(siteId);
                    station.put(siteId, staProtocol);
                }
                staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i * 8));     // 工作号
                staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i * 8 + 4));   // 目标站
                boolean[] status = siemensS7Net.getByteTransform().TransBool(result.Content, i*8, 1);
                staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i * 4));     // 工作号
                staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i * 4 + 2));   // 目标站
            }
        }
        Thread.sleep(200);
        OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB101.6", (short) (staNoSize * 4));
        if (result1.IsSuccess) {
            for (int i = 0; i < staNoSize; i++) {
                Integer siteId = staNos.get(i); // 站点编号
                boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, i * 4, 1);
                StaProtocol staProtocol = station.get(siteId);
                staProtocol.setAutoing(status[0]);  // 自动
                staProtocol.setLoading(status[1]);  // 有物
                staProtocol.setInEnable(status[2]); // 可入
@@ -216,7 +226,7 @@
                staProtocol.setFullPlt(status[5]);  // 满托盘
                staProtocol.setHigh(status[6]);     // 高库位
                staProtocol.setLow(status[7]);      // 低库位
                System.out.println(staProtocol);
                if (!staProtocol.isPakMk() && !staProtocol.isLoading()) {
                    staProtocol.setPakMk(true);
                }
@@ -227,21 +237,8 @@
                    //lfd入库印记  当stamp>=2时才入库
                    staProtocol.setStamp(staProtocol.getStamp() + 1);
                }
            }
        }
//        Thread.sleep(200);
//        OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB101.0", (short) (staNoSize * 4));
//        if (result1.IsSuccess) {
//            for (int i = 0; i < staNoSize; i++) {
//                Integer siteId = staNos.get(i); // 站点编号
//                StaProtocol staProtocol = station.get(siteId);
//
//
//
//            }
//        }
//        Thread.sleep(200);
//        OperateResultExOne<byte[]> result0 = siemensS7Net.Read("DB101.0", (short) 186);
@@ -259,8 +256,8 @@
//        }
        //条码扫描器
        Thread.sleep(200);
        OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.200", (short) (barcodeSize * 8));
        if (result2.IsSuccess && 1 != 1) {
        OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.2", (short) (barcodeSize * 8));
        if (result2.IsSuccess ) {
            if (slave.getId() == 1) {
                for (int i = 0; i < barcodeSize / 3; i++) {
                    String barcode = siemensS7Net.getByteTransform().TransString(result2.Content, i * 8, 8, "UTF-8");
@@ -290,8 +287,37 @@
                }
            }
        }
        if (result.IsSuccess /*&& result1.IsSuccess*/) {
        Thread.sleep(200);
        OperateResultExOne<byte[]> resultError = siemensS7Net.Read("DB101.102", (short) (8));
        if (resultError.IsSuccess) {
            ArrayList<Integer> staNoError = new ArrayList<Integer>() {{
                add(102);
                add(201);
                add(211);
            }};
            for (int i = 0; i < staNoError.size(); i++) {
                Integer siteId = staNoError.get(i); // 站点编号
                StaProtocol staProtocol = station.get(siteId);
                if (null == staProtocol) {
                    staProtocol = new StaProtocol();
                    staProtocol.setSiteId(siteId);
                    station.put(siteId, staProtocol);
                }
                boolean[] status = siemensS7Net.getByteTransform().TransBool(resultError.Content, i * 4 + 2, 1);
                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]);// 扫码失败
            }
        }
        if (result.IsSuccess && result1.IsSuccess) {
            OutputQueue.DEVP.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功", DateUtils.convert(new Date()), slave.getId()));