Ver Fonte

修改轴精度检测

wanghan há 7 meses atrás
pai
commit
6dd0f4262a

+ 82 - 18
TeamAAS-VM/ViewModels/Product/VisionDynamicAccuracyAnalyzerViewModel.cs

@@ -241,6 +241,43 @@ namespace TeamAAS_VP.ViewModels.Product
             get { return _precisionResult; }
             set { SetProperty(ref _precisionResult, value); }
         }
+
+        private int _ADelay = 300;
+        /// <summary>
+        /// A点延时时间
+        /// </summary>
+        public int ADelay
+        {
+            get { return _ADelay; }
+            set { SetProperty(ref _ADelay, value); }
+        }
+
+        private int _BDelay = 500;
+        /// <summary>
+        /// B点延时时间
+        /// </summary>
+        public int BDelay
+        {
+            get { return _BDelay; }
+            set { SetProperty(ref _BDelay, value); }
+        }
+
+        private bool _IsTakePhoto = true;
+        /// <summary>
+        /// 是否启用拍照
+        /// </summary>
+        public bool IsTakePhoto
+        {
+            get { return _IsTakePhoto; }
+            set { SetProperty(ref _IsTakePhoto, value); }
+        }
+
+        private int _ProIndex;
+        public int ProIndex
+        {
+            get { return _ProIndex; }
+            set { SetProperty(ref _ProIndex, value); }
+        }
         #endregion
 
         #region 命令
@@ -385,7 +422,7 @@ namespace TeamAAS_VP.ViewModels.Product
                     SendTaskMessage("机器人移动到A点失败!");
                     return;
                 }
-                await Task.Delay(200);
+                await Task.Delay(ADelay);
 
                 //移动机器人至B点
                 isSuccess1 = await Robot.CalibMotionAsync(PointB, null);
@@ -394,9 +431,13 @@ namespace TeamAAS_VP.ViewModels.Product
                     SendTaskMessage("机器人移动到B点失败!");
                     return;
                 }
-                await Task.Delay(300);
-                //相机拍照并处理
-                (bool isSuccess, double pixelX, double pixelY, double angleU, double transformX, double transformY) = await ExecutePhotoEx(CurrentProgress);
+                await Task.Delay(BDelay);
+
+                if (IsTakePhoto)
+                {
+                    //相机拍照并处理
+                    (bool isSuccess, double pixelX, double pixelY, double angleU, double transformX, double transformY) = await ExecutePhotoEx(CurrentProgress);
+                }
 
                 CycleTime = DateTime.Now.Subtract(startTime).TotalSeconds;
             }
@@ -435,6 +476,18 @@ namespace TeamAAS_VP.ViewModels.Product
                     return;
                 }
 
+                if (Robot == null || !Robot.IsConnected)
+                {
+                    SendTaskMessage("机器人未连接,无法示教!");
+                    return;
+                }
+
+                if (Camera == null || !Camera.IsConnected)
+                {
+                    SendTaskMessage("相机未连接,无法示教!");
+                    return;
+                }
+
                 //为机器人设置移动速度
                 await Robot.CalibParameAsync(new PickInfo(), MoveSpeed, 0, false, 0, 0);
 
@@ -454,7 +507,7 @@ namespace TeamAAS_VP.ViewModels.Product
                         SendTaskMessage("机器人移动到A点失败!");
                         return;
                     }
-                    await Task.Delay(200);
+                    await Task.Delay(ADelay);
                     if (_cts.Token.IsCancellationRequested)
                     {
                         Message = "测试已取消!";
@@ -468,30 +521,41 @@ namespace TeamAAS_VP.ViewModels.Product
                         SendTaskMessage("机器人移动到B点失败!");
                         return;
                     }
-                    await Task.Delay(300);
+                    await Task.Delay(BDelay);
                     if (_cts.Token.IsCancellationRequested)
                     {
                         Message = "测试已取消!";
                         break;
                     }
 
