Просмотр исходного кода

拍照功能支持拍照编号记录与展示

本次提交为拍照相关流程增加了“拍照编号”(PositionIndex)参数,涵盖接口、服务、数据记录、导出及前端展示。通过在调用链、数据库实体、导出CSV及界面中引入PositionIndex,实现了对多相机/多位置拍照任务的编号管理,提升了数据追溯性和管理精度。
徐孝锋 7 месяцев назад
Родитель
Сommit
233581bd6c

+ 3 - 3
TeamAAS-VM/Core/Management.cs

@@ -1328,7 +1328,7 @@ namespace TeamAAS_VP.Core
 
                             // 执行视觉任务
                             var _cts = new CancellationTokenSource();
-                            var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, null, _cts.Token, null);
+                            var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, null, _cts.Token, cameraIndex, null);
                             if (visionResult.IsSucceed)
                             {
                                 //披头偏差
@@ -1395,7 +1395,7 @@ namespace TeamAAS_VP.Core
 
                             // 执行视觉任务
                             var _cts = new CancellationTokenSource();
-                            var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, null, _cts.Token, null);
+                            var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, null, _cts.Token, cameraIndex, null);
                             if (visionResult.IsSucceed)
                             {
                                 //披头偏差
@@ -1502,7 +1502,7 @@ namespace TeamAAS_VP.Core
 
                             // 执行视觉任务
                             var _cts = new CancellationTokenSource();
-                            var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token, null);
+                            var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token, cameraIndex, null);
                             if (visionResult.IsSucceed)
                             {
                                 //是拍一个锁一个还是拍两个点锁所有

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

@@ -255,8 +255,10 @@ namespace TeamAAS_VP.Interfaces
         /// <param name="InputTerminal"></param>
         /// <param name="robotCoord"></param>
         /// <param name="cancellationToken"></param>
+        /// <param name="positionIndex"></param>
+        /// <param name="remark"></param>
         /// <returns></returns>
-        Task<(bool IsSucceed, double X, double Y, double U)> ExecutePhotoGetSinglePoint(ProcedureModel procedure, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken, string remark);
+        Task<(bool IsSucceed, double X, double Y, double U)> ExecutePhotoGetSinglePoint(ProcedureModel procedure, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken, int positionIndex, string remark);
 
         /// <summary>
         /// 执行相机拍照获取单个点位结果,并且返回图像和图形

+ 5 - 0
TeamAAS-VM/Models/PhotoCaptureRecord.cs

@@ -38,6 +38,11 @@ namespace TeamAAS_VP.Models
         [SugarColumn(Length = 255, IsNullable = true)]
         public string ProcessName { get; set; }
 
+        /// <summary>
+        /// λÖñàºÅ
+        /// </summary>
+        public int PositionIndex { get; set; }
+
         /// <summary>
         /// ÊÇ·ñ³É¹¦
         /// </summary>

+ 10 - 7
TeamAAS-VM/Services/RemoteCommandService.cs

@@ -1765,8 +1765,10 @@ namespace TeamAAS_VP.Services
         /// <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, double X, double Y, double U)> ExecutePhotoGetSinglePoint(ProcedureModel procedure, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken, string remark)
+        public async Task<(bool IsSucceed, double X, double Y, double U)> ExecutePhotoGetSinglePoint(ProcedureModel procedure, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken, int positionIndex, string remark)
         {
             DateTime nowtime = DateTime.Now;
             await SetLightBeforePhoto(procedure);
@@ -1788,7 +1790,7 @@ namespace TeamAAS_VP.Services
                     if (!outputCollection.Contains("Found"))
                     {
                         SendTaskMessage(Lang.未找到视觉输出结果, MessageLevel.Error);
-                        await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, remark);
+                        await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
                         return (false, 0, 0, 0);
                     }
 
@@ -1817,20 +1819,20 @@ namespace TeamAAS_VP.Services
                     var calibResult = _calibrationService.ConvertPixelToPosition((_pixel_x, _pixel_y, _pixel_u), robotCoord, calib, RobotBrand.XYZ_Platform);
                     if (!calibResult.IsSucceed)
                     {
-                        await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { _pixel_x, _pixel_y, _pixel_u }, new double[] { 0, 0, 0 }, string.Empty, remark);
+                        await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { _pixel_x, _pixel_y, _pixel_u }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
                         return (false, 0, 0, 0);
                     }
