wanghan 7 mēneši atpakaļ
vecāks
revīzija
0b791e0532
2 mainītis faili ar 36 papildinājumiem un 23 dzēšanām
  1. 33 20
      TeamAAS-VM/Core/Management.cs
  2. 3 3
      TeamAAS-VM/Views/SettingView.xaml

+ 33 - 20
TeamAAS-VM/Core/Management.cs

@@ -1499,8 +1499,17 @@ namespace TeamAAS_VP.Core
                             var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token, null);
                             if (visionResult.IsSucceed)
                             {
-                                UpCameraPutResults[cameraIndex] = new PointF((float)visionResult.X, (float)visionResult.Y);
-
+                                //是拍一个锁一个还是拍两个点锁所有
+                                var systemConfig = _configService.GetSystemConfiguration();
+                                //拍1打1 
+                                if (systemConfig.WorkMode == 1)
+                                {
+                                    UpCameraPutResults[1] = new PointF((float)visionResult.X, (float)visionResult.Y);
+                                }
+                                else
+                                {
+                                    UpCameraPutResults[cameraIndex] = new PointF((float)visionResult.X, (float)visionResult.Y);
+                                }
 
                                 await plc.WriteNodeAsync(addressConfig.Out_UpCameraPutStatus.Address, (Int16)1);
                             }
@@ -1765,17 +1774,17 @@ namespace TeamAAS_VP.Core
                             //吸嘴数量+1
                             NumStatistics.NozzleNum = await _systemDatabaseService.IncrementLatestNozzleLockCountAsync(currentUserName);
 
-                        
-                        await plc.WriteNodeAsync(addressConfig.In_WorkDone.Address, (Int16)0);
-                        // 停止采集压力并保存
-                        await StopAndSavePressureCollectionAsync(currentProduct.Name, _productService.CurrentProductCode, positionIndex);
-                    }
-                    else
-                    {
-                        SendTaskMessage(Lang.停止锁付信号已关闭, MessageLevel.Alarm);
+
+                            await plc.WriteNodeAsync(addressConfig.In_WorkDone.Address, (Int16)0);
+                            // 停止采集压力并保存
+                            await StopAndSavePressureCollectionAsync(currentProduct.Name, _productService.CurrentProductCode, positionIndex);
+                        }
+                        else
+                        {
+                            SendTaskMessage(Lang.停止锁付信号已关闭, MessageLevel.Alarm);
+                        }
                     }
                 }
-            }
                 // 多相机坐标合并
                 else if (addressConfig.In_RequestPosition.Address.Contains(tuple.nodeId))
                 {
@@ -1792,14 +1801,17 @@ namespace TeamAAS_VP.Core
                         if (state == 1)
                         {
                             SendTaskMessage(Lang.收到多相机坐标合并请求开始合并, MessageLevel.Debug);
+                            //位置编号
+                            Int16 positionIndex = plc.ReadNode<Int16>(addressConfig.In_ProductNum.Address);
                             //是拍一个锁一个还是拍两个点锁所有
                             var systemConfig = _configService.GetSystemConfiguration();
                             //拍1打1 
                             if (systemConfig.WorkMode == 1)
                             {
-                                currentProduct.ScrewPoints[0].X_Position = UpCameraPutResults[1].X + DowmCameraResults[0].X;
-                                currentProduct.ScrewPoints[0].Y_Position = UpCameraPutResults[1].Y + DowmCameraResults[0].Y;
-                                await currentProduct.ScrewPoints[0].WriteToPlcAddress(addressConfig.Out_Screw, plc);
+                                var point = currentProduct.ScrewPoints[positionIndex-1].Clone();
+                                point.X_Position = UpCameraPutResults[1].X + DowmCameraResults[1].X;
+                                point.Y_Position = UpCameraPutResults[1].Y + DowmCameraResults[1].Y;
+                                await point.WriteToPlcAddress(addressConfig.Out_Screw, plc);
                             }
                             //拍1打所有
                             else if (systemConfig.WorkMode == 2)
@@ -1867,7 +1879,7 @@ namespace TeamAAS_VP.Core
                         }
                     }
                 }
