Ver Fonte

优化MES交互及CT时间计算方式

移除Stopwatch计时器,改用时间差计算CT时间,仅在i==0时赋值CTtime,并调整相关日志写入逻辑,使CT时间获取更简洁高效。
孝锋 徐 há 7 meses atrás
pai
commit
a96207df5d
1 ficheiros alterados com 6 adições e 4 exclusões
  1. 6 4
      TeamAAS-VM/Core/Management.cs

+ 6 - 4
TeamAAS-VM/Core/Management.cs

@@ -114,7 +114,6 @@ namespace TeamAAS_VP.Core
         /// 超时自动停止秒数
         /// </summary>
         private int _pressureMaxDurationSeconds = 30; //超时自动停止秒数
-        Stopwatch swCT = new Stopwatch();
         List<LockResult> lockResultsAll = new List<LockResult>();//一个产品的总结果
         #endregion
 
@@ -1889,7 +1888,6 @@ namespace TeamAAS_VP.Core
                                 //询问mes
                                 if (state == 1)
                                 {
-                                    swCT.Restart();
                                     //这里缺少从MES获取产品配方的内容,需要补充
 
                                     _LastMesCheckTime[i] = DateTime.UtcNow;
@@ -1925,12 +1923,16 @@ namespace TeamAAS_VP.Core
 
                                     //这里缺少上传MES的本站数据结果及开始和结束时间,需要补充
 
+                                    if (i==0)
+                                    {
+                                        CTtime= DateTime.UtcNow.Subtract(_LastMesCheckTime[i]).TotalSeconds;
+                                    }
+
                                     (bool isSuccess, string response) = await _mesService.SubmitGetAsync(code, true, _LastMesCheckTime[i], DateTime.UtcNow);
                                     //假设上传成功,这里缺少上传失败的处理
 
                                     await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)3);
-                                    swCT.Stop();
-                                    CTtime = Math.Round(swCT.Elapsed.TotalSeconds, 3);
+
                                     WriteProductLog(lockResultsAll, code, CTtime);
                                     lockResultsAll.Clear();
                                 }