zly пре 5 месеци
родитељ
комит
69d4358cf4

+ 123 - 46
TeamAAS-VM/Core/Management.cs

@@ -7,6 +7,7 @@ using Prism.Events;
 using Prism.Ioc;
 using Prism.Mvvm;
 using Prism.Regions;
+using SqlSugar;
 using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
@@ -99,6 +100,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>
@@ -252,6 +277,7 @@ namespace TeamAAS_VP.Core
             _systemDatabaseService = systemDatabaseService;
             _lightManagerService = lightManagerService;
             _mesService = mesService;
+            _eventAggregator.GetEvent<CurrentStatusNotification>().Subscribe(CurrentRunStatus);
             InitPressure();
         }
 
@@ -1235,10 +1261,6 @@ namespace TeamAAS_VP.Core
         /// </summary>
         string PartSN = "";
         /// <summary>
-        /// 压力曲线编号
-        /// </summary>
-        int pngindex = 100;
-        /// <summary>
         /// 产品SN
         /// </summary>
         string[] ProductMainSN = new string[10];//产品主sn
@@ -1269,10 +1291,11 @@ namespace TeamAAS_VP.Core
         bool _LastFixedCameraPickExe = false;
         bool _LastFixedCameraPutExe = false;
         bool _LastFixedCameracheckExe = false;
-        bool _LastThrowExe = false;
-        bool _LastRunModel = false;
+        public bool _LastAutoRunning = false;
         bool _LastManualMode = false;
         bool _LastClearMode = false;
+        bool _LastThrowExe = false;
+        bool _LastRunModel = false;
         bool _LastFault = false;
         Int16[] _LastWorkStart = new Int16[7];
         Int16 _LastQrCodePhotoRequest = 0;
@@ -2588,13 +2611,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
                         {
@@ -2603,8 +2626,12 @@ namespace TeamAAS_VP.Core
                         if (state)
                         {
                             SendTaskMessage("收到切换成自动模式", MessageLevel.Info);
-                            StatusBackground = System.Windows.Media.Brushes.Green;
                         }
+                        else
+                        {
+                            SendTaskMessage("收到关闭自动模式", MessageLevel.Info);
+                        }
+                        CurrentRunStatus();
                     }
                 }
                 //切换成维修模式
@@ -2622,13 +2649,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;
                         }
                     }
                 }
@@ -2647,33 +2671,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;
-                        }
-                    }
-                }
-                //plc报警
-                else if (addressConfig.Fault.Address.Contains(tuple.nodeId))
-                {
-                    if (tuple.value is bool state)
-                    {
-                        if (_LastFault != state)
-                        {
-                            _LastFault = state;
-                        }
-                        else
-                        {
-                            return;
-                        }
-                        if (state)
-                        {
-                            SendTaskMessage("收到PLC报警", MessageLevel.Error);
-                            StatusBackground = System.Windows.Media.Brushes.Red;
-                        }
-                        else
-                        {
-                            SendTaskMessage("收到PLC消除报警", MessageLevel.Debug);
-                            StatusBackground = System.Windows.Media.Brushes.Green;
                         }
                     }
                 }
@@ -2774,7 +2775,12 @@ namespace TeamAAS_VP.Core
                                                     revision[i] = revisionItem.Replace("stage=", "").Trim();
                                                     SendTaskMessage($"stage:{revision[i]}", MessageLevel.Info);
                                                 }
-
+                                                //if (QRcode != camerasn)
+                                                //{
+                                                //    SendTaskMessage($"Camera_SN与相机获取sn不一致", MessageLevel.Error);
+                                                //    await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)2);
+                                                //    return;
+                                                //}
                                                 //切换产品
                                                 if (i == 0)//i=0时才会切换产品
                                                 {
@@ -2879,7 +2885,12 @@ namespace TeamAAS_VP.Core
                                                 revision[i] = revisionItem.Replace("stage=", "").Trim();
                                                 SendTaskMessage($"stage:{revision[i]}", MessageLevel.Info);
                                             }
