张田野 hai 2 semanas
pai
achega
1beb2ae6fe

+ 248 - 25
src/com/mes/ui/MesClient.java

@@ -85,6 +85,8 @@ public class MesClient extends JFrame {
     public static JTextField param2;
     public static JTextField param3;
     public static JTextField param4;
+    public static JTextField param5;
+    public static JTextField param6;
 
 
 
@@ -92,9 +94,10 @@ public class MesClient extends JFrame {
 //    public static ModbusTcp plcA = new ModbusTcp(1, "192.168.1.7");//81
 //    public static ModbusTcp plcB = new ModbusTcp(1, "192.168.1.8");//1
 
-//    tw-op130b
-    public static ModbusTcp plcA = new ModbusTcp(1, "192.168.1.7");//29
-    public static ModbusTcp plcB = new ModbusTcp(1, "192.168.1.8");//26
+//    tw-op210a
+    public static ModbusTcp plcA = new ModbusTcp(1, "192.168.1.9");//29 气枪
+    public static ModbusTcp plcB = new ModbusTcp(1, "192.168.1.8");//26 气枪
+    public static ModbusTcp plcC = new ModbusTcp(1, "192.168.1.7");//电枪
 
     public static Timer cjTimer;
 
@@ -102,19 +105,24 @@ public class MesClient extends JFrame {
 
     public static Timer cjTimer3;
 
-    public static Short aSetNum = 29;
+    public static Short aSetNum = 26;
 //public static Short aSetNum = 81;
 
     public static Short sortA = 0;
     public static Short aMax = 0;
     public static Short aFinish = 0;
     public static List<Map> alist = new ArrayList<>();
-    public static Short bSetNum = 26;
+    public static Short bSetNum = 28;
 //public static Short bSetNum = 1;
     public static Short sortB = 0;
     public static Short bMax = 0;
     public static Short bFinish = 0;
     public static List<Map> blist = new ArrayList<>();
+    public static Short cSetNum = 1;
+    public static Short sortC = 0;
+    public static int cMax = 0;
+    public static Short cFinish = 0;
+    public static List<Map> clist = new ArrayList<>();
     public static Short deviceControl = 0; // 0=本地 1=远程
     public static Integer tjStatus = 0; // 1=提交失败
 
@@ -124,6 +132,7 @@ public class MesClient extends JFrame {
 
     public static Integer zdStatusA = 0;
     public static Integer zdStatusB = 0;
+    public static Integer zdStatusC = 0;
     public static String foutA = "";
     public static String fmaxA = "";
     public static String fminA = "";
@@ -138,12 +147,22 @@ public class MesClient extends JFrame {
     public static String smaxB = "";
     public static String sminB = "";
     public static String curB = "";
+    public static String foutC = "";
+    public static String fmaxC = "";
+    public static String fminC = "";
+    public static String soutC = "";
+    public static String smaxC = "";
+    public static String sminC = "";
+    public static String curC = "";
     public static JButton resetResultA;
     public static JButton okResultA;
     public static JButton ngResultA;
     public static JButton resetResultB;
     public static JButton okResultB;
     public static JButton ngResultB;
+    public static JButton resetResultC;
+    public static JButton okResultC;
+    public static JButton ngResultC;
 
     public static JTable table;
     public static Object[] columnNames = { "物料名称", "绑定批次", "剩余次数", "操作" };
@@ -172,6 +191,8 @@ public class MesClient extends JFrame {
 
                     setDeviceStart();
 
+                    startHeartTimerC();
+
                     getMaterailData();
 
                 }catch (Exception e){
@@ -193,7 +214,9 @@ public class MesClient extends JFrame {
                     if(work_status == 1){
                         List<Boolean> yxstatus = plcA.readCoil(3128,1);
                         if(yxstatus.size() >= 1 && !yxstatus.get(0)){
-                            if(!MesClient.curSn.isEmpty() && MesClient.aMax > 0 && MesClient.aMax == MesClient.sortA){
+                            if(MesClient.zdStatusA == 1){
+                                // NG复判中断中,保持锁枪
+                            }else if(!MesClient.curSn.isEmpty() && MesClient.aMax > 0 && MesClient.aMax == MesClient.sortA){
                                 ModbusUtil.setPowerOff(plcA);
                             }else{
                                 ModbusUtil.setPowerOn(plcA);
@@ -202,12 +225,21 @@ public class MesClient extends JFrame {
 
                         List<Boolean> yxstatusb = plcB.readCoil(3128,1);
                         if(yxstatusb.size() >= 1 && !yxstatusb.get(0)){
-                            if(!MesClient.curSn.isEmpty() && MesClient.bMax > 0 && MesClient.bMax == MesClient.sortB){
+                            if(MesClient.zdStatusB == 1){
+                                // NG复判中断中,保持锁枪
+                            }else if(!MesClient.curSn.isEmpty() && MesClient.bMax > 0 && MesClient.bMax == MesClient.sortB){
                                 ModbusUtil.setPowerOff(plcB);
                             }else{
                                 ModbusUtil.setPowerOn(plcB);
                             }
                         }
+
+                        // C电枪:写心跳放枪,停心跳锁枪
+                        if(zdStatusC != 0 || (!MesClient.curSn.isEmpty() && MesClient.cMax > 0 && MesClient.sortC >= MesClient.cMax)){
+                            heartBeatFlagC = false;
+                        }else{
+                            heartBeatFlagC = true;
+                        }
                     }else{
                         List<Boolean> yxstatus = plcA.readCoil(3128,1);
                         if(yxstatus.size() >= 1 && yxstatus.get(0)){
@@ -218,6 +250,8 @@ public class MesClient extends JFrame {
                         if(yxstatusb.size() >= 1 && yxstatusb.get(0)){
                             ModbusUtil.setPowerOff(plcB);
                         }
+
+                        heartBeatFlagC = false;
                     }
                 }catch (Exception e){
                     e.printStackTrace();
@@ -226,6 +260,29 @@ public class MesClient extends JFrame {
         }, 1000,1000);
     }
 
+    public static java.util.Timer plcHeartBeatTimerC;
+    public static boolean heartBeatFlagC = false;
+    public static short heartBeatValueC = 1; // 心跳值,1→2→3→1循环
+
+    public static void startHeartTimerC() {
+        if (plcHeartBeatTimerC != null) {
+            plcHeartBeatTimerC.cancel();
+        }
+        plcHeartBeatTimerC = new java.util.Timer();
+        plcHeartBeatTimerC.schedule(new TimerTask() {
+            public void run() {
+                try{
+                    if(heartBeatFlagC){
+                        plcC.writeInt16(4160, heartBeatValueC);
+                        heartBeatValueC = (short) (heartBeatValueC % 3 + 1);
+                    }
+                } catch (Exception e){
+                    System.out.println("心跳C执行失败: " + e.getMessage());
+                }
+            }
+        }, 100,  500);
+    }
+
     //读配置文件
     private static void readProperty() throws IOException{
         String enconding = "UTF-8";
@@ -270,6 +327,15 @@ public class MesClient extends JFrame {
                 }catch (Exception e){
                     e.printStackTrace();
                 }
+
+                try{
+                    if(work_status == 1){
+                        ModbusUtil.getDataC(plcC);
+                    }
+
+                }catch (Exception e){
+                    e.printStackTrace();
+                }
             }
         }, 1000,500);
     }
@@ -441,25 +507,37 @@ public class MesClient extends JFrame {
 
         MesClient.aMax = 0;
         MesClient.bMax = 0;
+        MesClient.cMax = 0;
         MesClient.aFinish = 0;
         MesClient.bFinish = 0;
+        MesClient.cFinish = 0;
         MesClient.alist = new ArrayList<>();
         MesClient.blist = new ArrayList<>();
+        MesClient.clist = new ArrayList<>();
         MesClient.sortB = 0;
         MesClient.sortA = 0;
+        MesClient.sortC = 0;
         MesClient.param1.setText("");
         MesClient.param2.setText("");
         MesClient.param3.setText("");
         MesClient.param4.setText("");
+        MesClient.param5.setText("");
+        MesClient.param6.setText("");
+
+        heartBeatFlagC = false;
 
         zdStatusA = 0;
         zdStatusB = 0;
+        zdStatusC = 0;
         resetResultA.setEnabled(false);
         okResultA.setEnabled(false);
         ngResultA.setEnabled(false);
         resetResultB.setEnabled(false);
         okResultB.setEnabled(false);
         ngResultB.setEnabled(false);
+        resetResultC.setEnabled(false);
+        okResultC.setEnabled(false);
+        ngResultC.setEnabled(false);
 
         deviceControl = ModbusUtil.getControlModel(plcA);
         if(deviceControl == 1){
@@ -473,6 +551,7 @@ public class MesClient extends JFrame {
 
         ModbusUtil.setTask(MesClient.plcA,MesClient.aSetNum);
         ModbusUtil.setTask(MesClient.plcB,MesClient.bSetNum);
+        ModbusUtil.setTaskEle(MesClient.plcC,MesClient.cSetNum);
 
         updateMaterailData();
     }
@@ -790,12 +869,12 @@ public class MesClient extends JFrame {
         JLabel lblNewLabel = new JLabel("A\u67AA");
         lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
         lblNewLabel.setFont(new Font("微软雅黑", Font.PLAIN, 20));
-        lblNewLabel.setBounds(204, 186, 166, 28);
+        lblNewLabel.setBounds(100, 186, 166, 28);
         indexPanelA.add(lblNewLabel);
 
         JLabel lblNewLabel_1 = new JLabel("\u9884\u8BBE\u6570\u91CF");
         lblNewLabel_1.setFont(new Font("微软雅黑", Font.PLAIN, 18));
-        lblNewLabel_1.setBounds(204, 241, 83, 34);
+        lblNewLabel_1.setBounds(100, 241, 83, 34);
         indexPanelA.add(lblNewLabel_1);
 
         param1 = new JTextField();
@@ -803,13 +882,13 @@ public class MesClient extends JFrame {
         param1.setFont(new Font("微软雅黑", Font.PLAIN, 18));
         param1.setText("0");
         param1.setEditable(false);
-        param1.setBounds(288, 241, 83, 34);
+        param1.setBounds(184, 241, 83, 34);
         indexPanelA.add(param1);
         param1.setColumns(10);
 
         JLabel lblNewLabel_1_1 = new JLabel("\u5B8C\u6210\u6570\u91CF");
         lblNewLabel_1_1.setFont(new Font("微软雅黑", Font.PLAIN, 18));
-        lblNewLabel_1_1.setBounds(204, 285, 83, 34);
+        lblNewLabel_1_1.setBounds(100, 285, 83, 34);
         indexPanelA.add(lblNewLabel_1_1);
 
         param2 = new JTextField();
@@ -818,18 +897,18 @@ public class MesClient extends JFrame {
         param2.setText("0");
         param2.setEditable(false);
         param2.setColumns(10);
-        param2.setBounds(288, 285, 83, 34);
+        param2.setBounds(184, 285, 83, 34);
         indexPanelA.add(param2);
 
         JLabel lblB = new JLabel("B\u67AA");
         lblB.setHorizontalAlignment(SwingConstants.CENTER);
         lblB.setFont(new Font("微软雅黑", Font.PLAIN, 20));
-        lblB.setBounds(525, 186, 166, 28);
+        lblB.setBounds(380, 186, 166, 28);
         indexPanelA.add(lblB);
 
         JLabel lblNewLabel_1_2 = new JLabel("\u9884\u8BBE\u6570\u91CF");
         lblNewLabel_1_2.setFont(new Font("微软雅黑", Font.PLAIN, 18));
-        lblNewLabel_1_2.setBounds(525, 241, 83, 34);
+        lblNewLabel_1_2.setBounds(380, 241, 83, 34);
         indexPanelA.add(lblNewLabel_1_2);
 
         param3 = new JTextField();
@@ -838,12 +917,12 @@ public class MesClient extends JFrame {
         param3.setFont(new Font("微软雅黑", Font.PLAIN, 18));
         param3.setEditable(false);
         param3.setColumns(10);
-        param3.setBounds(608, 241, 83, 34);
+        param3.setBounds(463, 241, 83, 34);
         indexPanelA.add(param3);
 
         JLabel lblNewLabel_1_1_1 = new JLabel("\u5B8C\u6210\u6570\u91CF");
         lblNewLabel_1_1_1.setFont(new Font("微软雅黑", Font.PLAIN, 18));
-        lblNewLabel_1_1_1.setBounds(525, 285, 83, 34);
+        lblNewLabel_1_1_1.setBounds(380, 285, 83, 34);
         indexPanelA.add(lblNewLabel_1_1_1);
 
         param4 = new JTextField();
@@ -852,19 +931,58 @@ public class MesClient extends JFrame {
         param4.setFont(new Font("微软雅黑", Font.PLAIN, 18));
         param4.setEditable(false);
         param4.setColumns(10);
-        param4.setBounds(608, 285, 83, 34);
+        param4.setBounds(463, 285, 83, 34);
         indexPanelA.add(param4);
 
+        JLabel lblC = new JLabel("C\u67AA");
+        lblC.setHorizontalAlignment(SwingConstants.CENTER);
+        lblC.setFont(new Font("微软雅黑", Font.PLAIN, 20));
+        lblC.setBounds(660, 186, 166, 28);
+        indexPanelA.add(lblC);
+
+        JLabel lblNewLabel_1_3 = new JLabel("\u9884\u8BBE\u6570\u91CF");
+        lblNewLabel_1_3.setFont(new Font("微软雅黑", Font.PLAIN, 18));
+        lblNewLabel_1_3.setBounds(660, 241, 83, 34);
+        indexPanelA.add(lblNewLabel_1_3);
+
+        param5 = new JTextField();
+        param5.setText("0");
+        param5.setHorizontalAlignment(SwingConstants.CENTER);
+        param5.setFont(new Font("微软雅黑", Font.PLAIN, 18));
+        param5.setEditable(false);
+        param5.setColumns(10);
+        param5.setBounds(743, 241, 83, 34);
+        indexPanelA.add(param5);
+
+        JLabel lblNewLabel_1_1_2 = new JLabel("\u5B8C\u6210\u6570\u91CF");
+        lblNewLabel_1_1_2.setFont(new Font("微软雅黑", Font.PLAIN, 18));
+        lblNewLabel_1_1_2.setBounds(660, 285, 83, 34);
+        indexPanelA.add(lblNewLabel_1_1_2);
+
+        param6 = new JTextField();
+        param6.setText("0");
+        param6.setHorizontalAlignment(SwingConstants.CENTER);
+        param6.setFont(new Font("微软雅黑", Font.PLAIN, 18));
+        param6.setEditable(false);
+        param6.setColumns(10);
+        param6.setBounds(743, 285, 83, 34);
+        indexPanelA.add(param6);
+
         JLabel lblNgJudgeA = new JLabel("NG\u590d\u5224");
         lblNgJudgeA.setFont(new Font("微软雅黑", Font.PLAIN, 14));
-        lblNgJudgeA.setBounds(204, 322, 167, 22);
+        lblNgJudgeA.setBounds(100, 322, 167, 22);
         indexPanelA.add(lblNgJudgeA);
 
         JLabel lblNgJudgeB = new JLabel("NG\u590d\u5224");
         lblNgJudgeB.setFont(new Font("微软雅黑", Font.PLAIN, 14));
-        lblNgJudgeB.setBounds(525, 322, 167, 22);
+        lblNgJudgeB.setBounds(380, 322, 167, 22);
         indexPanelA.add(lblNgJudgeB);
 
+        JLabel lblNgJudgeC = new JLabel("NG\u590d\u5224");
+        lblNgJudgeC.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        lblNgJudgeC.setBounds(660, 322, 167, 22);
+        indexPanelA.add(lblNgJudgeC);
+
         resetResultA = new JButton("重拉");
         resetResultA.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
@@ -894,7 +1012,7 @@ public class MesClient extends JFrame {
         });
         resetResultA.setEnabled(false);
         resetResultA.setFont(new Font("微软雅黑", Font.PLAIN, 14));
-        resetResultA.setBounds(204, 348, 70, 36);
+        resetResultA.setBounds(100, 348, 70, 36);
         indexPanelA.add(resetResultA);
 
         okResultA = new JButton("OK");
@@ -929,7 +1047,7 @@ public class MesClient extends JFrame {
         okResultA.setEnabled(false);
         okResultA.setForeground(new Color(0, 128, 0));
         okResultA.setFont(new Font("微软雅黑", Font.PLAIN, 14));
-        okResultA.setBounds(281, 348, 70, 36);
+        okResultA.setBounds(177, 348, 70, 36);
         indexPanelA.add(okResultA);
 
         ngResultA = new JButton("NG");
@@ -963,7 +1081,7 @@ public class MesClient extends JFrame {
         ngResultA.setEnabled(false);
         ngResultA.setForeground(new Color(255, 0, 0));
         ngResultA.setFont(new Font("微软雅黑", Font.PLAIN, 14));
-        ngResultA.setBounds(358, 348, 70, 36);
+        ngResultA.setBounds(254, 348, 70, 36);
         indexPanelA.add(ngResultA);
 
         resetResultB = new JButton("重拉");
@@ -995,7 +1113,7 @@ public class MesClient extends JFrame {
         });
         resetResultB.setEnabled(false);
         resetResultB.setFont(new Font("微软雅黑", Font.PLAIN, 14));
-        resetResultB.setBounds(525, 348, 70, 36);
+        resetResultB.setBounds(380, 348, 70, 36);
         indexPanelA.add(resetResultB);
 
         okResultB = new JButton("OK");
@@ -1030,7 +1148,7 @@ public class MesClient extends JFrame {
         okResultB.setEnabled(false);
         okResultB.setForeground(new Color(0, 128, 0));
         okResultB.setFont(new Font("微软雅黑", Font.PLAIN, 14));
-        okResultB.setBounds(602, 348, 70, 36);
+        okResultB.setBounds(457, 348, 70, 36);
         indexPanelA.add(okResultB);
 
         ngResultB = new JButton("NG");
@@ -1064,9 +1182,114 @@ public class MesClient extends JFrame {
         ngResultB.setEnabled(false);
         ngResultB.setForeground(new Color(255, 0, 0));
         ngResultB.setFont(new Font("微软雅黑", Font.PLAIN, 14));
-        ngResultB.setBounds(679, 348, 70, 36);
+        ngResultB.setBounds(534, 348, 70, 36);
         indexPanelA.add(ngResultB);
 
+        resetResultC = new JButton("重拉");
+        resetResultC.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                if(zdStatusC == 1){
+                    JSONObject retObj = DataUtil.checkNgData(product_sn.getText(),"C");
+                    if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
+                        try {
+                            sortC = (short)(sortC - 1);
+                            param6.setText(sortC+"");
+                            plcC.writeInt16(66, sortC);
+                            zdStatusC = 0;
+                            resetResultC.setEnabled(false);
+                            okResultC.setEnabled(false);
+                            ngResultC.setEnabled(false);
+                            foutC = "";
+                            soutC = "";
+                            fmaxC = "";
+                            fminC = "";
+                            smaxC = "";
+                            sminC = "";
+                            curC = "";
+                            heartBeatFlagC = true;
+                        } catch (Exception ex) {
+                            setMenuStatus("C枪重拉失败", -1);
+                        }
+                    }else{
+                        setMenuStatus("NG中断未审核",-1);
+                    }
+                }
+            }
+        });
+        resetResultC.setEnabled(false);
+        resetResultC.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        resetResultC.setBounds(660, 348, 70, 36);
+        indexPanelA.add(resetResultC);
+
+        okResultC = new JButton("OK");
+        okResultC.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                if(zdStatusC == 1){
+                    JSONObject retObj = DataUtil.checkNgData(product_sn.getText(),"C");
+                    if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
+                        if(!product_sn.getText().isEmpty()){
+                            cFinish++;
+                            JdbcUtils.insertProdData(mes_gw, mes_line_sn, product_sn.getText(),"C",foutC,soutC,fminC,sminC,fmaxC,smaxC,"1",curC, user_menu.getText());
+                        }
+                        zdStatusC = 0;
+                        resetResultC.setEnabled(false);
+                        okResultC.setEnabled(false);
+                        ngResultC.setEnabled(false);
+                        foutC = "";
+                        soutC = "";
+                        fmaxC = "";
+                        fminC = "";
+                        smaxC = "";
+                        sminC = "";
+                        curC = "";
+                        ModbusUtil.upResult();
+                        heartBeatFlagC = true;
+                    }else{
+                        setMenuStatus("NG中断未审核",-1);
+                    }
+                }
+            }
+        });
+        okResultC.setEnabled(false);
+        okResultC.setForeground(new Color(0, 128, 0));
+        okResultC.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        okResultC.setBounds(737, 348, 70, 36);
+        indexPanelA.add(okResultC);
+
+        ngResultC = new JButton("NG");
+        ngResultC.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                if(zdStatusC == 1){
+                    JSONObject retObj = DataUtil.checkNgData(product_sn.getText(),"C");
+                    if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
+                        if(!product_sn.getText().isEmpty()){
+                            JdbcUtils.insertProdData(mes_gw, mes_line_sn, product_sn.getText(),"C",foutC,soutC,fminC,sminC,fmaxC,smaxC,"0",curC, user_menu.getText());
+                        }
+                        zdStatusC = 0;
+                        resetResultC.setEnabled(false);
+                        okResultC.setEnabled(false);
+                        ngResultC.setEnabled(false);
+                        foutC = "";
+                        soutC = "";
+                        fmaxC = "";
+                        fminC = "";
+                        smaxC = "";
+                        sminC = "";
+                        curC = "";
+                        ModbusUtil.upResult();
+                        heartBeatFlagC = true;
+                    }else{
+                        setMenuStatus("NG中断未审核",-1);
+                    }
+                }
+            }
+        });
+        ngResultC.setEnabled(false);
+        ngResultC.setForeground(new Color(255, 0, 0));
+        ngResultC.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        ngResultC.setBounds(814, 348, 70, 36);
+        indexPanelA.add(ngResultC);
+
         tabbedPane.addTab("工作面板", new ImageIcon(MesClient.class.getResource("/bg/a_side.png")), indexScrollPaneA, null);
         tabbedPane.setEnabledAt(0, true);
 

+ 3 - 0
src/com/mes/ui/MesRevice.java

@@ -30,6 +30,7 @@ public class MesRevice {
 //                }
                 ModbusUtil.setPowerOff(MesClient.plcA); // 远程关机
                 ModbusUtil.setPowerOff(MesClient.plcB); // 远程关机
+                MesClient.heartBeatFlagC = false; // C电枪停心跳锁枪
 
             }
         }catch (Exception e){
@@ -58,6 +59,8 @@ public class MesRevice {
 
                 ModbusUtil.setTask(MesClient.plcA,MesClient.aSetNum);
                 ModbusUtil.setTask(MesClient.plcB,MesClient.bSetNum);
+                ModbusUtil.setTaskEle(MesClient.plcC,MesClient.cSetNum);
+                MesClient.heartBeatFlagC = true; // C电枪写心跳放枪
             }
         }catch (Exception e){
             e.printStackTrace();

+ 136 - 15
src/com/mes/ui/ModbusUtil.java

@@ -47,10 +47,10 @@ public class ModbusUtil {
 
 
 //            op130
-            if(MesClient.sortA == 23){
-                plc.writeInt16(1070,(short) 4000);
-                plc.writeInt16(1071,(short) 5000);
-            }
+//            if(MesClient.sortA == 23){
+//                plc.writeInt16(1070,(short) 4000);
+//                plc.writeInt16(1071,(short) 5000);
+//            }
 
             //210
 //            if(MesClient.sortA == 75){
@@ -88,7 +88,7 @@ public class ModbusUtil {
             }
         }
 
-        if(MesClient.zdStatusA == 0 && MesClient.zdStatusB == 0){
+        if(MesClient.zdStatusA == 0 && MesClient.zdStatusB == 0 && MesClient.zdStatusC == 0){
             upResult();
         }
     }
@@ -131,6 +131,13 @@ public class ModbusUtil {
             MesClient.param4.setText(cur+"");
 
             System.out.println("cur:"+cur);
+
+            if(MesClient.sortB == 26){
+                plc.writeInt16(1070,(short) 3000);
+                plc.writeInt16(1071,(short) 4500);
+            }
+
+
             if(!MesClient.product_sn.getText().isEmpty()){
                 String qty = "1";
                 if(Integer.valueOf(fout) < Integer.valueOf(fmin) || Integer.valueOf(fout) > Integer.valueOf(fmax)){
@@ -161,18 +168,90 @@ public class ModbusUtil {
             }
         }
 
-        if(MesClient.zdStatusA == 0 && MesClient.zdStatusB == 0){
+        if(MesClient.zdStatusA == 0 && MesClient.zdStatusB == 0 && MesClient.zdStatusC == 0){
             upResult();
         }
 
     }
 
+    public static void getDataC(ModbusTcp plc){
+        try {
+            if (plc == null) {
+                return;
+            }
+
+            // NG中断锁枪:停心跳,PLC超时后禁止继续拉铆
+            if (MesClient.zdStatusC != 0) {
+                MesClient.heartBeatFlagC = false;
+                return;
+            }
+
+            Short cur = plc.readInt16(66);//已打数量
+
+            if(MesClient.cMax <= 0){
+                MesClient.cMax = plc.readInt32(4534); // 任务数量/预设数量
+                MesClient.param5.setText(String.valueOf(MesClient.cMax));
+            }
+
+            if(MesClient.sortC < cur){
+                MesClient.sortC = cur;
+                String fout = plc.readInt16(386)+"";
+                String sout = (float)plc.readInt16(376)/1000+"";
+
+                String fmin = plc.readInt32(4116)/10+"";
+                String smin = (float)plc.readInt32(4126)/1000+"";
+
+                String fmax = plc.readInt32(4114)/10+"";
+                String smax = (float)plc.readInt32(4124)/1000+"";
+
+                MesClient.param6.setText(cur+"");
+                System.out.println("curC:"+cur);
+                if(!MesClient.product_sn.getText().isEmpty()){
+                    String qty = isForceStrokeInRange(fout, sout, fmin, smin, fmax, smax) ? "1" : "0";
+                    // NG处理:停心跳锁枪
+                    if(qty.equals("0")){
+                        MesClient.zdStatusC = 1;
+                        MesClient.foutC = fout;
+                        MesClient.soutC = sout;
+                        MesClient.fmaxC = fmax;
+                        MesClient.fminC = fmin;
+                        MesClient.smaxC = smax;
+                        MesClient.sminC = smin;
+                        MesClient.curC = cur+"";
+                        MesClient.resetResultC.setEnabled(true);
+                        MesClient.okResultC.setEnabled(true);
+                        MesClient.ngResultC.setEnabled(true);
+                        MesClient.heartBeatFlagC = false;
+                        DataUtil.addNgData(MesClient.product_sn.getText(),"C");
+                        MesClient.setMenuStatus("C枪NG中断,请选择重拉/OK/NG", -1);
+                    }
+                    if(qty.equals("1")){
+                        MesClient.cFinish++;
+                        JdbcUtils.insertProdData(MesClient.mes_gw, MesClient.mes_line_sn, MesClient.product_sn.getText(),"C",fout,sout,fmin,smin,fmax,smax,qty,cur+"", MesClient.user_menu.getText());
+                    }
+                }
+
+                //预设数量等于已打数量,停心跳锁枪
+                if (MesClient.sortC >= MesClient.cMax && MesClient.cMax > 0){
+                    MesClient.heartBeatFlagC = false;
+                }
+            }
+
+            if(MesClient.zdStatusA == 0 && MesClient.zdStatusB == 0 && MesClient.zdStatusC == 0){
+                upResult();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
     // 上传总结果
     public static void upResult(){
-        if (MesClient.zdStatusA != 0 || MesClient.zdStatusB != 0) {
+        if (MesClient.zdStatusA != 0 || MesClient.zdStatusB != 0 || MesClient.zdStatusC != 0) {
             return;
         }
-        if(!MesClient.curSn.isEmpty() && MesClient.aMax > 0 && MesClient.aMax == MesClient.sortA && MesClient.bMax > 0 && MesClient.bMax == MesClient.sortB){
+        if(!MesClient.curSn.isEmpty() && MesClient.aMax > 0 && MesClient.aMax == MesClient.sortA && MesClient.bMax > 0 && MesClient.bMax == MesClient.sortB
+                && MesClient.cMax > 0 && MesClient.sortC >= MesClient.cMax){
             MesClient.finish_ok_bt.setEnabled(true);
             MesClient.finish_ng_bt.setEnabled(true);
 
@@ -186,6 +265,9 @@ public class ModbusUtil {
                 if(MesClient.bFinish != MesClient.bMax){
                     retf = "NG";
                 }
+                if(MesClient.cFinish != MesClient.cMax){
+                    retf = "NG";
+                }
                 Boolean ret = DataUtil.sendQuality(MesClient.nettyClient, MesClient.product_sn.getText(),retf, MesClient.user20);
                 if(!ret){
                     MesClient.setMenuStatus(MesClient.tjFlagTextErr,-1);
@@ -273,6 +355,39 @@ public class ModbusUtil {
         return ret;
     }
 
+    // 电枪任务(心跳锁枪机型)
+    public static void setTaskEle(ModbusTcp plc, Short setNum){
+        try{
+            plc.writeInt16(3023,(short) 1); // 速乐德
+            plc.writeInt16(8, (short) 1);
+            plc.writeInt16(4534, setNum);
+            plc.writeInt16(66,(short) 0);
+            plc.writeInt16(68,(short) 0);
+            plc.writeInt16(70,(short) 0);
+            plc.writeInt16(4170, (short) 10);  // 心跳间隔10(代表1秒)
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 拉力、行程是否都在上下限范围内
+     */
+    public static boolean isForceStrokeInRange(String fout, String sout, String fmin, String smin, String fmax, String smax) {
+        try {
+            double fOut = Double.parseDouble(fout);
+            double sOut = Double.parseDouble(sout);
+            double fMin = Double.parseDouble(fmin);
+            double sMin = Double.parseDouble(smin);
+            double fMax = Double.parseDouble(fmax);
+            double sMax = Double.parseDouble(smax);
+            return fOut >= fMin && fOut <= fMax && sOut >= sMin && sOut <= sMax;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
     // 重置任务
     public static void setTask(ModbusTcp plc,Short setNum){
         try{
@@ -290,15 +405,21 @@ public class ModbusUtil {
 
 
 //            op130
-            if(setNum == 29){
-                plc.writeInt16(1070,(short) 3200);
-                plc.writeInt16(1071,(short) 4200);
-            }
+//            if(setNum == 29){
+//                plc.writeInt16(1070,(short) 3200);
+//                plc.writeInt16(1071,(short) 4200);
+//            }
 
 //            op130
-            if(setNum == 26){
-                plc.writeInt16(1070,(short) 3200);
-                plc.writeInt16(1071,(short) 4200);
+
+//            if(setNum == 26){
+//                plc.writeInt16(1070,(short) 3500);
+//                plc.writeInt16(1071,(short) 4900);
+//            }
+
+            if(setNum == 28){
+                plc.writeInt16(1070,(short) 3500);
+                plc.writeInt16(1071,(short) 4900);
             }
 
         }catch (Exception e){

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

@@ -8,10 +8,10 @@ public class OprnoUtil {
 
     public static String[] xtoprnos = new String[]{
 
-            "OP210","OP130"
+            "OP210","OP130","OP230","OP310"
     };
     public static String[] xtoprnodes = new String[]{
-            "总成反面装配1","液冷板拉铆"
+            "总成反面装配1","液冷板拉铆","正面拉铆","反面拉铆"
     };
     public static String[] lboprnos = new String[]{
             "OP040","OP050","OP060","OP070","OP080","OP090","OP100","OP110",

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

@@ -1,6 +1,6 @@
-mes.gw=OP130B
-#mes.server_ip=127.0.0.1
-mes.server_ip=192.168.24.99
+mes.gw=OP210A
+mes.server_ip=127.0.0.1
+#mes.server_ip=192.168.24.99
 mes.tcp_port=3000
 mes.heart_beat_cycle=60
 mes.line_sn=XT