|
@@ -138,6 +138,8 @@ public class WorkJPanelDevice extends JPanel {
|
|
|
private static final String OP190_TEST_SN = "000020022144-0100101426053100009";
|
|
private static final String OP190_TEST_SN = "000020022144-0100101426053100009";
|
|
|
/** OP190 拉铆打满后是否已触发完工提交,防止重复提交 */
|
|
/** OP190 拉铆打满后是否已触发完工提交,防止重复提交 */
|
|
|
private volatile boolean op190RivetingComplete = false;
|
|
private volatile boolean op190RivetingComplete = false;
|
|
|
|
|
+ /** OP190 质量结果是否已异步提交(拉铆完成时提交,下料时不再重复) */
|
|
|
|
|
+ private volatile boolean op190QualitySubmitted = false;
|
|
|
|
|
|
|
|
public int aMax = 16; // A枪预设总数
|
|
public int aMax = 16; // A枪预设总数
|
|
|
public int sortA = 0; // A枪当前已读取的数量
|
|
public int sortA = 0; // A枪当前已读取的数量
|
|
@@ -296,8 +298,8 @@ public class WorkJPanelDevice extends JPanel {
|
|
|
|
|
|
|
|
Font rowLabelFont = new Font("微软雅黑", Font.PLAIN, 20);
|
|
Font rowLabelFont = new Font("微软雅黑", Font.PLAIN, 20);
|
|
|
Font rowFieldFont = new Font("微软雅黑", Font.BOLD, 20);
|
|
Font rowFieldFont = new Font("微软雅黑", Font.BOLD, 20);
|
|
|
- int actionW = 88;
|
|
|
|
|
- int fieldW = contentW - labelW - actionW - gap;
|
|
|
|
|
|
|
+ int actionW = 80;
|
|
|
|
|
+ int fieldW = contentW - labelW - actionW * 2 - gap * 2;
|
|
|
|
|
|
|
|
JLabel feedingLabel = new JLabel("工件码");
|
|
JLabel feedingLabel = new JLabel("工件码");
|
|
|
feedingLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
feedingLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
@@ -318,9 +320,19 @@ public class WorkJPanelDevice extends JPanel {
|
|
|
});
|
|
});
|
|
|
this.add(productSnFeeding);
|
|
this.add(productSnFeeding);
|
|
|
|
|
|
|
|
|
|
+ scanBtn = new JButton("读码");
|
|
|
|
|
+ scanBtn.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
|
|
+ scanBtn.setBounds(contentX + labelW + fieldW + gap, y, actionW, rowH);
|
|
|
|
|
+ scanBtn.addActionListener(new ActionListener() {
|
|
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
|
|
+ manualBarCode();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ this.add(scanBtn);
|
|
|
|
|
+
|
|
|
resetFeedingBtn = new JButton("重置");
|
|
resetFeedingBtn = new JButton("重置");
|
|
|
resetFeedingBtn.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
resetFeedingBtn.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
- resetFeedingBtn.setBounds(contentX + labelW + fieldW + gap, y, actionW, rowH);
|
|
|
|
|
|
|
+ resetFeedingBtn.setBounds(contentX + labelW + fieldW + gap * 2 + actionW, y, actionW, rowH);
|
|
|
resetFeedingBtn.addActionListener(new ActionListener() {
|
|
resetFeedingBtn.addActionListener(new ActionListener() {
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
int choice = JOptionPane.showConfirmDialog(null, "确定刷新上料工件吗?", "操作确认",
|
|
int choice = JOptionPane.showConfirmDialog(null, "确定刷新上料工件吗?", "操作确认",
|
|
@@ -547,9 +559,11 @@ public class WorkJPanelDevice extends JPanel {
|
|
|
int rowH = (int)(40 * scale);
|
|
int rowH = (int)(40 * scale);
|
|
|
int labelW = controlWidth / 5;
|
|
int labelW = controlWidth / 5;
|
|
|
int fieldX = labelW;
|
|
int fieldX = labelW;
|
|
|
- int fieldW = controlWidth * 3 / 5;
|
|
|
|
|
- int btnX = controlWidth * 4 / 5 + (int)(10 * scale);
|
|
|
|
|
- int btnW = controlWidth / 5 - (int)(10 * scale);
|
|
|
|
|
|
|
+ int fieldW = controlWidth * 2 / 5;
|
|
|
|
|
+ int btnGap = (int)(5 * scale);
|
|
|
|
|
+ int btnW = controlWidth / 5 - btnGap;
|
|
|
|
|
+ int scanBtnX = controlWidth * 3 / 5 + btnGap;
|
|
|
|
|
+ int resetBtnX = controlWidth * 4 / 5 + btnGap;
|
|
|
Font rowLabelFont = new Font("微软雅黑", Font.PLAIN, (int)(20 * scale));
|
|
Font rowLabelFont = new Font("微软雅黑", Font.PLAIN, (int)(20 * scale));
|
|
|
Font rowFieldFont = new Font("微软雅黑", Font.PLAIN, (int)(16 * scale));
|
|
Font rowFieldFont = new Font("微软雅黑", Font.PLAIN, (int)(16 * scale));
|
|
|
|
|
|
|
@@ -576,6 +590,16 @@ public class WorkJPanelDevice extends JPanel {
|
|
|
});
|
|
});
|
|
|
this.add(productSnFeeding);
|
|
this.add(productSnFeeding);
|
|
|
|
|
|
|
|
|
|
+ scanBtn = new JButton("读码");
|
|
|
|
|
+ scanBtn.addActionListener(new ActionListener() {
|
|
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
|
|
+ manualBarCode();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ scanBtn.setFont(new Font("微软雅黑", Font.PLAIN, (int)(18 * scale)));
|
|
|
|
|
+ scanBtn.setBounds(scanBtnX, row1Y, btnW, rowH);
|
|
|
|
|
+ this.add(scanBtn);
|
|
|
|
|
+
|
|
|
resetFeedingBtn = new JButton("刷新");
|
|
resetFeedingBtn = new JButton("刷新");
|
|
|
resetFeedingBtn.addActionListener(new ActionListener() {
|
|
resetFeedingBtn.addActionListener(new ActionListener() {
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
@@ -587,8 +611,8 @@ public class WorkJPanelDevice extends JPanel {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- resetFeedingBtn.setFont(new Font("微软雅黑", Font.PLAIN, (int)(22 * scale)));
|
|
|
|
|
- resetFeedingBtn.setBounds(btnX, row1Y, btnW, rowH);
|
|
|
|
|
|
|
+ resetFeedingBtn.setFont(new Font("微软雅黑", Font.PLAIN, (int)(18 * scale)));
|
|
|
|
|
+ resetFeedingBtn.setBounds(resetBtnX, row1Y, btnW, rowH);
|
|
|
this.add(resetFeedingBtn);
|
|
this.add(resetFeedingBtn);
|
|
|
|
|
|
|
|
productSn = new JTextField("");
|
|
productSn = new JTextField("");
|
|
@@ -878,11 +902,12 @@ public class WorkJPanelDevice extends JPanel {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 当完成数量达到预设时,自动关闭拉铆机电源;下料请求与反馈与其它工序一致,由 oprnoTimer 处理
|
|
|
|
|
|
|
+ // 当完成数量达到预设时:关电源 + OP190 立即异步提交质量;下料信号仅做 MES 反馈
|
|
|
if (cur == aMax) {
|
|
if (cur == aMax) {
|
|
|
powerOffRiveting();
|
|
powerOffRiveting();
|
|
|
- if (oprno.equals("OP190")) {
|
|
|
|
|
|
|
+ if (oprno.equals("OP190") && !op190RivetingComplete) {
|
|
|
op190RivetingComplete = true;
|
|
op190RivetingComplete = true;
|
|
|
|
|
+ submitOp190QualityAsync();
|
|
|
}
|
|
}
|
|
|
} else if (bindLbStatus && tjFeedingFlag >= 1 && sortA < aMax) {
|
|
} else if (bindLbStatus && tjFeedingFlag >= 1 && sortA < aMax) {
|
|
|
// 绑定冷板后,若拉铆机意外停机则尝试恢复
|
|
// 绑定冷板后,若拉铆机意外停机则尝试恢复
|
|
@@ -897,7 +922,30 @@ public class WorkJPanelDevice extends JPanel {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /** OP190 测试:拉铆完成数直接变为预设值,等待下料请求后走统一提交流程 */
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * OP190:拉铆完成后立即异步提交质量结果,不阻塞等待下料信号。
|
|
|
|
|
+ */
|
|
|
|
|
+ private void submitOp190QualityAsync() {
|
|
|
|
|
+ if (op190QualitySubmitted) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ final String sn = productSnFeeding.getText() == null
|
|
|
|
|
+ ? "" : productSnFeeding.getText().trim();
|
|
|
|
|
+ if (sn.isEmpty()) {
|
|
|
|
|
+ setMenuStatus("拉铆完成但工件码为空,无法提交", -1);
|
|
|
|
|
+ log.warn("OP190 拉铆完成但工件码为空,跳过提交");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ op190QualitySubmitted = true;
|
|
|
|
|
+ final String station = oprno + pos;
|
|
|
|
|
+ final String user = MesClient.user_menu.getText();
|
|
|
|
|
+ // 与 readResult() 一致:OP190 暂固定 OK
|
|
|
|
|
+ DataUtil.submitQualityAsync(sn, station, "OK", user);
|
|
|
|
|
+ setMenuStatus("拉铆完成,结果后台提交中,等待下料", 0);
|
|
|
|
|
+ log.info("OP190 拉铆完成,已异步提交质量 sn={}", sn);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /** OP190 测试:拉铆完成数直接变为预设值,并立即异步提交质量 */
|
|
|
private void simulateOp190RivetingComplete() {
|
|
private void simulateOp190RivetingComplete() {
|
|
|
if (op190RivetingComplete) {
|
|
if (op190RivetingComplete) {
|
|
|
return;
|
|
return;
|
|
@@ -917,6 +965,7 @@ public class WorkJPanelDevice extends JPanel {
|
|
|
log.warn("OP190 测试模式:关闭拉铆机电源跳过(无 PLC 时可忽略)", e);
|
|
log.warn("OP190 测试模式:关闭拉铆机电源跳过(无 PLC 时可忽略)", e);
|
|
|
}
|
|
}
|
|
|
op190RivetingComplete = true;
|
|
op190RivetingComplete = true;
|
|
|
|
|
+ submitOp190QualityAsync();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public Timer cjTimerText2;
|
|
public Timer cjTimerText2;
|
|
@@ -1063,9 +1112,7 @@ public class WorkJPanelDevice extends JPanel {
|
|
|
Boolean retFeedingAllow = readAllowFeeding();
|
|
Boolean retFeedingAllow = readAllowFeeding();
|
|
|
feedingmeslabel.setIcon(retFeedingAllow?imageGreen:imageGray);
|
|
feedingmeslabel.setIcon(retFeedingAllow?imageGreen:imageGray);
|
|
|
|
|
|
|
|
- if(!retFeeding && retFeedingAllow){
|
|
|
|
|
- writeAllowFeeding(false);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 允许上料仅在工位开始工作(tjFeedingFlag 1→2)时清除,不在空闲阶段自动复位
|
|
|
|
|
|
|
|
// 读取下料信号
|
|
// 读取下料信号
|
|
|
Boolean retBlanking = readBlanking();
|
|
Boolean retBlanking = readBlanking();
|
|
@@ -1104,6 +1151,7 @@ public class WorkJPanelDevice extends JPanel {
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
tjFeedingFlag = 2;
|
|
tjFeedingFlag = 2;
|
|
|
|
|
+ writeAllowFeeding(false); // 工位开始工作后再清除允许上料
|
|
|
resetFeeding();
|
|
resetFeeding();
|
|
|
setMenuStatus("工件加工中", 0);
|
|
setMenuStatus("工件加工中", 0);
|
|
|
getToolLife();
|
|
getToolLife();
|
|
@@ -1119,21 +1167,39 @@ public class WorkJPanelDevice extends JPanel {
|
|
|
tjStatus = 1;
|
|
tjStatus = 1;
|
|
|
writeAllowBlanking(true);
|
|
writeAllowBlanking(true);
|
|
|
blankingmeslabel.setIcon(imageGreen);
|
|
blankingmeslabel.setIcon(imageGreen);
|
|
|
- final String sn = productSnFeeding.getText() == null
|
|
|
|
|
- ? "" : productSnFeeding.getText().trim();
|
|
|
|
|
- final String station = oprno + pos;
|
|
|
|
|
- final String user = MesClient.user_menu.getText();
|
|
|
|
|
- final String result = "OK".equals(readResult()) ? "OK" : "NG";
|
|
|
|
|
- final boolean queued = !sn.isEmpty();
|
|
|
|
|
- if (queued) {
|
|
|
|
|
- DataUtil.submitQualityAsync(sn, station, result, user);
|
|
|
|
|
- }
|
|
|
|
|
- tjFeedingFlag = 3;
|
|
|
|
|
- resetBlanking();
|
|
|
|
|
- if (queued) {
|
|
|
|
|
- setMenuStatus("已下料,结果后台提交中", 0);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (oprno.equals("OP190")) {
|
|
|
|
|
+ // OP190:质量已在拉铆完成时异步提交;下料仅反馈。若尚未提交则兜底补交
|
|
|
|
|
+ if (!op190QualitySubmitted) {
|
|
|
|
|
+ final String sn = productSnFeeding.getText() == null
|
|
|
|
|
+ ? "" : productSnFeeding.getText().trim();
|
|
|
|
|
+ if (!sn.isEmpty()) {
|
|
|
|
|
+ DataUtil.submitQualityAsync(sn, oprno + pos, "OK",
|
|
|
|
|
+ MesClient.user_menu.getText());
|
|
|
|
|
+ op190QualitySubmitted = true;
|
|
|
|
|
+ log.warn("OP190 下料时质量尚未提交,已兜底异步提交 sn={}", sn);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ tjFeedingFlag = 3;
|
|
|
|
|
+ resetBlanking();
|
|
|
|
|
+ setMenuStatus("已下料,等待下一件", 0);
|
|
|
} else {
|
|
} else {
|
|
|
- setMenuStatus("工件码为空,无法提交", -1);
|
|
|
|
|
|
|
+ final String sn = productSnFeeding.getText() == null
|
|
|
|
|
+ ? "" : productSnFeeding.getText().trim();
|
|
|
|
|
+ final String station = oprno + pos;
|
|
|
|
|
+ final String user = MesClient.user_menu.getText();
|
|
|
|
|
+ final String result = "OK".equals(readResult()) ? "OK" : "NG";
|
|
|
|
|
+ final boolean queued = !sn.isEmpty();
|
|
|
|
|
+ if (queued) {
|
|
|
|
|
+ DataUtil.submitQualityAsync(sn, station, result, user);
|
|
|
|
|
+ }
|
|
|
|
|
+ tjFeedingFlag = 3;
|
|
|
|
|
+ resetBlanking();
|
|
|
|
|
+ if (queued) {
|
|
|
|
|
+ setMenuStatus("已下料,结果后台提交中", 0);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ setMenuStatus("工件码为空,无法提交", -1);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1192,10 +1258,84 @@ public class WorkJPanelDevice extends JPanel {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 手动从 PLC 读码(不依赖“允许MES读码”信号)
|
|
|
|
|
+ */
|
|
|
|
|
+ public void manualBarCode() {
|
|
|
|
|
+ if (MesClient.isLogin != 1) {
|
|
|
|
|
+ setMenuStatus("请先登录", -1);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!productSnFeeding.getText().trim().isEmpty()) {
|
|
|
|
|
+ int choice = JOptionPane.showConfirmDialog(null,
|
|
|
|
|
+ "当前已有工件码,确定重新从PLC读码吗?",
|
|
|
|
|
+ "操作确认",
|
|
|
|
|
+ JOptionPane.YES_NO_OPTION,
|
|
|
|
|
+ JOptionPane.QUESTION_MESSAGE);
|
|
|
|
|
+ if (choice != JOptionPane.YES_OPTION) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("人工手动读码,清空原工件码:" + productSnFeeding.getText().trim());
|
|
|
|
|
+ productSnFeeding.setText("");
|
|
|
|
|
+ tjFeedingFlag = 0;
|
|
|
|
|
+ writeAllowFeeding(false);
|
|
|
|
|
+ if (oprno.equals("OP190")) {
|
|
|
|
|
+ resetLbBinding();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("人工点击手动读码:" + oprno + pos);
|
|
|
|
|
+ setMenuStatus("正在从PLC读码...", 0);
|
|
|
|
|
+ barCode();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 手动提交当前工件质量结果(异步)。有工件码才提交。
|
|
|
|
|
+ * @return true 已入队提交
|
|
|
|
|
+ */
|
|
|
|
|
+ public boolean manualSubmitQuality() {
|
|
|
|
|
+ if (MesClient.isLogin != 1) {
|
|
|
|
|
+ setMenuStatus("请先登录", -1);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ final String sn = productSnFeeding.getText() == null
|
|
|
|
|
+ ? "" : productSnFeeding.getText().trim();
|
|
|
|
|
+ if (sn.isEmpty()) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (oprno.equals("OP190") && op190QualitySubmitted) {
|
|
|
|
|
+ int choice = JOptionPane.showConfirmDialog(null,
|
|
|
|
|
+ oprno + pos + " 已提交过,确定再次提交吗?\n" + sn,
|
|
|
|
|
+ "手动提交确认",
|
|
|
|
|
+ JOptionPane.YES_NO_OPTION,
|
|
|
|
|
+ JOptionPane.QUESTION_MESSAGE);
|
|
|
|
|
+ if (choice != JOptionPane.YES_OPTION) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ final String station = oprno + pos;
|
|
|
|
|
+ final String user = MesClient.user_menu.getText();
|
|
|
|
|
+ final String result = oprno.equals("OP190")
|
|
|
|
|
+ ? "OK"
|
|
|
|
|
+ : ("OK".equals(readResult()) ? "OK" : "NG");
|
|
|
|
|
+ DataUtil.submitQualityAsync(sn, station, result, user);
|
|
|
|
|
+ if (oprno.equals("OP190")) {
|
|
|
|
|
+ op190QualitySubmitted = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ writeAllowBlanking(true);
|
|
|
|
|
+ if (blankingmeslabel != null) {
|
|
|
|
|
+ blankingmeslabel.setIcon(imageGreen);
|
|
|
|
|
+ }
|
|
|
|
|
+ resetBlanking();
|
|
|
|
|
+ setMenuStatus("手动提交已入队,已给下料反馈", 0);
|
|
|
|
|
+ log.info("人工手动提交质量并给下料反馈 sn={}, station={}, result={}", sn, station, result);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public void resetBlanking() {
|
|
public void resetBlanking() {
|
|
|
tjFeedingFlag = 0;
|
|
tjFeedingFlag = 0;
|
|
|
tjStatus = 0;
|
|
tjStatus = 0;
|
|
|
op190RivetingComplete = false;
|
|
op190RivetingComplete = false;
|
|
|
|
|
+ op190QualitySubmitted = false;
|
|
|
productSnFeeding.setText("");
|
|
productSnFeeding.setText("");
|
|
|
resetLbBinding();
|
|
resetLbBinding();
|
|
|
setMenuStatus("工件结果已提交,等待下一件",0);
|
|
setMenuStatus("工件结果已提交,等待下一件",0);
|
|
@@ -1233,7 +1373,6 @@ public class WorkJPanelDevice extends JPanel {
|
|
|
// tjFeedingFlag = 0;
|
|
// tjFeedingFlag = 0;
|
|
|
// setMenuStatus("等待请求扫码",0);
|
|
// setMenuStatus("等待请求扫码",0);
|
|
|
resetFeedingBtn.setEnabled(true);
|
|
resetFeedingBtn.setEnabled(true);
|
|
|
- writeAllowFeeding(false);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void resetScanA() {
|
|
public void resetScanA() {
|
|
@@ -1241,6 +1380,7 @@ public class WorkJPanelDevice extends JPanel {
|
|
|
tjFlag = 0;
|
|
tjFlag = 0;
|
|
|
tjStatus = 0;
|
|
tjStatus = 0;
|
|
|
op190RivetingComplete = false;
|
|
op190RivetingComplete = false;
|
|
|
|
|
+ op190QualitySubmitted = false;
|
|
|
// productSn.setText("");
|
|
// productSn.setText("");
|
|
|
productSnFeeding.setText("");
|
|
productSnFeeding.setText("");
|
|
|
resetLbBinding();
|
|
resetLbBinding();
|