-                    //相机拍照并处理
-                    (bool isSuccess, double pixelX, double pixelY, double angleU, double transformX, double transformY) = await ExecutePhotoEx(CurrentProgress);
-                    CycleTime = DateTime.Now.Subtract(startTime).TotalSeconds;
-
-                    if (isSuccess)
+                    if (IsTakePhoto)
                     {
-                        SuccessCount++;
+                        //相机拍照并处理
+                        (bool isSuccess, double pixelX, double pixelY, double angleU, double transformX, double transformY) = await ExecutePhotoEx(CurrentProgress);
+
+                        CycleTime = DateTime.Now.Subtract(startTime).TotalSeconds;
+
+                        if (isSuccess)
+                        {
+                            SuccessCount++;
+                        }
+                        else
+                        {
+                            FailCount++;
+                        }
+                        TestResults.Add(new DynamicTestResult(CurrentProgress, isSuccess, PointB, CycleTime, pixelX, pixelY, angleU, transformX, transformY));
+                        OnTestResultAdded();
+
+                        CurrentProgress++;
+                        SuccessRate = (double)SuccessCount / CurrentProgress * 100;
                     }
                     else
                     {
-                        FailCount++;
+                        CycleTime = DateTime.Now.Subtract(startTime).TotalSeconds;
+                        SuccessCount++;
+                        CurrentProgress++;
+                        SuccessRate = (double)SuccessCount / CurrentProgress * 100;
                     }
-                    TestResults.Add(new DynamicTestResult(CurrentProgress, isSuccess, PointB, CycleTime, pixelX, pixelY, angleU, transformX, transformY));
-                    OnTestResultAdded();
-
-                    CurrentProgress++;
-                    SuccessRate = (double)SuccessCount / CurrentProgress * 100;
                     SendTaskMessage($"测试进行中... {CurrentProgress}/{RepeatCount}");
                 }
                 if (CurrentProgress >= RepeatCount)

+ 11 - 1
TeamAAS-VM/ViewModels/Product/VisionStaticAccuracyAnalyzerViewModel.cs

@@ -119,6 +119,16 @@ namespace TeamAAS_VP.ViewModels.Product
             set { SetProperty(ref _RepeatCount, value); }
         }
 
+        private int _DelayTime = 200;
+        /// <summary>
+        /// 延时时间
+        /// </summary>
+        public int DelayTime
+        {
+            get { return _DelayTime; }
+            set { SetProperty(ref _DelayTime, value); }
+        }
+
         private int _CurrentProgress;
         /// <summary>
         /// 当前进度
@@ -317,7 +327,7 @@ namespace TeamAAS_VP.ViewModels.Product
                         Message = "测试已取消!";
                         break;
                     }
