hzd 1 Minggu lalu
induk
melakukan
60099c707c

+ 165 - 65
src/com/mes/ui/MesClient.java

@@ -54,6 +54,7 @@ public class MesClient extends JFrame {
     public static int mes_heart_beat_cycle = 10; // 心跳周期
     public static int mes_heart_icon_cycle = 1;
     public static String mes_line_sn = ""; // 产线编号
+    public static String lastSn = "";
 
     //TCP连接
     public static NettyClient nettyClient;
@@ -103,11 +104,24 @@ public class MesClient extends JFrame {
     public static int index = 0;
 
     public static ModbusTcp modbusTcp = new ModbusTcp("192.168.1.20");
-
     public static JTable table;
     public static Object[] columnNames = { "物料名称", "绑定批次", "剩余次数", "操作" };
     public static Object[][] rowData = null;
 
+    public static JLabel feedinglabel;
+
+    public static JLabel feedingmeslabel;
+
+    public static JLabel runlabel; //运行反馈,
+
+    public static JLabel blankinglabel; // 下料反馈
+
+    public static JLabel blankingmeslabel; // 下料MES反馈
+
+    public static ImageIcon imageGreen;
+
+    public static ImageIcon imageGray;
+
     public static void main(String[] args) {
 
         EventQueue.invokeLater(new Runnable() {
@@ -123,10 +137,11 @@ public class MesClient extends JFrame {
 
                     JdbcUtils.getConn();
 
+//                    System.out.println("sn:"+change(modbusTcp.readString(100,120).toString()));
                     welcomeWin = new LoginFarme();
                     welcomeWin.setVisible(true);
 
-                    getMaterailData();
+//                    getMaterailData();
 
                     process();
 
@@ -275,7 +290,10 @@ public class MesClient extends JFrame {
         MesClient.f_scan_data_bt_1.setEnabled(true);
         MesClient.setMenuStatus("请扫工件码",0);
         MesClient.index = 0;
-        updateMaterailData();
+        lastSn = "";
+//        updateMaterailData();
+        // 清楚是否可以做件信号
+        ModbusUtils.rechargeAllow(modbusTcp);
 //        shiftUserCheck();
     }
 
@@ -612,6 +630,66 @@ public class MesClient extends JFrame {
 //        indexPanelA.add(finish_ng_bt);
 
 
+        imageGreen = new ImageIcon(MesClient.class.getResource("/bg/green_dot.png"));
+        imageGreen.setImage(imageGreen.getImage().getScaledInstance(40, 40, Image.SCALE_SMOOTH));
+
+        imageGray = new ImageIcon(MesClient.class.getResource("/bg/grey_dot.png"));
+        imageGray.setImage(imageGray.getImage().getScaledInstance(40, 40, Image.SCALE_SMOOTH));
+
+        feedinglabel = new JLabel("允许MES读码");
+        feedinglabel.setHorizontalAlignment(SwingConstants.LEFT);
+        feedinglabel.setIcon(imageGreen);
+        feedinglabel.setForeground(Color.BLACK);
+        feedinglabel.setBounds(50, 220, 150, 40);
+        indexPanelA.add(feedinglabel);
+
+        feedingmeslabel = new JLabel("MES允许上料");
+        feedingmeslabel.setHorizontalAlignment(SwingConstants.LEFT);
+        feedingmeslabel.setIcon(imageGreen);
+        feedingmeslabel.setForeground(Color.BLACK);
+        feedingmeslabel.setBounds(250, 220, 150, 40);
+        feedingmeslabel.addMouseListener(new MouseAdapter() {
+            public void mouseClicked(MouseEvent e) {
+                boolean ret = ModbusUtils.isAllown(modbusTcp);
+                int choice = JOptionPane.showConfirmDialog(null, "确定修改MES允许上料结果为"+(ret?"false":"true")+"吗?", "操作确认", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
+                if (choice == JOptionPane.YES_OPTION) {
+                    if(!ret){
+                        ModbusUtils.writeAllow(modbusTcp);
+                    }else{
+                        ModbusUtils.writeAllowDeny(modbusTcp);
+                    }
+
+                }
+            }
+        });
+        indexPanelA.add(feedingmeslabel);
+
+        runlabel = new JLabel("检测完成");
+        runlabel.setHorizontalAlignment(SwingConstants.LEFT);
+        runlabel.setIcon(imageGreen);
+        runlabel.setForeground(Color.BLACK);
+        runlabel.setBounds(450, 220, 150, 40);
+        indexPanelA.add(runlabel);
+
+        blankingmeslabel = new JLabel("MES读取结果反馈");
+        blankingmeslabel.setHorizontalAlignment(SwingConstants.LEFT);
+        blankingmeslabel.setIcon(imageGreen);
+        blankingmeslabel.setForeground(Color.BLACK);
+        blankingmeslabel.setBounds(650, 220, 150, 40);
+        indexPanelA.add(blankingmeslabel);
+        blankingmeslabel.addMouseListener(new MouseAdapter() {
+            public void mouseClicked(MouseEvent e) {
+                boolean ret = ModbusUtils.isGetDate(modbusTcp);
+                int choice = JOptionPane.showConfirmDialog(null, "确定修改MES读取结果反馈结果为"+(ret?"false":"true")+"吗?", "操作确认", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
+                if (choice == JOptionPane.YES_OPTION) {
+                    if(!ret){
+                        ModbusUtils.yjgetDate(modbusTcp);
+                    }else{
+                        ModbusUtils.rechargeYjgetDate(modbusTcp);
+                    }
+                }
+            }
+        });
 
 
 
@@ -799,68 +877,90 @@ public class MesClient extends JFrame {
        new Timer().schedule(new TimerTask() {
            @Override
            public void run() {
-                if (MesClient.index == 0){
-                    // 等待允许扫码信号
-                    // 提示栏显示等待扫码
-                    if (ModbusUtils.isGetDate(modbusTcp)){
-                        ModbusUtils.rechargeYjgetDate(modbusTcp);
-                    }
-                    MesClient.setMenuStatus("等待扫码",0);
-                    System.out.println("是否允许读码"+ModbusUtils.isReadable(modbusTcp));
-                    if (ModbusUtils.isReadable(modbusTcp)){
-                        // 允许扫码,进入下一阶段
-                        String sn = change(modbusTcp.readString(4100,120).toString());
-                        System.out.println("已读二维码:"+change(modbusTcp.readString(4100,120).toString()));
-                        MesClient.product_sn.setText(sn);
-                        MesClient.index = 1;
-                    }
-                }else if (MesClient.index == 1){
-                    // 查询工件质量
-                    Boolean sendret = DataUtil.checkQuality(nettyClient,MesClient.product_sn.getText(),user20);
-                    if(!sendret){
-                        JOptionPane.showMessageDialog(mesClientFrame,"消息发送失败,请重试","提示窗口", JOptionPane.INFORMATION_MESSAGE);
-                        return;
-                    }
-                } else if (MesClient.index == 2) {
-                    // 清楚是否可以做件信号
-                    ModbusUtils.rechargeAllow(modbusTcp);
-                    MesClient.index = 3;
-                }else if (MesClient.index == 3) {
-                    // 提示栏显示等待加工
-                    MesClient.setMenuStatus("加工中",0);
-                    //等待产品是否合格
-                    boolean ok = ModbusUtils.isQualityOk(modbusTcp);
-                    boolean ng = ModbusUtils.isQualityNG(modbusTcp);
-                    //当有一个为ture时
-                    if (ok || ng){
-                        if (ok){
-                            Boolean sendret = DataUtil.sendQuality(MesClient.product_sn.getText(),"OK",user20);
-                            if(!sendret){
-                                JOptionPane.showMessageDialog(mesClientFrame,"消息发送失败,请重试","提示窗口", JOptionPane.INFORMATION_MESSAGE);
-                                return;
-                            }
-                        }else {
-                            Boolean sendret = DataUtil.sendQuality(MesClient.product_sn.getText(),"NG",user20);
-                            if(!sendret){
-                                JOptionPane.showMessageDialog(mesClientFrame,"消息发送失败,请重试","提示窗口", JOptionPane.INFORMATION_MESSAGE);
-                                return;
-                            }
-                        }
-                    }
-                } else if (MesClient.index == 4) {
-                    boolean ok = ModbusUtils.isQualityOk(modbusTcp);
-                    boolean ng = ModbusUtils.isQualityNG(modbusTcp);
-                    work_status = 0;
-                    check_quality_result = false;
-                    MesClient.finish_ok_bt.setEnabled(false);
-                    MesClient.finish_ng_bt.setEnabled(false);
-                    product_sn.setText("");
-                    // 当两个都为false时
-                    if (!ok && !ng){
-                        ModbusUtils.rechargeYjgetDate(modbusTcp);
-                        MesClient.index = 0;
-                    }
-                }
+               if(!MesClient.sessionid.isEmpty()){
+
+                   //请求扫码
+                   Boolean retFeeding = ModbusUtils.isReadable(modbusTcp);
+                   feedinglabel.setIcon(retFeeding?imageGreen:imageGray);
+
+                   // 读取MES允许上料信号
+                   Boolean retFeedingAllow = ModbusUtils.isAllown(modbusTcp);
+                   feedingmeslabel.setIcon(retFeedingAllow?imageGreen:imageGray);
+
+                   boolean ok = ModbusUtils.isQualityOk(modbusTcp);
+                   boolean ng = ModbusUtils.isQualityNG(modbusTcp);
+                   // 读取下料信号
+                   Boolean retBlanking = ok || ng;
+                   runlabel.setIcon(retBlanking?imageGreen:imageGray);
+
+                   // 读取MES允许下料信号
+                   Boolean retAllowBlanking = ModbusUtils.isGetDate(modbusTcp);
+                   blankingmeslabel.setIcon(retAllowBlanking?imageGreen:imageGray);
+
+
+                   if (MesClient.index == 0){
+                       // 等待允许扫码信号
+                       // 提示栏显示等待扫码
+
+                       MesClient.setMenuStatus("等待扫码",0);
+                       String sn = change(modbusTcp.readString(100,120).toString());
+                       System.out.println("已读二维码1:"+sn);
+                       System.out.println("是否允许读码"+ModbusUtils.isReadable(modbusTcp));
+//                    String sn2 = product_sn.getText().trim();
+                       if(!lastSn.equals(sn) && !sn.isEmpty()){
+                           product_sn.setText(sn);
+                           lastSn = sn;
+                           MesClient.index = 1;
+                       }
+                   }else if (MesClient.index == 1){
+                       if (retAllowBlanking){
+                           ModbusUtils.rechargeYjgetDate(modbusTcp);
+                       }
+                       System.out.println("已读二维码2:"+product_sn.getText());
+                       // 查询工件质量
+                       Boolean sendret = DataUtil.checkQuality(nettyClient,MesClient.product_sn.getText(),user20);
+                       if(!sendret){
+                           JOptionPane.showMessageDialog(mesClientFrame,"消息发送失败,请重试","提示窗口", JOptionPane.INFORMATION_MESSAGE);
+                           return;
+                       }
+                   } else if (MesClient.index == 2) {
+                       if(ModbusUtils.isAllown(modbusTcp)){
+                           MesClient.index = 3;
+                       }
+                   }else if (MesClient.index == 3) {
+                       // 提示栏显示等待加工
+                       MesClient.setMenuStatus("加工中",0);
+                       //等待产品是否合格
+                       //当有一个为ture时
+                       if (ok || ng){
+                           if (ok){
+                               Boolean sendret = DataUtil.sendQuality(MesClient.product_sn.getText(),"OK",user20);
+                               if(!sendret){
+                                   JOptionPane.showMessageDialog(mesClientFrame,"消息发送失败,请重试","提示窗口", JOptionPane.INFORMATION_MESSAGE);
+                                   return;
+                               }
+                           }else {
+                               Boolean sendret = DataUtil.sendQuality(MesClient.product_sn.getText(),"NG",user20);
+                               if(!sendret){
+                                   JOptionPane.showMessageDialog(mesClientFrame,"消息发送失败,请重试","提示窗口", JOptionPane.INFORMATION_MESSAGE);
+                                   return;
+                               }
+                           }
+                       }
+                   } else if (MesClient.index == 4) {
+                       work_status = 0;
+                       check_quality_result = false;
+                       MesClient.finish_ok_bt.setEnabled(false);
+                       MesClient.finish_ng_bt.setEnabled(false);
+                       product_sn.setText("");
+                       // 当两个都为false时
+                       if (!ok && !ng){
+                           ModbusUtils.rechargeYjgetDate(modbusTcp);
+                           MesClient.index = 0;
+                       }
+                   }
+               }
+
            }
            // 1秒执行一次循环
        }, 1000, 1000);

+ 1 - 1
src/com/mes/ui/OprnoUtil.java

@@ -25,7 +25,7 @@ public class OprnoUtil {
             "TIG补焊尾孔+封堵片焊接", "总成清洁+涂封堵胶", "涂胶+压套筒", "胶水固化", "正面装配",
             "反面装配", "半成品气密", "箱体补强件位置涂胶", "安装补强件", "胶水固化",
             "FSW焊道位置涂胶", "胶水固化", "底护板装配", "复拧螺栓", "成品气密",
-            "液冷板气检", "总成检具", "CCD", "总成清洁", "终检",
+            "液冷板气检", "总成检具", "CCD", "总成检具", "终检",
             "GP12", "包装"
     };
     public static String[] lboprnos = new String[]{

+ 11 - 0
src/com/mes/util/ModbusUtils.java

@@ -13,12 +13,23 @@ public class ModbusUtils {
         return allow.get(0);
     }
 
+    public static boolean isAllown(ModbusTcp modbusTcp) {
+        List<Boolean> allow = modbusTcp.readCoil(293,1);
+        System.out.println("===========是否可以读码:"+allow.get(0)+"===========");
+        return allow.get(0);
+    }
+
     // 写入允许做件
     public static void writeAllow(ModbusTcp modbusTcp) {
         System.out.println("===========写入允许做件===========");
         modbusTcp.writeCoil(293,true);
     }
 
+    public static void writeAllowDeny(ModbusTcp modbusTcp) {
+        System.out.println("===========写入允许做件===========");
+        modbusTcp.writeCoil(293,false);
+    }
+
     // 写入不允许做件
     public static void writeNotAllow(ModbusTcp modbusTcp) {
         System.out.println("===========写入不允许做件===========");

+ 1 - 1
src/resources/config/config.properties

@@ -1,4 +1,4 @@
-mes.gw=OP400A
+mes.gw=OP420A
 #mes.server_ip=127.0.0.1
 mes.server_ip=192.168.22.99
 mes.tcp_port=3000