wanghan 7 месяцев назад
Родитель
Сommit
65d5ad705c

+ 7 - 1
TeamAAS-VM/Interfaces/IRemoteCommandService.cs

@@ -202,7 +202,7 @@ namespace TeamAAS_VP.Interfaces
         /// </summary>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        Task<bool> IsRobotInDebugModeAsync(int robotNumber,CancellationToken cancellationToken);
+        Task<bool> IsRobotInDebugModeAsync(int robotNumber, CancellationToken cancellationToken);
 
         /// <summary>
         /// 执行视觉任务
@@ -344,5 +344,11 @@ namespace TeamAAS_VP.Interfaces
         /// <param name="procedure">流程模型</param>
         /// <returns></returns>
         Task TurnOffLightAfterPhoto(ProcedureModel procedure);
+
+        /// <summary>
+        /// 获取复检结果
+        /// </summary>
+        Task<(bool IsSucceed, string distance)> ExecutePhotoGetDistance(ProcedureModel procedure, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken, int positionIndex, string remark);
+
     }
 }

+ 2 - 2
TeamAAS-VM/Services/MesService.cs

@@ -99,11 +99,11 @@ namespace TeamAAS_VP.Services
             string url = "";
             if (device.F == "PTL")
             {
-                url = $"{device.MesUrl}?c=QUERY_RECORD&line={device.Line}&station={device.Station}&fixtureid={device.FixtureId}&sn={sn}&comp={device.comp}:{comp}&p=unit_process_check,model";
+                url = $"{device.MesUrl}?c=QUERY_RECORD&line={device.Line}&station={device.Station}&fixtureid={device.FixtureId}&sn={sn}&comp={device.comp}:{comp}&p=unit_process_check,message,model";
             }
             else
             {
-                url = $"{device.MesUrl}?c=QUERY_RECORD&line={device.Line}&station={device.Station}&fixtureid={device.FixtureId}&sn={sn}&p=unit_process_check,model";
+                url = $"{device.MesUrl}?c=QUERY_RECORD&line={device.Line}&station={device.Station}&fixtureid={device.FixtureId}&sn={sn}&p=unit_process_check,message,model";
             }
 
             LogHelper.WriteLogMes($"¡¾Ñ¯ÎÊURL¡¿{url}");

+ 63 - 0
TeamAAS-VM/Services/RemoteCommandService.cs

@@ -1758,6 +1758,69 @@ namespace TeamAAS_VP.Services
 
             }
         }
+        /// <summary>
+        /// 获取复检结果
+        /// </summary>
+        /// <param name="procedure"></param>
+        /// <param name="InputTerminal"></param>
+        /// <param name="robotCoord"></param>
+        /// <param name="cancellationToken"></param>
+        /// <param name="positionIndex"></param>
+        /// <param name="remark"></param>
+        /// <returns></returns>
+        public async Task<(bool IsSucceed, string distance)> ExecutePhotoGetDistance(ProcedureModel procedure, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken, int positionIndex, string remark)
+        {
+            DateTime nowtime = DateTime.Now;
+            await SetLightBeforePhoto(procedure);
+            try
+            {
+                //拍照失败时,需要多次拍照
+                for (int i = 0; i < procedure.FeederFailLimit; i++)
+                {
+                    SendTaskMessage(Lang.开始执行视觉流程.Replace("{0}", $"{i + 1}").Replace("{1}", procedure.Name), MessageLevel.Info);
+
+                    // 1. 执行相机拍照并运行视觉工具
+                    bool visionSucceed = ExecutePhoto(procedure, InputTerminal, out CogToolBlockTerminalCollection outputCollection);
+                    if (!visionSucceed)
+                    {
+                        SendTaskMessage(Lang.视觉任务执行失败, MessageLevel.Error);
+                        continue;
+                    }
+
+                    if (!outputCollection.Contains("Found"))
+                    {
+                        SendTaskMessage(Lang.未找到视觉输出结果, MessageLevel.Error);
+                        return (false, "");
+                    }
+
+                    // 2. 获取视觉输出结果
+                    bool Found = (bool)(outputCollection["Found"].Value);
+                    if (!Found)
+                    {
+                        SendTaskMessage(Lang.拍照NG, MessageLevel.Debug);
+                        continue;
+                    }
+
+                    SendTaskMessage(Lang.拍照OK, MessageLevel.Debug);
+
+                    LogHelper.WriteLogInfo("开始获取视觉输出结果");
+                    string dis = (string)(outputCollection["CC"].Value);
+                    return (true, dis);
+                }
+                SendTaskMessage(Lang.多次拍照失败, MessageLevel.Alarm);
+                return (false, "");
+            }
+            catch (Exception ex)
+            {
+                LogHelper.WriteLogError("执行相机取图并获取单点位时出错!", ex);
+                return (false, "");
+            }
+            finally
+            {
+                await TurnOffLightAfterPhoto(procedure);
+
+            }
+        }
 
         /// <summary>
         /// 记录拍照结果数据至数据库