|
@@ -51,6 +51,12 @@ public class WorkJPanelScan extends JPanel {
|
|
|
public JLabel feedingmeslabel; // 0.1 扫码完成反馈
|
|
public JLabel feedingmeslabel; // 0.1 扫码完成反馈
|
|
|
public JLabel gunNoLabel; // DB7010.6 实时枪号
|
|
public JLabel gunNoLabel; // DB7010.6 实时枪号
|
|
|
|
|
|
|
|
|
|
+ // 手动输入(参考 auto3,模拟扫码枪),由 设置->扫码手动输入 开关控制显示
|
|
|
|
|
+ public JLabel manualLabel;
|
|
|
|
|
+ public JTextField manualSnField;
|
|
|
|
|
+ public JButton manualSubmitBtn;
|
|
|
|
|
+ public volatile String pendingManualSn = ""; // 待使用的手动码,下次请求扫码时代替扫码枪
|
|
|
|
|
+
|
|
|
public ImageIcon imageGreen;
|
|
public ImageIcon imageGreen;
|
|
|
public ImageIcon imageGray;
|
|
public ImageIcon imageGray;
|
|
|
|
|
|
|
@@ -154,6 +160,30 @@ public class WorkJPanelScan extends JPanel {
|
|
|
gunNoLabel.setBounds(workWidth * 2 / 3, 150, workWidth / 3, 30);
|
|
gunNoLabel.setBounds(workWidth * 2 / 3, 150, workWidth / 3, 30);
|
|
|
this.add(gunNoLabel);
|
|
this.add(gunNoLabel);
|
|
|
|
|
|
|
|
|
|
+ // 手动输入行
|
|
|
|
|
+ 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);
|
|
|
|
|
+ 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.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.addActionListener(e -> submitManualSn());
|
|
|
|
|
+ this.add(manualSubmitBtn);
|
|
|
|
|
+
|
|
|
|
|
+ setManualMode(MesClient.manualScanEnabled);
|
|
|
|
|
+
|
|
|
JLabel ipLabel = new JLabel("PLC " + plcIp + " | " + plcDb + " | 枪号 " + gunAddr);
|
|
JLabel ipLabel = new JLabel("PLC " + plcIp + " | " + plcDb + " | 枪号 " + gunAddr);
|
|
|
ipLabel.setFont(new Font("微软雅黑", Font.PLAIN, 12));
|
|
ipLabel.setFont(new Font("微软雅黑", Font.PLAIN, 12));
|
|
|
ipLabel.setForeground(Color.DARK_GRAY);
|
|
ipLabel.setForeground(Color.DARK_GRAY);
|
|
@@ -212,6 +242,34 @@ public class WorkJPanelScan extends JPanel {
|
|
|
status_menu.setText(msg);
|
|
status_menu.setText(msg);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 显示/隐藏手动输入行;关闭时丢弃未使用的手动码
|
|
|
|
|
+ public void setManualMode(boolean enabled) {
|
|
|
|
|
+ manualLabel.setVisible(enabled);
|
|
|
|
|
+ manualSnField.setVisible(enabled);
|
|
|
|
|
+ manualSubmitBtn.setVisible(enabled);
|
|
|
|
|
+ if (enabled) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ manualSnField.setText("");
|
|
|
|
|
+ if (!pendingManualSn.isEmpty()) {
|
|
|
|
|
+ pendingManualSn = "";
|
|
|
|
|
+ setMenuStatus("已关闭手动输入,未使用的手动码已丢弃", 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 提交手动码:校验长度后挂起,等下一次请求扫码时当作扫码结果
|
|
|
|
|
+ public void submitManualSn() {
|
|
|
|
|
+ String sn = manualSnField.getText().trim();
|
|
|
|
|
+ if (sn.length() != SN_LENGTH) {
|
|
|
|
|
+ setMenuStatus("手动码需为" + SN_LENGTH + "位,当前" + sn.length() + "位", -1);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ pendingManualSn = sn;
|
|
|
|
|
+ manualSnField.setText("");
|
|
|
|
|
+ log.info("<{}>手动输入工件码:{},操作人:{}", tag(), sn, MesClient.user_menu.getText());
|
|
|
|
|
+ setMenuStatus("手动码已就绪,等待请求扫码:" + sn, 0);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// scan.ips 里配了这把枪即有效,PLC 发几号就用几号
|
|
// scan.ips 里配了这把枪即有效,PLC 发几号就用几号
|
|
|
private boolean isValidGun(int no) {
|
|
private boolean isValidGun(int no) {
|
|
|
return no >= 1 && no <= MesClient.scanClients.length;
|
|
return no >= 1 && no <= MesClient.scanClients.length;
|
|
@@ -286,6 +344,15 @@ public class WorkJPanelScan extends JPanel {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void doScan(Integer plcGunNo) {
|
|
private void doScan(Integer plcGunNo) {
|
|
|
|
|
+ // 有手动码时优先使用并跳过本次扫码枪,用完即清(同 auto3)
|
|
|
|
|
+ String manualSn = pendingManualSn;
|
|
|
|
|
+ if (!manualSn.isEmpty()) {
|
|
|
|
|
+ pendingManualSn = "";
|
|
|
|
|
+ log.info("<{}>手动码执行:{}", tag(), manualSn);
|
|
|
|
|
+ gunField.setText("手动输入");
|
|
|
|
|
+ saveScan(manualSn, "手动输入(" + plcName + ")");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
// 读不到枪号不扫码
|
|
// 读不到枪号不扫码
|
|
|
if (plcGunNo == null) {
|
|
if (plcGunNo == null) {
|
|
|
gunField.setText("未读到枪号");
|
|
gunField.setText("未读到枪号");
|
|
@@ -315,11 +382,16 @@ public class WorkJPanelScan extends JPanel {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- slot.put(sn, gunNo + "号枪(" + plcName + ")");
|
|
|
|
|
|
|
+ saveScan(sn, gunNo + "号枪(" + plcName + ")");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 存入正面扫码码并回写扫码完成反馈
|
|
|
|
|
+ private void saveScan(String sn, String source) {
|
|
|
|
|
+ slot.put(sn, source);
|
|
|
productSnFeeding.setText(sn);
|
|
productSnFeeding.setText(sn);
|
|
|
writeScanFinish(true);
|
|
writeScanFinish(true);
|
|
|
scanDone = true;
|
|
scanDone = true;
|
|
|
- setMenuStatus("扫码成功", 0);
|
|
|
|
|
|
|
+ setMenuStatus("扫码成功" + (source.startsWith("手动") ? "(手动码)" : ""), 0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void resetScan() {
|
|
public void resetScan() {
|