Quellcode durchsuchen

2209增加标识位读取

qinqi vor 6 Monaten
Ursprung
Commit
ecc02efd99
1 geänderte Dateien mit 25 neuen und 8 gelöschten Zeilen
  1. 25 8
      wwwroot/API/PLC/shiYou/shiyou2209.ashx

+ 25 - 8
wwwroot/API/PLC/shiYou/shiyou2209.ashx

@@ -21,7 +21,8 @@ public class shiyou2209 : IHttpHandler
         public static int plcPort = 102;
         public static string dbResult = "100.0";   //结果;已记录成功=1,未记录成功(有错误)=2
         public static string dbBarcode = "100.4";  //产品条码
-        public static string dbUsercode = "100.18";//工号读取 (5位)
+        public static string dbUsercode = "100.18";//工号读取 (5位) 
+        public static string dbInfo = "100.24";//接收条码信息(int)接收不成功=0,接收成功=1
     }
 
     public static class API
@@ -34,9 +35,9 @@ public class shiyou2209 : IHttpHandler
         public static string sessionKey = "";
         public static int procedureID = 65; //施釉-入库-1&2#_刮登釉坯入库  
 
-        public static string userId1 = "1355"; 
+        public static string userId1 = "1355";
 
-        public static string userCode1 = "SCJ08"; 
+        public static string userCode1 = "SCJ08";
 
         public static int procedureID1 = 65; //施釉-入库-1&2#_刮登釉坯入库 
     }
@@ -84,7 +85,7 @@ public class shiyou2209 : IHttpHandler
                 {
                     //读取用户信息
                     GetUserinfo(userCode1);
-                          
+
                     //接口验证可到达
                     int check = ApiCheckBarcode(barCode);
                     if (check == 1)
@@ -93,9 +94,25 @@ public class shiyou2209 : IHttpHandler
 
                         if (addWorkPiece == 1)
                         {
-                                bool barcodeflag = PlcWriteRepeat<string>(PLC.dbBarcode, barCode);
-                                bool resultflag = PlcWriteRepeat<short>(PLC.dbResult, Convert.ToInt16(1));
-                                result.Add(new JObject(new JProperty("PLC读出(核对)", PLC.dbResult + " = " + s7.Read<short>(PLC.dbResult)  + ";" + PLC.dbBarcode + " = " + s7.Read<string>(PLC.dbBarcode, 11))));
+                            bool barcodeflag = PlcWriteRepeat<string>(PLC.dbBarcode, barCode);
+                            bool resultflag = PlcWriteRepeat<short>(PLC.dbResult, Convert.ToInt16(1));
+                            //result.Add(new JObject(new JProperty("PLC读出(核对)", PLC.dbResult + " = " + s7.Read<short>(PLC.dbResult)  + ";" + PLC.dbBarcode + " = " + s7.Read<string>(PLC.dbBarcode, 11))));
+
+                            int repeat = 5;
+                            int j = 1;
+                            result.Add(new JObject(new JProperty("PLC读取接收条码数据:",PLC.dbInfo + " = " + s7.Read<short>(PLC.dbInfo) + ";")));
+
+                            while ( Convert.ToInt16(s7.Read<short>(PLC.dbInfo)) != Convert.ToInt16(1) && j<repeat )
+                            {
+                                result.Add(new JObject(new JProperty("PLC写入数据(重写第" + j.ToString() + "次):")));
+                                barcodeflag = PlcWriteRepeat<string>(PLC.dbBarcode, barCode);
+                                resultflag = PlcWriteRepeat<short>(PLC.dbResult, Convert.ToInt16(1));
+
+                                result.Add(new JObject(new JProperty("PLC读取接收条码数据:",PLC.dbInfo + " = " + s7.Read<short>(PLC.dbInfo) + ";")));
+                                j++;
+                            }
+                            result.Add(new JObject(new JProperty("PLC读出(核对)", PLC.dbResult + " = " + s7.Read<short>(PLC.dbResult)  + ";" + PLC.dbBarcode + " = " + s7.Read<string>(PLC.dbBarcode, 11))));
+                           //========================================
 
                         }
                         else
@@ -146,7 +163,7 @@ public class shiyou2209 : IHttpHandler
         return isSuccess;
     }
 
-         //读取USERCODE
+    //读取USERCODE
     public string PlcReadUsercode(string usercodein,int len)
     {
         try