diff options
Diffstat (limited to 'Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/ViewModels/MainViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/ViewModels/MainViewVM.cs | 144 |
1 files changed, 96 insertions, 48 deletions
diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/ViewModels/MainViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/ViewModels/MainViewVM.cs index a21619aac..c301621f6 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/ViewModels/MainViewVM.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json; +using LiveCharts; +using LiveCharts.Wpf; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -10,6 +12,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Data; +using System.Windows.Media; using Tango.BL; using Tango.BL.DTO; using Tango.BL.Entities; @@ -21,6 +24,7 @@ using Tango.Core.ExtensionMethods; using Tango.CSV; using Tango.FSE.Common; using Tango.FSE.Common.AutoComplete; +using Tango.FSE.Common.Converters; using Tango.FSE.Common.Navigation; using Tango.FSE.Common.Notifications; using Tango.FSE.Common.Statistics; @@ -39,6 +43,7 @@ namespace Tango.FSE.Statistics.ViewModels private StatisticsModel _model; private String _currentFineTuningSessionID; private List<StopModel> _fineTuningStops; + private List<LiquidType> _liquidTypes; #region Properties @@ -171,6 +176,14 @@ namespace Tango.FSE.Statistics.ViewModels get { return Stops != null && Stops.Count > 0 && Stops[0].JobIndex != NULL_JOB_INDEX; } } + private SeriesCollection _seriesCollection; + public SeriesCollection SeriesCollection + { + get { return _seriesCollection; } + set { _seriesCollection = value; RaisePropertyChangedAuto(); } + } + + #endregion #region Commands @@ -350,6 +363,7 @@ namespace Tango.FSE.Statistics.ViewModels filters.RmlGuids = SelectedThreads.SynchedSource.Select(x => x.Guid).ToList(); _model = await StatisticsProvider.GetStatistics(filters); + _liquidTypes = _model.StatisticsResult.LiquidTypes.Select(x => x.ToObservable()).ToList(); List<StopModel> stops = new List<StopModel>(); @@ -447,11 +461,6 @@ namespace Tango.FSE.Statistics.ViewModels stop.Green = jobStop.Green; stop.Blue = jobStop.Blue; - stop.Cyan = jobStop.Cyan; - stop.Magenta = jobStop.Magenta; - stop.Yellow = jobStop.Yellow; - stop.Black = jobStop.Black; - stop.Catalog = jobStop.Catalog; stop.CatalogItem = jobStop.CatalogItem; @@ -495,37 +504,47 @@ namespace Tango.FSE.Statistics.ViewModels stats.TotalDyeingTime = TimeSpan.FromHours(timeRuns.Sum(x => (x.JobRun.EndDate - x.JobRun.ActualStartDate.Value).TotalHours)); stats.AverageDyeingTime = TimeSpan.FromHours(timeRuns.Average(x => (x.JobRun.EndDate - x.JobRun.ActualStartDate.Value).TotalHours)); + SeriesCollection seriesCollection = new SeriesCollection(); + List<LiquidQuantityModel> liquidQuantities = new List<LiquidQuantityModel>(); - Dictionary<LiquidTypes, double> quantities = new Dictionary<LiquidTypes, double>(); - quantities.Add(LiquidTypes.Cyan, 0); - quantities.Add(LiquidTypes.Magenta, 0); - quantities.Add(LiquidTypes.Yellow, 0); - quantities.Add(LiquidTypes.Black, 0); - quantities.Add(LiquidTypes.LightCyan, 0); - quantities.Add(LiquidTypes.LightMagenta, 0); - quantities.Add(LiquidTypes.LightYellow, 0); - quantities.Add(LiquidTypes.TransparentInk, 0); - quantities.Add(LiquidTypes.Lubricant, 0); + foreach (var liquidType in _liquidTypes.ToList()) + { + liquidQuantities.Add(new LiquidQuantityModel() + { + LiquidType = liquidType, + Quantity = 0 + }); + } foreach (var stop in Stops) { - quantities[LiquidTypes.Cyan] += stop.JobRun.CyanQuantity; - quantities[LiquidTypes.Magenta] += stop.JobRun.MagentaQuantity; - quantities[LiquidTypes.Yellow] += stop.JobRun.YellowQuantity; - quantities[LiquidTypes.Black] += stop.JobRun.BlackQuantity; - quantities[LiquidTypes.LightCyan] += stop.JobRun.LightCyanQuantity; - quantities[LiquidTypes.LightMagenta] += stop.JobRun.LightMagentaQuantity; - quantities[LiquidTypes.LightYellow] += stop.JobRun.LightYellowQuantity; - quantities[LiquidTypes.TransparentInk] += stop.JobRun.TransparentQuantity; - quantities[LiquidTypes.Lubricant] += stop.JobRun.LubricantQuantity; + foreach (var quantity in liquidQuantities) + { + quantity.Quantity += (double)typeof(JobRun).GetProperty(quantity.LiquidType.Type.ToString() + "Quantity").GetValue(stop.JobRun); + } } - foreach (var item in quantities) + var foreground = Application.Current.Resources["FSE_PrimaryForegroundBrush"] as SolidColorBrush; + var border = Application.Current.Resources["FSE_BorderBrush"] as SolidColorBrush; + + foreach (var liquidQuantity in liquidQuantities) { - liquidQuantities.Add(new LiquidQuantityModel() { LiquidType = item.Key, Quantity = item.Value }); + PieSeries series = new PieSeries(); + series.Foreground = foreground; + series.Stroke = border; + series.Fill = liquidQuantity.LiquidType.LiquidTypeBrush; + series.FontSize = 12; + series.Title = liquidQuantity.Title; + series.Values = new ChartValues<double>() { Convert.ToDouble(liquidQuantity.Quantity) }; + series.DataLabels = false; + series.LabelPoint = Stats.QuantityCounts; + + seriesCollection.Add(series); } + SeriesCollection = seriesCollection; + stats.LiquidQuantities = liquidQuantities; } catch (Exception ex) @@ -639,11 +658,11 @@ namespace Tango.FSE.Statistics.ViewModels input = $"{stop.Catalog}\t{stop.CatalogItem}"; break; case ColorSpaces.Volume: - input = $"{stop.Cyan}\t{stop.Magenta}\t{stop.Yellow}\t{stop.Black}"; + input = String.Join("\t", stop.GetVolumeInputs().Where(x => x.Volume > 0).Select(x => x.Volume)); break; } - Clipboard.SetText($"{stop.ColorSpace}\t{input}\t{stop.CyanOutput}\t{stop.MagentaOutput}\t{stop.YellowOutput}\t{stop.BlackOutput}\t{stop.LightCyanOutput}\t{stop.LightMagentaOutput}\t{stop.LightYellowOutput}\t{stop.TransparentInkOutput}", TextDataFormat.Text); + Clipboard.SetText($"{stop.ColorSpace}\t{input}\t{String.Join("\t", stop.Output.Where(x => x.LiquidType.HasPigment).Where(x => x.Volume > 0).Select(x => x.Volume))}", TextDataFormat.Text); } #endregion @@ -704,18 +723,23 @@ namespace Tango.FSE.Statistics.ViewModels "Measured B", "Delta E", "Approved", - "Input Red", - "Input Green", - "Input Blue", - "Input L", - "Input A", - "Input B", + "Input RGB (R)", + "Input RGB (G)", + "Input RGB (B)", + "Input LAB (L)", + "Input LAB (A)", + "Input LAB (B)", "Input Catalog", "Input Catalog Item", "Input Cyan", "Input Magenta", "Input Yellow", "Input Black", + "Input Blue", + "Input Orange", + "Input Rubine", + "Input Navy", + "Input Violet", "Output Cyan", "Output Magenta", "Output Yellow", @@ -723,6 +747,14 @@ namespace Tango.FSE.Statistics.ViewModels "Output Light Cyan", "Output Light Magenta", "Output Light Yellow", + "Output Blue", + "Output Light Blue", + "Output Orange", + "Output Light Orange", + "Output Rubine", + "Output Light Rubine", + "Output Navy", + "Output Violet", "Output Transparent Ink", "Output Lubricant", "Failure Reason", @@ -763,10 +795,16 @@ namespace Tango.FSE.Statistics.ViewModels model.InputCatalogItem = stop.CatalogItem; break; case ColorSpaces.Volume: - model.InputCyan = stop.Cyan.ToString(); - model.InputMagenta = stop.Magenta.ToString(); - model.InputYellow = stop.Yellow.ToString(); - model.InputBlack = stop.Black.ToString(); + model.InputCyan = stop.GetLiquidVolumeInputOrZero(LiquidTypes.Cyan).ToString(); + model.InputMagenta = stop.GetLiquidVolumeInputOrZero(LiquidTypes.Magenta).ToString(); + model.InputYellow = stop.GetLiquidVolumeInputOrZero(LiquidTypes.Yellow).ToString(); + model.InputBlack = stop.GetLiquidVolumeInputOrZero(LiquidTypes.Black).ToString(); + + model.InputBBlue = stop.GetLiquidVolumeInputOrZero(LiquidTypes.Blue).ToString(); + model.InputOrange = stop.GetLiquidVolumeInputOrZero(LiquidTypes.Orange).ToString(); + model.InputRubine = stop.GetLiquidVolumeInputOrZero(LiquidTypes.Rubine).ToString(); + model.InputNavy = stop.GetLiquidVolumeInputOrZero(LiquidTypes.Navy).ToString(); + model.InputViolet = stop.GetLiquidVolumeInputOrZero(LiquidTypes.Violet).ToString(); break; } @@ -787,15 +825,25 @@ namespace Tango.FSE.Statistics.ViewModels } } - model.OutputCyan = stop.CyanOutput.ToString(); - model.OutputMagenta = stop.MagentaOutput.ToString(); - model.OutputYellow = stop.YellowOutput.ToString(); - model.OutputBlack = stop.BlackOutput.ToString(); - model.OutputLightCyan = stop.LightCyanOutput.ToString(); - model.OutputLightMagenta = stop.LightMagentaOutput.ToString(); - model.OutputLightYellow = stop.LightYellowOutput.ToString(); - model.OutputTransparentInk = stop.TransparentInkOutput.ToString(); - model.OutputLubricant = stop.LubricantOutput.ToString(); + model.OutputCyan = stop.GetLiquidVolumeOutputOrZero(LiquidTypes.Cyan).ToString(); + model.OutputMagenta = stop.GetLiquidVolumeOutputOrZero(LiquidTypes.Magenta).ToString(); + model.OutputYellow = stop.GetLiquidVolumeOutputOrZero(LiquidTypes.Yellow).ToString(); + model.OutputBlack = stop.GetLiquidVolumeOutputOrZero(LiquidTypes.Black).ToString(); + model.OutputLightCyan = stop.GetLiquidVolumeOutputOrZero(LiquidTypes.LightCyan).ToString(); + model.OutputLightMagenta = stop.GetLiquidVolumeOutputOrZero(LiquidTypes.LightMagenta).ToString(); + model.OutputLightYellow = stop.GetLiquidVolumeOutputOrZero(LiquidTypes.LightYellow).ToString(); + + model.OutputBlue = stop.GetLiquidVolumeOutputOrZero(LiquidTypes.Blue).ToString(); + model.OutputLightBlue = stop.GetLiquidVolumeOutputOrZero(LiquidTypes.LightBlue).ToString(); + model.OutputOrange = stop.GetLiquidVolumeOutputOrZero(LiquidTypes.Orange).ToString(); + model.OutputLightOrange = stop.GetLiquidVolumeOutputOrZero(LiquidTypes.LightOrange).ToString(); + model.OutputRubine = stop.GetLiquidVolumeOutputOrZero(LiquidTypes.Rubine).ToString(); + model.OutputLightRubine = stop.GetLiquidVolumeOutputOrZero(LiquidTypes.LightRubine).ToString(); + model.OutputNavy = stop.GetLiquidVolumeOutputOrZero(LiquidTypes.Navy).ToString(); + model.OutputViolet = stop.GetLiquidVolumeOutputOrZero(LiquidTypes.Violet).ToString(); + + model.OutputTransparentInk = stop.GetLiquidVolumeOutputOrZero(LiquidTypes.TransparentInk).ToString(); + model.OutputLubricant = stop.GetLiquidVolumeOutputOrZero(LiquidTypes.Lubricant).ToString(); model.FailureReason = stop.JobRun.FailedMessage; csvFile.Append(model); |
