|
|
@@ -85,9 +85,21 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
public static JLabel fxlabel;
|
|
|
|
|
|
- public static S7PLC s7PLC = new S7PLC(EPlcType.S1500, "192.168.90.91");
|
|
|
+ // 信号灯
|
|
|
+ public static JLabel feedingLight;
|
|
|
+ public static JLabel replyLight;
|
|
|
+ public static JLabel plcCodeLabel; // PLC 码内容回显(DB5000.260)
|
|
|
+ public static ImageIcon imageGreen;
|
|
|
+ public static ImageIcon imageGray;
|
|
|
+ public static Timer lightTimer;
|
|
|
+
|
|
|
+ public static S7PLC s7PLC = new S7PLC(EPlcType.S1500, "192.168.90.86");
|
|
|
|
|
|
public static int dateLoading = 0;
|
|
|
+ // 已取码标志:取到码后锁住,等本件完成或刷新工件后才允许取下一件
|
|
|
+ public static boolean qrLoaded = false;
|
|
|
+ // 本件工位结果已提交标志:PLC 反馈复位后才允许下一轮提交
|
|
|
+ public static boolean resultSubmitted = false;
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
|
@@ -196,6 +208,7 @@ public class MesClient extends JFrame {
|
|
|
check_quality_result = false;
|
|
|
planStop = false;
|
|
|
nextRetryTime = 0;
|
|
|
+ qrLoaded = false;
|
|
|
MesClient.finish_ok_bt.setEnabled(false);
|
|
|
MesClient.finish_ng_bt.setEnabled(false);
|
|
|
product_sn.setText("");
|
|
|
@@ -510,12 +523,34 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
fxlabel = new JLabel("该工件为返修件,请仔细检查");
|
|
|
fxlabel.setFont(new Font("微软雅黑", Font.PLAIN, 38));
|
|
|
- fxlabel.setBounds(81, 170, 810, 70);
|
|
|
+ fxlabel.setBounds(81, 190, 810, 70);
|
|
|
fxlabel.setForeground(Color.RED);
|
|
|
fxlabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
fxlabel.setVisible(false);
|
|
|
indexPanelA.add(fxlabel);
|
|
|
|
|
|
+ // 信号灯:请求镭雕码、二维码接收反馈
|
|
|
+ imageGreen = new ImageIcon(MesClient.class.getResource("/bg/green_dot.png"));
|
|
|
+ imageGreen.setImage(imageGreen.getImage().getScaledInstance(24, 24, Image.SCALE_SMOOTH));
|
|
|
+ imageGray = new ImageIcon(MesClient.class.getResource("/bg/grey_dot.png"));
|
|
|
+ imageGray.setImage(imageGray.getImage().getScaledInstance(24, 24, Image.SCALE_SMOOTH));
|
|
|
+
|
|
|
+ feedingLight = new JLabel("请求镭雕码(DB5000.0.4)", imageGray, SwingConstants.LEFT);
|
|
|
+ feedingLight.setFont(new Font("微软雅黑", Font.PLAIN, 14));
|
|
|
+ feedingLight.setBounds(81, 150, 400, 30);
|
|
|
+ indexPanelA.add(feedingLight);
|
|
|
+
|
|
|
+ replyLight = new JLabel("二维码接收反馈(DB5000.0.5)", imageGray, SwingConstants.LEFT);
|
|
|
+ replyLight.setFont(new Font("微软雅黑", Font.PLAIN, 14));
|
|
|
+ replyLight.setBounds(481, 150, 400, 30);
|
|
|
+ indexPanelA.add(replyLight);
|
|
|
+
|
|
|
+ // PLC 码内容回显
|
|
|
+ plcCodeLabel = new JLabel("PLC码(DB5000.260):-");
|
|
|
+ plcCodeLabel.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
+ plcCodeLabel.setBounds(81, 270, 810, 35);
|
|
|
+ indexPanelA.add(plcCodeLabel);
|
|
|
+
|
|
|
finish_ok_bt = new JButton("OK");
|
|
|
finish_ok_bt.setEnabled(false);
|
|
|
finish_ok_bt.addActionListener(new ActionListener() {
|
|
|
@@ -618,6 +653,32 @@ public class MesClient extends JFrame {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ startLightTimer();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 信号灯单独刷新,与业务轮询解耦
|
|
|
+ public static void startLightTimer() {
|
|
|
+ if(lightTimer != null) {
|
|
|
+ lightTimer.cancel();
|
|
|
+ }
|
|
|
+ lightTimer = new Timer();
|
|
|
+ lightTimer.schedule(new TimerTask() {
|
|
|
+ public void run() {
|
|
|
+ try{
|
|
|
+ boolean feeding = PlcUtil.getFeeding(s7PLC);
|
|
|
+ boolean reply = PlcUtil.getReply(s7PLC);
|
|
|
+ String plcCode = PlcUtil.getQrcode(s7PLC);
|
|
|
+ SwingUtilities.invokeLater(() -> {
|
|
|
+ feedingLight.setIcon(feeding ? imageGreen : imageGray);
|
|
|
+ replyLight.setIcon(reply ? imageGreen : imageGray);
|
|
|
+ plcCodeLabel.setText("PLC码(DB5000.260):" + (plcCode == null || plcCode.isEmpty() ? "-" : plcCode));
|
|
|
+ });
|
|
|
+ }catch (Throwable t) {
|
|
|
+ log.error("信号灯刷新异常: " + t.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 500, 1000);
|
|
|
}
|
|
|
|
|
|
public static void setMenuStatus(String msg,int error){
|