Kaynağa Gözat

优化铁腾点位

hzd 1 hafta önce
ebeveyn
işleme
aee2a98486
2 değiştirilmiş dosya ile 40 ekleme ve 33 silme
  1. 2 2
      src/com/mes/ui/MesClient.java
  2. 38 31
      src/com/mes/ui/PlcUtil.java

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

@@ -106,7 +106,7 @@ public class MesClient extends JFrame {
 
 
     public static String namea = "A"; // 扭力枪通道 A
-    public static Integer maxa = 20; // A枪任务数
+    public static Integer maxa = 19; // A枪任务数
     public static Integer cura = 0; // A枪当前数
     public static Integer resulta = 0; // A枪结果 0=NG 1=OK
     public static List<String> atids = new ArrayList<>();
@@ -585,7 +585,7 @@ public class MesClient extends JFrame {
 
         PlcUtil.setPowerOffA(MesClient.plcA);
         PlcUtil.setPowerOffB(MesClient.plcA);
-        PlcUtil.setTask(MesClient.plcA,MesClient.aSetNum,MesClient.bSetNum);
+//        PlcUtil.setTask(MesClient.plcA,MesClient.aSetNum,MesClient.bSetNum);
 
         pzlabel.setVisible(false);
 

+ 38 - 31
src/com/mes/ui/PlcUtil.java

@@ -9,23 +9,25 @@ import java.text.DecimalFormat;
 public class PlcUtil {
 
     public static void getDataA(S7PLC plc){
-        int cur = plc.readInt32("DB1.184.0");
+        int cur = plc.readInt32("DB41.32.0");
 
         MesClient.param1.setText(String.valueOf(MesClient.aMax));
 
         if(MesClient.sortA < cur){
             MesClient.sortA = cur;
-            if (cur == 16){
-                plc.writeUInt16("DB1.DBW54",2);
+            if (cur == 16){ // 切换产品2配方
+                plc.writeUInt16("DB40.2",2);
+//                plc.writeUInt16("DB40.4",3);
+//                plc.writeUInt32("DB41.32",0);
             }
-            int fout = plc.readInt32("DB1.144.0");
-            Float sout = plc.readFloat32("DB1.148.0");
+            int fout = plc.readInt32("DB41.24.0");
+            Float sout = plc.readFloat32("DB41.28.0");
 
-            int fmin = plc.readInt32("DB1.26.0");
-            Float smin = plc.readFloat32("DB1.34.0");
+            int fmin = plc.readInt32("DB41.0.0") - plc.readInt32("DB41.8.0");
+            Float smin = plc.readFloat32("DB41.12.0") - plc.readFloat32("DB41.20.0");
 
-            int fmax = plc.readInt32("DB1.22.0");
-            Float smax = plc.readFloat32("DB1.30.0");
+            int fmax = plc.readInt32("DB41.0.0") + plc.readInt32("DB41.4.0");
+            Float smax = plc.readInt32("DB41.12.0") + plc.readFloat32("DB41.16.0");
 
             String qty = "0";
             if(getResultDingA(plc).equals("OK")){
@@ -61,21 +63,21 @@ public class PlcUtil {
     }
 
     public static void getDataB(S7PLC plc){
-        int cur = plc.readInt32("DB1.714.0");
+        int cur = plc.readInt32("DB51.32.0");
 
         MesClient.param3.setText(String.valueOf(MesClient.bMax));
 
         if(MesClient.sortB < cur){
             MesClient.sortB = cur;
 
-            int fout = plc.readInt32("DB1.674.0");
-            Float sout = plc.readFloat32("DB1.678.0");
+            int fout = plc.readInt32("DB51.24.0");
+            Float sout = plc.readFloat32("DB51.28.0");
 
-            int fmin = plc.readInt32("DB1.556.0");
-            Float smin = plc.readFloat32("DB1.564.0");
+            int fmin = plc.readInt32("DB51.0.0") - plc.readInt32("DB51.8.0");
+            Float smin = plc.readFloat32("DB51.12.0") - plc.readFloat32("DB51.20.0");
 
-            int fmax = plc.readInt32("DB1.552.0");
-            Float smax = plc.readFloat32("DB1.560.0");
+            int fmax = plc.readInt32("DB51.0.0") + plc.readInt32("DB51.4.0");
+            Float smax = plc.readFloat32("DB51.12.0") + plc.readFloat32("DB51.16.0");
 
             String qty = "0";
             if(getResultDingB(plc).equals("OK")){
@@ -164,8 +166,8 @@ public class PlcUtil {
     public static Boolean setPowerOn(S7PLC plc){
         Boolean ret = false;
         try{
-            plc.writeBoolean("DB4.DBX0.1",true);
-            plc.writeBoolean("DB4.DBX204.0",true);
+            plc.writeBoolean("DB40.0.0",true);
+            plc.writeBoolean("DB50.0.0",true);
             ret = true;
         }catch (Exception e){
             e.printStackTrace();
@@ -201,7 +203,8 @@ public class PlcUtil {
     public static Boolean setPowerOff(S7PLC plc){
         Boolean ret = false;
         try{
-            plc.writeBoolean("DB4.DBX0.1",true);
+            plc.writeBoolean("DB40.0.0",false);
+            plc.writeBoolean("DB50.0.0",false);
             ret = true;
         }catch (Exception e){
             e.printStackTrace();
@@ -213,7 +216,7 @@ public class PlcUtil {
     public static Boolean setPowerOffA(S7PLC plc){
         Boolean ret = false;
         try{
-            plc.writeBoolean("DB4.DBX0.1",false);
+            plc.writeBoolean("DB40.0.0",false);
             ret = true;
         }catch (Exception e){
             e.printStackTrace();
@@ -225,7 +228,7 @@ public class PlcUtil {
     public static Boolean setPowerOffB(S7PLC plc){
         Boolean ret = false;
         try{
-            plc.writeBoolean("DB4.DBX204.0",false);
+            plc.writeBoolean("DB50.0.0",false);
             ret = true;
         }catch (Exception e){
             e.printStackTrace();
@@ -237,9 +240,13 @@ public class PlcUtil {
 
     public static void setTask(S7PLC plc,int setNumA,int setNumB){
         try{
-            plc.writeUInt16("DB1.DBW54",1);
-            plc.writeInt32("DB1.184.0",0);
-            plc.writeInt32("DB1.714.0",0);
+            plc.writeUInt16("DB40.2",1);
+            plc.writeUInt16("DB40.4",setNumA);
+            plc.writeInt32("DB41.32.0",0);
+
+            plc.writeUInt16("DB50.2",1);
+            plc.writeUInt16("DB50.4",setNumB);
+            plc.writeInt32("DB51.32.0",0);
         }catch (Exception e){
             e.printStackTrace();
         }
@@ -248,9 +255,9 @@ public class PlcUtil {
     public static String getResultDingA(S7PLC plc){
         String ret = "OK";
         try{
-            boolean retang = plc.readBoolean("DB1.314.1");
-            boolean retang2 = plc.readBoolean("DB1.314.3");
-            if(retang || retang2){
+            byte retang = plc.readByte("DB41.26");
+            int rent = (int) retang;
+            if(rent == 0){
                 ret = "NG";
             }
         }catch (Exception e){
@@ -263,9 +270,9 @@ public class PlcUtil {
     public static String getResultDingB(S7PLC plc){
         String ret = "OK";
         try{
-            boolean retbng = plc.readBoolean("DB1.844.1");
-            boolean retbng2 = plc.readBoolean("DB1.844.3");
-            if(retbng || retbng2){
+            byte retang = plc.readByte("DB51.26");
+            int rent = (int) retang;
+            if(rent == 0){
                 ret = "NG";
             }
         }catch (Exception e){
@@ -277,7 +284,7 @@ public class PlcUtil {
 
     public static boolean plcReachable(S7PLC plc){
         try{
-            plc.readBoolean("DB4.DBX0.1");
+            plc.readBoolean("DB40.0.0");
             return true;
         }catch (Exception e){
             return false;