liuwei 1 روز پیش
والد
کامیت
5180774121

+ 7 - 6
src/com/mes/plc/TjPlcConfig.java

@@ -51,13 +51,14 @@ public class TjPlcConfig {
             this.scanFeedbackBit = parseInt(pro.getProperty(prefix + "scanFeedbackBit"), a1 ? 0 : 1);
             this.allowEntryByte = parseInt(pro.getProperty(prefix + "allowEntryByte"), 64);
             this.allowEntryBit = parseInt(pro.getProperty(prefix + "allowEntryBit"), a1 ? 2 : 3);
-            this.pathDoneByte = parseInt(pro.getProperty(prefix + "pathDoneByte"), a1 ? 64 : 76);
+            this.pathDoneByte = parseInt(pro.getProperty(prefix + "pathDoneByte"), a1 ? 64 : 74);
             this.pathDoneBit = parseInt(pro.getProperty(prefix + "pathDoneBit"), a1 ? 4 : 0);
-            this.allDoneByte = parseInt(firstNonBlank(pro.getProperty(prefix + "allDoneByte"), pro.getProperty(prefix + "glueDoneByte")), a1 ? 64 : 76);
+            this.allDoneByte = parseInt(firstNonBlank(pro.getProperty(prefix + "allDoneByte"), pro.getProperty(prefix + "glueDoneByte")), a1 ? 64 : 74);
             this.allDoneBit = parseInt(firstNonBlank(pro.getProperty(prefix + "allDoneBit"), pro.getProperty(prefix + "glueDoneBit")), a1 ? 5 : 1);
-            this.seqOffset = parseInt(pro.getProperty(prefix + "seqOffset"), a1 ? 66 : 78);
-            this.glueSpeedOffset = parseInt(pro.getProperty(prefix + "glueSpeedOffset"), a1 ? 68 : 80);
-            this.glueLengthOffset = parseInt(pro.getProperty(prefix + "glueLengthOffset"), a1 ? 72 : 84);
+            this.seqOffset = parseInt(pro.getProperty(prefix + "seqOffset"), a1 ? 66 : 76);
+            this.glueSpeedOffset = parseInt(pro.getProperty(prefix + "glueSpeedOffset"), a1 ? 68 : 78);
+            // 涂胶长度:博途为 Word(非 Real)
+            this.glueLengthOffset = parseInt(pro.getProperty(prefix + "glueLengthOffset"), a1 ? 72 : 82);
         }
 
         public String frameCodeAddr(int db) {
@@ -89,7 +90,7 @@ public class TjPlcConfig {
         }
 
         public String glueLengthAddr(int db) {
-            return String.format("DB%d.DBD%d", db, glueLengthOffset);
+            return String.format("DB%d.DBW%d", db, glueLengthOffset);
         }
     }
 

+ 2 - 1
src/com/mes/plc/TjPlcMonitorPanel.java

@@ -224,7 +224,8 @@ public class TjPlcMonitorPanel extends JPanel {
                 gun.seqAddr(config.db), s);
         s.glueSpeed = readText(() -> String.format("%.3f", s7Client.readFloat(gun.glueSpeedOffset)),
                 gun.glueSpeedAddr(config.db), s);
-        s.glueLength = readText(() -> String.format("%.3f", s7Client.readFloat(gun.glueLengthOffset)),
+        // 涂胶长度:Word
+        s.glueLength = readText(() -> String.valueOf(s7Client.readUInt16(gun.glueLengthOffset)),
                 gun.glueLengthAddr(config.db), s);
         return s;
     }

+ 4 - 3
src/com/mes/plc/TjPlcPoller.java

