From a5de87ea9863c6e7053e09ed1c2eabf58285af48 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Tue, 20 Jun 2023 16:40:58 +0300 Subject: PPC. Added Real Time Graph --- Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml | 1 + .../StatisticTabToVisibilityConverter.cs | 28 ++++ .../PPC/Tango.PPC.UI/Graphs/GraphHelper.cs | 36 +++++ .../PPC/Tango.PPC.UI/Graphs/RealTimeGraph.cs | 149 +++++++++++++++++++++ .../PPC/Tango.PPC.UI/Graphs/RealTimeGraph.xaml | 106 +++++++++++++++ .../Tango.PPC.UI/Images/Overview Icons/motor.png | Bin 0 -> 1023 bytes .../Tango.PPC.UI/Images/Overview Icons/pr_data.png | Bin 0 -> 1054 bytes .../Images/Overview Icons/pressure.png | Bin 0 -> 1156 bytes .../Images/Overview Icons/temperature.png | Bin 0 -> 1065 bytes .../PPC/Tango.PPC.UI/Images/screw.png | Bin 0 -> 937 bytes .../PPC/Tango.PPC.UI/Resources/Graphs.xaml | 8 ++ .../PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 26 +++- .../Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs | 112 ++++++++++++++++ .../PPC/Tango.PPC.UI/Views/MachineStatusView.xaml | 64 +++++++++ .../Tango.PPC.UI/Views/MachineStatusView.xaml.cs | 10 ++ .../Visual_Studio/PPC/Tango.PPC.UI/app.manifest | 2 +- 16 files changed, 540 insertions(+), 2 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/StatisticTabToVisibilityConverter.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/GraphHelper.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/RealTimeGraph.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/RealTimeGraph.xaml create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Overview Icons/motor.png create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Overview Icons/pr_data.png create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Overview Icons/pressure.png create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Overview Icons/temperature.png create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Images/screw.png create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Graphs.xaml (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml index bdcf675e3..38a5b91b2 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml @@ -20,6 +20,7 @@ + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/StatisticTabToVisibilityConverter.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/StatisticTabToVisibilityConverter.cs new file mode 100644 index 000000000..06c75a999 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/StatisticTabToVisibilityConverter.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; +using static Tango.PPC.UI.ViewModels.MachineStatusViewVM; + +namespace Tango.PPC.UI.Converters +{ + public class StatisticTabToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + StatisticTab selected = (StatisticTab)Enum.Parse(typeof(StatisticTab), parameter.ToString()); + StatisticTab statTab = (StatisticTab)value; + + return statTab.Equals(selected) ? Visibility.Visible : Visibility.Hidden; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/GraphHelper.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/GraphHelper.cs new file mode 100644 index 000000000..d06ed042a --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/GraphHelper.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Media; + +namespace Tango.PPC.UI.Graphs +{ + public static class GraphHelper + { + public enum GraphColor + { + White, + Red, + Yellow, + Green, + Orange + } + + public static Color GetGraphColor(GraphColor graphColor) + { + return (Color)Application.Current.Resources[$"Tango_RealTimeGraph_{graphColor.ToString()}"]; + } + + public static Brush GetGraphBrush(GraphColor graphColor) + { + return new SolidColorBrush(GetGraphColor(graphColor)); + } + + public static Color GetGraphStrokeColor() + { + return (Color)Application.Current.Resources["Tango_RealTimeGraph_ForegroundColor"]; + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/RealTimeGraph.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/RealTimeGraph.cs new file mode 100644 index 000000000..303b18892 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/RealTimeGraph.cs @@ -0,0 +1,149 @@ +using RealTimeGraphX; +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; + +namespace Tango.PPC.UI.Graphs +{ + public class RealTimeGraph : Control + { + /// + /// Gets or sets the graph controller. + /// + public IGraphController Controller + { + get { return (IGraphController)GetValue(ControllerProperty); } + set { SetValue(ControllerProperty, value); } + } + public static readonly DependencyProperty ControllerProperty = + DependencyProperty.Register("Controller", typeof(IGraphController), typeof(RealTimeGraph), new PropertyMetadata(null)); + + + /// + /// Gets or sets the string format of the y-axis. + /// + public String StringFormat + { + get { return (String)GetValue(StringFormatProperty); } + set { SetValue(StringFormatProperty, value); } + } + public static readonly DependencyProperty StringFormatProperty = + DependencyProperty.Register("StringFormat", typeof(String), typeof(RealTimeGraph), new PropertyMetadata("0.0")); + + + /// + /// Gets or sets the display name. + /// + public String DisplayName + { + get { return (String)GetValue(DisplayNameProperty); } + set { SetValue(DisplayNameProperty, value); } + } + public static readonly DependencyProperty DisplayNameProperty = + DependencyProperty.Register("DisplayName", typeof(String), typeof(RealTimeGraph), new PropertyMetadata(null)); + + + /// + /// Gets or sets the display units. + /// + public String DisplayUnits + { + get { return (String)GetValue(DisplayUnitsProperty); } + set { SetValue(DisplayUnitsProperty, value); } + } + public static readonly DependencyProperty DisplayUnitsProperty = + DependencyProperty.Register("DisplayUnits", typeof(String), typeof(RealTimeGraph), new PropertyMetadata(null)); + + /// + /// Gets or sets the graph label visibility. + /// + public Visibility GraphLabelVisibility + { + get { return (Visibility)GetValue(GraphLabelVisibilityProperty); } + set { SetValue(GraphLabelVisibilityProperty, value); } + } + public static readonly DependencyProperty GraphLabelVisibilityProperty = + DependencyProperty.Register("GraphLabelVisibility", typeof(Visibility), typeof(RealTimeGraph), new PropertyMetadata(Visibility.Visible)); + + + /// + /// Gets or sets the vertical ticks. + /// + public int VerticalTicks + { + get { return (int)GetValue(VerticalTicksProperty); } + set { SetValue(VerticalTicksProperty, value); } + } + public static readonly DependencyProperty VerticalTicksProperty = + DependencyProperty.Register("VerticalTicks", typeof(int), typeof(RealTimeGraph), new PropertyMetadata(10)); + + + /// + /// Gets or sets the horizontal ticks. + /// + public int HorizontalTicks + { + get { return (int)GetValue(HorizontalTicksProperty); } + set { SetValue(HorizontalTicksProperty, value); } + } + public static readonly DependencyProperty HorizontalTicksProperty = + DependencyProperty.Register("HorizontalTicks", typeof(int), typeof(RealTimeGraph), new PropertyMetadata(10)); + + public Brush GridLinesBrush + { + get { return (Brush)GetValue(GridLinesBrushProperty); } + set { SetValue(GridLinesBrushProperty, value); } + } + public static readonly DependencyProperty GridLinesBrushProperty = + DependencyProperty.Register("GridLinesBrush", typeof(Brush), typeof(RealTimeGraph), new PropertyMetadata(null)); + + public Visibility HorizontalAxisVisibility + { + get { return (Visibility)GetValue(HorizontalAxisVisibilityProperty); } + set { SetValue(HorizontalAxisVisibilityProperty, value); } + } + public static readonly DependencyProperty HorizontalAxisVisibilityProperty = + DependencyProperty.Register("HorizontalAxisVisibility", typeof(Visibility), typeof(RealTimeGraph), new PropertyMetadata(Visibility.Visible)); + + public Visibility VerticalAxisVisibility + { + get { return (Visibility)GetValue(VerticalAxisVisibilityProperty); } + set { SetValue(VerticalAxisVisibilityProperty, value); } + } + public static readonly DependencyProperty VerticalAxisVisibilityProperty = + DependencyProperty.Register("VerticalAxisVisibility", typeof(Visibility), typeof(RealTimeGraph), new PropertyMetadata(Visibility.Visible)); + + public Visibility CurrentValueVisibility + { + get { return (Visibility)GetValue(CurrentValueVisibilityProperty); } + set { SetValue(CurrentValueVisibilityProperty, value); } + } + public static readonly DependencyProperty CurrentValueVisibilityProperty = + DependencyProperty.Register("CurrentValueVisibility", typeof(Visibility), typeof(RealTimeGraph), new PropertyMetadata(Visibility.Collapsed)); + + public double CurrentValueFontSize + { + get { return (double)GetValue(CurrentValueFontSizeProperty); } + set { SetValue(CurrentValueFontSizeProperty, value); } + } + public static readonly DependencyProperty CurrentValueFontSizeProperty = + DependencyProperty.Register("CurrentValueFontSize", typeof(double), typeof(RealTimeGraph), new PropertyMetadata(25.0)); + + public Thickness CurrentValueMargin + { + get { return (Thickness)GetValue(CurrentValueMarginProperty); } + set { SetValue(CurrentValueMarginProperty, value); } + } + public static readonly DependencyProperty CurrentValueMarginProperty = + DependencyProperty.Register("CurrentValueMargin", typeof(Thickness), typeof(RealTimeGraph), new PropertyMetadata(new Thickness(20))); + + /// + /// Initializes the class. + /// + static RealTimeGraph() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(RealTimeGraph), new FrameworkPropertyMetadata(typeof(RealTimeGraph))); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/RealTimeGraph.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/RealTimeGraph.xaml new file mode 100644 index 000000000..8844f9627 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/RealTimeGraph.xaml @@ -0,0 +1,106 @@ + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Overview Icons/motor.png b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Overview Icons/motor.png new file mode 100644 index 000000000..8401a8e30 Binary files /dev/null and b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Overview Icons/motor.png differ diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Overview Icons/pr_data.png b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Overview Icons/pr_data.png new file mode 100644 index 000000000..ebd02a99b Binary files /dev/null and b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Overview Icons/pr_data.png differ diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Overview Icons/pressure.png b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Overview Icons/pressure.png new file mode 100644 index 000000000..12ade5d92 Binary files /dev/null and b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Overview Icons/pressure.png differ diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Overview Icons/temperature.png b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Overview Icons/temperature.png new file mode 100644 index 000000000..de9b042c4 Binary files /dev/null and b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Overview Icons/temperature.png differ diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/screw.png b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/screw.png new file mode 100644 index 000000000..46a8134fe Binary files /dev/null and b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/screw.png differ diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Graphs.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Graphs.xaml new file mode 100644 index 000000000..67047cf1f --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Graphs.xaml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index a3ec9667f..e2d447be5 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -176,6 +176,7 @@ + BitResultsView.xaml @@ -236,6 +237,8 @@ + + @@ -409,6 +412,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -433,6 +440,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -627,6 +638,11 @@ + + + + + @@ -648,6 +664,14 @@ + + {6b9774f7-960d-438e-ad81-c6b9be328d50} + RealTimeGraphX.WPF + + + {f13a489c-80ee-4cd0-bdd4-92d959215646} + RealTimeGraphX + {d129789c-3096-4d0b-8dd7-fe24a4df4b21} Tango.AnimatedGif @@ -964,7 +988,7 @@ if $(ConfigurationName) == Eureka copy /Y "$(ProjectDir)Intro.wmv" "$(TargetDir) - + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs index 2563cb331..103084e11 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs @@ -20,11 +20,27 @@ using System.Timers; using System.Windows.Threading; using System.Diagnostics; using Tango.PMR.Printing; +using System.ComponentModel; +using RealTimeGraphX.WPF; +using RealTimeGraphX.DataPoints; +using Tango.PPC.UI.Graphs; namespace Tango.PPC.UI.ViewModels { public class MachineStatusViewVM : PPCViewModel { + public enum StatisticTab + { + [Description("Production Data")] + Productiondata = 0, + [Description("Temperature")] + Temperature = 1, + [Description("Pressure")] + Pressure = 2, + [Description("Motor")] + Motor = 3 + } + #region Properties [TangoInject] @@ -227,6 +243,70 @@ namespace Tango.PPC.UI.ViewModels RaisePropertyChangedAuto();} } + private int _selectedStatisticTabIndex; + /// + /// Gets or sets the index of the selected category. + /// + public int SelectedStatisticTabIndex + { + get { return _selectedStatisticTabIndex; } + set + { + if (_selectedStatisticTabIndex != value) + { + _selectedStatisticTabIndex = value; + RaisePropertyChangedAuto(); + switch (_selectedStatisticTabIndex) + { + case 0: + { + SelectedStatisticTab = StatisticTab.Productiondata; + break; + } + case 1: + { + SelectedStatisticTab = StatisticTab.Temperature; + break; + } + case 2: + { + SelectedStatisticTab = StatisticTab.Pressure; + break; + } + case 3: + { + SelectedStatisticTab = StatisticTab.Motor; + break; + } + } + } + } + } + + private StatisticTab _selectedStatisticTab; + /// + /// Gets or sets the selected category. + /// + /// + public StatisticTab SelectedStatisticTab + { + get + { + return _selectedStatisticTab; + } + set + { + if (_selectedStatisticTab != value) + { + _selectedStatisticTab = value; + RaisePropertyChangedAuto(); + } + _selectedStatisticTabIndex = _selectedStatisticTab.ToInt32(); + RaisePropertyChanged(nameof(SelectedStatisticTabIndex)); + } + } + + public WpfGraphController JobController { get; set; } #endregion @@ -278,6 +358,9 @@ namespace Tango.PPC.UI.ViewModels MachineErrorStates = new MachineOverviewErrorStates(); IsExpandedNotifications = false; + SelectedStatisticTabIndex = 0; + + JobController = CreateController(CreateSeries("Total", GraphHelper.GraphColor.Green)); } public override void OnApplicationReady() @@ -613,6 +696,35 @@ namespace Tango.PPC.UI.ViewModels } } + private WpfGraphController CreateController(params WpfGraphDataSeries[] seriesCollection) + { + var controller = new WpfGraphController(); + + foreach (var series in seriesCollection) + { + controller.DataSeriesCollection.Add(series); + } + + controller.Range.AutoY = true; + controller.Range.MaximumY = 100; + controller.Range.MinimumY = 0; + controller.Range.MaximumX = new DateTime(0).AddMinutes(30); + + controller.RefreshRate = TimeSpan.FromMilliseconds(300000);//5 min + + return controller; + } + + private WpfGraphDataSeries CreateSeries(String name, GraphHelper.GraphColor fill) + { + WpfGraphDataSeries series = new WpfGraphDataSeries(); + series.Name = name; + series.Fill = GraphHelper.GetGraphBrush(fill); + series.StrokeThickness = 1; + series.Stroke = GraphHelper.GetGraphStrokeColor(); + return series; + } + #endregion } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineStatusView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineStatusView.xaml index 1445337ad..9e766fffc 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineStatusView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineStatusView.xaml @@ -12,6 +12,7 @@ xmlns:localConverters="clr-namespace:Tango.PPC.UI.Converters" xmlns:global="clr-namespace:Tango.PPC.UI" xmlns:models="clr-namespace:Tango.PPC.UI.Models" + xmlns:graphs="clr-namespace:Tango.PPC.UI.Graphs" xmlns:local="clr-namespace:Tango.PPC.UI.Views" mc:Ignorable="d" d:DesignHeight="1280" d:DesignWidth="932" d:DataContext="{d:DesignInstance Type=vm:MachineStatusViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MachineStatusViewVM}"> @@ -25,6 +26,7 @@ + + @@ -1203,6 +1209,64 @@ + + + + + + + + + + + + Production Data + + + + Temperature + + + + Pressure + + + + Motor + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineStatusView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineStatusView.xaml.cs index 2ee98bc2b..e49e062b7 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineStatusView.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineStatusView.xaml.cs @@ -57,5 +57,15 @@ namespace Tango.PPC.UI.Views { _timer.Stop(); } + + private void NavigationSTLinks_PreviewTouchDown(object sender, TouchEventArgs e) + { + e.Handled = true; + } + + private void NavigationSTLinks_PreviewMouseDown(object sender, MouseButtonEventArgs e) + { + e.Handled = true; + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest index d72e75011..efc5f8179 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest @@ -16,7 +16,7 @@ Remove this element if your application requires this virtualization for backwards compatibility. --> - + -- cgit v1.3.1