刘锦天 5 ay önce
ebeveyn
işleme
c264fdf28d

+ 96 - 79
TeamAAS-VM/Core/Management.cs

@@ -1,5 +1,7 @@
 using Cognex.VisionPro;
 using CSScripting;
+using NPOI.Util;
+
 //using ICSharpCode.SharpZipLib.Zip;
 using Prism.Events;
 using Prism.Ioc;
@@ -2234,7 +2236,8 @@ namespace TeamAAS_VP.Core
                                 {
                                     if (item.IsSucceed)
                                     {
-                                        _PrcTaskList.Add(ExecuteProcedureAsync(item.cameraIndex, item.procedureId, item.Images));
+                                        bool Is3d = Is3D(item.procedureId);
+                                        _PrcTaskList.Add(ExecuteProcedureAsync(item.cameraIndex, item.procedureId, item.Images, Is3d));
                                         //_PrcTaskList.Add(ExecuteProcedureAsync(cameraIndex, prcId, imageData.imges));
                                     }
                                     else
@@ -2520,6 +2523,18 @@ namespace TeamAAS_VP.Core
                                         {
                                             foreach (var item in lockResultsAll)
                                             {
+                                                for (int k = 1; k <=8; k++)
+                                                {
+                                                    if (item.PhotoName == "-"+"_"+k.ToString())
+                                                    {
+                                                        item.PhotoName = "'-" + "_" + k.ToString();
+                                                    }
+                                                    if (item.PhotoName == "=" + "_" + k.ToString())
+                                                    {
+                                                        item.PhotoName = "'=" + "_" + k.ToString();
+                                                    }
+                                                }
+                                                
                                                 DFC.Add(new DataFormCtq
                                                 {
                                                     PPID = ppid,
@@ -2555,30 +2570,33 @@ namespace TeamAAS_VP.Core
                                                 //上传数据
                                                 try
                                                 {
-                                                    DateTime dt = DateTime.Now;
-                                                    string filename = $"{ProductMainSN}_{dt.ToString("yyyyMMddHHmmss")}";
-                                                    var device = _configService.GetDeviceInfo();
-                                                    (bool isSuc, string resp) = await _mesService.SendFtpFileAsync(ProductMainSN, filename);
-                                                    if (isSuc)
-                                                    {
-                                                        LogHelper.WriteLogMes($"上传数据成功");
-                                                        SendTaskMessage($"上传数据成功", MessageLevel.Debug);
-                                                        string filePath = $"D:\\Image\\Recored\\{dt.ToString("yyyy-MM")}\\{dt.ToString("MM-dd")}\\{currentProduct.Name}\\{ProductMainSN[i]}";
-                                                        //复制csv
-                                                        string source_csv = $"{stationConfig.SaveCsvPath}\\{dt.ToString("yyyy-MM")}\\{i}_{stationConfig.DeviceName}_{dt.ToString("yyyy-MM-dd")}.csv";
-                                                        string target_csv = Path.Combine(filePath, Path.GetFileName(source_csv)); ;
-                                                        File.Copy(source_csv, target_csv, true);
-                                                        //复制log
-                                                        string source_log = $"..\\Log\\LogInfo\\{dt.ToString("yyyy-MM")}\\{dt.ToString("yyyy-MM-dd")}.txt";
-                                                        string target_log = Path.Combine(filePath, Path.GetFileName(source_log));
-                                                        File.Copy(source_log, target_log, true);
-                                                        CompressionImage(filePath, filename, device.Station, device.FixtureId);
-                                                    }
-                                                    else
+                                                    if (stationConfig.EnableMES)
                                                     {
-                                                        LogHelper.WriteLogMes($"上传数据失败");
-                                                        SendTaskMessage($"上传数据失败", MessageLevel.Error);
-                                                    }
+                                                        DateTime dt = DateTime.Now;
+                                                        string filename = $"{ProductMainSN}_{dt.ToString("yyyyMMddHHmmss")}";
+                                                        var device = _configService.GetDeviceInfo();
+                                                        (bool isSuc, string resp) = await _mesService.SendFtpFileAsync(ProductMainSN, filename);
+                                                        if (isSuc)
+                                                        {
+                                                            LogHelper.WriteLogMes($"上传数据成功");
+                                                            SendTaskMessage($"上传数据成功", MessageLevel.Debug);
+                                                            string filePath = $"D:\\Image\\Recored\\{dt.ToString("yyyy-MM")}\\{dt.ToString("MM-dd")}\\{currentProduct.Name}\\{ProductMainSN[i]}";
+                                                            //复制csv
+                                                            string source_csv = $"{stationConfig.SaveCsvPath}\\{dt.ToString("yyyy-MM")}\\{i}_{stationConfig.DeviceName}_{dt.ToString("yyyy-MM-dd")}.csv";
+                                                            string target_csv = Path.Combine(filePath, Path.GetFileName(source_csv)); ;
+                                                            File.Copy(source_csv, target_csv, true);
+                                                            //复制log
+                                                            string source_log = $"..\\Log\\LogInfo\\{dt.ToString("yyyy-MM")}\\{dt.ToString("yyyy-MM-dd")}.txt";
+                                                            string target_log = Path.Combine(filePath, Path.GetFileName(source_log));
+                                                            File.Copy(source_log, target_log, true);
+                                                            CompressionImage(filePath, filename, device.Station, device.FixtureId);
+                                                        }
+                                                        else
+                                                        {
+                                                            LogHelper.WriteLogMes($"上传数据失败");
+                                                            SendTaskMessage($"上传数据失败", MessageLevel.Error);
+                                                        }
+                                                    }    
                                                 }
                                                 catch (Exception ex)
                                                 {
@@ -2793,7 +2811,7 @@ namespace TeamAAS_VP.Core
         /// <param name="pointIndex"></param>
         /// <param name="procedureId"></param>
         /// <returns></returns>
-        private Task<(bool IsSucceed, bool[] Result, string Message)> ExecuteProcedureAsync(int pointIndex, Guid procedureId, ICogImage[] images)
+        private Task<(bool IsSucceed, bool[] Result, string Message)> ExecuteProcedureAsync(int pointIndex, Guid procedureId, ICogImage[] images,bool is3dmodel)
         {
             return Task.Run(async () =>
             {
@@ -2848,7 +2866,7 @@ namespace TeamAAS_VP.Core
                             await _remoteCommandService.TurnOffLightAfterPhoto(selectedProcedure);
                         }
                         //1. 执行拍照,图像处理
-                        var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint1(selectedProcedure, images, null, null, ctsAll.Token);
+                        var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint1(selectedProcedure, images, null, null, ctsAll.Token,is3dmodel);
                         if (visionResult.Count == 0)
                         {
                             SendTaskMessage("Count值为0", MessageLevel.Alarm);
@@ -2856,43 +2874,45 @@ namespace TeamAAS_VP.Core
                         }
 
                         //2. 结果分析
-                        for (int i = 1; i <= visionResult.Count; i++)
+                        lock (_stateLock)
                         {
+                            for (int i = 1; i <= visionResult.Count; i++)
+                            {
 
-                            LockResult lockResult1 = new LockResult();
-                            //if (pointIndex == currentProduct.PhotoCount && selectedProcedure.Id == currentProduct.FixedUpCamera1ProcedureId && i == 1)
-                            //{
-                            //    lockResult1.Number = 1;
-                            //    lock (_stateLock)
-                            //    {
-                            //        lockResultsAll.Clear();
-                            //    }
-                                
-                            //}
+                                LockResult lockResult1 = new LockResult();
+                                //if (pointIndex == currentProduct.PhotoCount && selectedProcedure.Id == currentProduct.FixedUpCamera1ProcedureId && i == 1)
+                                //{
+                                //    lockResult1.Number = 1;
+                                //    lock (_stateLock)
+                                //    {
+                                //        lockResultsAll.Clear();
+                                //    }
 
-                            string[] strpoints1 = visionResult.Items[i].Split(',');
-                            string[] body1 = strpoints1[1].Split(";");
-                            if (body1.Length > 1)
-                            {
-                                for (int j = 1; j <= body1.Length; j++)
+                                //}
+
+                                string[] strpoints1 = visionResult.Items[i].Split(',');
+                                string[] body1 = strpoints1[1].Split(";");
+                                if (body1.Length > 1)
                                 {
-                                    lockResult1.PhotoName = strpoints1[0] + j.ToString();
-                                    lockResult1.ResultData = body1[j - 1];
-                                    lockResult1.PhotoCode = ProductMainSN;
-                                    var globalParam = currentProduct.GlobalParamListCollection.FirstOrDefault(p => p.Name == strpoints1[0]);
-                                    if (globalParam != null)
+                                    for (int j = 1; j <= body1.Length; j++)
                                     {
-                                        lockResult1.UpLimit = globalParam.Param1;
-                                        lockResult1.DownLimit = globalParam.Param2;
-                                        lockResult1.MidLimit = globalParam.Param5;
-                                        string ResData = strpoints1[1];
-                                        if (ResData.Contains("NA"))
+                                        lockResult1.PhotoName = strpoints1[0] + "_" + j.ToString();
+                                        lockResult1.ResultData = body1[j - 1];
+                                        lockResult1.PhotoCode = ProductMainSN;
+                                        var globalParam = currentProduct.GlobalParamListCollection.FirstOrDefault(p => p.Name == strpoints1[0]);
+                                        if (globalParam != null)
                                         {
-                                            ResData = "-1000";
-                                        }
-                                        
-                                        bool resultflog = true;
-                                            if (Convert.ToDouble(lockResult1.ResultData) >= Convert.ToDouble(globalParam.Param2) && Convert.ToDouble(lockResult1.ResultData) <= Convert.ToDouble(globalParam.Param1))
+                                            lockResult1.UpLimit = globalParam.Param1;
+                                            lockResult1.DownLimit = globalParam.Param2;
+                                            lockResult1.MidLimit = globalParam.Param5;
+                                            string ResData = body1[j - 1];
+                                            if (ResData.Contains("NA"))
+                                            {
+                                                ResData = "-1000";
+                                            }
+
+                                            bool resultflog = true;
+                                            if (Convert.ToDouble(ResData) >= Convert.ToDouble(globalParam.Param2) && Convert.ToDouble(ResData) <= Convert.ToDouble(globalParam.Param1))
                                             {
 
                                             }
@@ -2900,25 +2920,23 @@ namespace TeamAAS_VP.Core
                                             {
                                                 resultflog = false;
                                             }
-                                        if (resultflog)
-                                        {
-                                            lockResult1.PhotoPassed = "OK";
-                                            results.Add(true);
-                                        }
-                                        else
-                                        {
-                                            lockResult1.PhotoPassed = "NG";
-                                            results.Add(false);
+                                            if (resultflog)
+                                            {
+                                                lockResult1.PhotoPassed = "OK";
+                                                results.Add(true);
+                                            }
+                                            else
+                                            {
+                                                lockResult1.PhotoPassed = "NG";
+                                                results.Add(false);
+                                            }
+                                            
                                         }
-                                    }
-                                    lock (_stateLock)
-                                    {
-                                        lockResultsAll.Add(lockResult1);
+                                        lockResultsAll.Add(lockResult1.Copy());
                                     }
                                 }
-                            }
-                            else
-                            {
+                                else
+                                {
                                     lockResult1.PhotoName = strpoints1[0];
                                     lockResult1.ResultData = strpoints1[1];
                                     lockResult1.PhotoCode = ProductMainSN;
@@ -2935,7 +2953,7 @@ namespace TeamAAS_VP.Core
                                         }
 
                                         bool resultflog = true;
-                                        if (Convert.ToDouble(lockResult1.ResultData) >= Convert.ToDouble(globalParam.Param2) && Convert.ToDouble(lockResult1.ResultData) <= Convert.ToDouble(globalParam.Param1))
+                                        if (Convert.ToDouble(ResData) >= Convert.ToDouble(globalParam.Param2) && Convert.ToDouble(ResData) <= Convert.ToDouble(globalParam.Param1))
                                         {
 
                                         }
@@ -2954,17 +2972,16 @@ namespace TeamAAS_VP.Core
                                             results.Add(false);
                                         }
                                     }
-                                    lock (_stateLock)
-                                    {
-                                        lockResultsAll.Add(lockResult1);
-                                    }
-                            }
+                                    lockResultsAll.Add(lockResult1);
+                                }
 
                                 App.Current.Dispatcher.Invoke(() =>
                                 {
                                     _eventAggregator.GetEvent<LockFinishNotification>().Publish(lockResult1);
                                 });
+                            }
                         }
+                        
 
                         ////排序
                         //lock (_stateLock)

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

@@ -275,7 +275,7 @@ namespace TeamAAS_VP.Interfaces
         /// <param name="robotCoord"></param>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        Task<(bool IsSucceed, string[] Items, double Count)> ExecutePhotoGetSinglePoint1(ProcedureModel procedure, ICogImage[] imges, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken);
+        Task<(bool IsSucceed, string[] Items, double Count)> ExecutePhotoGetSinglePoint1(ProcedureModel procedure, ICogImage[] imges, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken,bool is3dmodel);
 
         /// <summary>
         /// 执行相机拍照获取单个点位结果

+ 10 - 0
TeamAAS-VM/Models/SystemConfiguration.cs

@@ -445,5 +445,15 @@ namespace TeamAAS_VP.Models
             get => _AxisPassUse;
             set => SetProperty(ref _AxisPassUse, value);
         }
+
+        private bool _LightUse;
+        /// <summary>
+        /// šâÔ´ĘǡńĘšÓĂ
+        /// </summary>
+        public bool LightUse
+        {
+            get => _LightUse;
+            set => SetProperty(ref _LightUse, value);
+        }
     }
 }

+ 16 - 5
TeamAAS-VM/Services/RemoteCommandService.cs

@@ -1786,7 +1786,7 @@ namespace TeamAAS_VP.Services
         /// 执行相机拍照并运行 ToolBlock,返回是否成功并通过 out 参数返回 Outputs。
         /// 该方法会发布 RenderUpdateNotification 以更新 UI。
         /// </summary>
-        public bool ExecutePhoto(ProcedureModel procedure,ICogImage[] imges,Dictionary<string, string> InputTerminal, out CogToolBlockTerminalCollection outputCollection)
+        public bool ExecutePhoto(ProcedureModel procedure,ICogImage[] imges,Dictionary<string, string> InputTerminal, out CogToolBlockTerminalCollection outputCollection,bool is3dmodel)
         {
             try
             {
@@ -1864,7 +1864,7 @@ namespace TeamAAS_VP.Services
                         IsCompress = procedure.IsCompress,
                         ProceductName = procedure.Name,
                         ImageFileName = imgName,
-                        Is3DModel=false
+                        Is3DModel= is3dmodel
                     });
                     return true;
                 }
