diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2020-09-13 11:55:25 +0300 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2020-09-13 11:55:25 +0300 |
| commit | 526019f244c1fc6f08361cd15cfce47927048823 (patch) | |
| tree | 141872ae69fce44479bdda0783fcdc23a0246e4c /Software/Visual_Studio/Utilities | |
| parent | 138d78a6a4c9e93359074771b44113a57cc17c0d (diff) | |
| download | Tango-526019f244c1fc6f08361cd15cfce47927048823.tar.gz Tango-526019f244c1fc6f08361cd15cfce47927048823.zip | |
Dispenser Analyzer. A new analyzer was added - Process. Added additional level of Generic interfaces and implementation.
Diffstat (limited to 'Software/Visual_Studio/Utilities')
25 files changed, 973 insertions, 349 deletions
diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/AnalyserResultChartData.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/AnalyserResultChartData.cs new file mode 100644 index 000000000..54431968f --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/AnalyserResultChartData.cs @@ -0,0 +1,74 @@ +using OxyPlot; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; + +namespace Tango.DispenserAnalyzer.UI.Analysis +{ + public class AnalyzerResultChartData : ExtendedObject + { + public ObservableCollection<DataPoint> Points { get; set; } + + public string Title { get; set; } + + private int _step; + public int XStep + { + get { return _step; } + set { _step = value; RaisePropertyChangedAuto(); } + } + + private double _fromXAxis; + public double FromXAxis + { + get { return _fromXAxis; } + set { _fromXAxis = value; RaisePropertyChangedAuto(); } + } + + private double _toXAxis; + public double ToXAxis + { + get { return _toXAxis; } + set { _toXAxis = value; RaisePropertyChangedAuto(); } + } + + private double _fromYAxis; + public double FromYAxis + { + get { return _fromYAxis; } + set { _fromYAxis = value; RaisePropertyChangedAuto(); } + } + + private double _toYAxis; + public double ToYAxis + { + get { return _toYAxis; } + set { _toYAxis = value; RaisePropertyChangedAuto(); } + } + + public void UpdateData() + { + _toYAxis = Points.Max(x => x.Y) + 2; + _fromYAxis = Points.Min(x => x.Y) - 1; + _toXAxis = Points.Max(x => x.X); + _fromXAxis = Points.Min(x => x.X); + + RaisePropertyChanged("Title"); + RaisePropertyChanged("Points"); + } + + public AnalyzerResultChartData() + { + Points = new ObservableCollection<DataPoint>(); + _fromYAxis = 0; + _fromXAxis = 0; + _toYAxis = 1; + _toXAxis = 1; + XStep = 1; + } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/AnalysisService.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/AnalysisService.cs index 0bebb4f11..0dbf9a83e 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/AnalysisService.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/AnalysisService.cs @@ -4,24 +4,37 @@ using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; +using Tango.CSV; +using Tango.DispenserAnalyzer.UI.Models; +using System.Windows.Controls; +using System.Windows.Media; +using System.IO; namespace Tango.DispenserAnalyzer.UI.Analysis { public class AnalysisService { - public static IAnalyzer GetAnalyzer(String fileName) + public static dynamic GetAnalyzer(String fileName) { - var analyzerTypes = typeof(AnalysisService).Assembly.GetTypes().Where(x => typeof(IAnalyzer).IsAssignableFrom(x)).ToList(); - // var words = fileName.Split().Select(x => x.Trim(' ')); - var analyzerType = analyzerTypes.FirstOrDefault(x => fileName.IndexOf(x.GetCustomAttribute<AnalyzerAttribute>().Name, StringComparison.OrdinalIgnoreCase) >= 0); - return (analyzerType != null) ? Activator.CreateInstance(analyzerType) as IAnalyzer : null; + string filename = Path.GetFileNameWithoutExtension(fileName); + + var analyzerTypes = typeof(AnalysisService).Assembly.GetTypes().Where(x => typeof(IBaseAnalyzer).IsAssignableFrom(x)).ToList(); + var analyzerType = analyzerTypes.FirstOrDefault(x => filename.StartsWith(x.GetCustomAttribute<AnalyzerAttribute>().Name, StringComparison.OrdinalIgnoreCase) ); + if(analyzerType == null) + {//in case name of test is not first word + analyzerType = analyzerTypes.FirstOrDefault(x => filename.IndexOf(x.GetCustomAttribute<AnalyzerAttribute>().Name, StringComparison.OrdinalIgnoreCase) >= 0); + } + + return (analyzerType != null) ? Activator.CreateInstance(analyzerType) : null; } public static string GetTestName(String fileName) { - var analyzerTypes = typeof(AnalysisService).Assembly.GetTypes().Where(x => typeof(IAnalyzer).IsAssignableFrom(x)).ToList(); - var analyzerType = analyzerTypes.SingleOrDefault(x => fileName.Contains(x.GetCustomAttribute<AnalyzerAttribute>().Name)); + var analyzerTypes = typeof(AnalysisService).Assembly.GetTypes().Where(x => typeof(IBaseAnalyzer).IsAssignableFrom(x)).ToList(); + var analyzerType = analyzerTypes.FirstOrDefault(x => fileName.IndexOf(x.GetCustomAttribute<AnalyzerAttribute>().Name, StringComparison.OrdinalIgnoreCase) >= 0); + return analyzerType.GetCustomAttribute<AnalyzerAttribute>().Name; } } + } diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/AnalyzerResultBase.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/AnalyzerResultBase.cs index d3d217409..bc82d2215 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/AnalyzerResultBase.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/AnalyzerResultBase.cs @@ -15,7 +15,7 @@ namespace Tango.DispenserAnalyzer.UI.Analysis public class AnalyzerResultBase : ExtendedObject, IAnalyzerResult { public AnalyzerResultValue Result { get; set; } - public List<AnalysisPlotValue> PlotValues { get; set; } + // public List<AnalysisPlotValue> PlotValues { get; set; } //public ObservableCollection<DataPoint> Points { get; set; } public List<AnalyzerResultProperty> Properties @@ -53,17 +53,22 @@ namespace Tango.DispenserAnalyzer.UI.Analysis } public bool IsShowPlotResult { get; set; } - public AnalyzerResultPlotData RangeToCountChart { get; set; } - public AnalyzerResultPlotData RangeToTimeChart { get; set; } + public bool IsShowLineChartResult { get; set; } + public AnalyzerResultChartData RangeToCountChart { get; set; } + public AnalyzerResultChartData RangeToTimeChart { get; set; } + public AnalyzerResultChartData LineChart { get; set; } public bool BackgroundMode { get; set; } + public AnalyzerResultBase() { - PlotValues = new List<AnalysisPlotValue>(); + //PlotValues = new List<AnalysisPlotValue>(); Result = AnalyzerResultValue.Undetermined; IsShowPlotResult = false; - RangeToCountChart = new AnalyzerResultPlotData(); - RangeToTimeChart = new AnalyzerResultPlotData(); + IsShowLineChartResult = false; + RangeToCountChart = new AnalyzerResultChartData(); + RangeToTimeChart = new AnalyzerResultChartData(); + LineChart = new AnalyzerResultChartData(); BackgroundMode = false; } } diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/DispenserReader.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/DispenserReader.cs new file mode 100644 index 000000000..8bb519425 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/DispenserReader.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.CSV; +using Tango.DispenserAnalyzer.UI.Models; +using OxyPlot.Annotations; +using System.Windows.Media; +using System.Diagnostics; + +namespace Tango.DispenserAnalyzer.UI.Analysis +{ + public class DispenserReader: IReader<DispenserSample> + { + public List<DispenserSample> ReadScvFile(String filePath, List<OxyPlot.Wpf.LineAnnotation> annotations) + { + List<DispenserCsvRow> data = CsvFile.Read<DispenserCsvRow>(new CsvSource(filePath)).ToList(); + List<DispenserSample> samples = new List<DispenserSample>(); + int index = 0; + int last_labelIndex = 0; + foreach (var item in data) + { + 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, + }; + 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++; + } + } + return samples; + } + + public List<string> GetTitles(String filePath) + { + string xAxistitle = "Time[msec]"; + string yAxistitle = "Pressure [mbar]"; + return new List<string>() { xAxistitle, yAxistitle }; + } + + public bool PrintResultsToPDFFile() + { + return true ; + } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IAnalyzer.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IAnalyzer.cs index 6d522da82..fd3b3c267 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IAnalyzer.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IAnalyzer.cs @@ -7,9 +7,24 @@ using Tango.DispenserAnalyzer.UI.Models; namespace Tango.DispenserAnalyzer.UI.Analysis { + [Analyzer("BaseInterface")] + public interface IBaseAnalyzer + { + + } [Analyzer("INTERFACE")] - public interface IAnalyzer + public interface IAnalyzer<T>: IBaseAnalyzer + { + IReader<T> Reader { get; set; } + Task<List<IAnalyzerResult>> Process(List<T> csvRows, bool backgroundMode); + void GetPoints(List<T> samples, IList<OxyPlot.DataPoint> points); + } + [Analyzer("DISPENSERINTERFACE")] + public interface IDispenserDispenserAnalyser : IAnalyzer<DispenserSample> + { + } + [Analyzer("PROCESSINTERFACE")] + public interface IProcessAnalyzer : IAnalyzer<ProcessSample> { - Task<List<IAnalyzerResult>> Process(List<DispenserSample> csvRows, bool backgroundMode); } } 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 60f7fcb36..5203828e5 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IAnalyzerResult.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IAnalyzerResult.cs @@ -5,62 +5,17 @@ using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; -using Tango.Core; namespace Tango.DispenserAnalyzer.UI.Analysis { - public class AnalyzerResultPlotData: ExtendedObject - { - public ObservableCollection<DataPoint> Points { get; set; } - - public string Title { get; set; } - - private int _step; - public int XStep - { - get { return _step; } - set { _step = value; RaisePropertyChangedAuto(); } - } - - private double _from; - public double From - { - get { return _from; } - set { _from = value; RaisePropertyChangedAuto(); } - } - - private double _to; - public double To - { - get { return _to; } - set { _to = value; RaisePropertyChangedAuto(); } - } - - public void UpdateData() - { - _to = Points.Max(x => x.Y) + 2; - _from = Points.Min(x => x.Y)-1; - RaisePropertyChanged("Title"); - RaisePropertyChanged("Points"); - } - - public AnalyzerResultPlotData() - { - Points = new ObservableCollection<DataPoint>(); - _from = 0; - _to = 1; - XStep = 1; - } - - } public interface IAnalyzerResult { AnalyzerResultValue Result { get; set; } bool BackgroundMode { get; set; } - List<AnalysisPlotValue> PlotValues { get; set; } - - AnalyzerResultPlotData RangeToCountChart { get; set; } - AnalyzerResultPlotData RangeToTimeChart { get; set; } + //List<AnalysisPlotValue> PlotValues { get; set; } + + //AnalyzerResultChartData RangeToCountChart { get; set; } + //AnalyzerResultChartData RangeToTimeChart { get; set; } } } diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IReader.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IReader.cs new file mode 100644 index 000000000..35c7f8f76 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IReader.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DispenserAnalyzer.UI.Analysis +{ + public interface IReader<T> + { + List<T> ReadScvFile(String filePath, List<OxyPlot.Wpf.LineAnnotation> annotations); + + List<string> GetTitles(String filePath); + + bool PrintResultsToPDFFile(); + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/ProcessReader.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/ProcessReader.cs new file mode 100644 index 000000000..b2e6f0388 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/ProcessReader.cs @@ -0,0 +1,116 @@ +using OxyPlot; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.CSV; +using Tango.DispenserAnalyzer.UI.Models; +using OxyPlot.Annotations; +using System.Windows.Media; + + +namespace Tango.DispenserAnalyzer.UI.Analysis +{ + public class ProcessReader: IReader<ProcessSample> + { + public List<ProcessSample> ReadScvFile(String filePath, List<OxyPlot.Wpf.LineAnnotation> annotations) + { + List<ProcessSample> samples = new List<ProcessSample>(); + try + { + List<ProcessCsvRow> data = CsvFile.Read<ProcessCsvRow>(new CsvSource(filePath)).ToList(); + + double index = 0; + double delta = 0; + if (data.Count > 2) + { + DateTime time1; + DateTime time2; + if (DateTime.TryParse(data[0].Time, out time1) && DateTime.TryParse(data[1].Time, out time2)) + { + int m1 = time1.Millisecond; + int m2 = time2.Millisecond; + delta = (time2 - time1).Milliseconds / 100; + } + } + delta = Settings.GetValueByName(AnalyzerSettingsEnum.TimeInterval); + if(delta == 0) + return samples; + + int endPoint = (int)(Settings.GetValueByName(AnalyzerSettingsEnum.EndCalculation) / delta); + foreach (var item in data) + { + double dValue = 0; + + if (double.TryParse(item.Value, out dValue)) + { + DateTime time; + DateTime.TryParse(item.Time, out time); + int mil = time.Millisecond; + samples.Add(new ProcessSample() + { + Time = time, + Value = dValue, + TimeIntervalSec = index, + }); + index += delta; + } + } + OxyPlot.Wpf.LineAnnotation _line1 = new OxyPlot.Wpf.LineAnnotation() + { + StrokeThickness = 1, + Color = Color.FromRgb(255, 5, 5), + Type = LineAnnotationType.Vertical, + Text = index.ToString(), + X = Settings.GetValueByName(AnalyzerSettingsEnum.StartCalculation) + }; + annotations.Add(_line1); + OxyPlot.Wpf.LineAnnotation _line2 = new OxyPlot.Wpf.LineAnnotation() + { + StrokeThickness = 1, + Color = Color.FromRgb(255, 5, 5), + Type = LineAnnotationType.Vertical, + Text = index.ToString(), + X = Settings.GetValueByName(AnalyzerSettingsEnum.EndCalculation) + }; + annotations.Add(_line2); + + + return samples; + } + catch (Exception ex) + { + Debug.Write("Exception in ProcessReader ReadScvFile" + ex.Message); + return samples; + } + } + + public List<string> GetScvColumns(String filePath) + { + try + { + return CsvFile.GetColumns<ProcessCsvRow>(new CsvSource(filePath)).ToList(); + } + catch (Exception ex) + { + Debug.Write("Exception in ProcessReader ReadScvFile" + ex.Message); + return null; + } + } + + public List<string> GetTitles(String filePath) + { + List<string> columns = GetScvColumns(filePath); + string xAxistitle = "Time [sec]"; + string yAxistitle = columns!= null && columns.Count > 1 ? columns[1] : "Values"; + return new List<string>() { xAxistitle, yAxistitle }; + } + + public bool PrintResultsToPDFFile() + { + return false; + } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/DynamicSealingAnalyzer.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/DynamicSealingAnalyzer.cs index 8acd1651c..d440f42c3 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/DynamicSealingAnalyzer.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/DynamicSealingAnalyzer.cs @@ -10,8 +10,19 @@ using Tango.DispenserAnalyzer.UI.Models; namespace Tango.DispenserAnalyzer.UI.Analyzers { [Analyzer("dynamic")] - public class DynamicSealingAnalzyer : IAnalyzer + public class DynamicSealingAnalzyer : IDispenserDispenserAnalyser { + private IReader<DispenserSample> _reader; + public IReader<DispenserSample> Reader + { + get { return _reader; } + set { _reader = value; } + } + public DynamicSealingAnalzyer() + { + Reader = new DispenserReader(); + } + public Task<List<IAnalyzerResult>> Process(List<DispenserSample> csvRows, bool backgroundMode) { return Task.Factory.StartNew<List<IAnalyzerResult>>(() => @@ -61,6 +72,16 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers return results; }); } + + public void GetPoints(List<DispenserSample> samples, IList<OxyPlot.DataPoint> points) + { + samples.ForEach(x => + { + if (x.Pressure != 0.0) + { points.Add(new OxyPlot.DataPoint(x.Index, x.Pressure)); } + }); + } + public class DynamicSealingAnalyzerResult : AnalyzerResultBase { [Description("Dynamic sealing result")] 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 492fb3e6a..81c578e5c 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/FlowAnalyser.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/FlowAnalyser.cs @@ -19,15 +19,28 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers { [Analyzer("flow")] - public class FlowAnalyser : IAnalyzer + public class FlowAnalyser : IDispenserDispenserAnalyser { + private IReader<DispenserSample> _reader; + public IReader<DispenserSample> Reader + { + get { return _reader; } + set { _reader = value; } + } + + + public FlowAnalyser() + { + Reader = new DispenserReader(); + } + public Task<List<IAnalyzerResult>> Process(List<DispenserSample> csvRows, bool backgroundMode) { return Task.Factory.StartNew<List<IAnalyzerResult>>(() => { List<IAnalyzerResult> results = new List<IAnalyzerResult>(); List<DispenserSample> commands = csvRows.Where(x => x.Command != null && x.Command.ToLower().Contains("label")).ToList<DispenserSample>(); - 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(); + 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++) @@ -101,6 +114,16 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers return results; }); } + + public void GetPoints(List<DispenserSample> samples, IList<OxyPlot.DataPoint> points) + { + samples.ForEach(x => + { + if (x.Pressure != 0.0) + { points.Add(new OxyPlot.DataPoint(x.Index, x.Pressure)); } + }); + } + public class FlowAverageAnalyzerResult : AnalyzerResultBase { [Description("Average Value")] diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PressureBuildUpAnalyser.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PressureBuildUpAnalyser.cs index 79b643294..9288eb2ad 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PressureBuildUpAnalyser.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PressureBuildUpAnalyser.cs @@ -9,8 +9,19 @@ using Tango.DispenserAnalyzer.UI.Models; namespace Tango.DispenserAnalyzer.UI.Analyzers { [Analyzer("pressure build up")] - public class PressureBuildUpAnalyser : IAnalyzer + public class PressureBuildUpAnalyser : IDispenserDispenserAnalyser { + private IReader<DispenserSample> _reader; + public IReader<DispenserSample> Reader + { + get { return _reader; } + set { _reader = value; } + } + + public PressureBuildUpAnalyser() + { + Reader = new DispenserReader(); + } public Task<List<IAnalyzerResult>> Process(List<DispenserSample> csvRows, bool backgroundMode) { return Task.Factory.StartNew<List<IAnalyzerResult>>(() => @@ -36,6 +47,15 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers return results; }); } + + public void GetPoints(List<DispenserSample> samples, IList<OxyPlot.DataPoint> points) + { + samples.ForEach(x => + { + if (x.Pressure != 0.0) + { points.Add(new OxyPlot.DataPoint(x.Index, x.Pressure)); } + }); + } } } diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PrimingAnalyzer.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PrimingAnalyzer.cs index cfd4a7b55..315c384d6 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PrimingAnalyzer.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PrimingAnalyzer.cs @@ -11,8 +11,19 @@ using Tango.DispenserAnalyzer.UI.Models; namespace Tango.DispenserAnalyzer.UI.Analyzers { [Analyzer("priming")] - public class PrimingAnalyzer : IAnalyzer + public class PrimingAnalyzer : IDispenserDispenserAnalyser { + private IReader<DispenserSample> _reader; + public IReader<DispenserSample> Reader + { + get { return _reader; } + set { _reader = value; } + } + + public PrimingAnalyzer() + { + Reader = new DispenserReader(); + } public Task<List<IAnalyzerResult>> Process(List<DispenserSample> csvRows, bool backgroundMode) { return Task.Factory.StartNew<List<IAnalyzerResult>>(() => @@ -35,6 +46,15 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers return results; }); } + + public void GetPoints(List<DispenserSample> samples, IList<OxyPlot.DataPoint> points) + { + samples.ForEach(x => + { + if (x.Pressure != 0.0) + { points.Add(new OxyPlot.DataPoint(x.Index, x.Pressure)); } + }); + } } public class PrimingAnalyzerResult : AnalyzerResultBase { diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/ProcessAnalyser.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/ProcessAnalyser.cs new file mode 100644 index 000000000..65fe9c85d --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/ProcessAnalyser.cs @@ -0,0 +1,137 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.CSV; +using Tango.DispenserAnalyzer.UI.Analysis; +using Tango.DispenserAnalyzer.UI.Models; + +namespace Tango.DispenserAnalyzer.UI.Analyzers +{ + [Analyzer("process")] + public class ProcessAnalyser : IProcessAnalyzer + { + private IReader<ProcessSample> _reader; + public IReader<ProcessSample> Reader { + get { return _reader; } + set { _reader = value; } + } + + public ProcessAnalyser() + { + Reader = new ProcessReader(); + } + + public Task<List<IAnalyzerResult>> Process(List<ProcessSample> csvRows, bool backgroundMode) + { + return Task.Factory.StartNew<List<IAnalyzerResult>>(() => + { + List<IAnalyzerResult> results = new List<IAnalyzerResult>(); + ProcessAnalyzerResult result = new ProcessAnalyzerResult(); + result.BackgroundMode = backgroundMode; + double delta = Settings.GetValueByName(AnalyzerSettingsEnum.TimeInterval); + int startPoint = delta == 0? 0 : (int)(Settings.GetValueByName(AnalyzerSettingsEnum.StartCalculation) / delta); + int endPoint = delta == 0 ? (csvRows.Count -1) : (int)(Settings.GetValueByName(AnalyzerSettingsEnum.EndCalculation) / delta); + List<ProcessSample> rangeValues = csvRows.Skip(startPoint).Take(endPoint).ToList(); + + result.MinValue = rangeValues.Min(x => x.Value); + result.MaxValue = rangeValues.Max(x => x.Value); + result.AverageValue = rangeValues.Average(x => x.Value); + result.StandardDeviation = ProcessAnalyser.StdDev(rangeValues.Select(x => x.Value)); + + result.Result = AnalyzerResultValue.Passed; + + //Move Average data + List<Task> tasks = new List<Task>(); + int calc_count = (int)csvRows.Count() / 4; + int start_index = 0; + while (start_index < csvRows.Count()) + { + int calc_amount = (start_index + calc_count) >= (csvRows.Count() - 4) ? csvRows.Count() - start_index : calc_count; + var source_filter = csvRows.Skip(start_index).Take(calc_amount).ToList(); + tasks.Add(Task.Run(() => + { + ProcessAnalyser.Filtering(source_filter); + })); + start_index += calc_amount; + } + Task.WaitAll(tasks.ToArray()); + + result.CreateMovingAvgGraph(csvRows); + results.Add(result); + return results; + }); + } + + public static double StdDev(IEnumerable<double> values) + { + double avg = values.Average(); + double sum = values.Sum(v => (v - avg) * (v - avg)); + double denominator = values.Count() - 1; + return denominator > 0.0 ? Math.Sqrt(sum / denominator) : -1; + } + public static void Filtering(List<ProcessSample> source) + { + int periodAverage = (int)Settings.GetValueByName(AnalyzerSettingsEnum.MovingAvg); + int count = (source.Count < periodAverage) ? source.Count : source.Count - periodAverage; + for (int i = 0; i < count; i++) + { + source[i].Value = source.Skip(i).Take(periodAverage).Average(x => x.Value); + } + } + + public void GetPoints(List<ProcessSample> samples, IList<OxyPlot.DataPoint> points) + { + samples.ForEach(x => + { + points.Add(new OxyPlot.DataPoint(x.TimeIntervalSec, x.Value)); + }); + } + + } + + public class ProcessAnalyzerResult : AnalyzerResultBase + { + [Description("Selected Area")] + public string Header { get; set; } + + [Description("Average Value")] + public double AverageValue { get; set; } + [Description("Max value")] + public double MaxValue { get; set; } + [Description("Min value")] + public double MinValue { get; set; } + [Description("Standard deviation value")] + public double StandardDeviation { get; set; } + + + public ProcessAnalyzerResult() + { + double from = Settings.GetValueByName(AnalyzerSettingsEnum.StartCalculation); + double to = Settings.GetValueByName(AnalyzerSettingsEnum.EndCalculation); + Header = $"from {from} to {to} seconds"; + AverageValue = MaxValue = MinValue = 0.0; + Result = AnalyzerResultValue.Undetermined; + IsShowLineChartResult = true; + } + + public void CreateMovingAvgGraph(List<ProcessSample> avgValues) + { + if (!BackgroundMode) + { + var points = LineChart.Points; + points.Clear(); + avgValues.ForEach(x => + { + points.Add(new OxyPlot.DataPoint(x.TimeIntervalSec, x.Value)); + }); + + LineChart.Title = $"Moving Average Values"; + LineChart.UpdateData(); + } + } + + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/SealingAnalyzer.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/SealingAnalyzer.cs index e1fe232c3..841101b10 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/SealingAnalyzer.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/SealingAnalyzer.cs @@ -10,8 +10,19 @@ using Tango.DispenserAnalyzer.UI.Models; namespace Tango.DispenserAnalyzer.UI.Analyzers { [Analyzer("sealtest")] - public class SealingAnalyzer : IAnalyzer + public class SealingAnalyzer : IDispenserDispenserAnalyser { + private IReader<DispenserSample> _reader; + public IReader<DispenserSample> Reader + { + get { return _reader; } + set { _reader = value; } + } + + public SealingAnalyzer() + { + Reader = new DispenserReader(); + } public Task<List<IAnalyzerResult>> Process(List<DispenserSample> csvRows, bool backgroundMode) { return Task.Factory.StartNew<List<IAnalyzerResult>>(() => @@ -38,6 +49,15 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers return results; }); } + + public void GetPoints(List<DispenserSample> samples, IList<OxyPlot.DataPoint> points) + { + samples.ForEach(x => + { + if (x.Pressure != 0.0) + { points.Add(new OxyPlot.DataPoint(x.Index, x.Pressure)); } + }); + } } public class SealingAnalyzerResult : AnalyzerResultBase diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml index e56ae6639..595d74e3d 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml @@ -48,33 +48,34 @@ </Grid> <Grid Grid.Row="2"> <Border BorderBrush="Silver" Padding="5" BorderThickness="1" CornerRadius="5" Margin="10"> - <Expander Header="{Binding TestName}" IsExpanded="True"> - <!--<lvc:CartesianChart LegendLocation="Bottom" DisableAnimations="True" DataTooltip="{x:Null}" Hoverable="False" > - <lvc:CartesianChart.Series> - <lvc:LineSeries Values="{Binding Values}" PointGeometry="{x:Null}" Title="{Binding TestName}"/> - </lvc:CartesianChart.Series> - <lvc:CartesianChart.AxisX> - <lvc:Axis Title="TIME" Foreground="Silver" Labels="{Binding Labels}"> - <lvc:Axis.Separator> - <lvc:Separator Stroke="#A5A5A5" Step="{Binding XStep}"/> - </lvc:Axis.Separator> - </lvc:Axis> - </lvc:CartesianChart.AxisX> - <lvc:CartesianChart.AxisY> - <lvc:Axis Title="PRESSURE" LabelFormatter="{Binding YFormatter}" MinValue="{Binding From, Mode=TwoWay}" MaxValue="{Binding To, Mode=TwoWay}" Foreground="Silver" FontSize="16" > - <lvc:Axis.Separator> - <lvc:Separator Stroke="#B0B0B0" /> - </lvc:Axis.Separator> - </lvc:Axis> - </lvc:CartesianChart.AxisY> - </lvc:CartesianChart>--> - <oxy:Plot Title="{Binding TestName}" x:Name="PressurePlot" Height="300"> + <Expander IsExpanded="True"> + <Expander.Header> + <Grid > + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*" /> + <ColumnDefinition Width="auto" /> + </Grid.ColumnDefinitions> + <TextBlock Padding="0" Text="{Binding TestName}" Margin="10,0,0,0" VerticalAlignment="Center" FontWeight="DemiBold"/> + <materialDesign:PackIcon Grid.Column="1" Kind="Information" Width="24" Height="24" VerticalAlignment="Center" Foreground="#03A9F4" Background="Transparent"> + <materialDesign:PackIcon.ToolTip> + <TextBlock> + <Run Text="Panning: CTRL + RIGHT CLICK and select area;"></Run> + <LineBreak/> + <Run Text="Zooming: MOUSE WHEEL on Axis Area;"></Run> + <LineBreak/> + <Run Text="Reset all : CTRL + DOUBLE RIGHT CLICK;"></Run> + </TextBlock> + </materialDesign:PackIcon.ToolTip> + </materialDesign:PackIcon> + </Grid> + </Expander.Header> + <oxy:Plot Title="{Binding TestName}" x:Name="PressurePlot" Height="300"> <oxy:Plot.Series > <oxy:LineSeries ItemsSource="{Binding Points}" Color="#73B6EC" MarkerType="None"/> </oxy:Plot.Series> <oxy:Plot.Axes> - <oxy:LinearAxis Position="Bottom" Title = "Time [msec]" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True"/> - <oxy:LinearAxis Position="Left" Title = "Pressure [mbar]" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" Minimum="{Binding From}" Maximum="{Binding To}"/> + <oxy:LinearAxis Position="Bottom" Title = "{Binding TitleAxisBottom}" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True"/> + <oxy:LinearAxis Position="Left" Title = "{Binding TitleAxisLeft}" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" Minimum="{Binding From}" Maximum="{Binding To}"/> </oxy:Plot.Axes> </oxy:Plot> </Expander> @@ -130,7 +131,27 @@ </oxy:Plot.Series> <oxy:Plot.Axes> <oxy:LinearAxis Position="Bottom" Title = "Location" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True"/> - <oxy:LinearAxis Position="Left" Title = "Max-min \ range [mbar]" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" Minimum="{Binding RangeToTimeChart.From}" Maximum="{Binding RangeToTimeChart.To}"/> + <oxy:LinearAxis Position="Left" Title = "Max-min \ range [mbar]" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" Minimum="{Binding RangeToTimeChart.FromYAxis}" Maximum="{Binding RangeToTimeChart.ToYAxis}"/> + </oxy:Plot.Axes> + </oxy:Plot> + </StackPanel> + </Border> + <Border x:Name="ChartBorder" BorderBrush="Silver" Padding="2" BorderThickness="1" CornerRadius="5" Margin="10" Visibility="{Binding IsShowLineChartResult, Converter={StaticResource BooleanToVisibilityConverter}}" MinHeight="300"> + <StackPanel Orientation="Vertical" x:Name="ChartStackPanel"> + <!--<StackPanel Orientation="Horizontal"> + <TextBlock VerticalAlignment="Center">MinDisplayValue</TextBlock> + <TextBox VerticalAlignment="Center" Margin="10 0 30 0" x:Name="MinFilter" Text="{Binding LineChart.FromXAxis, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged, Delay=10}" FontWeight="DemiBold" FontSize="14" Foreground="Blue"></TextBox> + <TextBlock VerticalAlignment="Center" >MaxDisplayValue</TextBlock> + <TextBox Margin="10 0 10 0" x:Name="MaxFilter" Text="{Binding LineChart.ToXAxis,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Delay=10}" FontWeight="DemiBold" FontSize="14" Foreground="Blue"></TextBox> + </StackPanel>--> + <oxy:Plot x:Name="ChartProcess" Title="{Binding LineChart.Title}" LegendPlacement="Outside" LegendPosition="RightTop" LegendOrientation="Vertical" ClipToBounds="True" MinWidth="220" MinHeight="300"> + <oxy:Plot.Series > + <oxy:LineSeries ItemsSource="{Binding LineChart.Points}" Color="#73B6EC" MarkerType="None"/> + </oxy:Plot.Series> + + <oxy:Plot.Axes> + <oxy:LinearAxis Position="Bottom" Title = "Time [msec]" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" Minimum="{Binding LineChart.FromXAxis}" Maximum="{Binding LineChart.ToXAxis}"/> + <oxy:LinearAxis Position="Left" Title = "Value" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" /> </oxy:Plot.Axes> </oxy:Plot> </StackPanel> diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml.cs index d328ea8a5..e7d263a1c 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml.cs @@ -43,6 +43,10 @@ namespace Tango.DispenserAnalyzer.UI for (int index = 0; index < filePathArr.Length; index++) { await _vm.GenerateInBackground(filePathArr[index]); + if(index < filePathArr.Length) + { + await Task.Delay(500); + } } } await Task.Delay(500); diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/DispenserSample.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/DispenserSample.cs index d1d37955d..899aaa600 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/DispenserSample.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/DispenserSample.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Tango.DispenserAnalyzer.UI.Models { - public class DispenserSample + public class DispenserSample: ISample { public double Pressure { get; set; } public String Command { get; set; } diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/ISample.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/ISample.cs new file mode 100644 index 000000000..ea374a846 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/ISample.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DispenserAnalyzer.UI.Models +{ + public interface ISample + { + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/ProcessCsvRow.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/ProcessCsvRow.cs new file mode 100644 index 000000000..33e85d5b5 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/ProcessCsvRow.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.CSV; + +namespace Tango.DispenserAnalyzer.UI.Models +{ + public class ProcessCsvRow + { + [CsvOrder(0)] + public String Time { get; set; } + [CsvOrder(1)] + public String Value { get; set; } + } +}
\ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/ProcessSample.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/ProcessSample.cs new file mode 100644 index 000000000..3f02ea35d --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/ProcessSample.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DispenserAnalyzer.UI.Models +{ + public class ProcessSample : ISample + { + public double TimeIntervalSec { get; set; } + public DateTime Time { get; set; } + public double Value { get; set; } + + public ProcessSample() + { + Value = 0.0; + } + + public override string ToString() + { + return $"{TimeIntervalSec}, {Value}"; + } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Settings.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Settings.cs index 9a1f10aed..b8084b2d3 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Settings.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Settings.cs @@ -9,7 +9,8 @@ namespace Tango.DispenserAnalyzer.UI { public enum AnalyzerSettingsEnum { - //Undetermined + [Description("Print Results to PDF file")] + PrintResultsToPDF, [Description("PBU Pass fail")] PBUPassFail, [Description("PBU Pass fail")] @@ -28,6 +29,15 @@ namespace Tango.DispenserAnalyzer.UI MaxError, [Description("Take off 'Max-min' values(out of highest results)")] TakeOffMaxMin, + [Description("Time gap between data point [sec]")] + TimeInterval, + [Description("Time point to start calculation [sec]")] + StartCalculation, + [Description("Time point to end calculation [sec]")] + EndCalculation, + [Description("How many points to use for moving average")] + MovingAvg + } @@ -39,7 +49,6 @@ namespace Tango.DispenserAnalyzer.UI static Settings() { DefaultValues = new Dictionary<AnalyzerSettingsEnum, double>(); - DefaultValues[AnalyzerSettingsEnum.PBUPassFail] = 4.5; DefaultValues[AnalyzerSettingsEnum.FlowPBUPassFail] = 4.5; DefaultValues[AnalyzerSettingsEnum.ExcludeAnalysis] = 1800; @@ -49,17 +58,13 @@ namespace Tango.DispenserAnalyzer.UI DefaultValues[AnalyzerSettingsEnum.MaxMinIntervals] = 300; DefaultValues[AnalyzerSettingsEnum.MaxError] = 1.5; DefaultValues[AnalyzerSettingsEnum.TakeOffMaxMin] = 3; + DefaultValues[AnalyzerSettingsEnum.TimeInterval] = 0.1; + DefaultValues[AnalyzerSettingsEnum.StartCalculation] = 600; + DefaultValues[AnalyzerSettingsEnum.EndCalculation] = 900; + DefaultValues[AnalyzerSettingsEnum.MovingAvg] = 50; - CurrentValues = new Dictionary<AnalyzerSettingsEnum, double>(); - CurrentValues[AnalyzerSettingsEnum.PBUPassFail] = 4.5; - CurrentValues[AnalyzerSettingsEnum.FlowPBUPassFail] = 4.5; - CurrentValues[AnalyzerSettingsEnum.ExcludeAnalysis] = 1800; - CurrentValues[AnalyzerSettingsEnum.AvgMinValue] = 1400; - CurrentValues[AnalyzerSettingsEnum.AvgMaxValue] = 1850; - CurrentValues[AnalyzerSettingsEnum.MaxMinRange] = 500; - CurrentValues[AnalyzerSettingsEnum.MaxMinIntervals] = 300; - CurrentValues[AnalyzerSettingsEnum.MaxError] = 1.5; - CurrentValues[AnalyzerSettingsEnum.TakeOffMaxMin] = 3; + CurrentValues = new Dictionary<AnalyzerSettingsEnum, double>(DefaultValues); + } public static double GetValueByName(AnalyzerSettingsEnum name) { 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 b7db85ef8..5a261fb85 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 @@ -15,7 +15,7 @@ <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <Deterministic>true</Deterministic> <IsWebBootstrapper>false</IsWebBootstrapper> - <PublishUrl>P:\Users - Public\Ori\Dispenser Analyzer\</PublishUrl> + <PublishUrl>P:\Dispenser Analyzer Installer\</PublishUrl> <Install>true</Install> <InstallFrom>Disk</InstallFrom> <UpdateEnabled>false</UpdateEnabled> @@ -29,8 +29,8 @@ <ProductName>Dispenser Analyser</ProductName> <PublisherName>Twine</PublisherName> <OpenBrowserOnPublish>false</OpenBrowserOnPublish> - <ApplicationRevision>4</ApplicationRevision> - <ApplicationVersion>2.1.1.%2a</ApplicationVersion> + <ApplicationRevision>2</ApplicationRevision> + <ApplicationVersion>3.1.1.%2a</ApplicationVersion> <UseApplicationTrust>true</UseApplicationTrust> <CreateDesktopShortcut>true</CreateDesktopShortcut> <PublishWizardCompleted>true</PublishWizardCompleted> @@ -126,17 +126,22 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </ApplicationDefinition> + <Compile Include="Analysis\AnalyserResultChartData.cs" /> <Compile Include="Analysis\AnalysisPlotValue.cs" /> <Compile Include="Analysis\AnalyzerResultProperty.cs" /> <Compile Include="Analysis\AnalyzerResultBase.cs" /> <Compile Include="Analysis\AnalyzerResultValue.cs" /> <Compile Include="Analysis\AnalysisService.cs" /> + <Compile Include="Analysis\DispenserReader.cs" /> <Compile Include="Analysis\IAnalyzerResult.cs" /> <Compile Include="Analysis\IAnalyzer.cs" /> + <Compile Include="Analysis\IReader.cs" /> + <Compile Include="Analysis\ProcessReader.cs" /> <Compile Include="Analyzers\DynamicSealingAnalyzer.cs" /> <Compile Include="Analyzers\FlowAnalyser.cs" /> <Compile Include="Analyzers\PressureBuildUpAnalyser.cs" /> <Compile Include="Analyzers\PrimingAnalyzer.cs" /> + <Compile Include="Analyzers\ProcessAnalyser.cs" /> <Compile Include="Analyzers\ReliabilityTestAnalyser.cs" /> <Compile Include="Analyzers\SealingAnalyzer.cs" /> <Compile Include="Analysis\AnalyzerAttribute.cs" /> @@ -144,6 +149,9 @@ <Compile Include="Models\DispenserCsvRow.cs" /> <Compile Include="Models\DispenserSample.cs" /> <Compile Include="Models\DispenserSampleCommand.cs" /> + <Compile Include="Models\ISample.cs" /> + <Compile Include="Models\ProcessCsvRow.cs" /> + <Compile Include="Models\ProcessSample.cs" /> <Compile Include="Models\SettingsModel.cs" /> <Compile Include="Settings.cs" /> <Compile Include="ViewModels\MainWindowVM.cs" /> diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/SettingsWnd.xaml b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/SettingsWnd.xaml index 2bfa2bba1..d8d4594b8 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/SettingsWnd.xaml +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/SettingsWnd.xaml @@ -6,7 +6,7 @@ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:local="clr-namespace:Tango.DispenserAnalyzer.UI.View" mc:Ignorable="d" - Title="Settings" Height="630" Width="800" FontSize="22" ResizeMode="NoResize" WindowStyle="ToolWindow" Closing="Window_Closing"> + Title="Settings" Height="690" Width="800" FontSize="22" ResizeMode="NoResize" WindowStyle="ToolWindow" Closing="Window_Closing"> <Window.Resources> <Style TargetType="{x:Type TextBlock}" x:Key="WrapText"> <Setter Property="TextWrapping" Value="Wrap"/> @@ -18,7 +18,7 @@ <Setter Property="Padding" Value="0 0 0 0"></Setter> <Setter Property="Margin" Value="8 0 0 0"></Setter> <Setter Property="FontWeight" Value="SemiBold"/> - <Setter Property="BorderThickness" Value="0"/> + <Setter Property="BorderThickness" Value="1"/> <Setter Property="Height" Value="Auto"/> <Setter Property="FontSize" Value="14"/> </Style> @@ -64,138 +64,149 @@ </Style.Triggers> </Style> - <Style TargetType="DataGrid" BasedOn="{StaticResource {x:Type DataGrid}}"> + <Style x:Key="PropertyDataGrid" TargetType="DataGrid" BasedOn="{StaticResource {x:Type DataGrid}}"> <Setter Property="BorderBrush" Value="#FF688CAF"/> <Setter Property="BorderThickness" Value="0"/> <Setter Property="HorizontalScrollBarVisibility" Value="Disabled" /> <Setter Property="VerticalScrollBarVisibility" Value="Auto"/> </Style> - <DataGrid x:Key="PropertyDataGrid" x:Shared="False" HorizontalAlignment="Left" VerticalScrollBarVisibility ="Auto" SelectionUnit="FullRow" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" - ItemsSource="{Binding .}" GridLinesVisibility="None" SelectionMode="Single" AlternatingRowBackground="#F6F6F6" FontSize="12" > - <DataGrid.Columns> - <DataGridTextColumn Header="Property Name" Binding="{Binding PropertyName}" Width="150" ElementStyle="{StaticResource WrapText}"/> - <DataGridTemplateColumn Header="Property Value" Width="150"> - <DataGridTemplateColumn.CellTemplate> - <DataTemplate> - <StackPanel Orientation="Horizontal"> - <TextBox Text="{Binding PropertyValue, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" Width="50" VerticalAlignment="Top"> - <TextBox.Style> - <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource MaterialDesignTextBox}"> - <Setter Property="Visibility" Value="Visible"/> - <Style.Triggers> - <DataTrigger Binding="{Binding IsRangeVisible}" Value="true"> - <Setter Property="Visibility" Value="Collapsed"/> - </DataTrigger> - </Style.Triggers> - </Style> - </TextBox.Style> - </TextBox> - <DockPanel HorizontalAlignment="Stretch" Width="150"> - <DockPanel.Style> - <Style TargetType="{x:Type DockPanel}"> - <Setter Property="Visibility" Value="Collapsed"/> - <Style.Triggers> - <DataTrigger Binding="{Binding IsRangeVisible}" Value="true"> - <Setter Property="Visibility" Value="Visible"/> - </DataTrigger> - </Style.Triggers> + <Style x:Key="ItemsControlStyle1" TargetType="{x:Type ItemsControl}"> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type ItemsControl}"> + <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true"> + <ScrollViewer VerticalScrollBarVisibility="Auto"> + <ScrollViewer.Resources> + <Style TargetType="ScrollBar"> + <Setter Property="Width" Value="10"/> + <Setter Property="MinWidth" Value="10" /> </Style> - </DockPanel.Style> - <TextBox DockPanel.Dock="Left" Name="MinRangeValue" Width="50" Text="{Binding MinRangeValue, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"/> - <TextBox DockPanel.Dock="Right" Name="MaxRangeValue" Width="50" Text="{Binding MaxRangeValue, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"/> - </DockPanel> - </StackPanel> - </DataTemplate> - </DataGridTemplateColumn.CellTemplate> - </DataGridTemplateColumn> - <DataGridTextColumn Header="Default Value" Binding="{Binding DefaultValueDisplay}" Width="150" ElementStyle="{StaticResource WrapText}" /> - <DataGridTemplateColumn Header="" Width="1*"> - <DataGridTemplateColumn.CellStyle> - <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> - <Setter Property="BorderThickness" Value="0"/> - <Setter Property="FocusVisualStyle" Value="{x:Null}"/> - <Setter Property="VerticalContentAlignment" Value="Center"></Setter> - <Setter Property="VerticalAlignment" Value="Center"/> - <Setter Property="HorizontalAlignment" Value="Stretch"/> - <Setter Property="Margin" Value="0 0 0 0"/> - <Setter Property="Template"> - <Setter.Value> - <ControlTemplate TargetType="{x:Type DataGridCell}"> - <ContentPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> - </ControlTemplate> - </Setter.Value> - </Setter> - <Style.Triggers> - <Trigger Property="IsSelected" Value="True"> - <Setter Property="Background" Value="Transparent"></Setter> - <Setter Property="Foreground" Value="{StaticResource AccentColorBrush}" /> - </Trigger> - </Style.Triggers> - </Style> - </DataGridTemplateColumn.CellStyle> - <DataGridTemplateColumn.CellTemplate> - <DataTemplate> - <Grid HorizontalAlignment="Stretch" VerticalAlignment="Center"> - <Button Width="80" Padding="2" Height="26" FontSize="12" Margin="0 8" Command="{Binding SetDefaultCommand}">Set Default</Button> - </Grid> - </DataTemplate> - </DataGridTemplateColumn.CellTemplate> - </DataGridTemplateColumn> - </DataGrid.Columns> - </DataGrid> - + </ScrollViewer.Resources> + <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/> + </ScrollViewer> + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + </Window.Resources> <Grid> <Grid.RowDefinitions> - <RowDefinition Height="Auto"/> <RowDefinition Height="1*"/> - <RowDefinition Height="Auto"/> + <RowDefinition Height="80"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> - + </Grid.ColumnDefinitions> - <Grid Grid.Row="0"> - <Grid> - <Grid.RowDefinitions> - <RowDefinition Height="Auto"/> - <RowDefinition Height="Auto"/> - </Grid.RowDefinitions> - <Grid Grid.Row="0" VerticalAlignment="Top"> - <Border Margin="20 20 20 0" BorderBrush="LightGray" BorderThickness="0.6" CornerRadius="4" Height="36"> - <Border.Effect> - <DropShadowEffect/> - </Border.Effect> - </Border> - <Border Margin="20 20 20 0" BorderBrush="LightGray" BorderThickness="0.6" CornerRadius="4" Height="34" Background="#C4EEFC"> - <TextBlock FontSize="22" Padding="2">Pressure build up test</TextBlock> - </Border> - </Grid> - <ContentControl x:Name="PBUTestControl" Grid.Row="1" Content="{StaticResource PropertyDataGrid}" DataContext="{Binding Path=PBUTestSettings}" Margin="20 0 20 0"></ContentControl> - </Grid> - </Grid> - <Grid Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Stretch"> - <Grid> - <Grid.RowDefinitions> - <RowDefinition Height="Auto"/> - <RowDefinition Height="Auto"/> - </Grid.RowDefinitions> - <Grid Grid.Row="0" VerticalAlignment="Top"> - <Border Margin="20 20 20 0" BorderBrush="LightGray" BorderThickness="0.6" CornerRadius="4" Height="36"> - <Border.Effect> - <DropShadowEffect/> - </Border.Effect> - </Border> - <Border Margin="20 20 20 0" BorderBrush="LightGray" BorderThickness="0.6" CornerRadius="4" Height="34" Background="#C4EEFC"> - <TextBlock FontSize="22" Padding="2">Flow test</TextBlock> - </Border> - </Grid> - <ContentControl x:Name="FlowTestControl" Grid.Row="1" Content="{StaticResource PropertyDataGrid}" DataContext="{Binding Path=FlowTestSettings}" Margin="20 0 20 0"></ContentControl> - </Grid> + <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> + <ItemsControl ItemsSource="{Binding Settings}" Height="Auto" Style="{StaticResource ItemsControlStyle1}" MinHeight="20" Margin="0 0 20 20"> + <ItemsControl.ItemsPanel> + <ItemsPanelTemplate> + <StackPanel VerticalAlignment="Center" Orientation="Vertical" IsItemsHost="True"></StackPanel> + </ItemsPanelTemplate> + </ItemsControl.ItemsPanel> + + <ItemsControl.ItemTemplate> + <DataTemplate> + <Border BorderThickness="1" BorderBrush="#4D4B4B4B" Margin="10" CornerRadius="6"> + <Grid Height="Auto" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="Auto"/> + </Grid.RowDefinitions> + <Grid Grid.Row="0" VerticalAlignment="Top"> + <Border Margin="20 20 20 0" BorderBrush="LightGray" BorderThickness="0.6" CornerRadius="4" Height="36"> + <Border.Effect> + <DropShadowEffect/> + </Border.Effect> + </Border> + <Border Margin="20 20 20 0" BorderBrush="LightGray" BorderThickness="0.6" CornerRadius="4" Height="34" Background="#C4EEFC"> + <TextBlock FontSize="22" Padding="2" Text="{Binding Name}"/> + </Border> + </Grid> + <DataGrid Grid.Row="1" Style="{StaticResource PropertyDataGrid}" ItemsSource="{Binding Settings}" Margin="20 20 20 0" GridLinesVisibility="None" SelectionMode="Single" AlternatingRowBackground="#F6F6F6" FontSize="12" HorizontalAlignment="Left" SelectionUnit="FullRow" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False"> + <DataGrid.Columns> + <DataGridTextColumn Header="Property Name" Binding="{Binding PropertyName}" Width="250" ElementStyle="{StaticResource WrapText}"/> + <DataGridTemplateColumn Header="Property Value" Width="150"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <StackPanel Orientation="Horizontal"> + <TextBox Text="{Binding PropertyValue, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" Width="50" VerticalAlignment="Top"> + <TextBox.Style> + <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource MaterialDesignTextBox}"> + <Setter Property="Visibility" Value="Visible"/> + <Style.Triggers> + <DataTrigger Binding="{Binding IsRangeVisible}" Value="true"> + <Setter Property="Visibility" Value="Collapsed"/> + </DataTrigger> + </Style.Triggers> + </Style> + </TextBox.Style> + </TextBox> + <DockPanel HorizontalAlignment="Stretch" Width="150"> + <DockPanel.Style> + <Style TargetType="{x:Type DockPanel}"> + <Setter Property="Visibility" Value="Collapsed"/> + <Style.Triggers> + <DataTrigger Binding="{Binding IsRangeVisible}" Value="true"> + <Setter Property="Visibility" Value="Visible"/> + </DataTrigger> + </Style.Triggers> + </Style> + </DockPanel.Style> + <TextBox DockPanel.Dock="Left" Name="MinRangeValue" Width="50" Text="{Binding MinRangeValue, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"/> + <TextBox DockPanel.Dock="Right" Name="MaxRangeValue" Width="50" Text="{Binding MaxRangeValue, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"/> + </DockPanel> + </StackPanel> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTextColumn Header="Default Value" Binding="{Binding DefaultValueDisplay}" Width="150" ElementStyle="{StaticResource WrapText}" /> + <DataGridTemplateColumn Header="" Width="Auto"> + <DataGridTemplateColumn.CellStyle> + <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="FocusVisualStyle" Value="{x:Null}"/> + <Setter Property="VerticalContentAlignment" Value="Center"></Setter> + <Setter Property="VerticalAlignment" Value="Center"/> + <Setter Property="HorizontalAlignment" Value="Stretch"/> + <Setter Property="Margin" Value="0 0 0 0"/> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type DataGridCell}"> + <ContentPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> + </ControlTemplate> + </Setter.Value> + </Setter> + <Style.Triggers> + <Trigger Property="IsSelected" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="Foreground" Value="{StaticResource AccentColorBrush}" /> + </Trigger> + </Style.Triggers> + </Style> + </DataGridTemplateColumn.CellStyle> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <Grid HorizontalAlignment="Stretch" VerticalAlignment="Center"> + <Button Width="80" Padding="2" Height="26" FontSize="12" Margin="0 8" Command="{Binding SetDefaultCommand}">Set Default</Button> + </Grid> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + </DataGrid.Columns> + </DataGrid> + </Grid> + </Border> + </DataTemplate> + </ItemsControl.ItemTemplate> + </ItemsControl> </Grid> - <Grid Grid.Row="2" > + <Grid Grid.Row="1" > <Button Width="80" HorizontalAlignment="Right" Margin="20" Click="SaveButton_Click" IsDefault="True">Save</Button> </Grid> </Grid> 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); diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/SettingsVM.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/SettingsVM.cs index d5c54ab08..0f2b5a457 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/SettingsVM.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/SettingsVM.cs @@ -9,79 +9,124 @@ using Tango.SharedUI; namespace Tango.DispenserAnalyzer.UI.ViewModels { - public class SettingsVM : ViewModel, IDisposable + public class SettingVM: ViewModel { - private ObservableCollection<SettingsModel> _PBUSettings; + private string _name; - public ObservableCollection<SettingsModel> PBUTestSettings + public string Name { - get { return _PBUSettings; } - set { _PBUSettings = value; RaisePropertyChangedAuto(); } + get { return _name; } + set { _name = value; } } - private ObservableCollection<SettingsModel> _flowTestSettings; + private ObservableCollection<SettingsModel> _settings; + + public ObservableCollection<SettingsModel> Settings + { + get { return _settings; } + set { _settings = value; RaisePropertyChangedAuto(); } + } - public ObservableCollection<SettingsModel> FlowTestSettings + public SettingVM(string name) { - get { return _flowTestSettings; } - set { _flowTestSettings = value; RaisePropertyChangedAuto(); } + _settings = new ObservableCollection<SettingsModel>(); + Name = name; } - private Dictionary<AnalyzerSettingsEnum, double> changedValues; + public void AddSettings(List<SettingsModel> settings) + { + settings.ForEach(x => Settings.Add(x)); + } + + + } + public class SettingsVM : ViewModel, IDisposable + { + public Dictionary<AnalyzerSettingsEnum, double> ChangedValues { get; set; } + + private ObservableCollection<SettingVM> _settings; + public ObservableCollection<SettingVM> Settings + { + get { return _settings; } + set { _settings = value; RaisePropertyChangedAuto(); } + } + public SettingsVM() { - _PBUSettings = new ObservableCollection<SettingsModel>(); + _settings = new ObservableCollection<SettingVM>(); + ChangedValues = new Dictionary<AnalyzerSettingsEnum, double>(); InitPBUTestSettings(); - _flowTestSettings = new ObservableCollection<SettingsModel>(); - changedValues = new Dictionary<AnalyzerSettingsEnum, double>(); + InitProcessSettings(); InitFlowTestSettings(); + } private void InitPBUTestSettings() { - var setting = new SettingsModel(AnalyzerSettingsEnum.PBUPassFail, "4.5 sec"); - setting.SettingValueEvent += new EventHandler(OnSettingValueChanged); - _PBUSettings.Add(setting); + SettingVM model = new SettingVM("Pressure build up"); + List<SettingsModel> list = new List<SettingsModel>(); + list.Add(new SettingsModel(AnalyzerSettingsEnum.PBUPassFail, "4.5 sec")); + model.AddSettings(list); + list.ForEach(x => x.SettingValueEvent += new EventHandler(OnSettingValueChanged)); + Settings.Add(model); } private void InitFlowTestSettings() { - _flowTestSettings.Add(new SettingsModel(AnalyzerSettingsEnum.FlowPBUPassFail, "4.5 sec")); - _flowTestSettings.Add(new SettingsModel(AnalyzerSettingsEnum.ExcludeAnalysis, "1800 reads")); - _flowTestSettings.Add(new SettingsModel(AnalyzerSettingsEnum.AvgMinValue, "1400-1850 [mbar]", true)); - _flowTestSettings.Add(new SettingsModel(AnalyzerSettingsEnum.MaxMinRange, "500 reads")); - _flowTestSettings.Add(new SettingsModel(AnalyzerSettingsEnum.MaxMinIntervals, "300 reads")); - _flowTestSettings.Add(new SettingsModel(AnalyzerSettingsEnum.MaxError, "1.5%")); - _flowTestSettings.Add(new SettingsModel(AnalyzerSettingsEnum.TakeOffMaxMin, "3")); - - _flowTestSettings.ToList().ForEach(x => x.SettingValueEvent += new EventHandler(OnSettingValueChanged)); + SettingVM model = new SettingVM("Flow test"); + List<SettingsModel> list = new List<SettingsModel>(); + + list.Add(new SettingsModel(AnalyzerSettingsEnum.FlowPBUPassFail, "4.5 sec")); + list.Add(new SettingsModel(AnalyzerSettingsEnum.ExcludeAnalysis, "1800 reads")); + list.Add(new SettingsModel(AnalyzerSettingsEnum.AvgMinValue, "1400-1850 [mbar]", true)); + list.Add(new SettingsModel(AnalyzerSettingsEnum.MaxMinRange, "500 reads")); + list.Add(new SettingsModel(AnalyzerSettingsEnum.MaxMinIntervals, "300 reads")); + list.Add(new SettingsModel(AnalyzerSettingsEnum.MaxError, "1.5%")); + list.Add(new SettingsModel(AnalyzerSettingsEnum.TakeOffMaxMin, "3")); + list.ForEach(x => x.SettingValueEvent += new EventHandler(OnSettingValueChanged)); + model.AddSettings(list); + Settings.Add(model); + } + + private void InitProcessSettings() + { + SettingVM model = new SettingVM("Process"); + List<SettingsModel> list = new List<SettingsModel>(); + list.Add(new SettingsModel(AnalyzerSettingsEnum.TimeInterval, "0.1 sec")); + list.Add(new SettingsModel(AnalyzerSettingsEnum.StartCalculation, "600 sec")); + list.Add(new SettingsModel(AnalyzerSettingsEnum.EndCalculation, "900 sec")); + list.Add(new SettingsModel(AnalyzerSettingsEnum.MovingAvg, "50 points")); + list.ForEach(x => x.SettingValueEvent += new EventHandler(OnSettingValueChanged)); + model.AddSettings(list); + Settings.Add(model); } private void OnSettingValueChanged(object sender, EventArgs e) { - if(sender is SettingsModel) + if (sender is SettingsModel) { SettingsModel settingModel = sender as SettingsModel; - if(settingModel.IsRangeVisible) + if (settingModel.IsRangeVisible) { - changedValues[AnalyzerSettingsEnum.AvgMinValue] = settingModel.MinRangeValue; - changedValues[AnalyzerSettingsEnum.AvgMaxValue] = settingModel.MaxRangeValue; + ChangedValues[AnalyzerSettingsEnum.AvgMinValue] = settingModel.MinRangeValue; + ChangedValues[AnalyzerSettingsEnum.AvgMaxValue] = settingModel.MaxRangeValue; } else - changedValues[settingModel._enumName] = settingModel.PropertyValue; + ChangedValues[settingModel._enumName] = settingModel.PropertyValue; } } - + public Dictionary<AnalyzerSettingsEnum, double> GetChanges() { - return changedValues; + return ChangedValues; } - + public void Dispose() { - _PBUSettings.ToList().ForEach(x => x.SettingValueEvent -= OnSettingValueChanged); - _flowTestSettings.ToList().ForEach(x => x.SettingValueEvent -= OnSettingValueChanged); + Settings.ToList().ForEach(x => { + x.Settings.ToList().ForEach(k => k.SettingValueEvent -= OnSettingValueChanged); + }); } } } |
