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

新增系统参数配置功能及界面支持

本次提交实现了系统设置界面“系统参数”Tab,支持相机拍照次数等参数的可视化配置与保存。新增相关属性至 SystemConfiguration,并完善 SettingViewModel 逻辑,支持参数的加载与保存。移除已废弃的 CurentApplicationSettings.cs 文件。提升了系统参数管理的灵活性和用户体验。
孝锋 徐 8 месяцев назад
Родитель
Сommit
383dee074c

+ 0 - 55
TeamAAS-VM/Models/CurentApplicationSettings.cs

@@ -1,55 +0,0 @@
-using Prism.Mvvm;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using TeamAAS_VP.Core;
-using TeamAAS_VP;
-using static Org.BouncyCastle.Math.EC.ECCurve;
-
-namespace TeamAAS_VP.Models
-{
-    public class CurentApplicationSettings : BindableBase
-    {
-        public CurentApplicationSettings()
-        {
-
-        }
-
-        private string _CompanyTitle= "江苏新惕姆智能装备有限公司";
-        /// <summary>
-        /// 公司名称标题
-        /// </summary>
-        public string CompanyTitle
-        {
-            get { return _CompanyTitle; }
-            set { SetProperty(ref _CompanyTitle, value); }
-        }
-
-        private string _Title = "Team Vision";
-
-        public string Title
-        {
-            get { return _Title; }
-            set { SetProperty(ref _Title,value); }
-        }
-
-        private DateTime _DT = DateTime.Now;
-
-        public DateTime DT
-        {
-            get { return _DT; }
-            set { SetProperty(ref _DT, value); }
-        }
-
-        private Dictionary<Guid, double> _RobotJogSetpDistance = new Dictionary<Guid, double>();
-
-        public Dictionary<Guid, double> RobotJogSetpDistance
-        {
-            get { return _RobotJogSetpDistance; }
-            set { SetProperty(ref _RobotJogSetpDistance, value); }
-        }
-    }
-}

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

@@ -94,6 +94,78 @@ namespace TeamAAS_VP.Models
             set => SetProperty(ref _lastOpenedProductId, value);
             set => SetProperty(ref _lastOpenedProductId, value);
         }
         }
 
 
+        // 新增相机/拍照/检测计数属性
+
+        private int _cameraShotCount = 0;
+        /// <summary>
+        /// 相机拍照次数
+        /// </summary>
+        public int CameraShotCount
+        {
+            get => _cameraShotCount;
+            set => SetProperty(ref _cameraShotCount, value);
+        }
+
+        private int _upperCameraPickShotCount = 0;
+        /// <summary>
+        /// 上相机取料拍照次数
+        /// </summary>
+        public int UpperCameraPickShotCount
+        {
+            get => _upperCameraPickShotCount;
+            set => SetProperty(ref _upperCameraPickShotCount, value);
+        }
+
+        private int _upperCameraPlaceShotCount = 0;
+        /// <summary>
+        /// 上相机放料拍照次数
+        /// </summary>
+        public int UpperCameraPlaceShotCount
+        {
+            get => _upperCameraPlaceShotCount;
+            set => SetProperty(ref _upperCameraPlaceShotCount, value);
+        }
+
+        private int _upperCameraLockAssembleCount = 0;
+        /// <summary>
+        /// 上相机锁附/组装次数
+        /// </summary>
+        public int UpperCameraLockAssembleCount
+        {
+            get => _upperCameraLockAssembleCount;
+            set => SetProperty(ref _upperCameraLockAssembleCount, value);
+        }
+
+        private int _pickFixedPositionProductCameraCount = 0;
+        /// <summary>
+        /// 取料固定位置拍产品相机数量
+        /// </summary>
+        public int PickFixedPositionProductCameraCount
+        {
+            get => _pickFixedPositionProductCameraCount;
+            set => SetProperty(ref _pickFixedPositionProductCameraCount, value);
+        }
+
+        private int _lockFixedPositionProductCameraCount = 0;
+        /// <summary>
+        /// 锁附/组装固定位置拍产品相机数量
+        /// </summary>
+        public int LockFixedPositionProductCameraCount
+        {
+            get => _lockFixedPositionProductCameraCount;
+            set => SetProperty(ref _lockFixedPositionProductCameraCount, value);
+        }
+
+        private int _fixedCameraDetectLockAssembleCount = 0;
+        /// <summary>
+        /// 固定相机检测锁附/组装次数
+        /// </summary>
+        public int FixedCameraDetectLockAssembleCount
+        {
+            get => _fixedCameraDetectLockAssembleCount;
+            set => SetProperty(ref _fixedCameraDetectLockAssembleCount, value);
+        }
+
         /// <summary>
         /// <summary>
         /// 字体大小子设置
         /// 字体大小子设置
         /// </summary>
         /// </summary>

