|
|
@@ -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);
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
}
|