-
+                    await Task.Delay(DelayTime);
                     (bool isSuccess, object[] Result) = await ExecutePhotoEx(CurrentProgress);
                     if (isSuccess)
                     {

+ 39 - 5
TeamAAS-VM/Views/Product/VisionDynamicAccuracyAnalyzer.xaml

@@ -27,7 +27,6 @@
              HorizontalAlignment="Stretch"
              VerticalAlignment="Stretch"
              FontFamily="{DynamicResource DefaultFont}">
-
     <prism:Dialog.WindowStyle>
         <Style TargetType="Window">
             <Setter Property="prism:Dialog.WindowStartupLocation"
@@ -43,7 +42,7 @@
             <Setter Property="WindowState"
                     Value="Maximized" />
             <Setter Property="Topmost"
-                    Value="True" />
+                    Value="False" />
         </Style>
     </prism:Dialog.WindowStyle>
 
@@ -228,7 +227,7 @@
                                    Grid.Column="0"
                                    VerticalAlignment="Center" />
                                     <ComboBox Grid.Column="1"
-                                  ItemsSource="{Binding ProcedureModels}"
+                                  ItemsSource="{Binding ProcedureModels, Mode=TwoWay}"
                                   SelectedItem="{Binding SelectProcedure, Mode=TwoWay}"
                                   ToolTip="选择视觉处理流程">
                                         <ComboBox.ItemTemplate>
@@ -259,6 +258,8 @@
                                 <Grid.ColumnDefinitions>
                                     <ColumnDefinition Width="*" />
                                     <ColumnDefinition Width="*" />
+                                    <ColumnDefinition Width="*" />
+                                    <ColumnDefinition Width="*" />
                                 </Grid.ColumnDefinitions>
 
                                 <!-- 重复次数 -->
@@ -276,7 +277,7 @@
 
                                 <!-- 移动速度 -->
                                 <StackPanel Grid.Column="1"
-                                Margin="10,0,0,0">
+                                            Margin="10,0,0,0">
                                     <TextBlock Text="移动速度(%):" />
                                     <mah:NumericUpDown Value="{Binding MoveSpeed, Mode=TwoWay}"
                                            Minimum="1"
@@ -287,6 +288,31 @@
                                            HorizontalAlignment="Stretch"
                                            IsEnabled="{Binding IsRunning, Converter={StaticResource InvertBooleanConverter}}" />
                                 </StackPanel>
+
+                                <!-- A点延时 -->
+                                <StackPanel Grid.Column="2">
+                                    <TextBlock Text="A点延时(ms):" />
+                                    <mah:NumericUpDown Value="{Binding ADelay, Mode=TwoWay}"
+                                                       Minimum="50"
+                                                       d:Value="300"
+                                                       TextAlignment="Center"
+                                                       HorizontalContentAlignment="Center"
+                                                       HorizontalAlignment="Stretch"
+                                                       IsEnabled="{Binding IsRunning, Converter={StaticResource InvertBooleanConverter}}" />
+                                </StackPanel>
+
+                                <!-- B点延时 -->
+                                <StackPanel Grid.Column="3"
+                                            Margin="10,0,0,0">
+                                    <TextBlock Text="B点延时(ms):" />
+                                    <mah:NumericUpDown Value="{Binding BDelay, Mode=TwoWay}"
+                                                       Minimum="50"
+                                                       d:Value="500"
+                                                       TextAlignment="Center"
+                                                       HorizontalContentAlignment="Center"
+                                                       HorizontalAlignment="Stretch"
+                                                       IsEnabled="{Binding IsRunning, Converter={StaticResource InvertBooleanConverter}}" />
+                                </StackPanel>
                             </Grid>
 
 
@@ -302,7 +328,15 @@
                            Text="测试控制" />
 
                             <WrapPanel HorizontalAlignment="Center"
-                           Margin="0 10 0 0">
+                                       Margin="0 10 0 0">
+                                <CheckBox Content="启用拍照"
+                                          Foreground="Black"
+                                          Style="{StaticResource MaterialDesignCheckBox}"
+                                          VerticalAlignment="Center"
+                                          IsChecked="{Binding IsTakePhoto}"
+                                          Margin="10,0"
+                                          FontSize="15"/>
+
                                 <Button Content="单次测试"
                             Background="#3498DB"
                             Foreground="White"

+ 15 - 1
TeamAAS-VM/Views/Product/VisionStaticAccuracyAnalyzer.xaml

@@ -41,7 +41,7 @@
             <Setter Property="WindowState"
                     Value="Maximized" />
             <Setter Property="Topmost"
-                    Value="True" />
+                    Value="False" />
         </Style>
     </prism:Dialog.WindowStyle>
 
@@ -135,6 +135,7 @@
                                 <ColumnDefinition Width="Auto" />
                                 <ColumnDefinition Width="*" />
                                 <ColumnDefinition Width="Auto" />
+                                <ColumnDefinition Width="*" />
                             </Grid.ColumnDefinitions>
 
                             <TextBlock Text="重复次数:"
@@ -147,6 +148,19 @@
                                                HorizontalContentAlignment="Center"
                                                HorizontalAlignment="Stretch"
                                                IsEnabled="{Binding IsRunning,Converter={StaticResource InvertBooleanConverter}}" />
+
+                            <TextBlock Text="延时时间(ms):"
+                                       Grid.Column="2" />
+                            <mah:NumericUpDown Grid.Column="3"
+                                               Value="{Binding DelayTime, Mode=TwoWay}"
+                                               Minimum="50"
+                                               d:Value="200"
+                                               TextAlignment="Center"
+                                               HorizontalContentAlignment="Center"
+                                               HorizontalAlignment="Stretch"
+                                               IsEnabled="{Binding IsRunning,Converter={StaticResource InvertBooleanConverter}}" />
+
+
                             <!--<Button x:Name="btnSetCount"
                                     Grid.Column="2"
                                     Content="设置"