+ 0 - 1
TeamAAS-VM/TeamAAS-VP.csproj

@@ -655,7 +655,6 @@
     <Compile Include="Models\ActionParamsExtModel.cs" />
     <Compile Include="Models\ActionParamsExtModel.cs" />
     <Compile Include="Models\BgModbusTcp.cs" />
     <Compile Include="Models\BgModbusTcp.cs" />
     <Compile Include="Models\Camera\CameraInfo.cs" />
     <Compile Include="Models\Camera\CameraInfo.cs" />
-    <Compile Include="Models\CurentApplicationSettings.cs" />
     <Compile Include="Models\Feeder\FeederClearWork.cs" />
     <Compile Include="Models\Feeder\FeederClearWork.cs" />
     <Compile Include="Models\Feeder\FeederStockWork.cs" />
     <Compile Include="Models\Feeder\FeederStockWork.cs" />
     <Compile Include="Models\Feeder\FeederStockWorks.cs" />
     <Compile Include="Models\Feeder\FeederStockWorks.cs" />

+ 58 - 0
TeamAAS-VM/ViewModels/SettingViewModel.cs

@@ -311,6 +311,9 @@ namespace TeamAAS_VP.ViewModels
 
 
         #region 命令
         #region 命令
         public DelegateCommand LoadedCommand { get; set; }
         public DelegateCommand LoadedCommand { get; set; }
+        private DelegateCommand _SaveSystemParametersCommand;
+        public DelegateCommand SaveSystemParametersCommand =>
+            _SaveSystemParametersCommand ?? (_SaveSystemParametersCommand = new DelegateCommand(ExecuteSaveSystemParametersCommand));
         private DelegateCommand _AddRobotCommand;
         private DelegateCommand _AddRobotCommand;
         public DelegateCommand AddRobotCommand =>
         public DelegateCommand AddRobotCommand =>
             _AddRobotCommand ?? (_AddRobotCommand = new DelegateCommand(ExecuteAddRobotCommand));
             _AddRobotCommand ?? (_AddRobotCommand = new DelegateCommand(ExecuteAddRobotCommand));
@@ -1160,6 +1163,19 @@ namespace TeamAAS_VP.ViewModels
 
 
             CurrentLanguage = _configService.GetSystemConfiguration().CurrentLanguage;
             CurrentLanguage = _configService.GetSystemConfiguration().CurrentLanguage;
 
 
+            // load system parameters into UI
+            var sys = _configService.GetSystemConfiguration();
+            if (sys != null)
+            {
+                CameraShotCount = sys.CameraShotCount;
+                UpperCameraPickShotCount = sys.UpperCameraPickShotCount;
+                UpperCameraPlaceShotCount = sys.UpperCameraPlaceShotCount;
+                UpperCameraLockAssembleCount = sys.UpperCameraLockAssembleCount;
+                FixedPickCameraCount = sys.PickFixedPositionProductCameraCount;
+                FixedLockAssembleCameraCount = sys.LockFixedPositionProductCameraCount;
+                FixedCameraDetectLockAssembleCount = sys.FixedCameraDetectLockAssembleCount;
+            }
+
             if (isFirstLoad)
             if (isFirstLoad)
             {
             {
                 Title1 = (double)Application.Current.Resources["Font.Size.Title1"];
                 Title1 = (double)Application.Current.Resources["Font.Size.Title1"];
@@ -1218,5 +1234,47 @@ namespace TeamAAS_VP.ViewModels
                 IsAllowEdit = true;
                 IsAllowEdit = true;
             }
             }
         }
         }
