|
|
@@ -58,10 +58,12 @@ public class WorkJPanelScan extends JPanel {
|
|
|
public JTextField manualSnField;
|
|
|
public JButton manualSubmitBtn;
|
|
|
public volatile String pendingManualSn = ""; // 待使用的手动码,下次请求扫码时代替扫码枪
|
|
|
+ private int manualY = 185; // 手动行 y,有推码时下移到回显行下方
|
|
|
|
|
|
public ImageIcon imageGreen;
|
|
|
public ImageIcon imageGray;
|
|
|
|
|
|
+ public JLabel ipLabel;
|
|
|
public JButton signalBtn;
|
|
|
public PlcSignalMonitor02 signalMonitor;
|
|
|
|
|
|
@@ -198,65 +200,71 @@ public class WorkJPanelScan extends JPanel {
|
|
|
gunNoLabel.setBounds(workWidth * 2 / 3, 150, workWidth / 3, 30);
|
|
|
this.add(gunNoLabel);
|
|
|
|
|
|
+ // 回显行:紧贴指示灯下方,每把枪一行,显示从 PLC 读回的值
|
|
|
+ int y = 180;
|
|
|
+ for (PushPort p : pushPorts) {
|
|
|
+ JLabel echoLabel = new JLabel(p.gunNo + "号枪回显");
|
|
|
+ echoLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
+ echoLabel.setForeground(Color.BLACK);
|
|
|
+ echoLabel.setFont(new Font("微软雅黑", Font.PLAIN, 14));
|
|
|
+ echoLabel.setToolTipText(p.addr);
|
|
|
+ echoLabel.setBounds(0, y, workWidth / 5, 24);
|
|
|
+ this.add(echoLabel);
|
|
|
+
|
|
|
+ p.echoField = new JTextField("");
|
|
|
+ p.echoField.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
+ p.echoField.setForeground(Color.BLACK);
|
|
|
+ p.echoField.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
|
+ p.echoField.setEditable(false);
|
|
|
+ p.echoField.setToolTipText(p.gunNo + "号枪 → " + p.addr);
|
|
|
+ p.echoField.setBounds(workWidth / 5, y, workWidth * 4 / 5, 24);
|
|
|
+ this.add(p.echoField);
|
|
|
+ y += 26;
|
|
|
+ }
|
|
|
+ // 无推码保持原位 185,有推码放在回显行下方
|
|
|
+ manualY = pushPorts.length > 0 ? y + 1 : 185;
|
|
|
+
|
|
|
// 手动输入行
|
|
|
manualLabel = new JLabel("手动");
|
|
|
manualLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
manualLabel.setForeground(Color.BLACK);
|
|
|
manualLabel.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|
|
|
- manualLabel.setBounds(0, 185, workWidth / 5, 40);
|
|
|
+ manualLabel.setBounds(0, manualY, workWidth / 5, 40);
|
|
|
this.add(manualLabel);
|
|
|
|
|
|
manualSnField = new JTextField("");
|
|
|
manualSnField.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
manualSnField.setForeground(Color.BLACK);
|
|
|
manualSnField.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
- manualSnField.setBounds(workWidth / 5, 185, workWidth * 3 / 5, 40);
|
|
|
+ manualSnField.setBounds(workWidth / 5, manualY, workWidth * 3 / 5, 40);
|
|
|
manualSnField.addActionListener(e -> submitManualSn()); // 回车提交
|
|
|
this.add(manualSnField);
|
|
|
|
|
|
manualSubmitBtn = new JButton("确认");
|
|
|
manualSubmitBtn.setFont(new Font("微软雅黑", Font.PLAIN, 22));
|
|
|
- manualSubmitBtn.setBounds(workWidth * 4 / 5 + 10, 185, workWidth / 5 - 10, 40);
|
|
|
+ manualSubmitBtn.setBounds(workWidth * 4 / 5 + 10, manualY, workWidth / 5 - 10, 40);
|
|
|
manualSubmitBtn.addActionListener(e -> submitManualSn());
|
|
|
this.add(manualSubmitBtn);
|
|
|
|
|
|
- setManualMode(MesClient.manualScanEnabled);
|
|
|
-
|
|
|
- // 回显行:每个推码地址一个框,显示从 PLC 读回的值
|
|
|
- int footerY = 230;
|
|
|
- if (pushPorts.length > 0) {
|
|
|
- JLabel echoLabel = new JLabel("回显");
|
|
|
- echoLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
- echoLabel.setForeground(Color.BLACK);
|
|
|
- echoLabel.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|
|
|
- echoLabel.setBounds(0, 230, workWidth / 5, 32);
|
|
|
- this.add(echoLabel);
|
|
|
-
|
|
|
- int w = (workWidth * 4 / 5 - 5 * (pushPorts.length - 1)) / pushPorts.length;
|
|
|
- for (int i = 0; i < pushPorts.length; i++) {
|
|
|
- PushPort p = pushPorts[i];
|
|
|
- p.echoField = new JTextField("");
|
|
|
- p.echoField.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
- p.echoField.setForeground(Color.BLACK);
|
|
|
- p.echoField.setFont(new Font("微软雅黑", Font.PLAIN, 12));
|
|
|
- p.echoField.setEditable(false);
|
|
|
- p.echoField.setToolTipText(p.gunNo + "号枪 → " + p.addr);
|
|
|
- p.echoField.setBounds(workWidth / 5 + i * (w + 5), 230, w, 32);
|
|
|
- this.add(p.echoField);
|
|
|
- }
|
|
|
- footerY = 268;
|
|
|
- }
|
|
|
-
|
|
|
- JLabel ipLabel = new JLabel("PLC " + plcIp + " | " + plcDb + " | 枪号 " + gunAddr);
|
|
|
+ ipLabel = new JLabel("PLC " + plcIp + " | " + plcDb + " | 枪号 " + gunAddr);
|
|
|
ipLabel.setFont(new Font("微软雅黑", Font.PLAIN, 12));
|
|
|
ipLabel.setForeground(Color.DARK_GRAY);
|
|
|
- ipLabel.setBounds(5, footerY, workWidth * 2 / 3 + 55, 26);
|
|
|
+ ipLabel.setBounds(5, 230, workWidth * 2 / 3 + 55, 26);
|
|
|
this.add(ipLabel);
|
|
|
|
|
|
signalMonitor = new PlcSignalMonitor02(s7PLC, plcDb, gunAddr, tag(), MesClient.mesClientFrame);
|
|
|
signalBtn = signalMonitor.createSignalButton();
|
|
|
- signalBtn.setBounds(workWidth * 2 / 3 + 63, footerY, 90, 26);
|
|
|
+ signalBtn.setBounds(workWidth * 2 / 3 + 63, 230, 90, 26);
|
|
|
this.add(signalBtn);
|
|
|
+
|
|
|
+ setManualMode(MesClient.manualScanEnabled); // 会按手动行显隐摆放底部行
|
|
|
+ }
|
|
|
+
|
|
|
+ // 底部 IP 行:无推码固定 230;有推码时跟在手动行(显示时)或回显行(隐藏时)下方
|
|
|
+ private void layoutFooter() {
|
|
|
+ int y = pushPorts.length == 0 ? 230 : (manualLabel.isVisible() ? manualY + 41 : manualY + 2);
|
|
|
+ ipLabel.setLocation(5, y);
|
|
|
+ signalBtn.setLocation(workWidth * 2 / 3 + 63, y);
|
|
|
}
|
|
|
|
|
|
private void addRowLabel(String text, int y) {
|
|
|
@@ -310,6 +318,7 @@ public class WorkJPanelScan extends JPanel {
|
|
|
manualLabel.setVisible(enabled);
|
|
|
manualSnField.setVisible(enabled);
|
|
|
manualSubmitBtn.setVisible(enabled);
|
|
|
+ layoutFooter();
|
|
|
if (enabled) {
|
|
|
return;
|
|
|
}
|