-
+                                            //if (QRcode != camerasn)
+                                            //{
+                                            //    SendTaskMessage($"Camera_SN与相机获取sn不一致", MessageLevel.Alarm);
+                                            //    await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)2);
+                                            //    return;
+                                            //}
                                             LogHelper.WriteLogMes($"询问mes成功");
                                             SendTaskMessage($"询问mes成功:{response}", MessageLevel.Debug);
 
@@ -3290,7 +3301,7 @@ namespace TeamAAS_VP.Core
                                                                     {
                                                                         string target_Torque = target_Directory + item.Replace(source_Torque_Image, "");
                                                                         File.Copy(item, target_Torque, true);
-                                                                        SendTaskMessage($"曲线图{i}保存成功", MessageLevel.Error);
+                                                                        SendTaskMessage($"曲线图{i}保存成功", MessageLevel.Debug);
                                                                     }
                                                                 }
                                                                 catch (Exception)
@@ -3455,6 +3466,73 @@ 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
+            {
+                var allDevices = _configService.GetAllDeviceInfos();
+
+                for (int i = 0; i < allDevices.Count; i++)
+                {
+                     var stationConfig =  allDevices.FirstOrDefault(d => d.DeviceNo == i);
+                    //var stationConfig = _configService.GetDeviceInfo(i);
+                    if (!string.IsNullOrEmpty(stationConfig.Station) && stationConfig.Station != ""&&!string.IsNullOrEmpty(stationConfig.DeviceName) && stationConfig.DeviceName != "")
+                    {
+                        if (!stationConfig.EnableMES || !stationConfig.EnableDoubleMes || !stationConfig.SaveCsv)
+                        {
+                            SendTaskMessage("当前MES功能/双验证功能/保存CSV功能未启用,请检查...", MessageLevel.Info);
+                            mesStatus = false;
+                            break;
+                        }
+                    }    
+                }
+                //var systemConfig = _configService.GetSystemConfiguration();
+                //if (!systemConfig.PressureSensorConfig[0].IsSavePressureCurve || !systemConfig.PressureSensorConfig[1].IsSavePressureCurve)
+                //{
+                //    paraStatus = false;
+                //}
+                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 && _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;
+        }
 
         #region Pressure collection helpers
         public void InitPressure()
@@ -3598,7 +3676,6 @@ namespace TeamAAS_VP.Core
                         csvPath = string.Empty;
                         pngPath = string.Empty;
                     }
-                    pngindex = Index;
                     App.Current.Dispatcher.Invoke(() =>
                     {
                         _eventAggregator.GetEvent<PressureFinishNotification>().Publish((true, Index, snapshot.ToArray(), pngPath));

+ 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 - 10
TeamAAS-VM/Models/PLC/PlcAddressConfig.cs

@@ -739,6 +739,15 @@ namespace TeamAAS_VP.Models.PLC
             set { SetProperty(ref _RunMode, value); }
         }
 
+
+        private PlcAddress _AutoRunning;
+
+        public PlcAddress AutoRunning
+        {
+            get { return _AutoRunning; }
+            set { SetProperty(ref _AutoRunning, value); }
+        }
+
         private PlcAddress _ManualMode;
 
         public PlcAddress ManualMode
@@ -1295,11 +1304,10 @@ namespace TeamAAS_VP.Models.PLC
             In_Throw.DataType = "Bool";
             In_Throw.Description = "抛料信号";
 
-
-            RunMode = Ensure(RunMode);
-            RunMode.Address = "ns=4;s=DB_Control|Mode.Status.RunMode";
-            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";
@@ -1311,11 +1319,6 @@ namespace TeamAAS_VP.Models.PLC
             ClearMode.DataType = "Bool";
             ClearMode.Description = "流线模式";
 
-            Fault = Ensure(Fault);
-            Fault.Address = "ns=4;s=DB_Control|Mode.Status.Fault";
-            Fault.DataType = "Bool";
-            Fault.Description = "报警";
-
             // 说明:若项目中 PlcAddress 的实际属性名或类型与此不同(例如使用枚举、不同字段名),
             // 请根据实际类型调整赋值。本方法主要提供合理的默认字符串地址、数据类型及描述,便于后续从配置覆盖。
         }

