Răsfoiți Sursa

Merge branch 'master' of http://49.235.130.76/XXF_1122/DaisyNPILine

wanghan 5 luni în urmă
părinte
comite
c72d64da68

+ 107 - 0
TeamAAS-VM/Core/Management.cs

@@ -97,6 +97,15 @@ namespace TeamAAS_VP.Core
         #endregion
 
         #region 属性
+
+        private System.Windows.Media.Brush _StatusBackground;
+
+        public System.Windows.Media.Brush StatusBackground
+        {
+            get { return _StatusBackground; }
+            set { SetProperty(ref _StatusBackground, value); }
+        }
+
         private ObservableCollection<ShowRender> _Renders;
 
         /// <summary>
@@ -1186,6 +1195,10 @@ namespace TeamAAS_VP.Core
                 addressConfig.In_ScrewTeachExe.Address,
                 addressConfig.In_PickINC.Address,
                 addressConfig.In_Throw.Address,
+                addressConfig.RunMode.Address,
+                addressConfig.ManualMode.Address,
+                addressConfig.ClearMode.Address,
+                addressConfig.Fault.Address,
             };
             var systemconfig = _configService.GetSystemConfiguration();
             for (int i = 0; i < 10; i++)
@@ -1335,6 +1348,10 @@ namespace TeamAAS_VP.Core
         bool _LastFixedCameraPutExe = false;
         bool _LastFixedCameracheckExe = false;
         bool _LastThrowExe = false;
+        bool _LastRunModel = false;
+        bool _LastManualMode = false;
+        bool _LastClearMode = false;
+        bool _LastFault = false;
         Int16 _LastWorkStart = 0;
         Int16 _LastWorkDone = 0;
         Int16 _LastRequestPosition = 0;
@@ -2186,6 +2203,96 @@ namespace TeamAAS_VP.Core
                         }
                     }
                 }
+                //切换成自动运行模式
+                else if (addressConfig.RunMode.Address.Contains(tuple.nodeId))
+                {
+                    if (tuple.value is bool state)
+                    {
+                        if (_LastRunModel != state)
+                        {
+                            _LastRunModel = state;
+                        }
+                        else
+                        {
+                            return;
+                        }
+                        if (state)
+                        {
+                            SendTaskMessage("收到切换成自动模式", MessageLevel.Info);
+                            StatusBackground = System.Windows.Media.Brushes.Green;
+                        }
+                    }
+                }
+                //切换成维修模式
+                else if (addressConfig.ManualMode.Address.Contains(tuple.nodeId))
+                {
+                    if (tuple.value is bool state)
+                    {
+                        if (_LastManualMode != state)
+                        {
+                            _LastManualMode = state;
+                        }
+                        else
+                        {
+                            return;
+                        }
+                        if (state)
+                        {
+                            SendTaskMessage("收到切换成维修模式", MessageLevel.Info);
+                            StatusBackground = System.Windows.Media.Brushes.Yellow;
+                        }
+                        else
+                        {
+                            SendTaskMessage("收到切换成自动模式", MessageLevel.Info);
+                            StatusBackground = System.Windows.Media.Brushes.Green;
+                        }
+                    }
+                }
+                //切换成流线模式
+                else if (addressConfig.ClearMode.Address.Contains(tuple.nodeId))
+                {
+                    if (tuple.value is bool state)
+                    {
+                        if (_LastClearMode != state)
+                        {
+                            _LastClearMode = state;
+                        }
+                        else
+                        {
+                            return;
+                        }
+                        if (state)
+                        {
+                            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;
+                        }
+                    }
+                }
                 // 过站检查
                 else
                 {

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

@@ -724,6 +724,46 @@ namespace TeamAAS_VP.Models.PLC
             set { SetProperty(ref _In_Throw, value); }
         }
 
+        private PlcAddress _RunMode;
+        /// <summary>
+        /// 自动运行模式
+        /// </summary>
+        public PlcAddress RunMode
+        {
+            get { return _RunMode; }
+            set { SetProperty(ref _RunMode, value); }
+        }
+        /// <summary>
+        /// 维修模式
+        /// </summary>
+        private PlcAddress _ManualMode;
+
+        public PlcAddress ManualMode
+        {
+            get { return _ManualMode; }
+            set { SetProperty(ref _ManualMode, value); }
+        }
+
+        private PlcAddress _ClearMode;
+        /// <summary>
+        /// 流线模式
+        /// </summary>
+        public PlcAddress ClearMode
+        {
+            get { return _ClearMode; }
+            set { SetProperty(ref _ClearMode, value); }
+        }
+
+        private PlcAddress _Fault;
+        /// <summary>
+        /// 报警
+        /// </summary>
+        public PlcAddress Fault
+        {
+            get { return _Fault; }
+            set { SetProperty(ref _Fault, value); }
+        }
+
         #endregion
 
         public PlcAddressConfig()
