|
|
@@ -104,9 +104,9 @@ public class MesClient extends JFrame {
|
|
|
public static boolean timer_flag = false; // 开始计时标志 false=非工作开始计时 true=工件开始计时
|
|
|
public static long timer_nums = 0; // 秒数
|
|
|
|
|
|
- public static S7PLC s7PLC = new S7PLC(EPlcType.S1200,"10.88.10.180");
|
|
|
+ public static S7PLC s7PLC = new S7PLC(EPlcType.S1200,"10.88.10.80");
|
|
|
+
|
|
|
|
|
|
- public static Integer index = 0;
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
@@ -133,6 +133,8 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
getMaterailData();
|
|
|
|
|
|
+ startPlcTimer();
|
|
|
+
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -260,12 +262,16 @@ public class MesClient extends JFrame {
|
|
|
public static void resetScanA() {
|
|
|
work_status = 0;
|
|
|
check_quality_result = false;
|
|
|
- MesClient.finish_ok_bt.setEnabled(false);
|
|
|
- MesClient.finish_ng_bt.setEnabled(false);
|
|
|
+// MesClient.finish_ok_bt.setEnabled(false);
|
|
|
+// MesClient.finish_ng_bt.setEnabled(false);
|
|
|
product_sn.setText("");
|
|
|
+ product_sn_LB.setText("");
|
|
|
MesClient.fxlabel.setVisible(false);
|
|
|
-
|
|
|
- MesClient.f_scan_data_bt_1.setEnabled(true);
|
|
|
+ MesClient.index = 0;
|
|
|
+ // 信号重置
|
|
|
+ MesClient.s7PLC.writeBoolean("DB503.0.2", false);
|
|
|
+ MesClient.s7PLC.writeBoolean("DB503.0.5", false);
|
|
|
+// MesClient.f_scan_data_bt_1.setEnabled(true);
|
|
|
MesClient.status_menu.setText("请扫工件码");
|
|
|
|
|
|
updateMaterailData();
|
|
|
@@ -378,7 +384,7 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
// 判断工件码是不是空的
|
|
|
if(product_sn.getText().equalsIgnoreCase("")) {
|
|
|
- MesClient.setMenuStatus("请扫工件码",-1);
|
|
|
+ MesClient.setMenuStatus("等待机器人上料",-1);
|
|
|
return;
|
|
|
}
|
|
|
// 绑定冷板
|
|
|
@@ -391,6 +397,7 @@ public class MesClient extends JFrame {
|
|
|
setMenuStatus("绑定失败!", 1);
|
|
|
return;
|
|
|
}
|
|
|
+ product_sn_LB.setText(product_sn.getText());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -436,7 +443,7 @@ public class MesClient extends JFrame {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- JMenu settingMenu = new JMenu("设置");
|
|
|
+ JMenu settingMenu = new JMenu("交互设置");
|
|
|
//settingMenu.setVisible(false);
|
|
|
settingMenu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/menu_setting.png")));
|
|
|
settingMenu.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|
|
|
@@ -465,7 +472,65 @@ public class MesClient extends JFrame {
|
|
|
resetScanA();
|
|
|
}
|
|
|
});
|
|
|
- settingMenu.add(resetTcpMenu_1);
|
|
|
+// 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.0.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.0.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.0.2", false);
|
|
|
+ MesClient.s7PLC.writeBoolean("DB503.0.5", false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ settingMenu.add(reset_signal);
|
|
|
+
|
|
|
|
|
|
contentPane = new JPanel();
|
|
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
|
|
@@ -597,7 +662,7 @@ public class MesClient extends JFrame {
|
|
|
f_scan_data_bt_2.addActionListener(new ActionListener() {
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
scan_type = 2;
|
|
|
- scanBarcode();
|
|
|
+ scanBarcode2();
|
|
|
}
|
|
|
});
|
|
|
f_scan_data_bt_2.setIcon(new ImageIcon(MesClient.class.getResource("/bg/scan_barcode.png")));
|
|
|
@@ -891,4 +956,91 @@ 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.0.0") || MesClient.s7PLC.readBoolean("DB503.0.1")){
|
|
|
+ if (MesClient.s7PLC.readBoolean("DB503.0.0")){
|
|
|
+ sn = MesClient.s7PLC.readString("DB503.270.0");
|
|
|
+ // 赋值给输入框
|
|
|
+ product_sn.setText(sn);
|
|
|
+ }else if (MesClient.s7PLC.readBoolean("DB503.0.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.0.3")){
|
|
|
+ // 将允许上料清空·
|
|
|
+ MesClient.s7PLC.writeBoolean("DB503.0.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.0.4")){
|
|
|
+ // 冷板为空不允许提交
|
|
|
+ if (product_sn_LB.getText() == null || product_sn_LB.getText().trim().isEmpty()){
|
|
|
+ setMenuStatus("请先绑定底板", -1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Boolean reg = DataUtil.sendQuality(MesClient.nettyClient, MesClient.product_sn.getText(), "OK",MesClient.user20);
|
|
|
+ if (!reg){
|
|
|
+ setMenuStatus("报文发送异常", -1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (index == 4) {
|
|
|
+// 将允许上料信号及允许下料信号制空
|
|
|
+ MesClient.s7PLC.writeBoolean("DB503.0.2", false);
|
|
|
+ MesClient.s7PLC.writeBoolean("DB503.0.5", false);
|
|
|
+ // 两个输入框制空
|
|
|
+ product_sn.setText("");
|
|
|
+ product_sn_LB.setText("");
|
|
|
+ work_status = 0;
|
|
|
+ check_quality_result = false;
|
|
|
+ updateMaterailData();
|
|
|
+ shiftUserCheck();
|
|
|
+ index = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }, 0, 1000);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|