+ 2 - 5
TeamAAS-VM/Services/RemoteCommandService.cs

@@ -1895,7 +1895,7 @@ namespace TeamAAS_VP.Services
         /// <returns></returns>
         public async Task<(bool IsSucceed, double X, double Y, double U)> ExecutePhotoGetSinglePoint(ProcedureModel procedure, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken, int positionIndex, string remark)
         {
-            DateTime nowtime = DateTime.Now;
+            DateTime nowtime = DateTime.Now;            
             await SetLightBeforePhoto(procedure);
             try
             {
@@ -1918,17 +1918,14 @@ namespace TeamAAS_VP.Services
                         await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
                         return (false, 0, 0, 0);
                     }
-
                     // 2. 获取视觉输出结果
                     bool Found = (bool)(outputCollection["Found"].Value);
                     if (!Found)
                     {
                         SendTaskMessage(Lang.拍照NG, MessageLevel.Debug);
                         continue;
-                    }
-
+                    }                                      
                     SendTaskMessage(Lang.拍照OK, MessageLevel.Debug);
-
                     if (procedure.CalibrationId == Guid.Empty)
                     {
                         //没有关联校准时,则执行检测任务

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

@@ -538,6 +538,7 @@
     <Compile Include="Core\RectangleCenterCalculator.cs" />
     <Compile Include="Core\StabilityAnalyzer.cs" />
     <Compile Include="Core\VisionProFileHelper.cs" />
+    <Compile Include="Events\CurrentStatusNotification.cs" />
     <Compile Include="Events\DelaySaveImageNotification.cs" />
     <Compile Include="Events\MainTabSwitchNotification.cs" />
     <Compile Include="Interfaces\IMesService.cs" />

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

@@ -357,6 +357,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 });

+ 9 - 2
TeamAAS-VM/ViewModels/SettingViewModel.cs

@@ -516,6 +516,9 @@ 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 事件
@@ -1272,10 +1275,13 @@ namespace TeamAAS_VP.ViewModels
             }
             catch (Exception)
             {
-
             }
-        }
 
+        }
+        private void ExecuteCheckStatusCommandCommand()
+        {
+            _eventAggregator.GetEvent<CurrentStatusNotification>().Publish();
+        }
         private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
         {
             switch (e.PropertyName)
@@ -1659,6 +1665,7 @@ namespace TeamAAS_VP.ViewModels
                     _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
                 }
             }
+            _eventAggregator.GetEvent<CurrentStatusNotification>().Publish();
         }
 
         /// <summary>

+ 17 - 5
TeamAAS-VM/Views/MainWindowView.xaml

@@ -118,11 +118,23 @@
                                      Margin="10"
                                      Background="{Binding management.StatusBackground}"
                                      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"
                         Style="{StaticResource MaterialDesignIconButton}"

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

@@ -482,17 +482,20 @@
                                 <CheckBox Grid.Row="11"
                                           Grid.Column="1"
                                           IsChecked="{Binding SelectDeviceInfo.EnableMES, Mode=TwoWay}"
+                                          Command="{Binding CheckStatusCommand}"
                                           Margin="6,2" />
                                 <CheckBox Grid.Row="12"
                                           Grid.Column="1"
                                           Content="是否启用两次产品编号"
                                           IsChecked="{Binding SelectDeviceInfo.EnableDoubleMes, Mode=TwoWay}"
+                                          Command="{Binding CheckStatusCommand}"
                                           Margin="6,2" />
                                 <StackPanel Grid.Row="13"
                                             Grid.Column="1"
                                             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}"