Explorar el Código

修改压力曲线显示

wanghan hace 7 meses
padre
commit
b281131f83

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

@@ -1231,8 +1231,8 @@ namespace TeamAAS_VP.Core
                                         float toolX = (float)(visionResult.X - currentPosition.X);
                                         float toolY = (float)(visionResult.Y - currentPosition.Y);
 
-                                        DowmCameraResults[cameraIndex] = new OpenCvSharp.Point3f(toolX, toolX, (float)visionResult.U);
-                                        DownTool = new PointF(toolX, toolX);
+                                        DowmCameraResults[cameraIndex] = new OpenCvSharp.Point3f(toolX, toolY, (float)visionResult.U);
+                                        DownTool = new PointF(toolX, toolY);
                                         await plc.WriteNodeAsync(addressConfig.Out_DownCameraStatus.Address, (Int16)1);
                                         return;
                                     }
@@ -2278,16 +2278,16 @@ namespace TeamAAS_VP.Core
                                 }
                                 else
                                 {
-                                    //SendTaskMessage($"开始锁付信号[{i}]已关闭", MessageLevel.Alarm);
+                                    SendTaskMessage($"开始保压信号[{i}]已关闭", MessageLevel.Alarm);
                                     //// 关闭时的处理(如需)可放在这里
-                                    SendTaskMessage($"收到关闭保压信号[{i}]...", MessageLevel.Debug);
-                                    // 停止采集压力并保存
-                                    await StopAndSavePressureCollectionAsync(currentProduct.Name, code, i);
+                                    //SendTaskMessage($"收到关闭保压信号[{i}]...", MessageLevel.Debug);
+                                    //// 停止采集压力并保存
+                                    //await StopAndSavePressureCollectionAsync(currentProduct.Name, code, i);
                                 }
                             }
                         }
                         //停止组装
-                        /*else if (string.Format(addressConfig.In_WorkStart.Address, i).Contains(tuple.nodeId))
+                        else if (string.Format(addressConfig.In_WorkDone.Address, i).Contains(tuple.nodeId))
                         {
                             if (tuple.value is Int16 state)
                             {
@@ -2299,9 +2299,9 @@ namespace TeamAAS_VP.Core
                                 {
                                     return;
                                 }
-                                if (state == 1 || state == 2)
+                                if (state == 1)
                                 {
-                                    SendTaskMessage($"收到停止锁付信号[{i}]...", MessageLevel.Debug);
+                                    SendTaskMessage($"收到停止压力信号[{i}]...", MessageLevel.Debug);
                                     //获取当前锁付点
                                     //var screwPoint = currentProduct.ScrewPoints.FirstOrDefault(p => p.Number == positionIndex);
                                     ////获取当前的机器人点位
@@ -2351,10 +2351,10 @@ namespace TeamAAS_VP.Core
                                 }
                                 else
                                 {
-                                    SendTaskMessage($"停止锁付信号[{i}]已关闭", MessageLevel.Alarm);
+                                    SendTaskMessage($"停止压力信号[{i}]已关闭", MessageLevel.Alarm);
                                 }
                             }
-                        }*/
+                        }
                     }
                 }
             }

+ 1 - 1
TeamAAS-VM/Models/PLC/PlcAddressConfig.cs

@@ -997,7 +997,7 @@ namespace TeamAAS_VP.Models.PLC
             In_WorkStart.Description = "锁附/组装开始 =1";
 
             In_WorkDone = Ensure(In_WorkDone);
-            In_WorkDone.Address = "ns=4;s=DB_Communication|ToPC.WorkStart[{0}]";
+            In_WorkDone.Address = "ns=4;s=DB_Communication|ToPC.WorkDone[{0}]";
             In_WorkDone.DataType = "int16";
             In_WorkDone.Description = "锁附/组装结束 =1OK =2NG";
 

+ 21 - 18
TeamAAS-VM/Views/Home/ShowVisionRender.xaml.cs