@@ -1906,7 +1906,7 @@ namespace TeamAAS_VP.Services
                         SavePath = procedure.SavePath,
                         ProceductName = procedure.Name,
                         ImageFileName = imgName,
-                        Is3DModel = false
+                        Is3DModel = is3dmodel
                     });
                     return false;
                 }
@@ -1977,7 +1977,7 @@ namespace TeamAAS_VP.Services
         /// <param name="robotCoord"></param>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        public async Task<(bool IsSucceed, string[] Items, double Count)> ExecutePhotoGetSinglePoint1(ProcedureModel procedure, ICogImage[] imges, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken)
+        public async Task<(bool IsSucceed, string[] Items, double Count)> ExecutePhotoGetSinglePoint1(ProcedureModel procedure, ICogImage[] imges, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken,bool is3dmodel)
         {
             DateTime nowtime = DateTime.Now;
             try
@@ -1989,7 +1989,7 @@ namespace TeamAAS_VP.Services
                     SendTaskMessage(Lang.开始执行视觉流程.Replace("{0}", $"{i + 1}").Replace("{1}", procedure.Name), MessageLevel.Info);
 
                     // 1. 执行相机拍照并运行视觉工具
-                    bool visionSucceed = ExecutePhoto(procedure, imges, InputTerminal, out CogToolBlockTerminalCollection outputCollection);
+                    bool visionSucceed = ExecutePhoto(procedure, imges, InputTerminal, out CogToolBlockTerminalCollection outputCollection, is3dmodel);
                     if (!visionSucceed)
                     {
                         SendTaskMessage(Lang.视觉任务执行失败, MessageLevel.Error);
@@ -2917,6 +2917,12 @@ namespace TeamAAS_VP.Services
         /// <returns></returns>
         public async Task SetLightBeforePhoto(ProcedureModel procedure)
         {
+            var sysConfig = _configService.GetSystemConfiguration();
+            if (sysConfig.LightUse == true)
+            {
+                return;
+            }
+               
             //判断当前流程是否启用光源控制
             if (procedure.IsControlLightChannels)
             {
@@ -2945,6 +2951,11 @@ namespace TeamAAS_VP.Services
         /// <returns></returns>
         public async Task TurnOffLightAfterPhoto(ProcedureModel procedure)
         {
+            var sysConfig = _configService.GetSystemConfiguration();
+            if (sysConfig.LightUse == true)
+            {
+                return;
+            }
             //判断当前流程是否启用光源控制
             if (procedure.IsControlLightChannels)
             {

+ 2 - 2
TeamAAS-VM/Views/SettingView.xaml

@@ -635,7 +635,7 @@
                        VerticalAlignment="Center" />
                     <TextBox Grid.Row="9"
                          Grid.Column="1"
-                         Text="{Binding SelectDeviceInfo.LogUrl, Mode=TwoWay}"
+                         Text="{Binding DeviceInfo.LogUrl, Mode=TwoWay}"
                          Margin="6,2" />
 
                     <TextBlock Grid.Row="10"
@@ -645,7 +645,7 @@
                        VerticalAlignment="Center" />
                     <TextBox Grid.Row="10"
                          Grid.Column="1"
-                         Text="{Binding SelectDeviceInfo.ApiKey, Mode=TwoWay}"
+                         Text="{Binding DeviceInfo.ApiKey, Mode=TwoWay}"
                          Margin="6,2" />