ソースを参照

新增界面显示状态

KWD 5 ヶ月 前
コミット
f978dcdbb5

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

@@ -106,6 +106,30 @@ namespace TeamAAS_VP.Core
             set { SetProperty(ref _StatusBackground, value); }
         }
 
+        private System.Windows.Media.Brush _RunModelBackground;
+
+        public System.Windows.Media.Brush RunModelBackground
+        {
+            get { return _RunModelBackground; }
+            set { SetProperty(ref _RunModelBackground, value); }
+        }
+
+        private System.Windows.Media.Brush _ManualModeBackground;
+
+        public System.Windows.Media.Brush ManualModeBackground
+        {
+            get { return _ManualModeBackground; }
+            set { SetProperty(ref _ManualModeBackground, value); }
+        }
+
+        private System.Windows.Media.Brush _ClearModeBackground;
+
+        public System.Windows.Media.Brush ClearModeBackground
+        {
+            get { return _ClearModeBackground; }
+            set { SetProperty(ref _ClearModeBackground, value); }
+        }
+
         private ObservableCollection<ShowRender> _Renders;
 
         /// <summary>
@@ -286,6 +310,7 @@ namespace TeamAAS_VP.Core
             _systemDatabaseService = systemDatabaseService;
             _lightManagerService = lightManagerService;
             _mesService = mesService;
+            _eventAggregator.GetEvent<CurrentStatusNotification>().Subscribe(CurrentRunStatus);
         }
 
         #region 读取配置参数
@@ -1196,6 +1221,7 @@ namespace TeamAAS_VP.Core
                 addressConfig.In_PickINC.Address,
                 addressConfig.In_Throw.Address,
                 addressConfig.RunMode.Address,
+                addressConfig.AutoRunning.Address,
                 addressConfig.ManualMode.Address,
                 addressConfig.ClearMode.Address,
                 addressConfig.Fault.Address,
@@ -1349,6 +1375,7 @@ namespace TeamAAS_VP.Core
         bool _LastFixedCameracheckExe = false;
         bool _LastThrowExe = false;
         bool _LastRunModel = false;
+        public bool _LastAutoRunning = false;
         bool _LastManualMode = false;
         bool _LastClearMode = false;
         bool _LastFault = false;
@@ -2204,13 +2231,13 @@ namespace TeamAAS_VP.Core
                     }
                 }
                 //切换成自动运行模式
-                else if (addressConfig.RunMode.Address.Contains(tuple.nodeId))
+                else if (addressConfig.AutoRunning.Address.Contains(tuple.nodeId))
                 {
                     if (tuple.value is bool state)
                     {
-                        if (_LastRunModel != state)
+                        if (_LastAutoRunning != state)
                         {
-                            _LastRunModel = state;
+                            _LastAutoRunning = state;
                         }
                         else
                         {
@@ -2219,8 +2246,12 @@ namespace TeamAAS_VP.Core
                         if (state)
                         {
                             SendTaskMessage("收到切换成自动模式", MessageLevel.Info);
-                            StatusBackground = System.Windows.Media.Brushes.Green;
                         }
+                        else
+                        {
+                            SendTaskMessage("收到关闭自动模式", MessageLevel.Info);
+                        }
+                        CurrentRunStatus();
                     }
                 }
                 //切换成维修模式
@@ -2238,13 +2269,10 @@ namespace TeamAAS_VP.Core
                         }
                         if (state)
                         {
+                            ClearModeBackground = System.Windows.Media.Brushes.White;
+                            RunModelBackground = System.Windows.Media.Brushes.White;
+                            ManualModeBackground = System.Windows.Media.Brushes.Orange;
                             SendTaskMessage("收到切换成维修模式", MessageLevel.Info);
-                            StatusBackground = System.Windows.Media.Brushes.Yellow;
-                        }
-                        else
-                        {
-                            SendTaskMessage("收到切换成自动模式", MessageLevel.Info);
-                            StatusBackground = System.Windows.Media.Brushes.Green;
                         }
                     }
                 }
@@ -2263,8 +2291,10 @@ namespace TeamAAS_VP.Core
                         }
                         if (state)
                         {
+                            ClearModeBackground = System.Windows.Media.Brushes.Yellow;
+                            RunModelBackground = System.Windows.Media.Brushes.White;
+                            ManualModeBackground = System.Windows.Media.Brushes.White;
                             SendTaskMessage("收到切换成流线模式", MessageLevel.Info);
-                            StatusBackground = System.Windows.Media.Brushes.Green;
                         }
                     }
                 }
@@ -2974,6 +3004,71 @@ namespace TeamAAS_VP.Core
                 _eventAggregator.GetEvent<TaskMessageNotification>().Publish(new Models.MessageStruct() { Message = msg, level = level });
             });
         }
