diff options
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs | 192 |
1 files changed, 186 insertions, 6 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs index 828047ccf..103084e11 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs @@ -20,11 +20,27 @@ using System.Timers; using System.Windows.Threading; using System.Diagnostics; using Tango.PMR.Printing; +using System.ComponentModel; +using RealTimeGraphX.WPF; +using RealTimeGraphX.DataPoints; +using Tango.PPC.UI.Graphs; namespace Tango.PPC.UI.ViewModels { public class MachineStatusViewVM : PPCViewModel { + public enum StatisticTab + { + [Description("Production Data")] + Productiondata = 0, + [Description("Temperature")] + Temperature = 1, + [Description("Pressure")] + Pressure = 2, + [Description("Motor")] + Motor = 3 + } + #region Properties [TangoInject] @@ -45,6 +61,7 @@ namespace Tango.PPC.UI.ViewModels if (_job == null) IsDyeingProcess = false; RaisePropertyChangedAuto(); + InvalidateRelayCommands(); } } @@ -185,6 +202,13 @@ namespace Tango.PPC.UI.ViewModels set { _midTankLevels = value; RaisePropertyChangedAuto(); } } + private JerricanLevelModel _midTankLubLevel; + public JerricanLevelModel MidTankLubLevel + { + get { return _midTankLubLevel; } + set { _midTankLubLevel = value; RaisePropertyChangedAuto(); } + } + public MachineOverviewModel OverviewModel { get; set; } private bool _isDisplayJobOutline; @@ -206,7 +230,84 @@ namespace Tango.PPC.UI.ViewModels get { return _jobOutlineTicket; } set { _jobOutlineTicket = value; RaisePropertyChangedAuto(); } } - + + public MachineOverviewErrorStates MachineErrorStates { get; set; } + + private bool _isExpandedNotificatios; + + public bool IsExpandedNotifications + { + get { return _isExpandedNotificatios; } + set { + _isExpandedNotificatios = value; + RaisePropertyChangedAuto();} + } + + private int _selectedStatisticTabIndex; + /// <summary> + /// Gets or sets the index of the selected category. + /// </summary> + public int SelectedStatisticTabIndex + { + get { return _selectedStatisticTabIndex; } + set + { + if (_selectedStatisticTabIndex != value) + { + _selectedStatisticTabIndex = value; + RaisePropertyChangedAuto(); + switch (_selectedStatisticTabIndex) + { + case 0: + { + SelectedStatisticTab = StatisticTab.Productiondata; + break; + } + case 1: + { + SelectedStatisticTab = StatisticTab.Temperature; + break; + } + case 2: + { + SelectedStatisticTab = StatisticTab.Pressure; + break; + } + case 3: + { + SelectedStatisticTab = StatisticTab.Motor; + break; + } + } + } + } + } + + private StatisticTab _selectedStatisticTab; + /// <summary> + /// Gets or sets the selected category. + /// </summary> + /// + public StatisticTab SelectedStatisticTab + { + get + { + return _selectedStatisticTab; + } + set + { + if (_selectedStatisticTab != value) + { + _selectedStatisticTab = value; + RaisePropertyChangedAuto(); + } + _selectedStatisticTabIndex = _selectedStatisticTab.ToInt32(); + RaisePropertyChanged(nameof(SelectedStatisticTabIndex)); + } + } + + public WpfGraphController<DateTimeDataPoint, DoubleDataPoint> JobController { get; set; } + #endregion #region Commands @@ -241,7 +342,7 @@ namespace Tango.PPC.UI.ViewModels StopCommand = new RelayCommand(StopJob, () => CanStopped()); AbortCommand = new RelayCommand(AbortJob, () => CanStopped()); - GoToJobCommand = new RelayCommand(GoToJob); + GoToJobCommand = new RelayCommand(GoToJob, () => IsEnableGoToJob()); JobStatusViewCommand = new RelayCommand(JobStatusView); OverviewViewCommand = new RelayCommand(OverviewView); ClearAllNotificationsCommand = new RelayCommand(ClearAllNotifications); @@ -254,17 +355,32 @@ namespace Tango.PPC.UI.ViewModels IsWeghtView = false; OverviewModel = new MachineOverviewModel(); + MachineErrorStates = new MachineOverviewErrorStates(); + + IsExpandedNotifications = false; + SelectedStatisticTabIndex = 0; + + JobController = CreateController(CreateSeries("Total", GraphHelper.GraphColor.Green)); } public override void OnApplicationReady() { base.OnApplicationReady(); + EventLogger.EventReceived += EventLogger_EventReceived; - MidTankLevels = MachineProvider.Machine.Configuration.NoneEmptyIdsPacks.Where(x => x.MidTankType.HasLevelMeasure || x.MidTankType.Type == MidTankTypes.LubricantMidTank).OrderBy(x => x.PackIndex).Select(x => new JerricanLevelModel() + MidTankLevels = MachineProvider.Machine.Configuration.NoneEmptyIdsPacks.Where(x => x.MidTankType.HasLevelMeasure ).OrderBy(x => x.PackIndex).Select(x => new JerricanLevelModel() { Max = x.MidTankType.LiterCapacity, IDSPack = x, - }).OrderBy(y => y.IDSPack.LiquidType.PreferredIndex).ToList(); + }).OrderBy(y => y.IDSPack.LiquidType.Type).ToList(); + var LubLevel = MachineProvider.Machine.Configuration.NoneEmptyIdsPacks.Where(x => x.MidTankType.Type == MidTankTypes.LubricantMidTank).FirstOrDefault(); + + MidTankLubLevel = new JerricanLevelModel(); + if(LubLevel != null) + { + MidTankLubLevel.Max = LubLevel.MidTankType.LiterCapacity; + MidTankLubLevel.IDSPack = LubLevel; + }; MachineProvider.MachineOperator.MachineStatusChanged += MachineOperator_MachineStatusChanged; @@ -272,9 +388,21 @@ namespace Tango.PPC.UI.ViewModels #region Events - private void MachineOperator_MachineStatusChanged(object sender, MachineStatus status) + private void EventLogger_EventReceived(object sender, MachinesEvent ev) + { + InvokeUI(() => + { + if (ev.Category == EventTypeCategories.Error || ev.Category == EventTypeCategories.Critical) + { + IsExpandedNotifications = true; + } + }); + } + + private void MachineOperator_MachineStatusChanged(object sender, MachineStatus status) { UpdateMidTankLevels(status); + UpdateMachineStatusErrors(status); } private void UpdateMidTankLevels(MachineStatus status) { @@ -282,7 +410,15 @@ namespace Tango.PPC.UI.ViewModels { foreach (var item in status.IDSPacksLevels) { - var model = MidTankLevels.SingleOrDefault(x => x.IDSPack.PackIndex == item.Index); + JerricanLevelModel model = null; + if (item.Index == 8)//lub + { + model = MidTankLubLevel; + + } + else { + model = MidTankLevels.SingleOrDefault(x => x.IDSPack.PackIndex == item.Index); + } if (model != null) { @@ -348,6 +484,16 @@ namespace Tango.PPC.UI.ViewModels } } + private void UpdateMachineStatusErrors(MachineStatus status) + { + var windersInError = status.WindersInError.ToList();// to test + MachineErrorStates.UpdateWinders(windersInError); + var dansersInError = status.DancersInError.ToList(); + MachineErrorStates.UpdateDancers(dansersInError); + var btsrsInErrors = status.BtsrsInError.ToList(); + MachineErrorStates.UpdateBTSRs(btsrsInErrors); + } + private void MachineOperator_InkFillingStatusChanged(object sender, InkFillingStatusChangedEventArgs e) { //foreach (var cartridge in e.Status.CartridgesStatuses.Where(x => x.Cartridge.Slot != CartridgeSlot.Ink)) @@ -453,6 +599,11 @@ namespace Tango.PPC.UI.ViewModels #region Methods + private bool IsEnableGoToJob() + { + return Job != null && _handler != null; + } + private void GoToJob() { @@ -545,6 +696,35 @@ namespace Tango.PPC.UI.ViewModels } } + private WpfGraphController<DateTimeDataPoint, DoubleDataPoint> CreateController(params WpfGraphDataSeries[] seriesCollection) + { + var controller = new WpfGraphController<DateTimeDataPoint, DoubleDataPoint>(); + + foreach (var series in seriesCollection) + { + controller.DataSeriesCollection.Add(series); + } + + controller.Range.AutoY = true; + controller.Range.MaximumY = 100; + controller.Range.MinimumY = 0; + controller.Range.MaximumX = new DateTime(0).AddMinutes(30); + + controller.RefreshRate = TimeSpan.FromMilliseconds(300000);//5 min + + return controller; + } + + private WpfGraphDataSeries CreateSeries(String name, GraphHelper.GraphColor fill) + { + WpfGraphDataSeries series = new WpfGraphDataSeries(); + series.Name = name; + series.Fill = GraphHelper.GetGraphBrush(fill); + series.StrokeThickness = 1; + series.Stroke = GraphHelper.GetGraphStrokeColor(); + return series; + } + #endregion } } |
