liuwei 3 settimane fa
parent
commit
2ba9cb2f9c

+ 4 - 29
src/com/mes/component/DirectScanHandshake.java

@@ -5,7 +5,6 @@ import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType;
 import com.github.xingshuangs.iot.protocol.s7.service.S7PLC;
 import com.mes.ui.DataUtil;
 import com.mes.ui.MesClient;
-import com.mes.util.SnSlot;
 import com.mes.util.TCPClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -17,7 +16,7 @@ import java.util.TimerTask;
 /**
  * OP135 入口独立扫码握手。
  *
- * PLC 请求后触发新扫码枪,MES 校验通过后依次更新 PLC 工件码、130 下发通用码和允许信号。
+ * PLC 请求后触发新扫码枪,MES 校验通过后依次更新 PLC 工件码和允许信号。
  * 交付成功 33 秒后清理允许和本次写入的工件码,不再等待请求变为 0 后立即清理。
  */
 public class DirectScanHandshake {
@@ -43,7 +42,6 @@ public class DirectScanHandshake {
 
     private final S7PLC plc;
     private final TCPClient scanner;
-    private final SnSlot commonSlot;
 
     private State state = State.IDLE;
     private Boolean lastRequest = null;
@@ -51,16 +49,14 @@ public class DirectScanHandshake {
     private long clearAt = 0;
     private String validatedSn = "";
     private String plcOwnedSn = "";
-    private String commonOwnedSn = "";
     private String lastStatus = "";
     private Timer timer;
 
-    public DirectScanHandshake(String plcIp, TCPClient scanner, SnSlot commonSlot) {
+    public DirectScanHandshake(String plcIp, TCPClient scanner) {
         this.plc = new S7PLC(EPlcType.S1500, plcIp);
         this.plc.setConnectTimeout(1000);
         this.plc.setReceiveTimeout(1000);
         this.scanner = scanner;
-        this.commonSlot = commonSlot;
 
         log.info("OP135 独立扫码握手已初始化,PLC={},扫码枪={}:{},点位 {}/{}/{}",
                 plcIp, scanner.serverIP, scanner.serverPort, REQUEST_ADDR, SN_ADDR, ALLOW_ADDR);
@@ -129,7 +125,7 @@ public class DirectScanHandshake {
         if (previous && state != State.WAIT_CLEAR && state != State.WAIT_REQUEST_RISE) {
             validatedSn = "";
             nextScanAt = 0;
-            if (!plcOwnedSn.isEmpty() || !commonOwnedSn.isEmpty()) {
+            if (!plcOwnedSn.isEmpty()) {
                 scheduleDelayedCleanup();
             } else {
                 state = State.IDLE;
@@ -190,7 +186,7 @@ public class DirectScanHandshake {
 
         validatedSn = sn;
         state = State.VALIDATED;
-        log.info("OP135 工件码 {} MES 校验通过,准备写入 PLC 和通用码", sn);
+        log.info("OP135 工件码 {} MES 校验通过,准备写入 PLC", sn);
         deliverValidatedCode();
     }
 
@@ -220,24 +216,6 @@ public class DirectScanHandshake {
             }
         }
 
-        if (!sn.equals(commonOwnedSn)) {
-            if (!commonSlot.tryLock()) {
-                showStatus("OP135 通用码正在使用,稍后重试", -1);
-                return;
-            }
-            try {
-                commonSlot.put(sn, OPRNO + "新扫码");
-                commonOwnedSn = sn;
-                log.info("OP135 更新 130 下发通用码 -> {}", sn);
-            } catch (Exception e) {
-                log.error("OP135 更新 130 下发通用码 {} 失败:{}", sn, e.getMessage());
-                showStatus("OP135 通用码更新失败,稍后重试", -1);
-                return;
-            } finally {
-                commonSlot.unlock();
-            }
-        }
-
         Boolean request = readBoolean(REQUEST_ADDR);
         if (request == null) {
             showStatus("OP135 放行前读取请求失败,稍后重试", -1);
@@ -336,9 +314,6 @@ public class DirectScanHandshake {
             }
         }
 
-        // 通用码保留给后续流程使用;下次扫码成功时必须重新确认/覆盖。
-        commonOwnedSn = "";
-
         return true;
     }
 

+ 1 - 1
src/com/mes/ui/MesClient.java

@@ -329,7 +329,7 @@ public class MesClient extends JFrame {
         workJPanelScan93 = new WorkJPanelScan(WorkJPanelCnc.PLC_93, frontSlot93);
         if (directScanClient != null) {
             directScanHandshake = new DirectScanHandshake(
-                    WorkJPanelCnc.PLC_93, directScanClient, backSlot);
+                    WorkJPanelCnc.PLC_93, directScanClient);
         }
         workJPanelBackSlot = new WorkJPanelBackSlot();