From c03fb4a1b2aadd8952b321d08ca840e55fcee72d Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 14 Jul 2024 23:06:47 +0300 Subject: Revision of statistics and resumed jobs. --- .../Controls/RangeProgressBar.cs | 81 ++++++++++++++++++++++ .../Tango.FSE.Statistics/Models/StopModel.cs | 33 +++++++++ .../Tango.FSE.Statistics.csproj | 1 + .../Tango.FSE.Statistics/Themes/Generic.xaml | 17 +++++ .../Tango.FSE.Statistics/ViewModels/MainViewVM.cs | 4 +- .../Tango.FSE.Statistics/Views/MainView.xaml | 17 ++++- 6 files changed, 149 insertions(+), 4 deletions(-) create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Controls/RangeProgressBar.cs (limited to 'Software/Visual_Studio/FSE/Modules') diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Controls/RangeProgressBar.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Controls/RangeProgressBar.cs new file mode 100644 index 000000000..0d18bb4ca --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Controls/RangeProgressBar.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.FSE.Diagnostics.Controls +{ + public class RangeProgressBar : Control + { + private Border _innerBorder; + private Border _outerBorder; + + static RangeProgressBar() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(RangeProgressBar), new FrameworkPropertyMetadata(typeof(RangeProgressBar))); + } + + public Brush FillBrush + { + get { return (Brush)GetValue(FillBrushProperty); } + set { SetValue(FillBrushProperty, value); } + } + public static readonly DependencyProperty FillBrushProperty = + DependencyProperty.Register("FillBrush", typeof(Brush), typeof(RangeProgressBar), new PropertyMetadata(Brushes.Red)); + + public double Maximum + { + get { return (double)GetValue(MaximumProperty); } + set { SetValue(MaximumProperty, value); } + } + public static readonly DependencyProperty MaximumProperty = + DependencyProperty.Register("Maximum", typeof(double), typeof(RangeProgressBar), new PropertyMetadata(100.0)); + + public double LowerValue + { + get { return (double)GetValue(LowerValueProperty); } + set { SetValue(LowerValueProperty, value); } + } + public static readonly DependencyProperty LowerValueProperty = + DependencyProperty.Register("LowerValue", typeof(double), typeof(RangeProgressBar), new PropertyMetadata(20.0)); + + public double UpperValue + { + get { return (double)GetValue(UpperValueProperty); } + set { SetValue(UpperValueProperty, value); } + } + public static readonly DependencyProperty UpperValueProperty = + DependencyProperty.Register("UpperValue", typeof(double), typeof(RangeProgressBar), new PropertyMetadata(80.0)); + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + _innerBorder = GetTemplateChild("PART_InnerBorder") as Border; + _outerBorder = GetTemplateChild("PART_OuterBorder") as Border; + + PlaceInnerBorder(); + SizeChanged -= RangeProgressBar_SizeChanged; + SizeChanged += RangeProgressBar_SizeChanged; + } + + private void RangeProgressBar_SizeChanged(object sender, SizeChangedEventArgs e) + { + PlaceInnerBorder(); + } + + private void PlaceInnerBorder() + { + _innerBorder.Margin = new Thickness(LowerValue / Maximum * _outerBorder.ActualWidth, 0, _outerBorder.ActualWidth - (UpperValue / Maximum * _outerBorder.ActualWidth), 0); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Models/StopModel.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Models/StopModel.cs index 3d616f957..d979fe55b 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Models/StopModel.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Models/StopModel.cs @@ -178,6 +178,31 @@ namespace Tango.FSE.Statistics.Models get { return IsEureka ? JobRun.EndPosition * 4 : JobRun.EndPosition; } } + public double ActualStartPosition + { + get { return IsEureka ? JobRun.ActualStartPosition * 4 : JobRun.ActualStartPosition; } + } + + public double ActualEndPosition + { + get + { + if (JobRun.ActualEndPosition > 0) + { + return IsEureka ? JobRun.ActualEndPosition * 4 : JobRun.ActualEndPosition; + } + else + { + return IsEureka ? JobRun.EndPosition * 4 : JobRun.EndPosition; + } + } + } + + public double ActualLength + { + get { return IsEureka ? JobRun.JobLogicalLength * 4 : JobRun.JobLogicalLength; } + } + public String FineTuningMeasured { get @@ -244,5 +269,13 @@ namespace Tango.FSE.Statistics.Models } private set { _fineTuningDeltaE = value; } } + + public double Distance + { + get + { + return ActualEndPosition - ActualStartPosition; + } + } } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Tango.FSE.Statistics.csproj b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Tango.FSE.Statistics.csproj index 3ca736b8a..fcfb157e6 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Tango.FSE.Statistics.csproj +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Tango.FSE.Statistics.csproj @@ -105,6 +105,7 @@ Controls\JobOutlineControl.cs + JobRunExtendedInfoView.xaml diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Themes/Generic.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Themes/Generic.xaml index 2c6475626..313a46355 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Themes/Generic.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Themes/Generic.xaml @@ -1,9 +1,26 @@  + + \ No newline at end of file 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 538e8a795..a21619aac 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 @@ -487,8 +487,8 @@ namespace Tango.FSE.Statistics.ViewModels stats.CompletedRuns = _model.StatisticsResult.JobRuns.Count(x => x.JobRun.Status == (int)JobRunStatus.Completed); stats.FailedRuns = _model.StatisticsResult.JobRuns.Count(x => x.JobRun.Status == (int)JobRunStatus.Failed); stats.AbortedRuns = _model.StatisticsResult.JobRuns.Count(x => x.JobRun.Status == (int)JobRunStatus.Aborted); - stats.TotalDyeingLength = (int)_model.StatisticsResult.JobRuns.Where(x => x.JobRun.EndPosition > 0).Select(x => x.JobRun.EndPosition).Sum(); - stats.AverageDyeingLength = (int)_model.StatisticsResult.JobRuns.Where(x => x.JobRun.EndPosition > 0).Select(x => x.JobRun.EndPosition).Average(); + stats.TotalDyeingLength = (int)_model.StatisticsResult.JobRuns.Where(x => x.JobRun.EndPosition > 0).Select(x => x.Distance).Sum(); + stats.AverageDyeingLength = (int)_model.StatisticsResult.JobRuns.Where(x => x.JobRun.EndPosition > 0).Select(x => x.Distance).Average(); var timeRuns = _model.StatisticsResult.JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.JobRun.EndDate != null && z.JobRun.ActualStartDate != null).ToList(); diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Views/MainView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Views/MainView.xaml index 590192e28..0e1d8cb60 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Views/MainView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Views/MainView.xaml @@ -10,6 +10,7 @@ xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete" xmlns:material="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf" + xmlns:localControls="clr-namespace:Tango.FSE.Statistics.Controls" xmlns:local="clr-namespace:Tango.FSE.Statistics.Views" mc:Ignorable="d" d:DesignHeight="720" d:DesignWidth="1280" Background="{StaticResource FSE_PrimaryBackgroundBrush}" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> @@ -144,7 +145,19 @@ - + + + + + + + + + + + + + @@ -258,7 +271,7 @@ - + -- cgit v1.3.1