|
|
@@ -2,8 +2,6 @@ package com.mes.ui;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
-import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType;
|
|
|
-import com.github.xingshuangs.iot.protocol.s7.service.S7PLC;
|
|
|
import com.mes.component.MesRadio;
|
|
|
import com.mes.component.MesWebView;
|
|
|
import com.mes.netty.NettyClient;
|
|
|
@@ -85,9 +83,7 @@ public class MesClient extends JFrame {
|
|
|
public static JButton finish_ok_bt;
|
|
|
public static JButton finish_ng_bt;
|
|
|
public static JTextField product_sn;
|
|
|
- public static JTextField product_sn_lb;
|
|
|
public static JButton f_scan_data_bt_1;
|
|
|
- public static JButton f_scan_data_bt_2;
|
|
|
|
|
|
public static String user20 = "";
|
|
|
|
|
|
@@ -119,13 +115,11 @@ public class MesClient extends JFrame {
|
|
|
public static JTextField torsionalMaxValue; //扭力值范围
|
|
|
public static JTextField torsionalValue;//当前扭力值
|
|
|
public static Integer cur = 0; // 当前数
|
|
|
- public static Integer max = 91; //任务数
|
|
|
+ public static Integer max = 3; //任务数
|
|
|
public static List<String> atids = new ArrayList<>();
|
|
|
public static ArrayList<String> torsionalValueList = new ArrayList<String>();//扭力值存储数组
|
|
|
public static Boolean fininsh_flag = false; // false=不合格 true=合格
|
|
|
|
|
|
- public static S7PLC s7PLC = new S7PLC(EPlcType.S1200,"10.88.10.80");
|
|
|
-
|
|
|
public static void main(String[] args) {
|
|
|
EventQueue.invokeLater(new Runnable() {
|
|
|
@Override
|
|
|
@@ -354,8 +348,6 @@ public class MesClient extends JFrame {
|
|
|
MesClient.finish_ok_bt.setEnabled(false);
|
|
|
MesClient.finish_ng_bt.setEnabled(false);
|
|
|
product_sn.setText("");
|
|
|
- product_sn_lb.setText("");
|
|
|
- f_scan_data_bt_2.setEnabled(false);
|
|
|
|
|
|
MesClient.f_scan_data_bt_1.setEnabled(true);
|
|
|
MesClient.setMenuStatus("请扫工件码",0);
|
|
|
@@ -474,32 +466,6 @@ public class MesClient extends JFrame {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static void scanBarcodeLb() {
|
|
|
- product_sn_lb.setText("");
|
|
|
- String scanBarcodeTitle = "请扫底护板码";
|
|
|
- String scanBarcode = JOptionPane.showInputDialog(null, scanBarcodeTitle);
|
|
|
- if(scanBarcode!=null&&!scanBarcode.equalsIgnoreCase("")) {
|
|
|
- getUser();
|
|
|
- product_sn_lb.setText(scanBarcode);
|
|
|
- mesClientFrame.repaint();
|
|
|
-
|
|
|
- if(work_status == 1){
|
|
|
- String warehouseSn = getBarcode(product_sn_lb.getText());
|
|
|
- String sn = getBarcode(product_sn.getText());
|
|
|
- Boolean ret = DataUtil.bindWarehouse(nettyClient, sn, warehouseSn, user20, "400007");
|
|
|
- if(ret != null && ret) {
|
|
|
- MesClient.setMenuStatus("绑定成功",0);
|
|
|
- } else {
|
|
|
- MesClient.setMenuStatus("请求失败,请重试",-1);
|
|
|
- }
|
|
|
- }else{
|
|
|
- setMenuStatus("请先扫工件码",1);
|
|
|
- }
|
|
|
- }else {
|
|
|
- setMenuStatus("底护板码为空,请重新扫码",1);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
public static void logoff() {
|
|
|
// welcomeWin.setVisible(true);
|
|
|
mesClientFrame.setVisible(false);
|
|
|
@@ -575,64 +541,6 @@ public class MesClient extends JFrame {
|
|
|
// settingMenu.add(resetTcpMenu_1);
|
|
|
|
|
|
|
|
|
- //允许上料
|
|
|
- JMenuItem allow_up_material = new JMenuItem("允许上料");
|
|
|
- allow_up_material.setIcon(new ImageIcon(MesClient.class.getResource("/bg/reset_logo.png")));
|
|
|
- allow_up_material.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|
|
|
- allow_up_material.addMouseListener(new MouseAdapter() {
|
|
|
- @Override
|
|
|
- public void mousePressed(MouseEvent e) {
|
|
|
- super.mouseClicked(e);
|
|
|
- // 弹框输入密码,如果输入的为”503833“即可允许上料
|
|
|
- String input = JOptionPane.showInputDialog(null, "请输入密码");
|
|
|
- if (!input.equalsIgnoreCase("503833")) {
|
|
|
- JOptionPane.showMessageDialog(mesClientFrame, "密码错误", "提示窗口", JOptionPane.INFORMATION_MESSAGE);
|
|
|
- return;
|
|
|
- }
|
|
|
- // 允许上料
|
|
|
- MesClient.s7PLC.writeBoolean("DB503.216.2", true);
|
|
|
- }
|
|
|
- });
|
|
|
- settingMenu.add(allow_up_material);
|
|
|
- // 允许下料
|
|
|
- JMenuItem allow_down_material = new JMenuItem("允许下料");
|
|
|
- allow_down_material.setIcon(new ImageIcon(MesClient.class.getResource("/bg/reset_logo.png")));
|
|
|
- allow_down_material.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|
|
|
- allow_down_material.addMouseListener(new MouseAdapter() {
|
|
|
- @Override
|
|
|
- public void mousePressed(MouseEvent e) {
|
|
|
- super.mouseClicked(e);
|
|
|
- // 弹框输入密码,如果输入的为”503833“即可允许下料
|
|
|
- String input = JOptionPane.showInputDialog(null, "请输入密码");
|
|
|
- if (!input.equalsIgnoreCase("503833")) {
|
|
|
- JOptionPane.showMessageDialog(mesClientFrame, "密码错误", "提示窗口", JOptionPane.INFORMATION_MESSAGE);
|
|
|
- return;
|
|
|
- }
|
|
|
- MesClient.s7PLC.writeBoolean("DB503.216.5", true);
|
|
|
- }
|
|
|
- });
|
|
|
- settingMenu.add(allow_down_material);
|
|
|
- // 重置信号
|
|
|
- JMenuItem reset_signal = new JMenuItem("重置信号");
|
|
|
- reset_signal.setIcon(new ImageIcon(MesClient.class.getResource("/bg/reset_logo.png")));
|
|
|
- reset_signal.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|
|
|
- reset_signal.addMouseListener(new MouseAdapter() {
|
|
|
- @Override
|
|
|
- public void mousePressed(MouseEvent e) {
|
|
|
- super.mouseClicked(e);
|
|
|
- // 弹框输入密码,如果输入的为”503833“即可允许下料
|
|
|
- String input = JOptionPane.showInputDialog(null, "请输入密码");
|
|
|
- if (!input.equalsIgnoreCase("503833")) {
|
|
|
- JOptionPane.showMessageDialog(mesClientFrame, "密码错误", "提示窗口", JOptionPane.INFORMATION_MESSAGE);
|
|
|
- return;
|
|
|
- }
|
|
|
- MesClient.s7PLC.writeBoolean("DB503.216.2", false);
|
|
|
- MesClient.s7PLC.writeBoolean("DB503.216.5", false);
|
|
|
- }
|
|
|
- });
|
|
|
- settingMenu.add(reset_signal);
|
|
|
-
|
|
|
-
|
|
|
|
|
|
contentPane = new JPanel();
|
|
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
|
|
@@ -746,42 +654,9 @@ public class MesClient extends JFrame {
|
|
|
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);
|
|
|
-
|
|
|
- JLabel lbLabel = new JLabel("底护板");
|
|
|
- lbLabel.setFont(new Font("微软雅黑", Font.PLAIN, 24));
|
|
|
- lbLabel.setBounds(20, 165, 100, 50);
|
|
|
-// indexPanelA.add(lbLabel);
|
|
|
-
|
|
|
- product_sn_lb = new JTextField();
|
|
|
- product_sn_lb.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
- product_sn_lb.setEditable(false);
|
|
|
- product_sn_lb.setFont(new Font("微软雅黑", Font.PLAIN, 28));
|
|
|
- product_sn_lb.setBounds(100, 160, 580, 70);
|
|
|
-// indexPanelA.add(product_sn_lb);
|
|
|
- product_sn_lb.setColumns(10);
|
|
|
-
|
|
|
- f_scan_data_bt_2 = new JButton("绑定");
|
|
|
- f_scan_data_bt_2.addActionListener(new ActionListener() {
|
|
|
- public void actionPerformed(ActionEvent e) {
|
|
|
- if (product_sn.getText().isEmpty()){
|
|
|
- setMenuStatus("请在工件上料完成后扫码!",1);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (work_status == 1 && check_quality_result){
|
|
|
- scanBarcodeLb();
|
|
|
- }else{
|
|
|
- setMenuStatus("请在工件质量检测合格后扫码!",1);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- f_scan_data_bt_2.setIcon(new ImageIcon(MesClient.class.getResource("/bg/scan_barcode.png")));
|
|
|
- f_scan_data_bt_2.setFont(new Font("微软雅黑", Font.PLAIN, 30));
|
|
|
- f_scan_data_bt_2.setBounds(693, 160, 140, 70);
|
|
|
- f_scan_data_bt_2.setEnabled(false);
|
|
|
-// indexPanelA.add(f_scan_data_bt_2);
|
|
|
+ indexPanelA.add(f_scan_data_bt_1);
|
|
|
|
|
|
- finish_ok_bt = new JButton("下一件");
|
|
|
+ finish_ok_bt = new JButton("提交");
|
|
|
finish_ok_bt.setEnabled(false);
|
|
|
finish_ok_bt.addActionListener(new ActionListener() {
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
@@ -799,6 +674,11 @@ public class MesClient extends JFrame {
|
|
|
setMenuStatus("未扫工件码!",-1);
|
|
|
return;
|
|
|
}
|
|
|
+ // 校验扭力监控:已完成数必须等于任务数才允许提交
|
|
|
+ if(cur == null || max == null || !cur.equals(max)){
|
|
|
+ setMenuStatus("扭力监控未完成("+cur+"/"+max+")!",-1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
if(work_status == 1 && check_quality_result){
|
|
|
|
|
|
@@ -825,7 +705,7 @@ public class MesClient extends JFrame {
|
|
|
finish_ok_bt.setFont(new Font("微软雅黑", Font.PLAIN, 32));
|
|
|
finish_ok_bt.setBounds(357, 457, 240, 80);
|
|
|
finish_ok_bt.setEnabled(false);
|
|
|
-// indexPanelA.add(finish_ok_bt);
|
|
|
+ indexPanelA.add(finish_ok_bt);
|
|
|
|
|
|
finish_ng_bt = new JButton("NG");
|
|
|
finish_ng_bt.setEnabled(false);
|
|
|
@@ -1097,91 +977,4 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
|
|
|
|
|
|
- // plc交互定时任务
|
|
|
- public static java.util.Timer plcTimer;
|
|
|
-
|
|
|
- // 程序逻辑流程:0:等待扫码信号
|
|
|
- public static Integer index = 0;
|
|
|
-
|
|
|
-
|
|
|
- public static void startPlcTimer(){
|
|
|
- if (plcTimer != null){
|
|
|
- plcTimer.cancel();
|
|
|
- plcTimer = null;
|
|
|
- }
|
|
|
- plcTimer = new java.util.Timer();
|
|
|
- plcTimer.schedule(new TimerTask() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- if (index == 0){
|
|
|
- String sn ="";
|
|
|
- if (MesClient.s7PLC.readBoolean("DB503.216.0") || MesClient.s7PLC.readBoolean("DB503.216.1")){
|
|
|
- if (MesClient.s7PLC.readBoolean("DB503.216.0")){
|
|
|
- sn = MesClient.s7PLC.readString("DB503.270.0");
|
|
|
- // 赋值给输入框
|
|
|
- product_sn.setText(sn);
|
|
|
- }else if (MesClient.s7PLC.readBoolean("DB503.216.1")){
|
|
|
- sn = MesClient.s7PLC.readString("DB503.336.0");
|
|
|
- // 赋值给输入框
|
|
|
- product_sn.setText(sn);
|
|
|
- }
|
|
|
- if (sn == null || sn.trim().isEmpty() || "".equals(sn)){
|
|
|
- setMenuStatus("机器臂抓手读码为空", -1);
|
|
|
- return;
|
|
|
- }
|
|
|
- MesClient.product_sn.setText( sn);
|
|
|
- index = 1;
|
|
|
- }
|
|
|
- }else if (index == 1){
|
|
|
- // 取到二维码后发送质量检查
|
|
|
- String sn = MesClient.product_sn.getText();
|
|
|
- Boolean reg = DataUtil.checkQuality(MesClient.nettyClient, sn, MesClient.user20);
|
|
|
- if (!reg){
|
|
|
- setMenuStatus("报文发送异常", -1);
|
|
|
- }
|
|
|
- }else if (index == 2){
|
|
|
- // 等待上料完成
|
|
|
- if(MesClient.s7PLC.readBoolean("DB503.216.3")){
|
|
|
- // 将允许上料清空
|
|
|
- MesClient.s7PLC.writeBoolean("DB503.216.2",false);
|
|
|
- // 发送开始做件
|
|
|
- Boolean reg = DataUtil.startWork(MesClient.nettyClient, MesClient.product_sn.getText(), MesClient.user20);
|
|
|
- if (!reg){
|
|
|
- setMenuStatus("报文发送异常", -1);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (index == 3) {
|
|
|
- // 等待完成信号
|
|
|
- if (MesClient.s7PLC.readBoolean("DB503.216.4")){
|
|
|
- // 未到数量
|
|
|
- if (MesClient.cur < MesClient.max){
|
|
|
- // 菜单显示未拧紧完成
|
|
|
- setMenuStatus("未拧紧完成", -1);
|
|
|
- return;
|
|
|
- }
|
|
|
- Boolean reg = DataUtil.sendQuality( MesClient.product_sn.getText(), "OK",MesClient.user20);
|
|
|
- if (!reg){
|
|
|
- setMenuStatus("报文发送异常", -1);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (index == 4) {
|
|
|
- //将允许上料信号及允许下料信号制空
|
|
|
- MesClient.s7PLC.writeBoolean("DB503.216.2", false);
|
|
|
- MesClient.s7PLC.writeBoolean("DB503.216.5", false);
|
|
|
- // 两个输入框制空
|
|
|
- product_sn.setText("");
|
|
|
- work_status = 0;
|
|
|
- check_quality_result = false;
|
|
|
- updateMaterailData();
|
|
|
- shiftUserCheck();
|
|
|
- index = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- }, 1000, 1000);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|