|
|
@@ -2,6 +2,7 @@ package com.mes.ui;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.mes.component.MesWebView;
|
|
|
+import com.mes.util.PLCUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
@@ -10,6 +11,7 @@ import javax.swing.border.TitledBorder;
|
|
|
import java.awt.*;
|
|
|
import java.awt.event.ActionEvent;
|
|
|
import java.awt.event.ActionListener;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Timer;
|
|
|
import java.util.TimerTask;
|
|
|
@@ -22,8 +24,11 @@ public class WorkStationPanel extends JPanel {
|
|
|
private String serverIp;
|
|
|
|
|
|
public int workStatus = 0;
|
|
|
+ public int plcStatus = 0;
|
|
|
public boolean checkQualityResult = false;
|
|
|
private String currentUser = "system";
|
|
|
+
|
|
|
+ public static List<String> hjParams = new ArrayList<String>();
|
|
|
|
|
|
public JTextField productSnField;
|
|
|
public JButton scanButton;
|
|
|
@@ -272,6 +277,7 @@ public class WorkStationPanel extends JPanel {
|
|
|
|
|
|
private void resetState() {
|
|
|
workStatus = 0;
|
|
|
+ plcStatus = 0;
|
|
|
checkQualityResult = false;
|
|
|
productSnField.setText("");
|
|
|
finishOkButton.setEnabled(false);
|
|
|
@@ -352,6 +358,54 @@ public class WorkStationPanel extends JPanel {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
if (workStatus == 1) {
|
|
|
+ // TODO
|
|
|
+ // 加入工作流程
|
|
|
+ if (plcStatus == 0){
|
|
|
+ // 等待扫码
|
|
|
+ String sn = productSnField.getText().trim();
|
|
|
+ if (sn.isEmpty()) {
|
|
|
+ plcStatus = 1;
|
|
|
+ }
|
|
|
+ } else if (plcStatus == 1) {
|
|
|
+ // 发送允许启动信号
|
|
|
+ Boolean ret = PLCUtils.writeStartMethod();
|
|
|
+ if (ret) {
|
|
|
+ plcStatus = 2;
|
|
|
+ }
|
|
|
+ } else if (plcStatus == 2) {
|
|
|
+ // 等待开始加工信号
|
|
|
+ Boolean ret = PLCUtils.readStartMethod();
|
|
|
+ if (ret){
|
|
|
+ boolean ret2 = PLCUtils.writeStopMethod();
|
|
|
+ if (ret2){
|
|
|
+ plcStatus = 3;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (plcStatus ==3) {
|
|
|
+ // 等待加工结束信号
|
|
|
+ Boolean ret = PLCUtils.readStopMethod();
|
|
|
+ if (ret){
|
|
|
+ // 发送结果
|
|
|
+ String sn = productSnField.getText().trim();
|
|
|
+ JSONObject retObj = DataUtil.sendQuality( sn,"OK", currentUser, gw, lineSn, serverIp);
|
|
|
+ if (retObj != null && "true".equalsIgnoreCase(retObj.getString("result"))) {
|
|
|
+ // 发送允许下料
|
|
|
+ PLCUtils.writeDownMethod();
|
|
|
+ resetState();
|
|
|
+ statusLabel.setForeground(Color.GREEN);
|
|
|
+ statusLabel.setText("结果提交成功,请扫下一件");
|
|
|
+ finishNgButton.setEnabled(false);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ statusLabel.setForeground(Color.RED);
|
|
|
+ String msg = (retObj != null && retObj.containsKey("message")) ? retObj.getString("message") : "提交失败";
|
|
|
+ statusLabel.setText(msg);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ // 获取参数
|
|
|
+ PLCUtils.getParameter();
|
|
|
+ }
|
|
|
+ }
|
|
|
return;
|
|
|
} else if (workStatus == 0) {
|
|
|
JSONObject result = DataUtil.getCurSn(gw, serverIp, lineSn);
|