From 3c5f32456c72b26497c05bb35fd64e3c77c6b0f5 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 15 Apr 2019 12:06:30 +0300 Subject: Now using the latest RealTimeGraphX library! + infinity check! --- .../Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj index 8d9255926..8416758fa 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -356,10 +356,6 @@ - - {b9ae25d6-be35-492f-9079-21a7f3e6f7cc} - RealTimeGraphEx - {bb2abb74-ba58-4812-83aa-ec8171f42df4} Tango.AutoComplete @@ -614,7 +610,7 @@ copy /Y "$(SolutionDir)Referenced Assemblies\Microsoft.WITDataStore32.dll" "$(Ta - + \ No newline at end of file -- cgit v1.3.1 From 4b389560cf068961d2f09c91106f46e35bb8cb40 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 17 Apr 2019 15:20:13 +0300 Subject: Implemented "Thread per week" chart on statistics module. --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes Software/DB/TCC/TCC.mdf | Bin 8388608 -> 8388608 bytes Software/DB/TCC/TCC_log.ldf | Bin 8388608 -> 8388608 bytes Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../ViewModels/MainViewVM.cs | 237 ++++++++++++++++++--- .../Views/MainView.xaml | 44 +++- .../Tango.MachineStudio.UI.csproj | 10 +- 9 files changed, 264 insertions(+), 27 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index d593d608a..5f21b3e76 100644 Binary files a/Software/DB/PPC/Tango.mdf and b/Software/DB/PPC/Tango.mdf differ diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf index 5f34ab427..51159c580 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/DB/TCC/TCC.mdf b/Software/DB/TCC/TCC.mdf index 4a494371a..e166d54e4 100644 Binary files a/Software/DB/TCC/TCC.mdf and b/Software/DB/TCC/TCC.mdf differ diff --git a/Software/DB/TCC/TCC_log.ldf b/Software/DB/TCC/TCC_log.ldf index aaa771c9c..961d48114 100644 Binary files a/Software/DB/TCC/TCC_log.ldf and b/Software/DB/TCC/TCC_log.ldf differ diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 88bca6406..72789862c 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 0fd1ae21c..217fb1d8c 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/MainViewVM.cs index fd897e811..ef9561d0b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/MainViewVM.cs @@ -12,6 +12,8 @@ using Tango.BL.Enumerations; using Tango.Core.Helpers; using Tango.MachineStudio.Common; using Tango.MachineStudio.Statistics.Models; +using System.Data.Entity; +using Tango.MachineStudio.Common.Notifications; namespace Tango.MachineStudio.Statistics.ViewModels { @@ -20,6 +22,8 @@ namespace Tango.MachineStudio.Statistics.ViewModels private ObservablesContext _context; private List _job_runs; private bool rendered; + private INotificationProvider _notification; + private bool _loaded; private LabeledSeriesCollection _timelineJobStatusSeries; public LabeledSeriesCollection TimelineJobStatusSeries @@ -35,24 +39,58 @@ namespace Tango.MachineStudio.Statistics.ViewModels set { _pieJobFailedReasons = value; RaisePropertyChangedAuto(); } } - public MainViewVM() + private LabeledSeriesCollection _printPerWeekSeries; + public LabeledSeriesCollection PrintPerWeekSeries { + get { return _printPerWeekSeries; } + set { _printPerWeekSeries = value; RaisePropertyChangedAuto(); } + } + + private DateTime _startDate; + public DateTime StartDate + { + get { return _startDate; } + set { _startDate = value; RaisePropertyChangedAuto(); OnDateRangeChanged(); } + } + + private DateTime _endDate; + public DateTime EndDate + { + get { return _endDate; } + set { _endDate = value; RaisePropertyChangedAuto(); OnDateRangeChanged(); } + } + + private DateTime _minDate; + public DateTime MinDate + { + get { return _minDate; } + set { _minDate = value; RaisePropertyChangedAuto(); } + } + + private DateTime _maxDate; + public DateTime MaxDate + { + get { return _maxDate; } + set { _maxDate = value; RaisePropertyChangedAuto(); } + } + + + public MainViewVM(INotificationProvider notificationProvider) + { + _notification = notificationProvider; + StartDate = DateTime.Now.AddMonths(-1); + EndDate = DateTime.Now; } public override void OnApplicationReady() { - Task.Factory.StartNew(() => - { - _context = ObservablesContext.CreateDefault(); - DateTime start_date = DateTime.UtcNow.AddMonths(-1); - _job_runs = _context.JobRuns.OrderBy(x => x.StartDate).ToList(); - }); + } - private List GetJobRunsByStartDate(DateTime startDate, JobRunStatus? status = null) + private List GetJobRunsByDateRange(DateTime startDate, DateTime endTime, JobRunStatus? status = null) { - return _job_runs.Where(x => x.StartDate.ToLocalTime() >= startDate && (status == null || x.JobRunStatus == status)).ToList(); + return _job_runs.Where(x => x.StartDate.ToLocalTime() >= startDate && x.StartDate.ToLocalTime() <= endTime && (status == null || x.JobRunStatus == status)).ToList(); } private List GetJobRunsByDate(DateTime date, JobRunStatus? status = null) @@ -68,7 +106,9 @@ namespace Tango.MachineStudio.Statistics.ViewModels } } - public override void OnNavigatedTo() + + + public override async void OnNavigatedTo() { base.OnNavigatedTo(); @@ -76,21 +116,49 @@ namespace Tango.MachineStudio.Statistics.ViewModels rendered = true; - InvokeUIOnIdle(() => + + using (_notification.PushTaskItem("Loading statistics...")) { + IsFree = false; + + await Task.Factory.StartNew(() => + { + _context = ObservablesContext.CreateDefault(); + _job_runs = _context.JobRuns.Include(x => x.Job).Include(x => x.Job.Machine).OrderBy(x => x.StartDate).ToList(); + }); + if (_job_runs.Count > 0) { - GenerateTimelineJobStatusChart(); - GeneratePieFailedReasonsChart(); + MinDate = _job_runs.Min(x => x.StartDate); + MaxDate = _job_runs.Max(x => x.StartDate); } - }); + + InvokeUIOnIdle(() => + { + OnDateRangeChanged(); + }); + + _loaded = true; + + IsFree = true; + } + } + + private void OnDateRangeChanged() + { + if (_job_runs != null && _job_runs.Count > 0 && _loaded) + { + GenerateTimelineJobStatusChart(); + GeneratePieFailedReasonsChart(); + GeneratePrintPerWeekChart(); + } } private void GenerateTimelineJobStatusChart() { TimelineJobStatusSeries = new LabeledSeriesCollection() { - Title = "This Month Job Runs Status", + Title = "Job Runs Status", ChartTitle = "Number Of Runs", LabelsTitle = "Date", SeriesColors = new List() @@ -101,26 +169,62 @@ namespace Tango.MachineStudio.Statistics.ViewModels }, }; - var completed_job_runs = new ColumnSeries() + Series completed_job_runs = new ColumnSeries() { Title = "Completed", Values = new ChartValues(), Fill = Brushes.Green, + MinWidth = 1, + }; - var aborted_job_runs = new ColumnSeries() + Series aborted_job_runs = new ColumnSeries() { Title = "Aborted", Values = new ChartValues(), Fill = Brushes.Orange, + MinWidth = 1, }; - var failed_job_runs = new ColumnSeries() + Series failed_job_runs = new ColumnSeries() { Title = "Failed", Values = new ChartValues(), Fill = Brushes.Red, + MinWidth = 1, }; - foreach (var date in CreateDates(DateTime.Now.AddMonths(-1), DateTime.Now)) + if (EndDate - StartDate > TimeSpan.FromDays(40)) + { + completed_job_runs = new LineSeries() + { + Title = "Completed", + Values = new ChartValues(), + Fill = new SolidColorBrush(Colors.Green) { Opacity = 0.5 }, + MinWidth = 1, + PointGeometry = null, + StrokeThickness = 0, + + }; + aborted_job_runs = new LineSeries() + { + Title = "Aborted", + Values = new ChartValues(), + Fill = new SolidColorBrush(Colors.Orange) { Opacity = 0.5 }, + MinWidth = 1, + PointGeometry = null, + StrokeThickness = 0, + }; + failed_job_runs = new LineSeries() + { + Title = "Failed", + Values = new ChartValues(), + Fill = new SolidColorBrush(Colors.Red) { Opacity = 0.5 }, + MinWidth = 1, + PointGeometry = null, + StrokeThickness = 0, + }; + } + + foreach (var date in CreateDates(StartDate, EndDate)) { completed_job_runs.Values.Add(GetJobRunsByDate(date, JobRunStatus.Completed).Count()); aborted_job_runs.Values.Add(GetJobRunsByDate(date, JobRunStatus.Aborted).Count()); @@ -129,18 +233,20 @@ namespace Tango.MachineStudio.Statistics.ViewModels TimelineJobStatusSeries.Labels.Add(date.ToShortDateString()); } - TimelineJobStatusSeries.SeriesCollection.Add(completed_job_runs); - TimelineJobStatusSeries.SeriesCollection.Add(aborted_job_runs); + + TimelineJobStatusSeries.SeriesCollection.Add(failed_job_runs); + TimelineJobStatusSeries.SeriesCollection.Add(aborted_job_runs); + TimelineJobStatusSeries.SeriesCollection.Add(completed_job_runs); } private void GeneratePieFailedReasonsChart() { - var groups = GetJobRunsByStartDate(DateTime.Now.AddMonths(-1), JobRunStatus.Failed).GroupBy(x => x.FailedMessage).OrderBy(x => x.Count()); + var groups = GetJobRunsByDateRange(StartDate, EndDate, JobRunStatus.Failed).GroupBy(x => x.FailedMessage).OrderBy(x => x.Count()); List colors = new List(); - int max = groups.Max(x => x.Count()); + int max = groups.Count() > 0 ? groups.Max(x => x.Count()) : 0; for (int i = 0; i < groups.Count(); i++) { @@ -151,7 +257,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels PieJobFailedReasons = new LabeledSeriesCollection() { - Title = "This Month Job Failure Reasons", + Title = "Job Failure Reasons", SeriesColors = colors, }; @@ -173,5 +279,88 @@ namespace Tango.MachineStudio.Statistics.ViewModels PieJobFailedReasons.SeriesCollection.Add(series); } } + + private void GeneratePrintPerWeekChart() + { + List range_job_runs = GetJobRunsByDateRange(StartDate, EndDate); + + Dictionary> weeks_print_avg = new Dictionary>(); + + //Init machines weeks averages dictionary. + foreach (var machine in range_job_runs.Select(x => x.Job.Machine).OrderBy(x => x.Name).DistinctBy(x => x.Guid)) + { + weeks_print_avg[machine] = new List(); + } + + //Create all available dates + List all_dates = range_job_runs.Select(x => x.StartDate).ToList(); + + //get first Sunday. + DateTime current_sunday = all_dates.FirstOrDefault(x => x.DayOfWeek == DayOfWeek.Sunday); + + if (current_sunday != null && all_dates.Count > 0) + { + //Iterate over each week starting from the earliest Sunday. + while (current_sunday <= all_dates.Last()) + { + var week_job_runs = range_job_runs.Where(x => x.EndPosition > 10 && x.StartDate >= current_sunday && x.StartDate <= current_sunday.AddDays(7)).ToList(); + + foreach (var machine_job_runs in week_job_runs.GroupBy(x => x.Job.Machine)) + { + weeks_print_avg[machine_job_runs.Key].Add(machine_job_runs.Select(x => x.EndPosition).Average()); + } + + current_sunday = current_sunday.AddDays(8); + } + } + + Dictionary week_print_avg = new Dictionary(); + + //Init machines week average dictionary. + foreach (var machine in weeks_print_avg) + { + if (machine.Value.Count > 0) + { + week_print_avg[machine.Key] = machine.Value.Average(); + } + } + + //Init chart series + PrintPerWeekSeries = new LabeledSeriesCollection() + { + Title = "Average Printed Thread Per Week (m)", + ChartTitle = "Average Print Per Week (m)", + LabelsTitle = "Date", + SeriesColors = new List() + { + + }, + }; + + //Init series colors intensity by number of prints. + double max = week_print_avg.Count > 0 ? week_print_avg.Max(x => x.Value) : 0; + foreach (var machine in week_print_avg) + { + double a = (machine.Value / max); + PrintPerWeekSeries.SeriesColors.Add(Color.FromArgb((byte)(255d * (machine.Value / max)), 0, 200, 0)); + } + + //Init columns. + int index = 0; + + foreach (var machine in week_print_avg) + { + var series = new ColumnSeries() + { + Title = machine.Key.Name, + Values = new ChartValues() { (int)machine.Value }, + Fill = new SolidColorBrush(PrintPerWeekSeries.SeriesColors[index++]), + DataLabels = true, + ToolTip = machine.Key.SerialNumber, + }; + + PrintPerWeekSeries.SeriesCollection.Add(series); + } + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml index f063c1675..69708f517 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml @@ -5,13 +5,31 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:vm="clr-namespace:Tango.MachineStudio.Statistics.ViewModels" xmlns:global="clr-namespace:Tango.MachineStudio.Statistics" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:local="clr-namespace:Tango.MachineStudio.Statistics.Views" xmlns:tooltips="clr-namespace:Tango.MachineStudio.Statistics.Tooltips" xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf" mc:Ignorable="d" d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> - - + + + + + + + + + Start Date: + + + + + End Date: + + + + + @@ -48,6 +66,28 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj index 8416758fa..21fcdaa3c 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -343,6 +343,14 @@ Settings.settings True + + TCC\benchmarks_rgb_lab.csv + Always + + + TCC\template.bmp + Always + SettingsSingleFileGenerator @@ -610,7 +618,7 @@ copy /Y "$(SolutionDir)Referenced Assemblies\Microsoft.WITDataStore32.dll" "$(Ta - + \ No newline at end of file -- cgit v1.3.1 From 78ce7cd049ebee35b9d9b0a8de3972b85dde3397 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 24 Apr 2019 15:18:25 +0300 Subject: Fixed old RealTimeGraphEx reference from Machine Studio. --- .../MachineStudio/Tango.MachineStudio.UI/App.xaml | 3 --- .../Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj | 14 +++++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml index fe50851a0..20e381b70 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml @@ -11,9 +11,6 @@ - - - diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj index 21fcdaa3c..ede1bf828 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -364,6 +364,14 @@ + + {6b9774f7-960d-438e-ad81-c6b9be328d50} + RealTimeGraphX.WPF + + + {f13a489c-80ee-4cd0-bdd4-92d959215646} + RealTimeGraphX + {bb2abb74-ba58-4812-83aa-ec8171f42df4} Tango.AutoComplete @@ -424,6 +432,10 @@ {5001990f-977b-48ff-b217-0236a5022ad8} Tango.Web + + {f209fae8-73f9-441b-97f4-0844a0279390} + Tango.TCC.BL + {f69da3a8-f823-461e-87cf-a9275abc0b15} Tango.MachineStudio.Dispensers @@ -618,7 +630,7 @@ copy /Y "$(SolutionDir)Referenced Assemblies\Microsoft.WITDataStore32.dll" "$(Ta - + \ No newline at end of file -- cgit v1.3.1