From d33c19b3ac6803de4b5c8d475832efef131c1a45 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Wed, 30 Dec 2020 15:11:34 +0000 Subject: Revert "Hope it is fine" --- .../Models/ExcelModel.cs | 34 +++ .../Models/JobRunModel.cs | 39 +++ .../Models/JobRunStatisticsModel.cs | 45 +++ .../Models/RmlModel.cs | 15 + .../Models/StatisticsValueCollection.cs | 319 +++++++++++++++++++++ .../Models/TotalLiquidQuantityModel.cs | 15 + 6 files changed, 467 insertions(+) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/ExcelModel.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunModel.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunStatisticsModel.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/RmlModel.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/TotalLiquidQuantityModel.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/ExcelModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/ExcelModel.cs new file mode 100644 index 000000000..f06b9fe60 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/ExcelModel.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Statistics.Models +{ + public class ExcelModel + { + public String ID { get; set; } + public String Machine { get; set; } + public String User { get; set; } + public String JobName { get; set; } + public String Thread { get; set; } + public String Length { get; set; } + public String Source { get; set; } + public String UploadDuration { get; set; } + public String HeatingDuration { get; set; } + public String StartTime { get; set; } + public String IsGradient { get; set; } + public String GR { get; set; } + public String Status { get; set; } + public String EndTime { get; set; } + public String EndPosition { get; set; } + public String Cyan { get; set; } + public String Magenta { get; set; } + public String Yellow { get; set; } + public String Black { get; set; } + public String Transparent { get; set; } + public String Lubricant { get; set; } + public String Cleaner { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunModel.cs new file mode 100644 index 000000000..83897ca16 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunModel.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; + +namespace Tango.MachineStudio.Statistics.Models +{ + public class JobRunModel + { + public JobRun JobRun { get; set; } + + public Machine Machine { get; set; } + + public User User { get; set; } + + public TimeSpan? UploadDuration { get; set; } + + public TimeSpan? HeatingDuration { get; set; } + + public RmlModel Rml { get; set; } + + public void Init() + { + if (JobRun.HeatingStartDate != null) + { + UploadDuration = JobRun.HeatingStartDate - JobRun.StartDate; + } + + if (JobRun.ActualStartDate != null && JobRun.HeatingStartDate != null) + { + HeatingDuration = JobRun.ActualStartDate - JobRun.HeatingStartDate; + } + + + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunStatisticsModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunStatisticsModel.cs new file mode 100644 index 000000000..98b719cae --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunStatisticsModel.cs @@ -0,0 +1,45 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using Tango.Core.ExtensionMethods; + +namespace Tango.MachineStudio.Statistics.Models +{ + public class JobRunStatisticsModel : JobRun + { + private static Dictionary _machines = new Dictionary(); + + public JobRunStatisticsModel() + { + + } + + public JobRunStatisticsModel(JobRun run) + { + run.MapPropertiesTo(this, MappingFlags.NoReferenceTypes); + } + + public Task LoadMachine(ObservablesContext context) + { + return Task.Factory.StartNew(() => + { + if (!_machines.ContainsKey(MachineGuid)) + { + Machine = context.Machines.SingleOrDefault(x => x.Guid == MachineGuid); + _machines.Add(MachineGuid, Machine); + } + else + { + Machine = _machines[MachineGuid]; + } + }); + } + + public Machine Machine { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/RmlModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/RmlModel.cs new file mode 100644 index 000000000..789779e42 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/RmlModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Statistics.Models +{ + public class RmlModel + { + public string Guid { get; set; } + + public string Name { get; set; } + } +} 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 new file mode 100644 index 000000000..b5615e4d1 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs @@ -0,0 +1,319 @@ +using LiveCharts; +using LiveCharts.Wpf; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +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 +{ + public class StatisticsValue + { + public string Name { get; set; } + + public object Value { get; set; } + + public string Unit { get; set; } + } + public class MoreValue + { + public string Text { get; set; } + } + + public class StatisticsValueCollection : ExtendedObject + { + private List _pieColors; + + #region Properties + + private ObservableCollection _statisticsCollection; + + /// + /// Gets or sets the statistics collection of StatisticsValue object. + /// + public ObservableCollection StatisticsCollection + { + get { return _statisticsCollection; } + set + { + _statisticsCollection = value; + RaisePropertyChangedAuto(); + } + } + + 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; } + set { _pieJobSource = value; RaisePropertyChangedAuto(); } + } + + private LabeledSeriesCollection _pieJobRunStatus; + + /// + /// Gets or sets the pie job run status. + /// + public LabeledSeriesCollection PieJobRunStatus + { + get { return _pieJobRunStatus; } + set { _pieJobRunStatus = value; RaisePropertyChangedAuto(); } + } + + private LabeledSeriesCollection _pieGradientSolid; + + /// + /// Gets or sets the pie gradient solid. + /// + public LabeledSeriesCollection PieGradientSolid + { + get { return _pieGradientSolid; } + set { _pieGradientSolid = value; RaisePropertyChangedAuto(); } + } + + private List _liquidQuantities; + + /// + /// Gets or sets the liquid quantities. + /// + public List LiquidQuantities + { + get + { + if (_liquidQuantities == null) + { + _liquidQuantities = new List(); + } + return _liquidQuantities; + } + set + { _liquidQuantities = value; RaisePropertyChangedAuto(); } + } + + private ulong _totalLiquidQuantities; + + /// + /// Gets or sets the total liquid quantities. + /// + public ulong TotalLiquidQuantities + { + get { return _totalLiquidQuantities; } + set { _totalLiquidQuantities = value; RaisePropertyChangedAuto(); } + } + + #endregion + + public StatisticsValueCollection() + { + StatisticsCollection = new ObservableCollection(); + ThreadConsumptionPerThread = new List(); + ThreadConsumptionPerThreadCollection = new CompositeCollection(); + + _pieColors = new List(); + _pieColors.Add(((SolidColorBrush)Application.Current.Resources["RedBrush500"]).Color); + _pieColors.Add(((SolidColorBrush)Application.Current.Resources["OrangeBrush"]).Color); + _pieColors.Add(((SolidColorBrush)Application.Current.Resources["GreenBrush"]).Color); + _pieColors.Add(((SolidColorBrush)Application.Current.Resources["BlueBrush100"]).Color); + _pieColors.Add(Color.FromRgb(255, 216, 76)); + + + PieJobSource = new LabeledSeriesCollection() + { + Title = "PPC/MS", + SeriesColors = _pieColors, + }; + PieJobRunStatus = new LabeledSeriesCollection() + { + Title = "Failed/Aborted/Completed", + SeriesColors = _pieColors, + }; + PieGradientSolid = new LabeledSeriesCollection() + { + Title = "Gradient/Solid", + SeriesColors = _pieColors, + }; + } + + /// + /// Cleans all values. + /// + public void Clean() + { + StatisticsCollection.Clear(); + ThreadConsumptionPerThreadCollection.Clear(); + ThreadConsumptionPerThread.Clear(); + PieJobSource.SeriesCollection.Clear(); + PieJobRunStatus.SeriesCollection.Clear(); + PieGradientSolid.SeriesCollection.Clear(); + } + + /// + /// Adds the statistics value. + /// + public void AddStatisticsValue(string name, object value, string 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 ..." } } }); + ThreadConsumptionPerThread = threads.Skip(2).ToList(); + } + + RaisePropertyChanged("ThreadConsumptionPerThreadCollection"); + } + + #region GeneratePieChart + Func labelPoint = chartPoint => + string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation); + + public void GeneratePieJobSource(int PPCCount, int MSCount) + { + var series = new PieSeries() + { + Title = "PPC", + Values = new ChartValues() { PPCCount }, + Fill = new SolidColorBrush(_pieColors[4]), + DataLabels = true, + ToolTip = "", + LabelPoint = labelPoint + + }; + + PieJobSource.SeriesCollection.Add(series); + + series = new PieSeries() + { + Title = "MS", + Values = new ChartValues() { MSCount }, + Fill = new SolidColorBrush(_pieColors[3]), + DataLabels = true, + ToolTip = "", + LabelPoint = labelPoint + }; + PieJobSource.SeriesCollection.Add(series); + RaisePropertyChanged("PieJobSource"); + } + + public void GeneratePieJobRunStatus(int failedCount, int abortedCount, int completedCount) + { + var series = new PieSeries() + { + Title = "Failed", + Values = new ChartValues() { failedCount }, + Fill = new SolidColorBrush(_pieColors[0]), + DataLabels = true, + ToolTip = "", + LabelPoint = labelPoint + }; + + PieJobRunStatus.SeriesCollection.Add(series); + + series = new PieSeries() + { + Title = "Aborted", + Values = new ChartValues() { abortedCount }, + Fill = new SolidColorBrush(_pieColors[1]), + DataLabels = true, + ToolTip = "", + LabelPoint = labelPoint, + + }; + PieJobRunStatus.SeriesCollection.Add(series); + + series = new PieSeries() + { + Title = "Completed", + Values = new ChartValues() { completedCount }, + Fill = new SolidColorBrush(_pieColors[2]), + DataLabels = true, + ToolTip = "", + LabelPoint = labelPoint + }; + PieJobRunStatus.SeriesCollection.Add(series); + + RaisePropertyChanged("PieJobRunStatus"); + } + + public void GeneratePieGradientSolid(int gradientCount, int solidCount) + { + var series = new PieSeries() + { + Title = "Solid", + Values = new ChartValues() { solidCount }, + Fill = new SolidColorBrush(_pieColors[4]), + DataLabels = true, + ToolTip = "", + LabelPoint = labelPoint + }; + PieGradientSolid.SeriesCollection.Add(series); + + series = new PieSeries() + { + Title = "Gradient", + Values = new ChartValues() { gradientCount }, + Fill = new SolidColorBrush(_pieColors[3]), + DataLabels = true, + ToolTip = "", + LabelPoint = labelPoint + + }; + + PieGradientSolid.SeriesCollection.Add(series); + + + RaisePropertyChanged("PieGradientSolid"); + } + #endregion + + /// + /// Generates the statistics liquid quantity and TotalLiquidQuantities. + /// + public void GenerateStatisticsLiquidQuantity(List liquidQuantities) + { + LiquidQuantities = liquidQuantities; + TotalLiquidQuantities = 0; + + foreach (var item in liquidQuantities) + { + TotalLiquidQuantities += (ulong)item.Quantity; + } + } + + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/TotalLiquidQuantityModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/TotalLiquidQuantityModel.cs new file mode 100644 index 000000000..b5e2e9fb7 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/TotalLiquidQuantityModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Enumerations; + +namespace Tango.MachineStudio.Statistics.Models +{ + public class TotalLiquidQuantityModel + { + public LiquidTypes LiquidType { get; set; } + public ulong Quantity { get; set; } + } +} -- cgit v1.3.1