From 56678ae530fe45b0880053793ab46f47051e4dc6 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Sun, 15 Mar 2020 16:12:26 +0200 Subject: MS Statistics Job Runs page. Added comments. --- .../Models/StatisticsValueCollection.cs | 49 +++++++++++++++++++--- 1 file changed, 44 insertions(+), 5 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs index 2a298777b..2ad165d79 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs @@ -35,6 +35,9 @@ namespace Tango.MachineStudio.Statistics.Models private ObservableCollection _statisticsCollection; + /// + /// Gets or sets the statistics collection of StatisticsValue object. + /// public ObservableCollection StatisticsCollection { get { return _statisticsCollection; } @@ -44,16 +47,25 @@ namespace Tango.MachineStudio.Statistics.Models } private List _threadConsumptionPerThread; - + /// + /// Gets or sets the thread consumption per thread list. + /// public List ThreadConsumptionPerThread { get { return _threadConsumptionPerThread; } set { _threadConsumptionPerThread = value; RaisePropertyChangedAuto(); } } + /// + /// Gets or sets the thread consumption per thread collection. + /// public CompositeCollection ThreadConsumptionPerThreadCollection { get; set; } private LabeledSeriesCollection _pieJobSource; + + /// + /// Gets or sets the pie job source. + /// public LabeledSeriesCollection PieJobSource { get { return _pieJobSource; } @@ -61,6 +73,10 @@ namespace Tango.MachineStudio.Statistics.Models } private LabeledSeriesCollection _pieJobRunStatus; + + /// + /// Gets or sets the pie job run status. + /// public LabeledSeriesCollection PieJobRunStatus { get { return _pieJobRunStatus; } @@ -68,6 +84,10 @@ namespace Tango.MachineStudio.Statistics.Models } private LabeledSeriesCollection _pieGradientSolid; + + /// + /// Gets or sets the pie gradient solid. + /// public LabeledSeriesCollection PieGradientSolid { get { return _pieGradientSolid; } @@ -75,6 +95,10 @@ namespace Tango.MachineStudio.Statistics.Models } private List _liquidQuantities; + + /// + /// Gets or sets the liquid quantities. + /// public List LiquidQuantities { get @@ -91,6 +115,9 @@ namespace Tango.MachineStudio.Statistics.Models private int _totalLiquidQuantities; + /// + /// Gets or sets the total liquid quantities. + /// public int TotalLiquidQuantities { get { return _totalLiquidQuantities; } @@ -128,6 +155,9 @@ namespace Tango.MachineStudio.Statistics.Models }; } + /// + /// Cleans all values. + /// public void Clean() { StatisticsCollection.Clear(); @@ -138,21 +168,27 @@ namespace Tango.MachineStudio.Statistics.Models PieGradientSolid.SeriesCollection.Clear(); } - public void AddStatisticsValue( string name, double value, string unit) + /// + /// Adds the statistics value. + /// + public void AddStatisticsValue(string name, double value, string unit) { - StatisticsCollection.Add(new StatisticsValue() { Name = name, Value=value, Unit = unit }); + StatisticsCollection.Add(new StatisticsValue() { Name = name, Value = value, Unit = unit }); RaisePropertyChanged("StatisticsCollection"); } + /// + /// Creates the thread consumption per thread. + /// public void CreateThreadConsumptionPerThread(List threads) { ThreadConsumptionPerThreadCollection.Add(new CollectionContainer() { Collection = threads.Take(threads.Count() > 2 ? 2 : threads.Count()) }); if (threads.Count() > 2) { - ThreadConsumptionPerThreadCollection.Add(new CollectionContainer() { Collection = new List() { new MoreValue(){ Text="More threads ..." } } }); + ThreadConsumptionPerThreadCollection.Add(new CollectionContainer() { Collection = new List() { new MoreValue() { Text = "More threads ..." } } }); ThreadConsumptionPerThread = threads.Skip(2).ToList(); } - + RaisePropertyChanged("ThreadConsumptionPerThreadCollection"); } @@ -259,6 +295,9 @@ namespace Tango.MachineStudio.Statistics.Models } #endregion + /// + /// Generates the statistics liquid quantity and TotalLiquidQuantities. + /// public void GenerateStatisticsLiquidQuantity(List liquidQuantities) { LiquidQuantities = liquidQuantities; -- cgit v1.3.1 From 1e563685f9c74fc7cfc204b714a1401002eba5fd Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Sun, 15 Mar 2020 17:11:16 +0200 Subject: Machine Studio. Statistics Job Runs page, change colors of pies, a little changes in GUI. --- .../Models/StatisticsValueCollection.cs | 20 ++++++++++++-------- .../ViewModels/JobRunsViewVM.cs | 18 +++++++++--------- .../Views/JobRunsView.xaml | 12 ++++++------ 3 files changed, 27 insertions(+), 23 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs index 2ad165d79..287e09009 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs @@ -11,6 +11,8 @@ using System.Windows.Media; using Tango.BL.Enumerations; using Tango.BL.ValueObjects; using Tango.Core; +using System.Windows.Media; +using System.Windows; namespace Tango.MachineStudio.Statistics.Models { @@ -133,8 +135,10 @@ namespace Tango.MachineStudio.Statistics.Models ThreadConsumptionPerThreadCollection = new CompositeCollection(); _pieColors = new List(); - _pieColors.Add(Color.FromRgb(239, 131, 43));//green - _pieColors.Add(Color.FromRgb(144, 233, 144));//orange + _pieColors.Add(((SolidColorBrush)Application.Current.Resources["RedBrush100"]).Color); + _pieColors.Add(((SolidColorBrush)Application.Current.Resources["OrangeBrush300"]).Color); + _pieColors.Add(((SolidColorBrush)Application.Current.Resources["GreenBrush300"]).Color); + _pieColors.Add(((SolidColorBrush)Application.Current.Resources["BlueBrush100"]).Color); _pieColors.Add(Color.FromRgb(100, 184, 236));//blue @@ -202,7 +206,7 @@ namespace Tango.MachineStudio.Statistics.Models { Title = "PPC", Values = new ChartValues() { PPCCount }, - Fill = new SolidColorBrush(_pieColors[0]), + Fill = new SolidColorBrush(_pieColors[2]), DataLabels = true, ToolTip = "", LabelPoint = labelPoint @@ -215,7 +219,7 @@ namespace Tango.MachineStudio.Statistics.Models { Title = "MS", Values = new ChartValues() { MSCount }, - Fill = new SolidColorBrush(_pieColors[2]), + Fill = new SolidColorBrush(_pieColors[3]), DataLabels = true, ToolTip = "", LabelPoint = labelPoint @@ -242,7 +246,7 @@ namespace Tango.MachineStudio.Statistics.Models { Title = "Aborted", Values = new ChartValues() { abortedCount }, - Fill = new SolidColorBrush(_pieColors[2]), + Fill = new SolidColorBrush(_pieColors[1]), DataLabels = true, ToolTip = "", LabelPoint = labelPoint, @@ -254,7 +258,7 @@ namespace Tango.MachineStudio.Statistics.Models { Title = "Completed", Values = new ChartValues() { completedCount }, - Fill = new SolidColorBrush(_pieColors[1]), + Fill = new SolidColorBrush(_pieColors[2]), DataLabels = true, ToolTip = "", LabelPoint = labelPoint @@ -270,7 +274,7 @@ namespace Tango.MachineStudio.Statistics.Models { Title = "Solid", Values = new ChartValues() { solidCount }, - Fill = new SolidColorBrush(_pieColors[0]), + Fill = new SolidColorBrush(_pieColors[2]), DataLabels = true, ToolTip = "", LabelPoint = labelPoint @@ -281,7 +285,7 @@ namespace Tango.MachineStudio.Statistics.Models { Title = "Gradient", Values = new ChartValues() { gradientCount }, - Fill = new SolidColorBrush(_pieColors[2]), + Fill = new SolidColorBrush(_pieColors[3]), DataLabels = true, ToolTip = "", LabelPoint = labelPoint diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs index ed7bbec56..ca40273f9 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs @@ -368,10 +368,10 @@ namespace Tango.MachineStudio.Statistics.ViewModels { StatisticsValueCollection.Clean(); GenerateTotalRunsLength(); + GenerateTotalThreadConsumption(); GenerateRunsDuration(); GenerateAverageUploadDuration(); GenerateAverageHeatingDuration(); - GenerateTotalThreadConsumption(); GeneratePieCharts(); CreateThreadConsumptionPerThread(); @@ -395,8 +395,8 @@ namespace Tango.MachineStudio.Statistics.ViewModels var selection = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.JobRun.EndDate != null && z.JobRun.ActualStartDate != null); double val = selection.Sum(x => (x.JobRun.EndDate - x.JobRun.ActualStartDate).Value.TotalHours); StatisticsValueCollection.AddStatisticsValue("Total Runs Duration", val, " hours"); - double average = selection.Average(x => (x.JobRun.EndDate - x.JobRun.ActualStartDate).Value.TotalHours); - StatisticsValueCollection.AddStatisticsValue("Average Runs Duration", average, " hours"); + double average = selection.Average(x => (x.JobRun.EndDate - x.JobRun.ActualStartDate).Value.TotalMilliseconds); + StatisticsValueCollection.AddStatisticsValue("Average Runs Duration", Math.Max(TimeSpan.FromMilliseconds(average).TotalHours, 0), " hours"); } /// @@ -404,8 +404,8 @@ namespace Tango.MachineStudio.Statistics.ViewModels /// protected void GenerateAverageUploadDuration() { - var val = (long)JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.UploadDuration != null).Average(x => x.UploadDuration.Value.TotalMilliseconds); - StatisticsValueCollection.AddStatisticsValue("Average Upload Duration", Math.Max(TimeSpan.FromMilliseconds(val).TotalMinutes, 0), " minutes"); + var average = (long)JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.UploadDuration != null).Average(x => x.UploadDuration.Value.TotalMilliseconds); + StatisticsValueCollection.AddStatisticsValue("Average Upload Duration", Math.Max(TimeSpan.FromMilliseconds(average).TotalMinutes, 0), " minutes"); } /// @@ -413,8 +413,8 @@ namespace Tango.MachineStudio.Statistics.ViewModels /// protected void GenerateAverageHeatingDuration() { - var average = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.HeatingDuration != null && z.HeatingDuration.Value.Ticks > 0).Average(x => x.HeatingDuration.Value.TotalMinutes); - StatisticsValueCollection.AddStatisticsValue("Average Heating Duration", Math.Max(average, 0), " minutes"); + var average = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.HeatingDuration != null && z.HeatingDuration.Value.Ticks > 0).Average(x => x.HeatingDuration.Value.TotalMilliseconds); + StatisticsValueCollection.AddStatisticsValue("Average Heating Duration", Math.Max(TimeSpan.FromMilliseconds(average).TotalMinutes, 0), " minutes"); } /// @@ -423,7 +423,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels protected void GenerateTotalThreadConsumption() { double val = JobRuns.Where(z => z.JobRun.EndPosition > 0).Sum(x => x.JobRun.EndPosition); - StatisticsValueCollection.AddStatisticsValue("Total Thread Consumption", val, " m"); + StatisticsValueCollection.AddStatisticsValue("Actual Total Runs Length", val, " m"); } /// @@ -466,7 +466,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels foreach (LiquidTypes ltype in (LiquidTypes[])Enum.GetValues(typeof(LiquidTypes))) { - var liquidQuantityByTypeList = db_liquidQuantities.Select(x => x.SingleOrDefault(y => y.LiquidType == ltype)).Where(x => x != null); + var liquidQuantityByTypeList = db_liquidQuantities.Select(x => x.FirstOrDefault(y => y.LiquidType == ltype)).Where(x => x != null); var count = liquidQuantityByTypeList != null ? liquidQuantityByTypeList.Sum(x => x.Quantity) : 0; JobRunLiquidQuantity lq = new JobRunLiquidQuantity() { LiquidType = ltype, Quantity = count }; allLiquidQuantities.Add(lq); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml index 58d94aca1..057647858 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml @@ -552,7 +552,7 @@ - + @@ -560,7 +560,7 @@ - +