From f2f69df22abf814ac8060bf948cd72adeec08b4b Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Sun, 5 Jul 2020 14:20:32 +0300 Subject: Dispenser Analyzer. Added settings wnd, changes in printing to pdf - set real height of document, removed printing graphs to png files. --- .../PPC/Tango.PPC.Common/PPCSettings.cs | 2 +- .../Analysis/IAnalyzerResult.cs | 3 + .../Analyzers/FlowAnalyser.cs | 19 ++- .../Tango.DispenserAnalyzer.UI/MainWindow.xaml | 11 +- .../Models/SettingsModel.cs | 52 +++++++ .../Tango.DispenserAnalyzer.UI.csproj | 9 ++ .../View/SettingsWnd.xaml | 155 +++++++++++++++++++++ .../View/SettingsWnd.xaml.cs | 38 +++++ .../ViewModels/MainWindowVM.cs | 30 +++- .../ViewModels/SettingsVM.cs | 54 +++++++ 10 files changed, 357 insertions(+), 16 deletions(-) create mode 100644 Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/SettingsModel.cs create mode 100644 Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/SettingsWnd.xaml create mode 100644 Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/SettingsWnd.xaml.cs create mode 100644 Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/SettingsVM.cs (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index 2c605ec36..5586b5341 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -279,7 +279,7 @@ namespace Tango.PPC.Common HotSpotPassword = "Aa123456"; LockScreenTimeout = TimeSpan.FromMinutes(10); LockScreenPassword = "1111"; - DeploymentSlot = DeploymentSlot.TEST; + DeploymentSlot = DeploymentSlot.DEV; EnableWatchDog = true; EnableEmergencyNotifications = true; EmergencyComPort = "COM2"; diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IAnalyzerResult.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IAnalyzerResult.cs index 074d5ec86..6b404d2a5 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IAnalyzerResult.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IAnalyzerResult.cs @@ -13,6 +13,8 @@ namespace Tango.DispenserAnalyzer.UI.Analysis { public ObservableCollection Points { get; set; } + public string Title { get; set; } + private int _step; public int XStep { @@ -38,6 +40,7 @@ namespace Tango.DispenserAnalyzer.UI.Analysis { _to = Points.Max(x => x.Y) + 2; _from = Points.Min(x => x.Y)-1; + RaisePropertyChanged("Title"); RaisePropertyChanged("Points"); } diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/FlowAnalyser.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/FlowAnalyser.cs index 60ca14fa9..2d4775a37 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/FlowAnalyser.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/FlowAnalyser.cs @@ -22,10 +22,11 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers { return Task.Factory.StartNew>(() => { - List results = new List(); - List commands = csvRows.Where(x => x.Command != null && x.Command.ToLower().Contains("label")).ToList(); - var pairs = commands.Select((x, i) => new { Index = i, Value = x }).GroupBy(x => x.Index / 2).Select(x => x.Select(v => v.Value).ToList()).ToList(); - MovingAverageFilter filter = new MovingAverageFilter(); + List results = new List(); + List commands = csvRows.Where(x => x.Command != null && x.Command.ToLower().Contains("label")).ToList(); + var pairs = commands.Select((x, i) => new { Index = i, Value = x }).GroupBy(x => x.Index / 2).Select(x => x.Select(v => v.Value).ToList()).ToList(); + MovingAverageFilter filter = new MovingAverageFilter(); + int flowtestNumber = 0; for (int index = 0; index < pairs.Count(); index++) { var pair = pairs[index]; @@ -73,7 +74,7 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers averageResult.Result = (averageResult.AverageValue <= 1850 && averageResult.AverageValue >= 1400) ? AnalyzerResultValue.Passed : AnalyzerResultValue.Failed; results.Add(averageResult); - FlowAnalyzerResult result = new FlowAnalyzerResult(); + FlowAnalyzerResult result = new FlowAnalyzerResult(++flowtestNumber); result.AverageValue = averageResult.AverageValue; result.SetLocalErrors(differenceMaxMin, differenceMaxMinToLocationArr); results.Add(result); @@ -114,13 +115,15 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers public double AverageValue { get; set; } + public int TestNumber { get; set; } + #endregion Properties - public FlowAnalyzerResult():base() + public FlowAnalyzerResult(int testNumber) :base() { AverageValue = 0.0; Result = AnalyzerResultValue.Undetermined; - //this.Points = new ObservableCollection(); + TestNumber = testNumber; } /// @@ -142,6 +145,7 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers } } this.IsShowPlotResult = true; + RangeToCountChart.Title = $"Flow Range To Count {TestNumber}"; RangeToCountChart.UpdateData(); var rangeToTimePoints = RangeToTimeChart.Points; rangeToTimePoints.Clear(); @@ -149,6 +153,7 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers { rangeToTimePoints.Add(new DataPoint(differenceMaxMinToLocationArr.ElementAt(y), differenceMaxMin.ElementAt(y))); } + RangeToTimeChart.Title = $"Flow Time Location To Range {TestNumber}"; RangeToTimeChart.UpdateData(); } diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml index c73d67ba7..e56ae6639 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml @@ -40,7 +40,12 @@ - + + + + @@ -106,7 +111,7 @@ - + @@ -119,7 +124,7 @@ - + diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/SettingsModel.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/SettingsModel.cs new file mode 100644 index 000000000..0d9e20288 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/SettingsModel.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; + +namespace Tango.DispenserAnalyzer.UI.Models +{ + public class SettingsModel: ExtendedObject + { + private string _propertyName; + + public string PropertyName + { + get { return _propertyName; } + set { _propertyName = value; RaisePropertyChangedAuto(); } + } + + private double _propertyvalue; + + public double PropertyValue + { + get { return _propertyvalue; } + set { _propertyvalue = value; RaisePropertyChangedAuto(); } + } + + private double _defaultValue; + + public double DefaultValue + { + get { return _defaultValue; } + set { _defaultValue = value; RaisePropertyChangedAuto(); } + } + + private string _defaultValueDisplay; + + public string DefaultValueDisplay + { + get { return _defaultValueDisplay; } + set { _defaultValueDisplay = value; } + } + + + public SettingsModel( string propertyName, string defaultValueDisplay, double defaultValue) + { + PropertyName = propertyName; + DefaultValueDisplay = defaultValueDisplay; + DefaultValue = defaultValue; + } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Tango.DispenserAnalyzer.UI.csproj b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Tango.DispenserAnalyzer.UI.csproj index 373654985..7efcaa58d 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Tango.DispenserAnalyzer.UI.csproj +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Tango.DispenserAnalyzer.UI.csproj @@ -143,7 +143,12 @@ + + + + SettingsWnd.xaml + MSBuild:Compile Designer @@ -156,6 +161,10 @@ MainWindow.xaml Code + + Designer + MSBuild:Compile + diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/SettingsWnd.xaml b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/SettingsWnd.xaml new file mode 100644 index 000000000..5c3cbb054 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/SettingsWnd.xaml @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Pressure build up test + + + + + + + + + + + + + Flow test + + + + + + + + + + diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/SettingsWnd.xaml.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/SettingsWnd.xaml.cs new file mode 100644 index 000000000..f0e35726e --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/SettingsWnd.xaml.cs @@ -0,0 +1,38 @@ +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.Shapes; +using Tango.DispenserAnalyzer.UI.ViewModels; + +namespace Tango.DispenserAnalyzer.UI.View +{ + /// + /// Interaction logic for SettingsWnd.xaml + /// + public partial class SettingsWnd : Window + { + public SettingsWnd() + { + InitializeComponent(); + DataContext = new SettingsVM(); + Loaded += Window_loaded; + } + + private void Window_loaded(object sender, RoutedEventArgs e) + { + Application curApp = Application.Current; + Window mainWindow = curApp.MainWindow; + this.Left = mainWindow.Left + (mainWindow.Width - this.ActualWidth) / 2; + this.Top = mainWindow.Top + (mainWindow.Height - this.ActualHeight) / 2; + } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/MainWindowVM.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/MainWindowVM.cs index 1182d5301..ab571ec43 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/MainWindowVM.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/MainWindowVM.cs @@ -27,6 +27,7 @@ using System.Windows.Media.Imaging; using PdfSharp; using OxyPlot.Reporting; using System.Threading; +using Tango.DispenserAnalyzer.UI.View; namespace Tango.DispenserAnalyzer.UI.ViewModels { @@ -144,12 +145,14 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels public RelayCommand OpenCSVFileCommand { get; set; } public RelayCommand GenerateCommand { get; set; } + public RelayCommand OpenSettingWndCommand { get; set; } public MainWindowVM() { OpenCSVFileCommand = new RelayCommand(OpenCSVFile); GenerateCommand = new RelayCommand(Generate, CanGenerate); - + OpenSettingWndCommand = new RelayCommand(OpenSettingWnd); + YFormatter = value => value.ToString(); _from = 0; _to = 1; @@ -160,6 +163,18 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels this.Points = new List(); } + + #region Settings + + public void OpenSettingWnd() + { + SettingsWnd settings = new SettingsWnd(); + settings.Owner = System.Windows.Application.Current.MainWindow; + settings.ShowDialog(); + } + + #endregion + #region Read File private void OpenCSVFile() { @@ -209,6 +224,7 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels } } #endregion + #region Generate public bool CanGenerate() { @@ -351,10 +367,11 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels string pngPlotFileName = String.Format($"{fileNameWithoutExtension}_Plottest{index}.png"); File.Delete(pngPlotFileName); System.Windows.Controls.Image plotImage = new System.Windows.Controls.Image(); - using (var stream = File.Open(pngPlotFileName, FileMode.Create, FileAccess.ReadWrite)) + //print plot to png file - removed 2/07/2020 + //using (var stream = File.Open(pngPlotFileName, FileMode.Create, FileAccess.ReadWrite)) { PngExporter exporter = new PngExporter() { Width = (int)item.ActualWidth, Height = (int)item.ActualHeight, Background = OxyColors.White, Resolution = 96 }; - exporter.Export(item.ActualModel, stream); + //exporter.Export(item.ActualModel, stream); BitmapSource bitmap = exporter.ExportToBitmap(item.ActualModel); plotImage.Source = bitmap; @@ -400,7 +417,10 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels FixedDocument fixedDoc = new FixedDocument(); PageContent pageContent = new PageContent(); FixedPage fixedPage = new FixedPage(); + fixedPage.Width = reportSize.Width; + fixedPage.Height = reportSize.Height; fixedPage.Children.Add(ResultsPanel); + fixedPage.UpdateLayout(); pageContent.BeginInit(); ((System.Windows.Markup.IAddChild)pageContent).AddChild(fixedPage); @@ -445,8 +465,8 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels private static Size GetReportSize(ItemsControl reportContainer) { - double reportWidth = reportContainer.ActualWidth; - double reportHeight = reportContainer.ActualHeight;// (reportWidth / printDialog.PrintableAreaWidth) * printDialog.PrintableAreaHeight; + double reportWidth = reportContainer.ActualWidth + 10; + double reportHeight = reportContainer.ActualHeight + 10;// (reportWidth / printDialog.PrintableAreaWidth) * printDialog.PrintableAreaHeight; return new Size(reportWidth, reportHeight); } diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/SettingsVM.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/SettingsVM.cs new file mode 100644 index 000000000..99b6e948a --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/SettingsVM.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DispenserAnalyzer.UI.Models; +using Tango.SharedUI; + +namespace Tango.DispenserAnalyzer.UI.ViewModels +{ + public class SettingsVM : ViewModel + { + private ObservableCollection _PBUSettings; + + public ObservableCollection PBUTestSettings + { + get { return _PBUSettings; } + set { _PBUSettings = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection _flowTestSettings; + + public ObservableCollection FlowTestSettings + { + get { return _flowTestSettings; } + set { _flowTestSettings = value; RaisePropertyChangedAuto(); } + } + + public SettingsVM() + { + _PBUSettings = new ObservableCollection(); + InitPBUTestSettings(); + _flowTestSettings = new ObservableCollection(); + InitFlowTestSettings(); + } + + private void InitPBUTestSettings() + { + _PBUSettings.Add(new SettingsModel("PBU Pass fail", "4.5 sec", 4.5)); + } + + private void InitFlowTestSettings() + { + _flowTestSettings.Add(new SettingsModel("PBU Pass fail", "4.5 sec", 4.5)); + _flowTestSettings.Add(new SettingsModel("Exclude from analysis", "1800 reads", 1800)); + _flowTestSettings.Add(new SettingsModel("Avg value", "1400-1850 [mbar]", 1400)); + _flowTestSettings.Add(new SettingsModel("Max-Min range", "500 reads", 500)); + _flowTestSettings.Add(new SettingsModel("Max Min intervals", "300 reads", 300)); + _flowTestSettings.Add(new SettingsModel("Max error", "1.5%", 1.5)); + _flowTestSettings.Add(new SettingsModel("Take off 'Max-min' values (out of highest results)", "3", 3)); + } + } +} -- cgit v1.3.1