diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2023-08-25 19:26:42 +0300 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2023-08-25 19:26:42 +0300 |
| commit | f6b8be518df438baa155f718619ad04905b4fae5 (patch) | |
| tree | 1dd5ec989a3b44c3e40905bcb4b9c8449558a0a8 /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs | |
| parent | 03ed23e3615d4ff7789f40631d2b81dda3b1daba (diff) | |
| download | Tango-f6b8be518df438baa155f718619ad04905b4fae5.tar.gz Tango-f6b8be518df438baa155f718619ad04905b4fae5.zip | |
Resume button. Set SettingUpTotalProgress as global Start Position.
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 | 77 |
1 files changed, 74 insertions, 3 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 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<TimeToDyeValueItem> items; + public TimeToDyeValueCollection() + { + items = new List<TimeToDyeValueItem>(); + } + }; + + 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<DateTimeDataPoint, DoubleDataPoint> 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 } } |
