|
|
@@ -74,6 +74,7 @@ public class MesClient extends JFrame {
|
|
|
public static JButton finish_ng_bt;
|
|
|
public static JTextField product_sn;
|
|
|
public static JButton f_scan_data_bt_1;
|
|
|
+ public static JButton f_start_bt;
|
|
|
|
|
|
public static String user20 = "";
|
|
|
public static boolean mes_enable = true; // true=MES开启
|
|
|
@@ -341,7 +342,7 @@ public class MesClient extends JFrame {
|
|
|
MesClient.finish_ok_bt.setEnabled(false);
|
|
|
MesClient.finish_ng_bt.setEnabled(false);
|
|
|
product_sn.setText("");
|
|
|
- product_sn.setEditable(true);
|
|
|
+ product_sn.setEditable(false);
|
|
|
tjFlag = 0;
|
|
|
mesStartFlag = 0;
|
|
|
curTaskName.setText("");
|
|
|
@@ -353,14 +354,64 @@ public class MesClient extends JFrame {
|
|
|
if (param4 != null) {
|
|
|
param4.setText("");
|
|
|
}
|
|
|
-
|
|
|
-// f_scan_data_bt_1.setIcon(new ImageIcon(MesClient.class.getResource("/bg/scan_barcode.png")));
|
|
|
-// f_scan_data_bt_1.setText("扫码");
|
|
|
-// MesClient.f_scan_data_bt_1.setEnabled(true);
|
|
|
+ setStartButtonEnabled(false);
|
|
|
+ if (f_scan_data_bt_1 != null) {
|
|
|
+ f_scan_data_bt_1.setEnabled(true);
|
|
|
+ }
|
|
|
+ // 测完恢复常态:继续每 5s 发停止/复位
|
|
|
+ if (serialPortUtils != null && serialPortUtils.isOpen) {
|
|
|
+ WorkTimer.startStopTimer();
|
|
|
+ }
|
|
|
MesClient.setMenuStatus("请扫工件码",0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 启动按钮可用状态(校验成功后点亮;检测中强制不可用) */
|
|
|
+ public static void setStartButtonEnabled(boolean enabled) {
|
|
|
+ if (f_start_bt == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 设备检测中(已进入测试)不允许再点启动
|
|
|
+ if (enabled && mesStartFlag != null && mesStartFlag == 1) {
|
|
|
+ f_start_bt.setEnabled(false);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ f_start_bt.setEnabled(enabled);
|
|
|
+ }
|
|
|
|
|
|
-// MesClient.result.setText("等待结果");
|
|
|
-// MesClient.result.setForeground(Color.GRAY);
|
|
|
+ /**
|
|
|
+ * 扫码校验成功后:停止复位定时器,并按启动模式点亮启动或自动启动。
|
|
|
+ */
|
|
|
+ public static void onScanValidated() {
|
|
|
+ WorkTimer.stopStopTimer();
|
|
|
+ if (configParam != null && "自动启动".equals(configParam.getStartMode())) {
|
|
|
+ doStartTest();
|
|
|
+ } else {
|
|
|
+ setStartButtonEnabled(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 点击启动:发启动报文,然后熄灭启动按钮。
|
|
|
+ * 复位定时器已在扫码成功时停止,此处不再发停止信号。
|
|
|
+ */
|
|
|
+ public static void doStartTest() {
|
|
|
+ if (work_status != 1) {
|
|
|
+ setMenuStatus("请先扫工件码", -1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ WorkTimer.stopStopTimer();
|
|
|
+ loadAteqProgramTimes();
|
|
|
+ boolean ok = serialPortUtils != null && serialPortUtils.start();
|
|
|
+ setStartButtonEnabled(false);
|
|
|
+ if (ok) {
|
|
|
+ mesStartFlag = 1; // 已发启动,视为进入检测,启动按钮保持不可用
|
|
|
+ setMenuStatus("已启动,测试中", 0);
|
|
|
+ result.setText("等待结果");
|
|
|
+ result.setForeground(Color.GRAY);
|
|
|
+ } else {
|
|
|
+ setMenuStatus("启动失败,请检查设备后重试", -1);
|
|
|
+ setStartButtonEnabled(true);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static int userLoginHours;//用户登录所处小时
|
|
|
@@ -628,12 +679,23 @@ public class MesClient extends JFrame {
|
|
|
}
|
|
|
|
|
|
public static void scanBarcode() {
|
|
|
+ doStartTest();
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 扫码按钮:弹窗输入工件码后走与输入框回车相同的校验流程 */
|
|
|
+ public static void scanBarcodeByButton() {
|
|
|
if (work_status == 1) {
|
|
|
- loadAteqProgramTimes();
|
|
|
- MesClient.serialPortUtils.start();
|
|
|
+ setMenuStatus("已扫码,请点击启动", 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String scanBarcode = JOptionPane.showInputDialog(mesClientFrame, "请扫工件码");
|
|
|
+ if (scanBarcode == null || scanBarcode.trim().isEmpty()) {
|
|
|
+ setMenuStatus("请扫工件码", -1);
|
|
|
return;
|
|
|
}
|
|
|
- setMenuStatus("请先扫工件码", -1);
|
|
|
+ product_sn.setText(scanBarcode.trim());
|
|
|
+ scan_type = 1;
|
|
|
+ scanBarcode2();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -750,14 +812,14 @@ public class MesClient extends JFrame {
|
|
|
MesClient.setMenuStatus("消息发送失败,请重试",-1);
|
|
|
return;
|
|
|
}
|
|
|
+ // 扫码已通过本地校验并已发质量查询:此后不再发停止/复位
|
|
|
+ WorkTimer.stopStopTimer();
|
|
|
}else{
|
|
|
work_status = 1;
|
|
|
MesClient.tjFlag = 1;
|
|
|
MesClient.setMenuStatus("扫码成功,等待测试",0);
|
|
|
product_sn.setEditable(false);
|
|
|
- if(MesClient.configParam.getStartMode().equals("自动启动")){
|
|
|
- MesClient.serialPortUtils.start();
|
|
|
- }
|
|
|
+ MesClient.onScanValidated();
|
|
|
MesClient.result.setText("等待结果");
|
|
|
MesClient.result.setForeground(Color.GRAY);
|
|
|
}
|
|
|
@@ -821,15 +883,9 @@ public class MesClient extends JFrame {
|
|
|
mesClientFrame.repaint();
|
|
|
|
|
|
work_status = 1;
|
|
|
-// f_scan_data_bt_1.setEnabled(false);
|
|
|
MesClient.tjFlag = 1;
|
|
|
MesClient.setMenuStatus("扫码成功,等待测试",0);
|
|
|
-
|
|
|
- if(MesClient.configParam.getStartMode().equals("自动启动")){
|
|
|
- MesClient.serialPortUtils.start();
|
|
|
- }
|
|
|
- f_scan_data_bt_1.setIcon(null);
|
|
|
- f_scan_data_bt_1.setText("启动");
|
|
|
+ MesClient.onScanValidated();
|
|
|
|
|
|
}else {
|
|
|
JOptionPane.showMessageDialog(mesClientFrame,"请扫工件码","提示窗口", JOptionPane.INFORMATION_MESSAGE);
|
|
|
@@ -1000,30 +1056,35 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
product_sn = new JTextField();
|
|
|
product_sn.setHorizontalAlignment(SwingConstants.LEFT);
|
|
|
- product_sn.setEditable(true);
|
|
|
- product_sn.setFont(new Font("微软雅黑", Font.PLAIN, 28));
|
|
|
- product_sn.setBounds(81, 70, 602, 70);
|
|
|
+ product_sn.setEditable(false);
|
|
|
+ product_sn.setFocusable(false);
|
|
|
+ product_sn.setFont(new Font("微软雅黑", Font.PLAIN, 24));
|
|
|
+ // 尺寸不变:宽550;与按钮统一间距 18px
|
|
|
+ product_sn.setBounds(50, 70, 550, 70);
|
|
|
indexPanelA.add(product_sn);
|
|
|
product_sn.setColumns(10);
|
|
|
- product_sn.addActionListener(new ActionListener() {
|
|
|
+
|
|
|
+ f_scan_data_bt_1 = new JButton("扫码");
|
|
|
+ f_scan_data_bt_1.addActionListener(new ActionListener() {
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
scan_type = 1;
|
|
|
- scanBarcode2();
|
|
|
+ scanBarcodeByButton();
|
|
|
}
|
|
|
});
|
|
|
+ f_scan_data_bt_1.setFont(new Font("微软雅黑", Font.PLAIN, 28));
|
|
|
+ f_scan_data_bt_1.setBounds(618, 70, 120, 70);
|
|
|
+ indexPanelA.add(f_scan_data_bt_1);
|
|
|
|
|
|
-// f_scan_data_bt_1 = new JButton("扫码");
|
|
|
- f_scan_data_bt_1 = new JButton("启动");
|
|
|
- f_scan_data_bt_1.addActionListener(new ActionListener() {
|
|
|
+ f_start_bt = new JButton("启动");
|
|
|
+ f_start_bt.setEnabled(false);
|
|
|
+ f_start_bt.addActionListener(new ActionListener() {
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
- scan_type = 1;
|
|
|
- scanBarcode();
|
|
|
+ doStartTest();
|
|
|
}
|
|
|
});
|
|
|
-// f_scan_data_bt_1.setIcon(new ImageIcon(MesClient.class.getResource("/bg/scan_barcode.png")));
|
|
|
- f_scan_data_bt_1.setFont(new Font("微软雅黑", Font.PLAIN, 32));
|
|
|
- f_scan_data_bt_1.setBounds(693, 70, 198, 70);
|
|
|
- indexPanelA.add(f_scan_data_bt_1);
|
|
|
+ f_start_bt.setFont(new Font("微软雅黑", Font.PLAIN, 28));
|
|
|
+ f_start_bt.setBounds(756, 70, 120, 70);
|
|
|
+ indexPanelA.add(f_start_bt);
|
|
|
|
|
|
JLabel lblNewLabel = new JLabel("测试压");
|
|
|
lblNewLabel.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|