|
@@ -46,6 +46,10 @@ public class MesClientComponent extends JPanel {
|
|
|
public JLabel sllabel1;
|
|
public JLabel sllabel1;
|
|
|
/** 下料完成反馈(可手动点击翻转) */
|
|
/** 下料完成反馈(可手动点击翻转) */
|
|
|
public JLabel sllabel2;
|
|
public JLabel sllabel2;
|
|
|
|
|
+ /** 上料完成信号(仅展示,不可点击) */
|
|
|
|
|
+ public JLabel sllabelLoad;
|
|
|
|
|
+ /** 下料完成信号(仅展示,不可点击) */
|
|
|
|
|
+ public JLabel sllabelUnload;
|
|
|
/** 工位状态:正常/故障 */
|
|
/** 工位状态:正常/故障 */
|
|
|
public JLabel stationStatusLabel;
|
|
public JLabel stationStatusLabel;
|
|
|
/** 加工结果展示 */
|
|
/** 加工结果展示 */
|
|
@@ -102,7 +106,8 @@ public class MesClientComponent extends JPanel {
|
|
|
y += hStatus + gap;
|
|
y += hStatus + gap;
|
|
|
|
|
|
|
|
productSn = new JTextField("");
|
|
productSn = new JTextField("");
|
|
|
- productSn.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
|
|
|
|
+ // 过长时右对齐,尾部顶满格,开头被裁切,便于看清后缀
|
|
|
|
|
+ productSn.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
productSn.setForeground(Color.BLACK);
|
|
productSn.setForeground(Color.BLACK);
|
|
|
int snFont = Math.max(14, Math.min(22, w / 16));
|
|
int snFont = Math.max(14, Math.min(22, w / 16));
|
|
|
productSn.setFont(new Font("微软雅黑", Font.PLAIN, snFont));
|
|
productSn.setFont(new Font("微软雅黑", Font.PLAIN, snFont));
|
|
@@ -110,26 +115,28 @@ public class MesClientComponent extends JPanel {
|
|
|
productSn.setBounds(margin, y, w - 2 * margin, hSn);
|
|
productSn.setBounds(margin, y, w - 2 * margin, hSn);
|
|
|
productSn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
|
productSn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
|
|
productSn.setToolTipText("点击显示二维码");
|
|
productSn.setToolTipText("点击显示二维码");
|
|
|
- productSn.setFocusable(false);
|
|
|
|
|
|
|
+ productSn.setColumns(10);
|
|
|
productSn.addMouseListener(new MouseAdapter() {
|
|
productSn.addMouseListener(new MouseAdapter() {
|
|
|
@Override
|
|
@Override
|
|
|
public void mousePressed(MouseEvent e) {
|
|
public void mousePressed(MouseEvent e) {
|
|
|
- MesClient.createQRCode(productSn.getText(), oprnoClass.getOprno());
|
|
|
|
|
|
|
+ // 与 op300 一致:可点;工控触摸屏上 pressed 比 clicked 更稳
|
|
|
|
|
+ String sn = productSn.getText() == null ? "" : productSn.getText().trim();
|
|
|
|
|
+ if (!sn.isEmpty()) {
|
|
|
|
|
+ MesClient.createQRCode(sn, oprnoClass.getOprno());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
this.add(productSn);
|
|
this.add(productSn);
|
|
|
y += hSn + gap;
|
|
y += hSn + gap;
|
|
|
|
|
|
|
|
- stationStatusLabel = new JLabel("工位状态: --");
|
|
|
|
|
- stationStatusLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
|
|
- stationStatusLabel.setFont(new Font("微软雅黑", Font.PLAIN, Math.max(12, w / 18)));
|
|
|
|
|
- stationStatusLabel.setBounds(0, y, w / 2, hLab);
|
|
|
|
|
- this.add(stationStatusLabel);
|
|
|
|
|
|
|
+ // 工位状态(station_status)暂不显示:现场点位未就绪时会一直报故障
|
|
|
|
|
+ stationStatusLabel = new JLabel("");
|
|
|
|
|
+ stationStatusLabel.setVisible(false);
|
|
|
|
|
|
|
|
resultLabel = new JLabel("结果: --");
|
|
resultLabel = new JLabel("结果: --");
|
|
|
resultLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
resultLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
resultLabel.setFont(new Font("微软雅黑", Font.PLAIN, Math.max(12, w / 18)));
|
|
resultLabel.setFont(new Font("微软雅黑", Font.PLAIN, Math.max(12, w / 18)));
|
|
|
- resultLabel.setBounds(w / 2, y, w - w / 2, hLab);
|
|
|
|
|
|
|
+ resultLabel.setBounds(margin, y, w - 2 * margin, hLab);
|
|
|
this.add(resultLabel);
|
|
this.add(resultLabel);
|
|
|
y += hLab + gap;
|
|
y += hLab + gap;
|
|
|
|
|
|
|
@@ -204,6 +211,26 @@ public class MesClientComponent extends JPanel {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
this.add(sllabel2);
|
|
this.add(sllabel2);
|
|
|
|
|
+ y += hFeedback + gap;
|
|
|
|
|
+
|
|
|
|
|
+ // 上料/下料信号:只读展示 PLC→MES 完成位,不可点击
|
|
|
|
|
+ sllabelLoad = new JLabel("上料信号");
|
|
|
|
|
+ sllabelLoad.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
|
|
+ sllabelLoad.setVerticalAlignment(SwingConstants.CENTER);
|
|
|
|
|
+ sllabelLoad.setIcon(dot(false));
|
|
|
|
|
+ sllabelLoad.setForeground(Color.BLACK);
|
|
|
|
|
+ sllabelLoad.setToolTipText("上料完成信号(只读)");
|
|
|
|
|
+ sllabelLoad.setBounds(0, y, w / 2, hFeedback);
|
|
|
|
|
+ this.add(sllabelLoad);
|
|
|
|
|
+
|
|
|
|
|
+ sllabelUnload = new JLabel("下料信号");
|
|
|
|
|
+ sllabelUnload.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
|
|
+ sllabelUnload.setVerticalAlignment(SwingConstants.CENTER);
|
|
|
|
|
+ sllabelUnload.setIcon(dot(false));
|
|
|
|
|
+ sllabelUnload.setForeground(Color.BLACK);
|
|
|
|
|
+ sllabelUnload.setToolTipText("下料完成信号(只读)");
|
|
|
|
|
+ sllabelUnload.setBounds(w / 2, y, w - w / 2, hFeedback);
|
|
|
|
|
+ this.add(sllabelUnload);
|
|
|
|
|
|
|
|
this.startOprnoTimer();
|
|
this.startOprnoTimer();
|
|
|
}
|
|
}
|
|
@@ -258,8 +285,12 @@ public class MesClientComponent extends JPanel {
|
|
|
try {
|
|
try {
|
|
|
boolean lf = MesClient.s7PLC.readBoolean(oprnoClass.getLoad_feedback());
|
|
boolean lf = MesClient.s7PLC.readBoolean(oprnoClass.getLoad_feedback());
|
|
|
boolean uf = MesClient.s7PLC.readBoolean(oprnoClass.getUnload_feedback());
|
|
boolean uf = MesClient.s7PLC.readBoolean(oprnoClass.getUnload_feedback());
|
|
|
|
|
+ boolean lc = MesClient.s7PLC.readBoolean(oprnoClass.getLoad_complete());
|
|
|
|
|
+ boolean uc = MesClient.s7PLC.readBoolean(oprnoClass.getUnload_complete());
|
|
|
sllabel1.setIcon(dot(lf));
|
|
sllabel1.setIcon(dot(lf));
|
|
|
sllabel2.setIcon(dot(uf));
|
|
sllabel2.setIcon(dot(uf));
|
|
|
|
|
+ sllabelLoad.setIcon(dot(lc));
|
|
|
|
|
+ sllabelUnload.setIcon(dot(uc));
|
|
|
} catch (Exception ignored) {
|
|
} catch (Exception ignored) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -310,28 +341,6 @@ public class MesClientComponent extends JPanel {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void pollOnce() {
|
|
private void pollOnce() {
|
|
|
- // 工位状态显示(故障时同步到上方状态栏)
|
|
|
|
|
- try {
|
|
|
|
|
- boolean stationOk = MesClient.s7PLC.readBoolean(oprnoClass.getStation_status());
|
|
|
|
|
- final boolean ok = stationOk;
|
|
|
|
|
- SwingUtilities.invokeLater(() -> {
|
|
|
|
|
- if (ok) {
|
|
|
|
|
- stationStatusLabel.setText("工位状态: 正常");
|
|
|
|
|
- stationStatusLabel.setForeground(new Color(0, 128, 0));
|
|
|
|
|
- if (lastStationOk != null && !lastStationOk) {
|
|
|
|
|
- restoreStatusAfterFault();
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- stationStatusLabel.setText("工位状态: 故障");
|
|
|
|
|
- stationStatusLabel.setForeground(Color.RED);
|
|
|
|
|
- setMenuStatus("工位故障", -1);
|
|
|
|
|
- }
|
|
|
|
|
- lastStationOk = ok;
|
|
|
|
|
- });
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- // PLC 未就绪时忽略
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
refreshFeedbackIcons();
|
|
refreshFeedbackIcons();
|
|
|
|
|
|
|
|
boolean loadComplete = false;
|
|
boolean loadComplete = false;
|
|
@@ -359,7 +368,10 @@ public class MesClientComponent extends JPanel {
|
|
|
lastUnloadComplete = unloadComplete;
|
|
lastUnloadComplete = unloadComplete;
|
|
|
|
|
|
|
|
if (work_status == 0) {
|
|
if (work_status == 0) {
|
|
|
- if (loadComplete && !loadEdgeHandled) {
|
|
|
|
|
|
|
+ // 面板尚无码时按电平触发,避免 loadEdgeHandled 卡住后 PLC 已有上料完成+码却一直“等待上料完成”
|
|
|
|
|
+ String curSn = productSn.getText();
|
|
|
|
|
+ boolean noSnYet = curSn == null || curSn.trim().isEmpty();
|
|
|
|
|
+ if (loadComplete && (!loadEdgeHandled || noSnYet)) {
|
|
|
String sn = "";
|
|
String sn = "";
|
|
|
try {
|
|
try {
|
|
|
sn = MesClient.s7PLC.readString(oprnoClass.getProduct_sn());
|
|
sn = MesClient.s7PLC.readString(oprnoClass.getProduct_sn());
|
|
@@ -501,6 +513,8 @@ public class MesClientComponent extends JPanel {
|
|
|
resultLabel.setText("结果: --");
|
|
resultLabel.setText("结果: --");
|
|
|
resultLabel.setForeground(Color.BLACK);
|
|
resultLabel.setForeground(Color.BLACK);
|
|
|
work_status = 0;
|
|
work_status = 0;
|
|
|
|
|
+ loadEdgeHandled = false;
|
|
|
|
|
+ unloadEdgeHandled = false;
|
|
|
resultHandled = false;
|
|
resultHandled = false;
|
|
|
aqdwSent = false;
|
|
aqdwSent = false;
|
|
|
setMenuStatus("等待上料完成", 0);
|
|
setMenuStatus("等待上料完成", 0);
|