@@ -1221,6 +1261,26 @@ 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 = "自动运行模式";
+
+            ManualMode = Ensure(ManualMode);
+            ManualMode.Address = "ns=4;s=DB_Control|Mode.Status.ManualMode";
+            ManualMode.DataType = "Bool";
+            ManualMode.Description = "维修模式";
+
+            ClearMode = Ensure(ClearMode);
+            ClearMode.Address = "ns=4;s=DB_Control|Mode.Status.ClearMode";
+            ClearMode.DataType = "Bool";
+            ClearMode.Description = "流线模式";
+
+            Fault = Ensure(Fault);
+            Fault.Address = "ns=4;s=DB_Control|Mode.Status.Fault";
+            Fault.DataType = "Bool";
+            Fault.Description = "报警";
+
             //ns=4;s=DB_Input|X16_螺丝供料器1螺丝到位
             //ns=4;s=DB_Input|X17_螺丝供料器2螺丝到位
 

+ 25 - 25
TeamAAS-VM/ViewModels/HomeViewModel.cs

@@ -665,31 +665,31 @@ namespace TeamAAS_VP.ViewModels
         {
             //更新对应传感器的曲线图
 
-            App.Current.Dispatcher.BeginInvoke(new Action(() =>
-            {
-                var model = PressurePlotModel;
-                var series = model.Series[0] as LineSeries;
-                series.Points.Clear();
-                //第一个点的时间作为X轴起点
-                DateTime xAxisStart = tuple.values[0].Timestamp;
-                foreach (var dataPoint in tuple.values)
-                {
-                    // 计算相对于起点的秒数作为X轴坐标
-                    double xValue = (dataPoint.Timestamp - xAxisStart).TotalSeconds;
-                    series.Points.Add(new OxyPlot.DataPoint(xValue, dataPoint.Value));
-                }
-                // 重置所有轴的范围以适应新数据
-                model.ResetAllAxes();
-                model.InvalidatePlot(true);
-                if (!string.IsNullOrEmpty(tuple.SavePath))
-                {
-                    if (!Directory.Exists(Path.GetDirectoryName(tuple.SavePath)))
-                    {
-                        Directory.CreateDirectory(Path.GetDirectoryName(tuple.SavePath));
-                    }
-                   PngExporter.Export(model, tuple.SavePath, (int)model.Width, (int)model.Height);
-                }
-            }));
+            //App.Current.Dispatcher.BeginInvoke(new Action(() =>
+            //{
+            //    var model = PressurePlotModel;
+            //    var series = model.Series[0] as LineSeries;
+            //    series.Points.Clear();
+            //    //第一个点的时间作为X轴起点
+            //    DateTime xAxisStart = tuple.values[0].Timestamp;
+            //    foreach (var dataPoint in tuple.values)
+            //    {
+            //        // 计算相对于起点的秒数作为X轴坐标
+            //        double xValue = (dataPoint.Timestamp - xAxisStart).TotalSeconds;
+            //        series.Points.Add(new OxyPlot.DataPoint(xValue, dataPoint.Value));
+            //    }
+            //    // 重置所有轴的范围以适应新数据
+            //    model.ResetAllAxes();
+            //    model.InvalidatePlot(true);
+            //    if (!string.IsNullOrEmpty(tuple.SavePath))
+            //    {
+            //        if (!Directory.Exists(Path.GetDirectoryName(tuple.SavePath)))
+            //        {
+            //            Directory.CreateDirectory(Path.GetDirectoryName(tuple.SavePath));
+            //        }
+            //       PngExporter.Export(model, tuple.SavePath, (int)model.Width, (int)model.Height);
+            //    }
+            //}));
         }
 
 

+ 7 - 1
TeamAAS-VM/ViewModels/MainWindowViewModel.cs

@@ -57,7 +57,6 @@ namespace TeamAAS_VP.ViewModels
         ISystemDatabaseService _systemDatabaseService;
         IDatabaseInitializer _databaseInitializer;
         ShiftWatcherService _shiftWatcherService;
-        private Management management;
         private Guid CurrentTime;
         private Guid RunTime;
         private DateTime StartTime;
@@ -67,6 +66,13 @@ namespace TeamAAS_VP.ViewModels
 
         #region 属性
 
+        private Management _management;
+        public Management management
+        {
+            get { return _management; }
+            set { SetProperty(ref _management, value); }
+        }
+
         private string _CompanyTitle;
         public string CompanyTitle
         {

+ 1 - 0
TeamAAS-VM/Views/MainWindowView.xaml

@@ -116,6 +116,7 @@
                 </Button>
                 <materialDesign:Card Grid.Column="4"
                                      Margin="10"
+                                     Background="{Binding management.StatusBackground}"
                                      UniformCornerRadius="15">
                     <TextBlock Text="{Binding MyTitle}"
                                FontSize="{DynamicResource Font.Size.Title1}"