+
+        #region 系统参数
+        private int _CameraShotCount;
+        public int CameraShotCount { get => _CameraShotCount; set => SetProperty(ref _CameraShotCount, value); }
+
+        private int _UpperCameraPickShotCount;
+        public int UpperCameraPickShotCount { get => _UpperCameraPickShotCount; set => SetProperty(ref _UpperCameraPickShotCount, value); }
+
+        private int _UpperCameraPlaceShotCount;
+        public int UpperCameraPlaceShotCount { get => _UpperCameraPlaceShotCount; set => SetProperty(ref _UpperCameraPlaceShotCount, value); }
+
+        private int _UpperCameraLockAssembleCount;
+        public int UpperCameraLockAssembleCount { get => _UpperCameraLockAssembleCount; set => SetProperty(ref _UpperCameraLockAssembleCount, value); }
+
+        private int _FixedPickCameraCount;
+        public int FixedPickCameraCount { get => _FixedPickCameraCount; set => SetProperty(ref _FixedPickCameraCount, value); }
+
+        private int _FixedLockAssembleCameraCount;
+        public int FixedLockAssembleCameraCount { get => _FixedLockAssembleCameraCount; set => SetProperty(ref _FixedLockAssembleCameraCount, value); }
+
+        private int _FixedCameraDetectLockAssembleCount;
+        public int FixedCameraDetectLockAssembleCount { get => _FixedCameraDetectLockAssembleCount; set => SetProperty(ref _FixedCameraDetectLockAssembleCount, value); }
+
+        async void ExecuteSaveSystemParametersCommand()
+        {
+            var view = new ShowMessage($"AAS", "是否保存系统参数?");
+            var result = await DialogHost.Show(view, "RootDialog", null, null, null);
+            if (result != null && result is bool && (bool)result)
+            {
+                var sysConfig = _configService.GetSystemConfiguration();
+                sysConfig.CameraShotCount = CameraShotCount;
+                sysConfig.UpperCameraPickShotCount = UpperCameraPickShotCount;
+                sysConfig.UpperCameraPlaceShotCount = UpperCameraPlaceShotCount;
+                sysConfig.UpperCameraLockAssembleCount = UpperCameraLockAssembleCount;
+                sysConfig.PickFixedPositionProductCameraCount = FixedPickCameraCount;
+                sysConfig.LockFixedPositionProductCameraCount = FixedLockAssembleCameraCount;
+                sysConfig.FixedCameraDetectLockAssembleCount = FixedCameraDetectLockAssembleCount;
+                _configService.SaveSystemConfiguration(sysConfig);
+                _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
+            }
+        }
+        #endregion
     }
     }
 }
 }

+ 170 - 0
TeamAAS-VM/Views/SettingView.xaml

@@ -1798,6 +1798,176 @@
                 </Grid>
                 </Grid>
             </TabItem>
             </TabItem>
 
 