@@ -81,17 +81,20 @@ namespace TeamAAS_VP.Views.Home
                             {
                                 // 注意:CreateContentBitmap 可能比较耗时,但你这里已经在 UI 线程里调用了;
                                 // 如果卡顿明显,建议把 bitmap 生成放到后台线程(需谨慎处理线程访问)
-                                var bmp = (Bitmap)disp.CreateContentBitmap(Cognex.VisionPro.Display.CogDisplayContentBitmapConstants.Custom);
-
-                                SaveImage(
-                                    render.SaveImageModel,
-                                    render.SaveImagePathModel,
-                                    render.SavePath,
-                                    render.Image,
-                                    bmp,
-                                    render.Result,
-                                    render.IsCompress
-                                );
+                                App.Current.Dispatcher.BeginInvoke(new Action(() =>
+                                {
+                                    var bmp = (Bitmap)disp.CreateContentBitmap(Cognex.VisionPro.Display.CogDisplayContentBitmapConstants.Custom);
+
+                                    SaveImage(
+                                        render.SaveImageModel,
+                                        render.SaveImagePathModel,
+                                        render.SavePath,
+                                        render.Image,
+                                        bmp,
+                                        render.Result,
+                                        render.IsCompress
+                                    );
+                                }));
                             }
                             break;
                         }
@@ -103,7 +106,7 @@ namespace TeamAAS_VP.Views.Home
         /// <summary>
         /// 【核心】根据 obj.Count 自动生成 1~16 个显示格子(标题+CogRecordDisplay)
         /// </summary>
-        private void ViewModel_UpdateLayout(System.Collections.ObjectModel.ObservableCollection<Models.ShowRender> obj)
+        private async void ViewModel_UpdateLayout(System.Collections.ObjectModel.ObservableCollection<Models.ShowRender> obj)
         {
             System.Windows.Media.FontFamily font = Application.Current.Resources["DefaultFont"] as System.Windows.Media.FontFamily;
 
@@ -158,7 +161,10 @@ namespace TeamAAS_VP.Views.Home
                 var host = new WindowsFormsHost()
                 {
                     Tag = sr.ProceductName,
-                    Child = new CogRecordDisplay() { Tag = sr.ProceductName }
+                    Child = new CogRecordDisplay()
+                    {
+                        Tag = sr.ProceductName,
+                    }
                 };
                 vmRenders.Add(sr.Id, host);
 
@@ -174,10 +180,7 @@ namespace TeamAAS_VP.Views.Home
                 };
                 Titles.Add(sr.Id, title);
 
-                // (3) 配置 VisionPro 显示属性
-                ConfigureCogDisplay((CogRecordDisplay)host.Child);
-
-                // (4) 子Grid(标题 + 显示)
+                // (3) 子Grid(标题 + 显示)
                 var cell = new Grid();
                 cell.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) });  // 标题
                 cell.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });  // 图像
@@ -191,7 +194,7 @@ namespace TeamAAS_VP.Views.Home
                 Grid.SetRow(host, 1);
                 Grid.SetColumn(host, 0);
 
-                // (5) 放到主 gridRender 中
+                // (4) 放到主 gridRender 中
                 int row = i / cols;
                 int col = i % cols;
 

+ 2 - 2
TeamAAS-VM/Views/User/CardLoginWindow.xaml

@@ -250,7 +250,7 @@
                                        FontWeight="SemiBold" />
                         </Grid>
                         <Button x:Name="NameLoginButton"
-                                Height="50"
+                                Height="45"
                                 Width="50"
                                 materialDesign:ButtonAssist.CornerRadius="5"
                                 HorizontalAlignment="Center"
@@ -350,7 +350,7 @@
                     <Button Grid.Row="3"
                             Grid.Column="0"
                             Grid.ColumnSpan="2"
-                            Height="50"
+                            Height="45"
                             Width="50"
                             materialDesign:ButtonAssist.CornerRadius="5"
                             HorizontalAlignment="Center"