wangxichen пре 2 недеља
родитељ
комит
f85778c954

+ 10 - 6
src/com/mes/controller/LaserControllerDual.java

@@ -60,6 +60,8 @@ public class LaserControllerDual {
 
     /**
      * A面状态检测(参考OP60的getStatusA)
+     * 完成判定只看 #1593==1(持续信号),不要求 working==1
+     * 因为加工完成瞬间 #1591 会变 0、#1593 变 1,两者互斥
      */
     private void checkStatusA() {
         try {
@@ -76,13 +78,13 @@ public class LaserControllerDual {
                 device.writeMesEnable(0);
                 log.info("写入#1590=0(禁止启动)");
 
-            } else if(tjFlaga == 2 && working == 1) {
-                // 运行中,检测是否完成
+            } else if(tjFlaga == 2) {
+                // 运行中,检测是否完成(不看 working,因为完成瞬间 working 会变 0)
                 int finish = device.readFinish("A");
                 if(finish == 1) {
                     // 状态切换:2(运行中)→ 3(完成)
                     tjFlaga = 3;
-                    log.info("A面检测到设备完成");
+                    log.info("A面检测到设备完成(#1593=1)");
                     MesClient.pxstatus1.setText("A面完成,提交中");
 
                     // 保存剩余参数
@@ -111,6 +113,8 @@ public class LaserControllerDual {
 
     /**
      * B面状态检测(参考OP60的getStatusB)
+     * 完成判定只看 #1594==1(持续信号),不要求 working==1
+     * 因为加工完成瞬间 #1592 会变 0、#1594 变 1,两者互斥
      */
     private void checkStatusB() {
         try {
@@ -127,13 +131,13 @@ public class LaserControllerDual {
                 device.writeMesEnable(0);
                 log.info("写入#1590=0(禁止启动)");
 
-            } else if(tjFlagb == 2 && working == 1) {
-                // 运行中,检测是否完成
+            } else if(tjFlagb == 2) {
+                // 运行中,检测是否完成(不看 working,因为完成瞬间 working 会变 0)
                 int finish = device.readFinish("B");
                 if(finish == 1) {
                     // 状态切换:2(运行中)→ 3(完成)
                     tjFlagb = 3;
-                    log.info("B面检测到设备完成");
+                    log.info("B面检测到设备完成(#1594=1)");
                     MesClient.pxstatus2.setText("B面完成,提交中");
 
                     // 保存剩余参数

+ 15 - 11
src/com/mes/ui/MesClient.java

@@ -104,7 +104,6 @@ public class MesClient extends JFrame {
     public static JButton finish_ok_bt;
     public static JButton finish_ng_bt;
     public static JTextField product_sn;
-    public static JButton f_scan_data_bt_1;
 
     public static String user20 = "";
 
@@ -129,7 +128,7 @@ public class MesClient extends JFrame {
     // 激光切割设备
     public static LaserDevice laserDevice;
     public static com.mes.controller.LaserControllerDual laserController;
-    public static String laser_device_ip = ""; // 激光设备IP,从配置文件读取
+    public static String laser_device_ip = "192.168.2.199"; // 激光设备IP,从配置文件读取
 
     // 双面UI组件
     public static JTextField product_sn2;  // B面工件码
@@ -310,13 +309,13 @@ public class MesClient extends JFrame {
     public static void resetScanA() {
         work_status = 0;
         check_quality_result = false;
-        MesClient.finish_ok_bt.setEnabled(false);
-        MesClient.finish_ng_bt.setEnabled(false);
-        product_sn.setText("");
-        MesClient.fxlabel.setVisible(false);
 
-        MesClient.f_scan_data_bt_1.setEnabled(true);
-        MesClient.status_menu.setText("请扫工件码");
+        // 老版本的隐藏按钮/返修标签 op090 不一定创建,防御式访问
+        if (finish_ok_bt != null) finish_ok_bt.setEnabled(false);
+        if (finish_ng_bt != null) finish_ng_bt.setEnabled(false);
+        if (product_sn != null) product_sn.setText("");
+        if (fxlabel != null) fxlabel.setVisible(false);
+        if (status_menu != null) status_menu.setText("请扫工件码");
 
         // 清空参数显示
         if(param1 != null) param1.setText("");
@@ -1195,7 +1194,7 @@ public class MesClient extends JFrame {
                 }
             }, 1000, 1000);
 
-            // 2.5 转台位置检测(1秒)— 更新顶部标签 + 保持扫码框焦点
+            // 2.5 转台位置检测(1秒)— 更新顶部标签 + 保持扫码框焦点 + 面切换禁用(对齐 OP60)
             Timer sideDetectTimer = new Timer();
             sideDetectTimer.schedule(new TimerTask() {
                 public void run() {
@@ -1208,10 +1207,15 @@ public class MesClient extends JFrame {
                         String side = laserDevice.readSideAtLoad();
                         SwingUtilities.invokeLater(() -> updateCurSideLabel(side));
 
-                        // 记录最近一次上料面(供状态跟踪用;不主动写 #1590,避免跟 checkStatus 打架)
+                        // 面切换瞬间 → 写 #1590=0 禁用启动(对齐 OP60 的 changeEnable(false))
+                        // 防止转台旋转过程中机床误触发下一次加工循环
                         if (!side.equals(lastSideAtLoad)) {
+                            String prev = lastSideAtLoad;
                             lastSideAtLoad = side;
-                            log.info("转台面切换,检测到上料面={}", side.isEmpty() ? "未到位" : side);
+                            laserDevice.writeMesEnable(0);
+                            log.info("转台面切换 [{} → {}],写#1590=0 禁用启动",
+                                    prev.isEmpty() ? "未到位" : prev,
+                                    side.isEmpty() ? "未到位" : side);
                         }
                     } catch (Exception e) {
                         log.error("转台位置检测异常", e);

+ 1 - 1
src/resources/config/config.properties

@@ -7,4 +7,4 @@ mes.heart_beat_cycle=60
 mes.line_sn=XT
 
 # 激光切割设备配置
-laser.device.ip=192.168.1.100
+laser.device.ip=192.168.2.199