From 4ab8c2aa4996e2d16fe0a214e2a41a4c77378d35 Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期二, 07 四月 2026 16:22:37 +0800
Subject: [PATCH] 1

---
 zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/thread/S7DevpThread.java |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/thread/S7DevpThread.java b/zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/thread/S7DevpThread.java
index 8995531..6c44feb 100644
--- a/zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/thread/S7DevpThread.java
+++ b/zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/thread/S7DevpThread.java
@@ -15,9 +15,9 @@
 import com.zy.acs.conveyor.core.constant.TaskField;
 import com.zy.acs.conveyor.core.enums.SlaveType;
 import com.zy.acs.conveyor.core.enums.TaskType;
-import com.zy.acs.conveyor.core.properties.DevpSlave;
 import com.zy.acs.conveyor.core.model.Task;
 import com.zy.acs.conveyor.core.model.protocol.StaProtocol;
+import com.zy.acs.conveyor.core.properties.DevpSlave;
 import com.zy.acs.conveyor.entity.Devp;
 import com.zy.acs.conveyor.service.DevpService;
 import com.zy.acs.conveyor.utils.SpringContextUtil;
@@ -93,7 +93,7 @@
     private void read() throws InterruptedException {
         List<Integer> staNos = slave.getStaNos();
         int staNoSize = staNos.size();
-        byte[] stationStatus = s7PLC.readByte(StationStatusField.TASK_NUMBER.getAddressPattern() + PlcConstant.ADDRESS_CONCATENATION + StationStatusField.TASK_NUMBER.getOffset(), StationStatusField.TASK_NUMBER.getOffset() + staNoSize * PlcConstant.STATION_STATUS_LENGTH);
+        byte[] stationStatus = s7PLC.readByte(StationStatusField.TASK_NUMBER.getAddressPattern() + PlcConstant.ADDRESS_CONCATENATION + StationStatusField.TASK_NUMBER.getOffset(), StationStatusField.TASK_NUMBER.getOffset() + staNoSize * StationStatusField.ALL.getByteLength());
         for (int i = 0; i < staNoSize; i++) {
             // 绔欑偣缂栧彿
             Integer siteId = staNos.get(i);
@@ -103,9 +103,9 @@
                 staProtocol.setSiteId(siteId);
                 station.put(siteId, staProtocol);
             }
-            staProtocol.setWorkNo((int) ByteUtils.getLong(stationStatus, StationStatusField.TASK_NUMBER.getOffset() + i * PlcConstant.STATION_STATUS_LENGTH));
-            staProtocol.setStaNo((int) ByteUtils.getShort(stationStatus, StationStatusField.FINAL_TARGET.getOffset() + i * PlcConstant.STATION_STATUS_LENGTH));
-            boolean[] status = ByteUtils.getBooleans(stationStatus, StationStatusField.STATUS_WORD.getOffset() + i * PlcConstant.STATION_STATUS_LENGTH, StationStatusField.STATUS_WORD.getByteLength());
+            staProtocol.setWorkNo((int) ByteUtils.getLong(stationStatus, StationStatusField.TASK_NUMBER.getOffset() + i * StationStatusField.ALL.getByteLength()));
+            staProtocol.setStaNo((int) ByteUtils.getShort(stationStatus, StationStatusField.FINAL_TARGET.getOffset() + i * StationStatusField.ALL.getByteLength()));
+            boolean[] status = ByteUtils.getBooleans(stationStatus, StationStatusField.STATUS_WORD.getOffset() + i * StationStatusField.ALL.getByteLength(), StationStatusField.STATUS_WORD.getByteLength());
             staProtocol.setAutoing(status[0]);  // 鑷姩
             staProtocol.setLoading(status[1]);  // 鏈夌墿
             staProtocol.setInEnable(status[2]); // 鍙叆
@@ -118,11 +118,11 @@
                 staProtocol.setPakMk(true);
             }
         }
-
-        byte[] deviceField = s7PLC.readByte(DeviceField.BARCODE.getAddressPattern() + PlcConstant.ADDRESS_CONCATENATION + DeviceField.BARCODE.getOffset(), DeviceField.BARCODE.getOffset() + DeviceField.BARCODE.getByteLength() * slave.getBarcodeSize());
-        for (int i = 0; i < slave.getBarcodeSize(); i++) {
+        List<Integer> barcodeNumber = slave.getBarcodeNumber();
+        byte[] deviceField = s7PLC.readByte(DeviceField.BARCODE.getAddressPattern() + PlcConstant.ADDRESS_CONCATENATION + DeviceField.BARCODE.getOffset(), DeviceField.BARCODE.getOffset() + DeviceField.BARCODE.getByteLength() * barcodeNumber.size());
+        for (int i = 0; i < barcodeNumber.size(); i++) {
             String barcode = ByteUtils.getString(deviceField, i * DeviceField.BARCODE.getByteLength(), DeviceField.BARCODE.getByteLength());
-            BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i);
+            BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcodeNumber.get(i));
             if (Cools.isEmpty(barcode)) {
                 barcodeThread.clearBarcode();
             } else {
@@ -167,9 +167,9 @@
         List<Integer> staNos = slave.getStaNos();
         int index = staNos.indexOf(staProtocol.getSiteId());
 
-        s7PLC.writeInt32(TaskField.TASK_NUMBER.getAddressPattern() + PlcConstant.ADDRESS_CONCATENATION + (TaskField.DEST_STATION.getOffset() + index * PlcConstant.TASK_LENGTH), staProtocol.getWorkNo());    // 宸ヤ綔鍙�
+        s7PLC.writeInt32(TaskField.TASK_NUMBER.getAddressPattern() + PlcConstant.ADDRESS_CONCATENATION + (TaskField.DEST_STATION.getOffset() + index * TaskField.ALL.getByteLength()), staProtocol.getWorkNo());    // 宸ヤ綔鍙�
         Thread.sleep(100);
-        s7PLC.writeInt16(TaskField.DEST_STATION.getAddressPattern() + PlcConstant.ADDRESS_CONCATENATION + (index * PlcConstant.TASK_LENGTH + TaskField.DEST_STATION.getOffset() + TaskField.DEST_STATION.getAddressPattern()), staProtocol.getStaNo().shortValue());    // 鐩爣绔�
+        s7PLC.writeInt16(TaskField.DEST_STATION.getAddressPattern() + PlcConstant.ADDRESS_CONCATENATION + (index * TaskField.ALL.getByteLength() + TaskField.DEST_STATION.getOffset() + TaskField.DEST_STATION.getAddressPattern()), staProtocol.getStaNo().shortValue());    // 鐩爣绔�
 
         OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎绔欑偣鏁版嵁澶辫触銆傝緭閫佺嚎plc缂栧彿={1}锛岀珯鐐规暟鎹�={2}", slave.getId(), JSON.toJSON(staProtocol)));
         News.error("SiemensDevp" + " - 4" + " - 鍐欏叆杈撻�佺嚎绔欑偣鏁版嵁澶辫触銆傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={}", slave.getId(), JSON.toJSON(staProtocol));

--
Gitblit v1.9.1