+
+        public bool concurrenty = true;
+        public void CurrentRunStatus()
+        {
+            if (!concurrenty)
+            {
+                return;
+            }
+            concurrenty = true;
+            bool connectStaus = true;
+            bool mesStatus = true;
+            bool paraStatus = true;
+            try
+            {
+
+                for (int i = 0; i < 1; i++)
+                {
+                    var stationConfig = _configService.GetDeviceInfo(i);
+                    if (!stationConfig.EnableMES ||  !stationConfig.SaveCsv)
+                    {
+                        SendTaskMessage("当前MES功能/保存CSV功能未启用,请检查...", MessageLevel.Info);
+                        mesStatus = false;
+                        break;
+                    }
+                }
+                var systemConfig = _configService.GetSystemConfiguration();
+                if (!systemConfig.IsSaveScrewCurve)
+                {
+                    paraStatus = false;
+                    SendTaskMessage("当前保存扭力曲线未勾选,请检查...", MessageLevel.Info);
+                }
+                foreach (var item in Status)
+                {
+                    if (item.Background == System.Windows.Media.Brushes.Red)
+                    {
+                        SendTaskMessage("当前有设备未连接,请检查...", MessageLevel.Info);
+                        connectStaus = false;
+                        break;
+                    }
+                }
+            }
+            catch (Exception)
+            {
+                connectStaus = false;
+                mesStatus = false;
+                paraStatus = false;
+            }
+            if (connectStaus && mesStatus && paraStatus && _LastAutoRunning)
+            {
+                RunModelBackground = System.Windows.Media.Brushes.Green;
+                ClearModeBackground = System.Windows.Media.Brushes.White;
+                ManualModeBackground = System.Windows.Media.Brushes.White;
+                SendTaskMessage("当前为生产模式", MessageLevel.Info);
+            }
+            else
+            {
+                RunModelBackground = System.Windows.Media.Brushes.White;
+                ClearModeBackground = System.Windows.Media.Brushes.White;
+                ManualModeBackground = System.Windows.Media.Brushes.Orange;
+                SendTaskMessage("当前为调机模式", MessageLevel.Info);
+            }
+            concurrenty = true;
+        }
+
+
         private float _maxPressure = float.MinValue;
         #region Pressure collection helpers
         /// <summary>

+ 13 - 0
TeamAAS-VM/Events/CurrentStatusNotification.cs

@@ -0,0 +1,13 @@
+using Prism.Events;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TeamAAS_VP.Events
+{
+    public class CurrentStatusNotification : PubSubEvent
+    {
+    }
+}

+ 13 - 0
TeamAAS-VM/Models/PLC/PlcAddressConfig.cs

@@ -733,6 +733,14 @@ namespace TeamAAS_VP.Models.PLC
             get { return _RunMode; }
             set { SetProperty(ref _RunMode, value); }
         }
+
+        private PlcAddress _AutoRunning;
+
+        public PlcAddress AutoRunning
+        {
+            get { return _AutoRunning; }
+            set { SetProperty(ref _AutoRunning, value); }
+        }
         /// <summary>
         /// 维修模式
         /// </summary>
@@ -1266,6 +1274,11 @@ namespace TeamAAS_VP.Models.PLC
             RunMode.DataType = "Bool";
             RunMode.Description = "自动运行模式";
 
+            AutoRunning = Ensure(AutoRunning);
+            AutoRunning.Address = "ns=4;s=DB_Control|Mode.Status.AutoRunning";
+            AutoRunning.DataType = "Bool";
+            AutoRunning.Description = "生产模式";
+
             ManualMode = Ensure(ManualMode);
             ManualMode.Address = "ns=4;s=DB_Control|Mode.Status.ManualMode";
             ManualMode.DataType = "Bool";

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

@@ -540,6 +540,7 @@
     <Compile Include="Core\StabilityAnalyzer.cs" />
     <Compile Include="Core\TxtFile.cs" />
     <Compile Include="Core\VisionProFileHelper.cs" />
+    <Compile Include="Events\CurrentStatusNotification.cs" />
     <Compile Include="Events\DelaySaveImageNotification.cs" />
     <Compile Include="Events\MainTabSwitchNotification.cs" />
     <Compile Include="Events\WorkShiftChangedNotification.cs" />

+ 2 - 0
TeamAAS-VM/ViewModels/MainWindowViewModel.cs

@@ -399,6 +399,8 @@ namespace TeamAAS_VP.ViewModels
             var homeviewmodel = _container.Resolve<HomeViewModel>();
             homeviewmodel.OnNavigatedTo(null);
 