@@ -164,17 +164,18 @@ public class TjPlcPoller {
 
         int seq = s7Client.readUInt16(gun.seqOffset);
         float speed = s7Client.readFloat(gun.glueSpeedOffset);
-        float length = s7Client.readFloat(gun.glueLengthOffset);
+        // 涂胶长度:Word
+        int length = s7Client.readUInt16(gun.glueLengthOffset);
         MesClient.addTjPath(seq, speed, length);
         final int seqF = seq;
         final float speedF = speed;
-        final float lengthF = length;
+        final int lengthF = length;
         SwingUtilities.invokeLater(() -> {
             MesClient.refreshTjPathUi();
             MesClient.status_menu.setForeground(Color.GREEN);
             MesClient.status_menu.setText("[" + gun.name + "]单道完成 序号=" + seqF
                     + " 速度=" + String.format("%.2f", speedF)
-                    + " 长度=" + String.format("%.2f", lengthF));
+                    + " 长度=" + lengthF);
         });
     }
 

+ 8 - 3
src/com/mes/ui/MesClient.java

@@ -132,15 +132,20 @@ public class MesClient extends JFrame {
             if (i > 0) {
                 sb.append('#');
             }
-            sb.append(r.seq).append('#').append(formatNum(r.speed)).append('#').append(formatNum(r.length));
+            // 序号#速度(Real)#长度(Word整数)
+            sb.append(r.seq).append('#').append(formatSpeed(r.speed)).append('#').append(formatLength(r.length));
         }
         return sb.toString();
     }
 
-    private static String formatNum(double v) {
+    private static String formatSpeed(double v) {
         return String.format(java.util.Locale.US, "%.2f", v);
     }
 
+    private static String formatLength(double v) {
+        return String.valueOf((int) Math.round(v));
+    }
+
     public static void refreshTjPathUi() {
         String data = buildTjDataString();
         int count = tjPathCache.size();
@@ -152,7 +157,7 @@ public class MesClient extends JFrame {
             tjSpeedLabel.setText(last == null ? "涂胶速度: -" : String.format("涂胶速度: %.2f", last.speed));
         }
         if (tjLengthLabel != null) {
-            tjLengthLabel.setText(last == null ? "涂胶长度: -" : String.format("涂胶长度: %.2f", last.length));
+            tjLengthLabel.setText(last == null ? "涂胶长度: -" : ("涂胶长度: " + formatLength(last.length)));
         }
         if (tjPathCountLabel != null) {
             tjPathCountLabel.setText("已采集道次: " + count);

+ 7 - 5
src/resources/config/config.properties

@@ -16,6 +16,7 @@ mes.tj.plc.slot=1
 mes.tj.plc.db=1300
 
 # ---- 胶枪 A1 (R1) ----
+# 与博途一致:序号Word=66,速度Real=68,长度Word=72
 mes.tj.a1.frameCodeOffset=0
 mes.tj.a1.frameCodeLen=30
 mes.tj.a1.scanFeedbackByte=64
@@ -31,16 +32,17 @@ mes.tj.a1.glueSpeedOffset=68
 mes.tj.a1.glueLengthOffset=72
 
 # ---- 胶枪 B1 (R2) ----
+# 与博途 InterfaceMes[DB1300] 一致:单道/全部=74.0/74.1,序号=76,速度Real=78,长度Word=82
 mes.tj.b1.frameCodeOffset=32
 mes.tj.b1.frameCodeLen=30
 mes.tj.b1.scanFeedbackByte=64
 mes.tj.b1.scanFeedbackBit=1
 mes.tj.b1.allowEntryByte=64
 mes.tj.b1.allowEntryBit=3
-mes.tj.b1.pathDoneByte=76
+mes.tj.b1.pathDoneByte=74
 mes.tj.b1.pathDoneBit=0
-mes.tj.b1.allDoneByte=76
+mes.tj.b1.allDoneByte=74
 mes.tj.b1.allDoneBit=1
-mes.tj.b1.seqOffset=78
-mes.tj.b1.glueSpeedOffset=80
-mes.tj.b1.glueLengthOffset=84
+mes.tj.b1.seqOffset=76
+mes.tj.b1.glueSpeedOffset=78
+mes.tj.b1.glueLengthOffset=82