wangxichen hace 14 horas
padre
commit
b932f89e2f

BIN
lib/iot-communication-1.4.4.jar


BIN
lib/iot-communication-1.5.4.jar


+ 70 - 35
src/com/mes/component/StationPanel.java

@@ -4,7 +4,7 @@ import javax.swing.*;
 import java.awt.*;
 
 /**
- * 氦检工位面板:读码回显 + 流程状态 + 本底/漏率 + 检测结果
+ * 氦检工位面板:读码回显 + 流程状态 + 本底/漏率 + 检测结果 + PLC 信号灯
  * 视觉沿用原客户端风格:白底、黑底彩字状态、原图标
  * 所有 set 方法可在任意线程调用,内部已切到 EDT
  */
@@ -17,12 +17,23 @@ public class StationPanel extends JPanel {
     public static final Color STATE_NG = Color.RED;
     public static final Color STATE_RUN = new Color(0x4F, 0xC3, 0xF7);
 
-    private static final Icon DOT_GREEN = new ImageIcon(StationPanel.class.getResource("/bg/green_dot.png"));
-    private static final Icon DOT_GREY = new ImageIcon(StationPanel.class.getResource("/bg/grey_dot.png"));
+    // 信号灯下标
+    public static final int SIG_SCAN = 0;   // 扫码成功
+    public static final int SIG_ALLOW = 1;  // MES 允许
+    public static final int SIG_START = 2;  // 检测开始
+    public static final int SIG_END = 3;    // 检测结束
+    public static final int SIG_LEAK = 4;   // 泄露
+    public static final int SIG_BASE = 5;   // 本底
+    public static final int SIG_CODE = 6;   // 二维码
+
+    private static final String[] SIG_NAMES = {"扫码成功", "MES允许", "检测开始", "检测结束", "泄露", "本底", "二维码"};
+
+    private static final Icon DOT_GREEN = stationDot(true);
+    private static final Icon DOT_GREY = stationDot(false);
     private static final Icon ICON_OK = new ImageIcon(StationPanel.class.getResource("/bg/ok_bg.png"));
     private static final Icon ICON_NG = new ImageIcon(StationPanel.class.getResource("/bg/ng_bg.png"));
 
-    private final JLabel lampLabel;
+    private final JLabel[] signalLabels = new JLabel[SIG_NAMES.length];
     private final JTextField codeField;
     private final JLabel stateLabel;
     private final JLabel baseLabel;
@@ -30,7 +41,11 @@ public class StationPanel extends JPanel {
     private final JLabel resultLabel;
     private final JLabel retryLabel;
 
-    public StationPanel(String title) {
+    /**
+     * @param title  工位标题,如 "A 工位"
+     * @param addrs  7 个信号点位,顺序:扫码成功、MES允许、检测开始、检测结束、泄露、本底、二维码
+     */
+    public StationPanel(String title, String[] addrs) {
         setLayout(null);
         setBackground(Color.WHITE);
 
@@ -39,68 +54,86 @@ public class StationPanel extends JPanel {
         titleLabel.setBounds(20, 4, 340, 36);
         add(titleLabel);
 
-        // PLC 信号灯
-        lampLabel = new JLabel(DOT_GREY);
-        lampLabel.setBounds(400, 4, 36, 36);
-        add(lampLabel);
+        stateLabel = new JLabel("等待扫码", SwingConstants.CENTER);
+        stateLabel.setFont(new Font("微软雅黑", Font.BOLD, 32));
+        stateLabel.setForeground(STATE_WAIT);
+        stateLabel.setOpaque(true);
+        stateLabel.setBackground(Color.BLACK);
+        stateLabel.setBounds(20, 44, 420, 56);
+        add(stateLabel);
 
         // 读码回显框:沿用原扫码框样式,只读、居中
         codeField = new JTextField();
         codeField.setHorizontalAlignment(SwingConstants.CENTER);
         codeField.setEditable(false);
         codeField.setFont(new Font("微软雅黑", Font.PLAIN, 28));
-        codeField.setBounds(20, 110, 420, 52);
+        codeField.setBounds(20, 106, 420, 46);
         codeField.setText("--");
         add(codeField);
 
-        stateLabel = new JLabel("等待扫码", SwingConstants.CENTER);
-        stateLabel.setFont(new Font("微软雅黑", Font.BOLD, 32));
-        stateLabel.setForeground(STATE_WAIT);
-        stateLabel.setOpaque(true);
-        stateLabel.setBackground(Color.BLACK);
-        stateLabel.setBounds(20, 44, 420, 62);
-        add(stateLabel);
-
         JLabel baseTitle = new JLabel("本底");
-        baseTitle.setFont(new Font("微软雅黑", Font.PLAIN, 22));
+        baseTitle.setFont(new Font("微软雅黑", Font.PLAIN, 20));
         baseTitle.setForeground(new Color(0x61, 0x61, 0x61));
-        baseTitle.setBounds(30, 174, 100, 34);
+        baseTitle.setBounds(30, 158, 90, 30);
         add(baseTitle);
 
         baseLabel = new JLabel("--");
-        baseLabel.setFont(new Font("微软雅黑", Font.BOLD, 26));
-        baseLabel.setBounds(130, 174, 300, 34);
+        baseLabel.setFont(new Font("微软雅黑", Font.BOLD, 24));
+        baseLabel.setBounds(120, 158, 310, 30);
         add(baseLabel);
 
         JLabel leakTitle = new JLabel("漏率");
-        leakTitle.setFont(new Font("微软雅黑", Font.PLAIN, 22));
+        leakTitle.setFont(new Font("微软雅黑", Font.PLAIN, 20));
         leakTitle.setForeground(new Color(0x61, 0x61, 0x61));
-        leakTitle.setBounds(30, 212, 100, 34);
+        leakTitle.setBounds(30, 192, 90, 30);
         add(leakTitle);
 
         leakLabel = new JLabel("--");
-        leakLabel.setFont(new Font("微软雅黑", Font.BOLD, 26));
-        leakLabel.setBounds(130, 212, 300, 34);
+        leakLabel.setFont(new Font("微软雅黑", Font.BOLD, 24));
+        leakLabel.setBounds(120, 192, 310, 30);
         add(leakLabel);
 
         resultLabel = new JLabel("--", SwingConstants.CENTER);
-        resultLabel.setFont(new Font("微软雅黑", Font.BOLD, 32));
-        resultLabel.setForeground(new Color(0xBD, 0xBD, 0xBD));
+        resultLabel.setFont(new Font("微软雅黑", Font.BOLD, 30));
+        resultLabel.setForeground(STATE_WAIT);
         resultLabel.setIconTextGap(12);
-        resultLabel.setBounds(110, 252, 240, 80);
+        resultLabel.setBounds(120, 230, 220, 70);
         add(resultLabel);
 
         retryLabel = new JLabel("该工件为返修件,请仔细检查", SwingConstants.CENTER);
-        retryLabel.setFont(new Font("微软雅黑", Font.BOLD, 22));
+        retryLabel.setFont(new Font("微软雅黑", Font.BOLD, 20));
         retryLabel.setForeground(Color.RED);
-        retryLabel.setBounds(20, 336, 420, 32);
+        retryLabel.setBounds(20, 300, 420, 28);
         retryLabel.setVisible(false);
         add(retryLabel);
+
+        // PLC 信号灯:两列排布,点位写在括号里
+        for (int i = 0; i < SIG_NAMES.length; i++) {
+            int col = i / 4;
+            int row = i % 4;
+            JLabel lamp = new JLabel(SIG_NAMES[i] + "(" + addrs[i] + ")");
+            lamp.setIcon(DOT_GREY);
+            lamp.setFont(new Font("微软雅黑", Font.PLAIN, 16));
+            lamp.setForeground(new Color(0x42, 0x42, 0x42));
+            lamp.setBounds(20 + col * 210, 336 + row * 26, 205, 26);
+            add(lamp);
+            signalLabels[i] = lamp;
+        }
+    }
+
+    /** 生成小圆点图标,避免直接用 36x36 大图标 */
+    private static Icon stationDot(boolean green) {
+        ImageIcon src = new ImageIcon(StationPanel.class.getResource(green ? "/bg/green_dot.png" : "/bg/grey_dot.png"));
+        Image img = src.getImage().getScaledInstance(18, 18, Image.SCALE_SMOOTH);
+        return new ImageIcon(img);
     }
 
-    /** PLC 信号灯:true 亮绿,false 灰 */
-    public void setLamp(boolean on) {
-        SwingUtilities.invokeLater(() -> lampLabel.setIcon(on ? DOT_GREEN : DOT_GREY));
+    /** 点亮/熄灭某个信号灯,index 用 SIG_xxx 常量 */
+    public void setSignal(int index, boolean on) {
+        if (index < 0 || index >= signalLabels.length) {
+            return;
+        }
+        SwingUtilities.invokeLater(() -> signalLabels[index].setIcon(on ? DOT_GREEN : DOT_GREY));
     }
 
     public void setCode(String code) {
@@ -158,7 +191,9 @@ public class StationPanel extends JPanel {
             resultLabel.setText("--");
             resultLabel.setForeground(STATE_WAIT);
             retryLabel.setVisible(false);
-            lampLabel.setIcon(DOT_GREY);
+            for (JLabel lamp : signalLabels) {
+                lamp.setIcon(DOT_GREY);
+            }
         });
     }
 }

+ 10 - 6
src/com/mes/ui/MesClient.java

@@ -418,12 +418,16 @@ public class MesClient extends JFrame {
         indexPanelA.setLayout(null);
 
         // 氦检双工位面板:A/B 并排卡片 + 底部日志
-        stationA = new StationPanel("A 工位");
-        stationA.setBounds(10, 10, 460, 370);
+        // 点位顺序:扫码成功、MES允许、检测开始、检测结束、泄露、本底、二维码
+        // 本底、二维码点位待 PLC 确认,先留空
+        stationA = new StationPanel("A 工位",
+                new String[]{"M205", "M206", "M207", "M208", "D200", "--", "--"});
+        stationA.setBounds(10, 10, 460, 440);
         indexPanelA.add(stationA);
 
-        stationB = new StationPanel("B 工位");
-        stationB.setBounds(485, 10, 460, 370);
+        stationB = new StationPanel("B 工位",
+                new String[]{"M215", "M216", "M217", "M218", "D210", "--", "--"});
+        stationB.setBounds(485, 10, 460, 440);
         indexPanelA.add(stationB);
 
         logArea = new JTextArea();
@@ -433,10 +437,10 @@ public class MesClient extends JFrame {
         logArea.setForeground(Color.BLACK);
         logArea.setMargin(new Insets(6, 8, 6, 8));
         JScrollPane logScrollPane = new JScrollPane(logArea);
-        logScrollPane.setBounds(10, 390, 935, 150);
+        logScrollPane.setBounds(10, 455, 935, 90);
         indexPanelA.add(logScrollPane);
 
-        indexPanelA.setPreferredSize(new Dimension(955, 550));
+        indexPanelA.setPreferredSize(new Dimension(955, 553));
 
         tabbedPane.addTab("检测面板", new ImageIcon(MesClient.class.getResource("/bg/a_side.png")), indexScrollPaneA, null);
         tabbedPane.setEnabledAt(0, true);

BIN
~$交互流程(1).doc