瀏覽代碼

优化扫码程序,增加检测kb错误信息上传

zly 4 月之前
父節點
當前提交
84e7201e37
共有 1 個文件被更改,包括 32 次插入23 次删除
  1. 32 23
      TeamAAS-VM/Core/Management.cs

+ 32 - 23
TeamAAS-VM/Core/Management.cs

@@ -1214,7 +1214,7 @@ namespace TeamAAS_VP.Core
                 monitorNodeIds.Add(string.Format(addressConfig.In_MesCheck.Address, i));
             }
             //订阅PLC地址变化
-            plc.SubscribeNodes("AutoSensor", monitorNodeIds, PlcCommandTrigger,OpcUaSubscriptionMode.CustomPolling);
+            plc.SubscribeNodes("AutoSensor", monitorNodeIds, PlcCommandTrigger, OpcUaSubscriptionMode.CustomPolling);
         }
 
         /// <summary>
@@ -1907,7 +1907,8 @@ namespace TeamAAS_VP.Core
                             //位置编号
                             Int16 positionIndex = plc.ReadNode<Int16>(addressConfig.In_ProductNum.Address);
                             SendTaskMessage(string.Format(Lang.编号0, positionIndex), MessageLevel.Info);
-                            // 开始采集压力值
+                            // 开始采集压力值,ProductMainSN[i]
+                            //StartPressureCollection(currentProduct.Name, _productService.CurrentProductCode, 0);
                             StartPressureCollection(currentProduct.Name, _productService.CurrentProductCode, 0);
                         }
                         else