+            management.CurrentRunStatus();
+
             _ = App.Current.Dispatcher.BeginInvoke(new Action(() =>
             {
                 _eventAggregator.GetEvent<ProgressNotification>().Publish(new UProgressBar.ProgressParameter { Maximum = max, Minimum = 0, SubTitle = $"{Lang.初始化中}...", Message = $"{Lang.完成}", Value = -1 });

+ 4 - 1
TeamAAS-VM/ViewModels/Product/ProductParamsViewModel.cs

@@ -215,7 +215,10 @@ namespace TeamAAS_VP.ViewModels.Product
                     DialogHost.Close("RootDialog");
                 }
                 await task;
-
+                App.Current.Dispatcher.Invoke(() =>
+                {
+                    _eventAggregator.GetEvent<TaskMessageNotification>().Publish(new Models.MessageStruct() { Message = "保存配方参数成功...", level = Enums.MessageLevel.Info });
+                });
             }
             NavigationParameters param = new NavigationParameters();
             param.Add("SelectProduct", SelectProduct);

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

@@ -553,6 +553,10 @@ namespace TeamAAS_VP.ViewModels
         public DelegateCommand SaveProWithMesCommand =>
             _SaveProWithMesCommand ?? (_SaveProWithMesCommand = new DelegateCommand(ExecuteSaveProWithMesCommandAsync));
 
+        private DelegateCommand _CheckStatusCommand;
+        public DelegateCommand CheckStatusCommand =>
+            _CheckStatusCommand ?? (_CheckStatusCommand = new DelegateCommand(ExecuteCheckStatusCommandCommand));
+
         #endregion
 
         #region 事件
@@ -1327,6 +1331,10 @@ namespace TeamAAS_VP.ViewModels
             }
         }
 
+        private void ExecuteCheckStatusCommandCommand()
+        {
+            _eventAggregator.GetEvent<CurrentStatusNotification>().Publish();
+        }
         private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
         {
             switch (e.PropertyName)
@@ -1790,10 +1798,12 @@ namespace TeamAAS_VP.ViewModels
                     _configService.SaveSystemConfiguration(sysConfig);
                     await management.WriteSystemParameterToPlcAsync(sysConfig);
                     _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
+                    _eventAggregator.GetEvent<CurrentStatusNotification>().Publish();
                 }
                 catch (Exception ex)
                 {
                     _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
+                    _eventAggregator.GetEvent<CurrentStatusNotification>().Publish();
                 }
             }
         }

+ 21 - 7
TeamAAS-VM/Views/MainWindowView.xaml

@@ -125,14 +125,28 @@
                 </Button>
                 <materialDesign:Card Grid.Column="4"
                                      Margin="10"
-                        Grid.Row="1"
-                                     Background="{Binding management.StatusBackground}"
+                                     Grid.Row="1"
+                                     Background="White"
                                      UniformCornerRadius="15">
-                    <TextBlock Text="{Binding MyTitle}"
-                               FontSize="{DynamicResource Font.Size.Title1}"
-                               HorizontalAlignment="Center"
-                               VerticalAlignment="Center"
-                               FontWeight="Bold"/>
+                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+                        <TextBlock Text="{Binding MyTitle}"
+                                FontSize="{DynamicResource Font.Size.Title1}"
+                                HorizontalAlignment="Center"
+                                   Margin="280,0,0,0"
+                                VerticalAlignment="Center"
+                                FontWeight="Bold"/>
+                        <materialDesign:Card HorizontalAlignment="Center" VerticalAlignment="Center" Margin="50,10" Background="{Binding management.RunModelBackground}" >
+                            <TextBlock Text="生产" FontSize="22" Margin="8" />
+                        </materialDesign:Card >
+                        <materialDesign:Card HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20,10" Background="{Binding management.ManualModeBackground}" >
+                            <TextBlock Text="调机" FontSize="22" Margin="8"/>
+                        </materialDesign:Card>
+                        <materialDesign:Card HorizontalAlignment="Center" VerticalAlignment="Center" Margin="50,10" Background="{Binding management.ClearModeBackground}" >
+                            <TextBlock Text="流线" FontSize="22" Margin="8" />
+                        </materialDesign:Card>
+                    </StackPanel>
+
+
                 </materialDesign:Card>
                 <Button Grid.Column="5"
                         Grid.Row="1"

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

@@ -478,6 +478,7 @@
                                           Grid.Column="1"
                                           Content="启用 MES"
                                           IsChecked="{Binding SelectDeviceInfo.EnableMES, Mode=TwoWay}"
+                                           Command="{Binding CheckStatusCommand}"
                                           Margin="6,2" />
                                 <!--<CheckBox Grid.Row="10"
                                           Grid.Column="1"
@@ -489,6 +490,7 @@
                                             Orientation="Horizontal">
                                     <CheckBox Content="是否保存CSV文件"
                                               IsChecked="{Binding SelectDeviceInfo.SaveCsv, Mode=TwoWay}"
+                                           Command="{Binding CheckStatusCommand}"
                                               Margin="6,2" />
                                     <CheckBox Content="是否保存ppid"
                                               IsChecked="{Binding SelectDeviceInfo.SaveCsvPPID, Mode=TwoWay}"