From f6b8be518df438baa155f718619ad04905b4fae5 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Fri, 25 Aug 2023 19:26:42 +0300 Subject: Resume button. Set SettingUpTotalProgress as global Start Position. --- .../Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs | 77 +++++++++++++++++++++- 1 file changed, 74 insertions(+), 3 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels') 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 f8c139cf6..131476c9e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs @@ -24,6 +24,9 @@ using System.ComponentModel; using RealTimeGraphX.WPF; using RealTimeGraphX.DataPoints; using Tango.PPC.UI.Graphs; +using Tango.BL; +using System.Data.Entity; +using System.Windows.Media; namespace Tango.PPC.UI.ViewModels { @@ -41,6 +44,25 @@ namespace Tango.PPC.UI.ViewModels Motor = 3 } + public class TimeToDyeValueItem + { + public DateTime startTime; + public DateTime endTime; + public double totalValue; + }; + + public class TimeToDyeValueCollection + { + public DateTime StartTime { get; set;} + public List items; + public TimeToDyeValueCollection() + { + items = new List(); + } + }; + + private DispatcherTimer _productiondata_timer; + #region Properties [TangoInject] @@ -344,7 +366,10 @@ namespace Tango.PPC.UI.ViewModels public MachineStatusViewVM() { - + _productiondata_timer = new DispatcherTimer(); + _productiondata_timer.Interval = TimeSpan.FromMinutes(10); + _productiondata_timer.Tick += _productiondata_timer_Tick; + StopCommand = new RelayCommand(StopJob, () => CanStopped()); AbortCommand = new RelayCommand(AbortJob, () => CanStopped()); @@ -355,7 +380,7 @@ namespace Tango.PPC.UI.ViewModels ClearJobCommand = new RelayCommand(ClearJob, () => CanStopped()); - GoToJobCommand = new RelayCommand(GoToJob, () => IsEnableGoToJob()); + GoToJobCommand = new RelayCommand(GoToJob, () => IsEnableGoToJob()); JobStatusViewCommand = new RelayCommand(JobStatusView); OverviewViewCommand = new RelayCommand(OverviewView); ClearAllNotificationsCommand = new RelayCommand(ClearAllNotifications); @@ -397,6 +422,12 @@ namespace Tango.PPC.UI.ViewModels MachineProvider.MachineOperator.MachineStatusChanged += MachineOperator_MachineStatusChanged; + DateTime dateTime = DateTime.Now; + DateTime onedayEarlier = dateTime.AddDays(-1); + + GetCollectionDyePropByStartTime(onedayEarlier); + + _productiondata_timer.Start(); } #region Events @@ -520,6 +551,10 @@ namespace Tango.PPC.UI.ViewModels //} } + private void _productiondata_timer_Tick(object sender, EventArgs e) + { + var CurrentDateTime = DateTime.Now; + } #endregion #region printing @@ -749,6 +784,12 @@ namespace Tango.PPC.UI.ViewModels IsDisplayJobOutline = true; } } + + #endregion + + #region graph + + public TimeToDyeValueCollection graphDyeingValuesCollection = new TimeToDyeValueCollection(); private WpfGraphController CreateController(params WpfGraphDataSeries[] seriesCollection) { @@ -771,7 +812,10 @@ namespace Tango.PPC.UI.ViewModels private WpfGraphDataSeries CreateSeries(String name, GraphHelper.GraphColor fill) { - WpfGraphDataSeries series = new WpfGraphDataSeries(); + WpfGraphDataSeries series = new WpfGraphDataSeries() + { + Stroke = Colors.DodgerBlue, + }; series.Name = name; series.Fill = GraphHelper.GetGraphBrush(fill); series.StrokeThickness = 1; @@ -779,6 +823,33 @@ namespace Tango.PPC.UI.ViewModels return series; } + public async void GetCollectionDyePropByStartTime(DateTime starttime) + { + try + { + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var jobRuns = await db.JobRuns.Where(x => x.StartDate >= starttime).Select(x => new { x.StartDate, x.EndDate, x.EndPosition }).OrderBy(y => y.StartDate).ToListAsync(); + double allvalues = 0; + graphDyeingValuesCollection.StartTime = starttime; + for ( int i = 0; i < jobRuns.Count; i++) + { + JobController.PushData(jobRuns[i].StartDate, allvalues); + if (i > 0) + { + allvalues += jobRuns[i-1].EndPosition; + } + graphDyeingValuesCollection.items.Add( new TimeToDyeValueItem(){ startTime = jobRuns[i].StartDate, endTime = jobRuns[i].EndDate, totalValue = allvalues }); + JobController.PushData(jobRuns[i].EndDate, allvalues); + } + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error loading machine counters."); + + } + } #endregion } } -- cgit v1.3.1