Procházet zdrojové kódy

取消拉铆自动取消设备连接并提示重启生效

wangxichen před 1 týdnem
rodič
revize
5a664fb9cb
1 změnil soubory, kde provedl 20 přidání a 0 odebrání
  1. 20 0
      src/com/mes/ui/MainFrame.java

+ 20 - 0
src/com/mes/ui/MainFrame.java

@@ -1786,6 +1786,19 @@ public class MainFrame extends JFrame {
         deviceHint.setAlignmentX(Component.LEFT_ALIGNMENT);
         panel.add(deviceHint);
 
+        // 单向联动:取消"拉铆流程"时自动取消"设备连接"(用户可再手动勾回)
+        final JCheckBox rivetingCb = checkBoxes.get("riveting");
+        if (rivetingCb != null) {
+            rivetingCb.addActionListener(ev -> {
+                if (!rivetingCb.isSelected()) {
+                    deviceEnabledCb.setSelected(false);
+                }
+            });
+        }
+
+        // 记录旧的"设备连接"状态,用于保存后判断是否需要提示重启
+        boolean oldDeviceEnabled = deviceCurrently;
+
         int result = JOptionPane.showConfirmDialog(this, panel,
                 "工艺流程配置", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
         if (result != JOptionPane.OK_OPTION) return;
@@ -1848,6 +1861,13 @@ public class MainFrame extends JFrame {
         JOptionPane.showMessageDialog(this,
                 "工艺流程已更新,所有工位已重建",
                 "配置成功", JOptionPane.INFORMATION_MESSAGE);
+
+        // 设备连接状态变更需要重启程序生效(PLC 连接在启动时初始化,软重建工位不会重连)
+        if (deviceEnabledCb.isSelected() != oldDeviceEnabled) {
+            JOptionPane.showMessageDialog(this,
+                    "设备连接配置已变更,请重启程序使其生效",
+                    "需要重启", JOptionPane.WARNING_MESSAGE);
+        }
     }
 
     /**