-                    await RecordPhotoCaptureAsync(procedure, robotCoord,true, new double[] { _pixel_x, _pixel_y, _pixel_u }, new double[] { calibResult.X, calibResult.Y, calibResult.U }, string.Empty, remark);
+                    await RecordPhotoCaptureAsync(procedure, robotCoord,true, new double[] { _pixel_x, _pixel_y, _pixel_u }, new double[] { calibResult.X, calibResult.Y, calibResult.U }, string.Empty, positionIndex, remark);
                     return (true, calibResult.X, calibResult.Y, calibResult.U);
                 }
                 SendTaskMessage(Lang.多次拍照失败, MessageLevel.Alarm);
-                await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, remark);
+                await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
                 return (false, 0, 0, 0);
             }
             catch (Exception ex)
             {
                 LogHelper.WriteLogError(Lang.执行相机取图并获取单点位时出错, ex);
-                await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, remark);
+                await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
                 return (false, 0, 0, 0);
             }
             finally
@@ -1849,9 +1851,10 @@ namespace TeamAAS_VP.Services
         /// <param name="pixelPosition"></param>
         /// <param name="absolutePosition"></param>
         /// <param name="imagePath"></param>
+        /// <param name="positionIndex"></param>
         /// <param name="emarks"></param>
         /// <returns></returns>
-        private async Task RecordPhotoCaptureAsync(ProcedureModel procedure, double[] robotCoord, bool isSuccess, double[] pixelPosition, double[] absolutePosition, string imagePath, string emarks)
+        private async Task RecordPhotoCaptureAsync(ProcedureModel procedure, double[] robotCoord, bool isSuccess, double[] pixelPosition, double[] absolutePosition, string imagePath, int positionIndex, string emarks)
         {
             try
             {

+ 2 - 1
TeamAAS-VM/ViewModels/Statistics/PhotoCaptureQueryViewModel.cs

@@ -150,7 +150,7 @@ namespace TeamAAS_VP.ViewModels.Statistics
                 var path = dlg.FileName;
                 using (var sw = new StreamWriter(path, false, Encoding.UTF8))
                 {
-                    sw.WriteLine("Id,CaptureTime,RecipeName,ProcessName,CameraName,ProductSN,IsSuccess,RobotPosition,PixelPosition,AbsolutePosition,ImagePath,OperatorName,Remarks");
+                    sw.WriteLine("Id,CaptureTime,RecipeName,ProcessName,CameraName,ProductSN,PositionIndex,IsSuccess,RobotPosition,PixelPosition,AbsolutePosition,ImagePath,OperatorName,Remarks");
                     foreach (var r in all)
                     {
                         sw.WriteLine(string.Join(",",
@@ -160,6 +160,7 @@ namespace TeamAAS_VP.ViewModels.Statistics
                             EscapeCsv(r.ProcessName),
                             EscapeCsv(r.CameraName),
                             EscapeCsv(r.ProductSN),
+                            EscapeCsv(r.PositionIndex.ToString()),
                             EscapeCsv(r.IsSuccess ? "1" : "0"),
                             EscapeCsv(r.RobotPosition),
                             EscapeCsv(r.PixelPosition),

+ 2 - 0
TeamAAS-VM/Views/Statistics/PhotoCaptureQuery.xaml

@@ -96,6 +96,8 @@
                                     Binding="{Binding CameraName}" />
                 <DataGridTextColumn Header="产品SN"
                                     Binding="{Binding ProductSN}" />
+                <DataGridTextColumn Header="拍照编号"
+                                    Binding="{Binding PositionIndex}" />
                 <!-- Changed to TemplateColumn to show OK/NG with color -->
                 <DataGridTemplateColumn Header="是否成功"
                                         Width="85">