diff options
Diffstat (limited to 'Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/MainWindowVM.cs')
| -rw-r--r-- | Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/MainWindowVM.cs | 143 |
1 files changed, 56 insertions, 87 deletions
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 38f8dee81..48d426d23 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/MainWindowVM.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/MainWindowVM.cs @@ -126,7 +126,24 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels } } - + private string _titleAxisBottom; + + public string TitleAxisBottom + { + get { return _titleAxisBottom; } + set { _titleAxisBottom = value; RaisePropertyChangedAuto(); } + } + + private string _titleAxisLeft; + + public string TitleAxisLeft + { + get { return _titleAxisLeft; } + set { _titleAxisLeft = value; RaisePropertyChangedAuto(); } + } + + + private bool _isRunning; /// <summary> /// Gets or sets a value indicating whether this instance is running. @@ -162,7 +179,8 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels XStep = 1; AnalyzerResults = new ObservableCollection<IAnalyzerResult>(); _isRunning = false; - + TitleAxisBottom = ""; + TitleAxisLeft = ""; this.Points = new List<DataPoint>(); } @@ -251,69 +269,38 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels return; ResetSettings(); - IAnalyzer analyzer = AnalysisService.GetAnalyzer(OpenFilePath); + var analyzer = AnalysisService.GetAnalyzer(OpenFilePath); if (analyzer == null) return; IsRunning = true; - AnalyzerAttribute attribute = (AnalyzerAttribute)analyzer.GetType().GetCustomAttributes(typeof(AnalyzerAttribute), true).FirstOrDefault(); - - TestName = attribute.Name; - List<DispenserCsvRow> data = CsvFile.Read<DispenserCsvRow>(new CsvSource(OpenFilePath)).ToList(); - List<DispenserSample> samples = new List<DispenserSample>(); - - To = 0; - From = 0; - int index = 0; - int last_labelIndex = 0; - - - foreach (var item in data) + AnalyzerAttribute[] attr = analyzer.GetType().GetCustomAttributes(typeof(AnalyzerAttribute), true); + if (attr != null && attr.Count() > 0) { - double pressure = 0; - if(item.Label == "Label") - { - item.Pressure = "0"; - item.Command = "Label"; - if (last_labelIndex == 0 || last_labelIndex < (index + 5)) - { - last_labelIndex = index; - - OxyPlot.Wpf.LineAnnotation _line = new OxyPlot.Wpf.LineAnnotation() - { - StrokeThickness = 1, - Color = Color.FromRgb(255, 5, 5), - Type = LineAnnotationType.Vertical, - Text = index.ToString(), - X = index, - }; - PlotControl.Annotations.Add(_line); - - } - } - if (double.TryParse(item.Pressure, out pressure) || !String.IsNullOrWhiteSpace(item.Command)) - { - samples.Add(new DispenserSample() - { - Pressure = pressure, - Command = String.IsNullOrWhiteSpace(item.Command) ? null : item.Command, - Index = index - }); - index++; - } + TestName = attr[0].Name; + } + List<OxyPlot.Wpf.LineAnnotation> annotations = new List<OxyPlot.Wpf.LineAnnotation>(); + var samples = analyzer.Reader.ReadScvFile(OpenFilePath, annotations); + analyzer.GetPoints(samples, Points); + if (Points.Count == 0) + { + IsRunning = false; + return; } + annotations.ForEach(x => PlotControl.Annotations.Add(x)); + To = 0; + From = 0; + List<IAnalyzerResult> res = await analyzer.Process(samples, false); AnalyzerResults = new ObservableCollection<IAnalyzerResult>(res); - samples.ForEach(x => - { - if (x.Pressure != 0.0) - { Points.Add(new DataPoint(x.Index, x.Pressure)); } - }); _to = Points.Max(x => x.Y); _from = TestName.Contains("sealtest") ? Points.FirstOrDefault(x => x.X == 0).Y : Points.Min(x => x.Y); + List<string> titles = analyzer.Reader.GetTitles(OpenFilePath); + TitleAxisBottom = titles[0]; + TitleAxisLeft = titles[1]; - data.Clear(); + // data.Clear(); _to += 100; RaisePropertyChanged("To"); if (_from != 0) @@ -324,8 +311,10 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels IsRunning = false; PlotControl.InvalidatePlot(true); - await PrintToXpsFile(); - + if(analyzer.Reader.PrintResultsToPDFFile()) + { + await PrintToXpsFile(); + } } /// <summary> @@ -338,44 +327,24 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels if (false == File.Exists(OpenFilePath) || IsFileLocked(OpenFilePath)) return; - IAnalyzer analyzer = AnalysisService.GetAnalyzer(OpenFilePath); + var analyzer = AnalysisService.GetAnalyzer(OpenFilePath); if (analyzer == null) return; - - AnalyzerAttribute attribute = (AnalyzerAttribute)analyzer.GetType().GetCustomAttributes(typeof(AnalyzerAttribute), true).FirstOrDefault(); - - TestName = attribute.Name; - List<DispenserCsvRow> data = CsvFile.Read<DispenserCsvRow>(new CsvSource(OpenFilePath)).ToList(); - List<DispenserSample> samples = new List<DispenserSample>(); - - int index = 0; - int last_labelIndex = 0; + AnalyzerAttribute[] attr = analyzer.GetType().GetCustomAttributes(typeof(AnalyzerAttribute), true); + if (attr != null && attr.Count() > 0) + { + TestName = attr[0].Name; + } - foreach (var item in data) + List<OxyPlot.Wpf.LineAnnotation> annotations = new List<OxyPlot.Wpf.LineAnnotation>(); + var samples = analyzer.Reader.ReadScvFile(OpenFilePath, annotations); + analyzer.GetPoints(samples, Points); + if (Points.Count == 0) { - double pressure = 0; - if (item.Label == "Label") - { - item.Pressure = "0"; - item.Command = "Label"; - if (last_labelIndex == 0 || last_labelIndex < (index + 5)) - { - last_labelIndex = index; - } - } - if (double.TryParse(item.Pressure, out pressure) || !String.IsNullOrWhiteSpace(item.Command)) - { - samples.Add(new DispenserSample() - { - Pressure = pressure, - Command = String.IsNullOrWhiteSpace(item.Command) ? null : item.Command, - Index = index - }); - index++; - } + return; } - + List<IAnalyzerResult> res = await analyzer.Process(samples, true); AnalyzerResults = new ObservableCollection<IAnalyzerResult>(res); |