-                
+
                 // 过站检查
                 else
                 {
@@ -1932,7 +1944,6 @@ namespace TeamAAS_VP.Core
                                     swCT.Stop();
                                     CTtime = Math.Round(swCT.Elapsed.TotalSeconds, 3);
                                     WriteProductLog(lockResultsAll, code, CTtime);
-                                    lockResultsAll.Clear();
                                 }
                                 else
                                 {
@@ -1970,7 +1981,7 @@ namespace TeamAAS_VP.Core
         /// <param name="productName">配方名称</param>
         /// <param name="productCode">产品编号</param>
         /// <param name="positionIndex">锁付点编号</param>
-        private void StartPressureCollection(string productName,string productCode, int positionIndex)
+        private void StartPressureCollection(string productName, string productCode, int positionIndex)
         {
             try
             {
@@ -2016,7 +2027,7 @@ namespace TeamAAS_VP.Core
                     if (_pressureTimeoutCts.IsCancellationRequested && !_pressureCts.IsCancellationRequested)
                     {
                         SendTaskMessage("Pressure collection timed out, saving collected data.", MessageLevel.Alarm);
-                        await StopAndSavePressureCollectionAsync(productName, productCode,positionIndex);
+                        await StopAndSavePressureCollectionAsync(productName, productCode, positionIndex);
                     }
                 }, token);
             }
@@ -2164,7 +2175,7 @@ namespace TeamAAS_VP.Core
         /// 产品锁付记录进行存储
         /// </summary>
         /// <param name="result">结果</param>
-        public void WriteProductLog(List<LockResult> lockResults,string rfid,double ct)
+        public void WriteProductLog(List<LockResult> lockResults, string rfid, double ct)
         {
             try
             {
@@ -2183,7 +2194,7 @@ namespace TeamAAS_VP.Core
                 string path = $"E:\\Data\\生产数据\\{dt.ToString("yyyy-MM")}\\{dt.ToString("yyyy-MM-dd")}.csv";
                 StringBuilder sb = new StringBuilder();
                 //具体的ct需要优化
-                sb.Append($"{dt.ToString("yyyy-MM-dd HH:mm:ss")},{lockResults[0].ProductName},{Math.Round(ct, 3)},{rfid},{result},{lockResults[number-1].NozzleNumber},{lockResults[number - 1].HeadNumber},");
+                sb.Append($"{dt.ToString("yyyy-MM-dd HH:mm:ss")},{lockResults[0].ProductName},{Math.Round(ct, 3)},{rfid},{result},{lockResults[number - 1].NozzleNumber},{lockResults[number - 1].HeadNumber},");
                 foreach (var item in lockResults)
                 {
                     try
@@ -2230,6 +2241,8 @@ namespace TeamAAS_VP.Core
             {
                 LogHelper.WriteLogError("写入产品记录时出错!", ex);
             }
+
+            lockResultsAll.Clear();
         }
         #endregion
 

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

@@ -2324,7 +2324,7 @@
                                            Minimum="0"
                                            Maximum="100"
                                            FontSize="{DynamicResource Font.Size.Body3}"
-                                           materialDesign:HintAssist.HelperTextFontSize="6"
+                                           materialDesign:HintAssist.HelperTextFontSize="10"
                                            materialDesign:HintAssist.HelperText="1:拍1打1 - 2:拍1打所有" />
 
                         <!-- 取料位置 -->
@@ -2343,7 +2343,7 @@
                                            Minimum="0"
                                            Maximum="100"
                                            FontSize="{DynamicResource Font.Size.Body3}"
-                                           materialDesign:HintAssist.HelperTextFontSize="6"
+                                           materialDesign:HintAssist.HelperTextFontSize="10"
                                            materialDesign:HintAssist.HelperText="0:不需要取料 - 1:需要取料" />
                         <!-- 披头矫正的模式 -->
                         <TextBlock Grid.Row="9"
@@ -2361,7 +2361,7 @@
                                            Maximum="100"
                                            FontSize="{DynamicResource Font.Size.Body3}"
                                            ToolTip="1:初始化时矫正,2:每个产品矫正一次,3:每颗螺丝矫正一次"
-                                           materialDesign:HintAssist.HelperTextFontSize="6"
+                                           materialDesign:HintAssist.HelperTextFontSize="10"
                                            materialDesign:HintAssist.HelperText="1:初始化时矫正,2:每个产品矫正一次,3:每颗螺丝矫正一次" />
 
                         <CheckBox Grid.Row="10"