@@ -2417,7 +2418,7 @@ namespace TeamAAS_VP.Core
                                     {
                                         code = outputCollection["QR"].Value as string;
                                         code = code.ToUpper();
-                                        if (!string.IsNullOrEmpty(code))
+                                        if (!string.IsNullOrEmpty(code) && code.Length > 5)
                                         {
                                             if (systemConfig.IsBasePartCodeChooseScrew)//是否基于零件码,判断是不是当站要打的螺丝
                                             {
@@ -2470,10 +2471,10 @@ namespace TeamAAS_VP.Core
                                     //获取过站时间
                                     _LastMesCheckTime[i] = (await _mesService.GetServerTimeAsync(i, code, 2)).Now;
                                     if (_configService.GetDeviceInfo().EnableMES)
-                                    {                                              
+                                    {
                                         LogHelper.WriteLogMes($"【mes开始QUERY】");
                                         SendTaskMessage($"mes开始QUERY", MessageLevel.Info);
-                                        dataToMes.Clear();
+                                        //dataToMes.Clear();
                                         if (systemConfig.IsBasePartCodeGetSN)//是否基于零件码,判断是否过站
                                         {
                                             SendTaskMessage($"基于零件码,判断是否过站", MessageLevel.Debug);
@@ -2507,7 +2508,10 @@ namespace TeamAAS_VP.Core
                                                     if (snItem != null)
                                                     {
                                                         ProductMainSN[i] = snItem.Replace("sn=", "").Trim();
-                                                        _productService.CurrentProductCode = ProductMainSN[i];
+                                                        if (i == 0)
+                                                        {
+                                                            _productService.CurrentProductCode = ProductMainSN[i];
+                                                        }
                                                         //_eventAggregator.GetEvent<DelaySaveImageNotification>().Publish(true);//通知界面延迟保存图片,等待MES查询结果返回,避免图片和数据不同步
                                                         SendTaskMessage($"产品主sn:{ProductMainSN[i]}", MessageLevel.Info);
                                                     }
@@ -2627,7 +2631,10 @@ namespace TeamAAS_VP.Core
                                                     if (snItem != null)
                                                     {
                                                         ProductMainSN[i] = snItem.Replace("sn=", "").Trim();
-                                                        _productService.CurrentProductCode = ProductMainSN[i];
+                                                        if (i == 0)
+                                                        {
+                                                            _productService.CurrentProductCode = ProductMainSN[i];
+                                                        }
                                                         SendTaskMessage($"产品主sn:{ProductMainSN[i]}", MessageLevel.Info);
                                                     }
                                                     string woItem = item.FirstOrDefault(f => f.Contains("wo="));
@@ -2735,10 +2742,10 @@ namespace TeamAAS_VP.Core
                                 }
                                 // 上传本站数据
                                 else if (state == 2)
-                                {                                
+                                {
                                     DFC.Clear();//CTQ数据集合
-
-                                    //获取当前工位的配置
+                                                // string productccode = ProductMainSN[i];
+                                                //获取当前工位的配置
                                     var stationConfig = _configService.GetDeviceInfo(i);
                                     SendTaskMessage($"收到{i}:{stationConfig.DeviceName}上传本站数据请求...", MessageLevel.Debug);
                                     //从服务器中获取当前时间
@@ -2879,36 +2886,38 @@ namespace TeamAAS_VP.Core
                                                 PD_ATTR_03 = "NA",
                                                 PD_ATTR_04 = productSn,
                                                 PD_ATTR_05 = "NA",
-                                            });                                            
+                                            });
                                         }
                                         if (systemConfig.IsBasePartOpenLightKB)
                                         {
                                             string midValue = "999", saveppid = "NA";
                                             double upvlalue = 0, doenvlaue = 0;
                                             if (stationConfig.SaveCsvPPID) saveppid = ppid[i];
-                                            bool pressureRes=true;                                            
+                                            bool pressureRes = true;
                                             foreach (var item in mes_cc)
                                             {
-                                                switch(item.Key)
+                                                switch (item.Key)
                                                 {
                                                     case "1":
                                                         upvlalue = Convert.ToDouble(currentProduct.GlobalParamEx.CC1DownLimit.ToString("F3"));
                                                         doenvlaue = Convert.ToDouble(currentProduct.GlobalParamEx.CC1UpLimit.ToString("F3"));
                                                         midValue = ((currentProduct.GlobalParamEx.CC1DownLimit + currentProduct.GlobalParamEx.CC1UpLimit) / 2).ToString("F3");
+                                                        if (Convert.ToDouble(item.Value) < upvlalue || Convert.ToDouble(item.Value) > doenvlaue)
+                                                        {
+                                                            resultToMes.Add($"CC{item.Key}_Fail");
+                                                            SendTaskMessage($"CC{item.Key}:超限", MessageLevel.Error);
+                                                        }
                                                         break;
                                                     case "2":
                                                         upvlalue = Convert.ToDouble(currentProduct.GlobalParamEx.CC2DownLimit.ToString("F3"));
                                                         doenvlaue = Convert.ToDouble(currentProduct.GlobalParamEx.CC2UpLimit.ToString("F3"));
                                                         midValue = ((currentProduct.GlobalParamEx.CC2DownLimit + currentProduct.GlobalParamEx.CC2UpLimit) / 2).ToString("F3");
-                                                        break;                                                   
-                                                }
-                                                if (doenvlaue<= currentProduct.GlobalParamEx.CC1DownLimit|| doenvlaue >= currentProduct.GlobalParamEx.CC1UpLimit)
-                                                {
-                                                    pressureRes = false;
-                                                }
-                                                if (doenvlaue <= currentProduct.GlobalParamEx.CC2DownLimit|| doenvlaue >= currentProduct.GlobalParamEx.CC2UpLimit)
-                                                {
-                                                    pressureRes = false;
+                                                        if (Convert.ToDouble(item.Value) < upvlalue || Convert.ToDouble(item.Value) > doenvlaue)
+                                                        {
+                                                            resultToMes.Add($"CC{item.Key}_Fail");
+                                                            SendTaskMessage($"CC{item.Key}:超限", MessageLevel.Error);
+                                                        }
+                                                        break;
                                                 }
                                                 dataToMes.Add($"CC{item.Key}", $"{item.Value}");
                                                 DFC.Add(new DataFormCtq
@@ -3080,7 +3089,7 @@ namespace TeamAAS_VP.Core
                                     WriteProductLog(lockResultsAll, ProductMainSN[i], CTtime);
                                     mes_cc.Clear();
                                     LogHelper.WriteLogMes($"【mes结束ADD】");
-                                    SendTaskMessage($"mes结束ADD", MessageLevel.Info);                                 
+                                    SendTaskMessage($"mes结束ADD", MessageLevel.Info);
                                 }
                                 else
                                 {