+            <!--系统参数-->
+            <TabItem>
+                <TabItem.Header>
+                    <StackPanel HorizontalAlignment="Stretch">
+                        <materialDesign:PackIcon Width="24"
+                                                 Height="24"
+                                                 HorizontalAlignment="Center"
+                                                 Kind="CellphoneSystemUpdate" />
+                        <TextBlock Style="{StaticResource TabHeaderTextBlockStyle}"
+                                   FontSize="{DynamicResource Font.Size.Body2}"
+                                   Text="{lex:Loc 系统参数}"
+                                   HorizontalAlignment="Stretch" />
+                    </StackPanel>
+                </TabItem.Header>
+                <StackPanel Orientation="Vertical"
+                            Margin="20">
+                    <Grid>
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="auto" />
+                            <ColumnDefinition Width="200" />
+                            <ColumnDefinition Width="*" />
+                        </Grid.ColumnDefinitions>
+                        <Grid.RowDefinitions>
+                            <RowDefinition Height="Auto" />
+                            <RowDefinition Height="Auto" />
+                            <RowDefinition Height="Auto" />
+                            <RowDefinition Height="Auto" />
+                            <RowDefinition Height="Auto" />
+                            <RowDefinition Height="Auto" />
+                            <RowDefinition Height="Auto" />
+                            <RowDefinition Height="40" />
+                        </Grid.RowDefinitions>
+
+                        <!-- 相机拍照次数 -->
+                        <TextBlock Grid.Row="0"
+                                   Grid.Column="0"
+                                   Style="{StaticResource MaterialDesignSubtitle1TextBlock}"
+                                   VerticalAlignment="Center"
+                                   HorizontalAlignment="Right"
+                                   Margin="0,6,10,6"
+                                   Text="相机拍照次数:" />
+                        <mah:NumericUpDown Grid.Row="0"
+                                           Grid.Column="1"
+                                           Margin="0,6"
+                                           Value="{Binding CameraShotCount,Mode=TwoWay}"
+                                           Minimum="0"
+                                           Maximum="100"
+                                           FontSize="{DynamicResource Font.Size.Body3}" />
+
+                        <!-- 上相机取料拍照次数 -->
+                        <TextBlock Grid.Row="1"
+                                   Grid.Column="0"
+                                   Style="{StaticResource MaterialDesignSubtitle1TextBlock}"
+                                   VerticalAlignment="Center"
+                                   HorizontalAlignment="Right"
+                                   Margin="0,6,10,6"
+                                   Text="上相机取料拍照次数:" />
+                        <mah:NumericUpDown Grid.Row="1"
+                                           Grid.Column="1"
+                                           Margin="0,6"
+                                           Value="{Binding UpperCameraPickShotCount,Mode=TwoWay}"
+                                           Minimum="0"
+                                           Maximum="100"
+                                           FontSize="{DynamicResource Font.Size.Body3}" />
+
+                        <!-- 上相机放料拍照次数 -->
+                        <TextBlock Grid.Row="2"
+                                   Grid.Column="0"
+                                   Style="{StaticResource MaterialDesignSubtitle1TextBlock}"
+                                   VerticalAlignment="Center"
+                                   HorizontalAlignment="Right"
+                                   Margin="0,6,10,6"
+                                   Text="上相机放料拍照次数:" />
+                        <mah:NumericUpDown Grid.Row="2"
+                                           Grid.Column="1"
+                                           Margin="0,6"
+                                           Value="{Binding UpperCameraPlaceShotCount,Mode=TwoWay}"
+                                           Minimum="0"
+                                           Maximum="100"
+                                           FontSize="{DynamicResource Font.Size.Body3}" />
+
+                        <!-- 上相机锁附/组装次数 -->
+                        <TextBlock Grid.Row="3"
+                                   Grid.Column="0"
+                                   Style="{StaticResource MaterialDesignSubtitle1TextBlock}"
+                                   VerticalAlignment="Center"
+                                   HorizontalAlignment="Right"
+                                   Margin="0,6,10,6"
+                                   Text="上相机锁附/组装次数:" />
+                        <mah:NumericUpDown Grid.Row="3"
+                                           Grid.Column="1"
+                                           Margin="0,6"
+                                           Value="{Binding UpperCameraLockAssembleCount,Mode=TwoWay}"
+                                           Minimum="0"
+                                           Maximum="100"
+                                           FontSize="{DynamicResource Font.Size.Body3}" />
+
+                        <!-- 取料固定位置拍产品相机数量 -->
+                        <TextBlock Grid.Row="4"
+                                   Grid.Column="0"
+                                   Style="{StaticResource MaterialDesignSubtitle1TextBlock}"
+                                   VerticalAlignment="Center"
+                                   HorizontalAlignment="Right"
+                                   Margin="0,6,10,6"
+                                   Text="取料固定位置拍产品相机数量:" />
+                        <mah:NumericUpDown Grid.Row="4"
+                                           Grid.Column="1"
+                                           Margin="0,6"
+                                           Value="{Binding FixedPickCameraCount,Mode=TwoWay}"
+                                           Minimum="0"
+                                           Maximum="10"
+                                           FontSize="{DynamicResource Font.Size.Body3}" />
+
+                        <!-- 锁附/组装固定位置拍产品相机数量 -->
+                        <TextBlock Grid.Row="5"
+                                   Grid.Column="0"
+                                   Style="{StaticResource MaterialDesignSubtitle1TextBlock}"
+                                   VerticalAlignment="Center"
+                                   HorizontalAlignment="Right"
+                                   Margin="0,6,10,6"
+                                   Text="锁附/组装固定位置拍产品相机数量:" />
+                        <mah:NumericUpDown Grid.Row="5"
+                                           Grid.Column="1"
+                                           Margin="0,6"
+                                           Value="{Binding FixedLockAssembleCameraCount,Mode=TwoWay}"
+                                           Minimum="0"
+                                           Maximum="10"
+                                           FontSize="{DynamicResource Font.Size.Body3}" />
+
+                        <!-- 固定相机检测锁附/组装次数 -->
+                        <TextBlock Grid.Row="6"
+                                   Grid.Column="0"
+                                   Style="{StaticResource MaterialDesignSubtitle1TextBlock}"
+                                   VerticalAlignment="Center"
+                                   HorizontalAlignment="Right"
+                                   Margin="0,6,10,6"
+                                   Text="固定相机检测锁附/组装次数:" />
+                        <mah:NumericUpDown Grid.Row="6"
+                                           Grid.Column="1"
+                                           Margin="0,6"
+                                           Value="{Binding FixedCameraDetectLockAssembleCount,Mode=TwoWay}"
+                                           Minimum="0"
+                                           Maximum="100"
+                                           FontSize="{DynamicResource Font.Size.Body3}" />
+
+                        <!-- 保存按钮 -->
+                        <StackPanel Grid.Row="7"
+                                    Grid.ColumnSpan="3"
+                                    Orientation="Horizontal"
+                                    HorizontalAlignment="Right"
+                                    VerticalAlignment="Center"
+                                    Margin="0,10,0,0">
+                            <Button Style="{StaticResource MaterialDesignRaisedButton}"
+                                    materialDesign:ButtonAssist.CornerRadius="10"
+                                    MinWidth="120"
+                                    Command="{Binding SaveSystemParametersCommand}"
+                                    IsEnabled="{Binding IsAllowEdit}">
+                                <StackPanel Orientation="Horizontal"
+                                            HorizontalAlignment="Center">
+                                    <materialDesign:PackIcon Kind="ContentSaveCheck"
+                                                             Margin="0,0,6,0" />
+                                    <TextBlock VerticalAlignment="Center"
+                                               Text="保存系统参数" />
+                                </StackPanel>
+                            </Button>
+                        </StackPanel>
+                    </Grid>
+                </StackPanel>
+            </TabItem>
+
             <!--生产排班-->
             <!--生产排班-->
             <TabItem>
             <TabItem>
                 <TabItem.Header>
                 <TabItem.Header>