aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IAnalyzer.cs4
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/ProcessReader.cs8
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/DynamicSealingAnalyzer.cs4
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/FlowAnalyser.cs51
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PressureBuildUpAnalyser.cs6
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PrimingAnalyzer.cs4
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/ProcessAnalyser.cs44
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/SealingAnalyzer.cs5
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/App.config2
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Converters/ObjectToBoolConverter.cs26
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Converters/ObjectToDoubleConverter.cs45
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml28
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/CompareResultModel.cs58
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/SettingsModel.cs83
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Properties/AssemblyInfo.cs2
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Settings.cs68
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Tango.DispenserAnalyzer.UI.csproj22
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/CompareResultsDlg.xaml31
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/CompareResultsDlg.xaml.cs46
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/SettingsWnd.xaml44
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/SettingsWnd.xaml.cs2
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/CompareResultsDlgVM.cs242
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/MainWindowVM.cs251
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/SettingsVM.cs85
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/packages.config1
25 files changed, 972 insertions, 190 deletions
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 fd3b3c267..6f5e411a5 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IAnalyzer.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IAnalyzer.cs
@@ -18,11 +18,15 @@ namespace Tango.DispenserAnalyzer.UI.Analysis
IReader<T> Reader { get; set; }
Task<List<IAnalyzerResult>> Process(List<T> csvRows, bool backgroundMode);
void GetPoints(List<T> samples, IList<OxyPlot.DataPoint> points);
+ bool ShowChartAfterProcess { get; }
+ bool AvailableCompareResults { get; }
}
+
[Analyzer("DISPENSERINTERFACE")]
public interface IDispenserDispenserAnalyser : IAnalyzer<DispenserSample>
{
}
+
[Analyzer("PROCESSINTERFACE")]
public interface IProcessAnalyzer : IAnalyzer<ProcessSample>
{
diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/ProcessReader.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/ProcessReader.cs
index b2e6f0388..ef5ef91f8 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/ProcessReader.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/ProcessReader.cs
@@ -35,11 +35,11 @@ namespace Tango.DispenserAnalyzer.UI.Analysis
delta = (time2 - time1).Milliseconds / 100;
}
}
- delta = Settings.GetValueByName(AnalyzerSettingsEnum.TimeInterval);
+ delta = (double)Settings.GetValueByName(AnalyzerSettingsEnum.TimeInterval);
if(delta == 0)
return samples;
- int endPoint = (int)(Settings.GetValueByName(AnalyzerSettingsEnum.EndCalculation) / delta);
+ int endPoint = (int)((double)Settings.GetValueByName(AnalyzerSettingsEnum.EndCalculation) / delta);
foreach (var item in data)
{
double dValue = 0;
@@ -64,7 +64,7 @@ namespace Tango.DispenserAnalyzer.UI.Analysis
Color = Color.FromRgb(255, 5, 5),
Type = LineAnnotationType.Vertical,
Text = index.ToString(),
- X = Settings.GetValueByName(AnalyzerSettingsEnum.StartCalculation)
+ X = (double)Settings.GetValueByName(AnalyzerSettingsEnum.StartCalculation)
};
annotations.Add(_line1);
OxyPlot.Wpf.LineAnnotation _line2 = new OxyPlot.Wpf.LineAnnotation()
@@ -73,7 +73,7 @@ namespace Tango.DispenserAnalyzer.UI.Analysis
Color = Color.FromRgb(255, 5, 5),
Type = LineAnnotationType.Vertical,
Text = index.ToString(),
- X = Settings.GetValueByName(AnalyzerSettingsEnum.EndCalculation)
+ X = (double)Settings.GetValueByName(AnalyzerSettingsEnum.EndCalculation)
};
annotations.Add(_line2);
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 d440f42c3..103d8affd 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/DynamicSealingAnalyzer.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/DynamicSealingAnalyzer.cs
@@ -82,6 +82,10 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
});
}
+ public bool ShowChartAfterProcess { get { return true; } }
+
+ public bool AvailableCompareResults { get { return false; } }
+
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 213f4e4f0..59722d499 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/FlowAnalyser.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/FlowAnalyser.cs
@@ -53,28 +53,29 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
if (index % 2 == 1)//testing Flow-error
{
-
- List<DispenserSample> filteredValues = rangeTestValues.Skip((int)Settings.GetValueByName(AnalyzerSettingsEnum.ExcludeAnalysis)).ToList();
-
- //Move Average data
- List<Task> tasks = new List<Task>();
- int calc_count = (int)filteredValues.Count() / 4;
- int start_index = 0;
- while (start_index < filteredValues.Count())
+ bool isCancelAverageProc = (bool)Settings.GetValueByName(AnalyzerSettingsEnum.CancelMovingAVG);
+ List<DispenserSample> filteredValues = rangeTestValues.Skip((int)((double)Settings.GetValueByName(AnalyzerSettingsEnum.ExcludeAnalysis))).ToList();
+ if (false == isCancelAverageProc)
{
- int calc_amount = (start_index + calc_count) >= (filteredValues.Count() - 4) ? filteredValues.Count() - start_index : calc_count;
- var source_filter = filteredValues.Skip(start_index).Take(calc_amount).ToList();
- tasks.Add(Task.Run(() =>
+ //Move Average data
+ List<Task> tasks = new List<Task>();
+ int calc_count = (int)filteredValues.Count() / 4;
+ int start_index = 0;
+ while (start_index < filteredValues.Count())
{
- filter.Filtering(source_filter);
- }));
- start_index += calc_amount;
+ int calc_amount = (start_index + calc_count) >= (filteredValues.Count() - 4) ? filteredValues.Count() - start_index : calc_count;
+ var source_filter = filteredValues.Skip(start_index).Take(calc_amount).ToList();
+ tasks.Add(Task.Run(() =>
+ {
+ filter.Filtering(source_filter);
+ }));
+ start_index += calc_amount;
+ }
+ Task.WaitAll(tasks.ToArray());
}
- Task.WaitAll(tasks.ToArray());
-
//calculate difference Max Min values for each 300 values
- int periodCalcMaxMin = (int)Settings.GetValueByName(AnalyzerSettingsEnum.MaxMinRange);
- int intervalCalcMaxMin = (int)Settings.GetValueByName(AnalyzerSettingsEnum.MaxMinIntervals);
+ int periodCalcMaxMin = (int)((double)Settings.GetValueByName(AnalyzerSettingsEnum.MaxMinRange));
+ int intervalCalcMaxMin = (int)((double)Settings.GetValueByName(AnalyzerSettingsEnum.MaxMinIntervals));
List<int> differenceMaxMin = new List<int>();
List<int> differenceMaxMinToLocationArr = new List<int>();
int location_index = 0;
@@ -89,7 +90,7 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
FlowAverageAnalyzerResult averageResult = new FlowAverageAnalyzerResult();
averageResult.BackgroundMode = backgroundMode;
averageResult.AverageValue = filteredValues.Average(t => t.Pressure);
- averageResult.Result = (averageResult.AverageValue <= Settings.GetValueByName(AnalyzerSettingsEnum.AvgMaxValue) && averageResult.AverageValue >= Settings.GetValueByName(AnalyzerSettingsEnum.AvgMinValue)) ? AnalyzerResultValue.Passed : AnalyzerResultValue.Failed;
+ averageResult.Result = (averageResult.AverageValue <= (double)Settings.GetValueByName(AnalyzerSettingsEnum.AvgMaxValue) && averageResult.AverageValue >= (double)Settings.GetValueByName(AnalyzerSettingsEnum.AvgMinValue)) ? AnalyzerResultValue.Passed : AnalyzerResultValue.Failed;
results.Add(averageResult);
FlowAnalyzerResult result = new FlowAnalyzerResult(++flowtestNumber);
@@ -106,7 +107,7 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
int avgMaxIndex = rangeTestValues.Select(x => x.Index).Max();
double totalsec = TimeSpan.FromMilliseconds((avgMaxIndex - avgMinIndex) * 100).TotalSeconds;
result.Time = totalsec.ToString() + $" sec (succeed for period < {AnalyzerSettingsEnum.FlowPBUPassFail})"; ;
- result.Result = (totalsec < Settings.GetValueByName(AnalyzerSettingsEnum.FlowPBUPassFail)) ? AnalyzerResultValue.Passed : AnalyzerResultValue.Failed;
+ result.Result = (totalsec < (double)Settings.GetValueByName(AnalyzerSettingsEnum.FlowPBUPassFail)) ? AnalyzerResultValue.Passed : AnalyzerResultValue.Failed;
results.Add(result);
}
}
@@ -124,6 +125,10 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
});
}
+ public bool ShowChartAfterProcess { get { return true; } }
+
+ public bool AvailableCompareResults { get { return false; } }
+
public class FlowAverageAnalyzerResult : AnalyzerResultBase
{
[Description("Average Value")]
@@ -202,7 +207,7 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
private double BuildMeasurementError(List<int> range_values)
{
int count = range_values.Count();
- return (count - (int)Settings.GetValueByName(AnalyzerSettingsEnum.TakeOffMaxMin));
+ return (count - (int)((double)Settings.GetValueByName(AnalyzerSettingsEnum.TakeOffMaxMin)));
}
/// <summary>
@@ -211,7 +216,7 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
private int FindMaxErrorObject(List<int> range_values)
{
var countValArr = range_values.GroupBy(x => x).Select(t => new { Key = t.Key, Value = t.Count() }).OrderBy(x=>x.Key).ToArray();
- double merror = Settings.GetValueByName(AnalyzerSettingsEnum.TakeOffMaxMin);// BuildMeasurementError(range_values);
+ double merror = (double)Settings.GetValueByName(AnalyzerSettingsEnum.TakeOffMaxMin);// BuildMeasurementError(range_values);
double sum = 0;
int max_key = 0;
int range = 0;
@@ -231,7 +236,7 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
}
var res = range / AverageValue * 100;
- Result = res <= Settings.GetValueByName(AnalyzerSettingsEnum.MaxError) ? AnalyzerResultValue.Passed : AnalyzerResultValue.Failed;
+ Result = res <= (double)Settings.GetValueByName(AnalyzerSettingsEnum.MaxError) ? AnalyzerResultValue.Passed : AnalyzerResultValue.Failed;
return max_key;
}
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 9288eb2ad..71f3d6f54 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PressureBuildUpAnalyser.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PressureBuildUpAnalyser.cs
@@ -40,7 +40,7 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
int avgMaxIndex = rangeTestValues.Select(x => x.Index).Max();
double totalsec = TimeSpan.FromMilliseconds((avgMaxIndex - avgMinIndex) * 100).TotalSeconds;
result.Time = totalsec.ToString() + " sec";
- result.Result = (totalsec < Settings.GetValueByName(AnalyzerSettingsEnum.PBUPassFail)) ? AnalyzerResultValue.Passed : AnalyzerResultValue.Failed;
+ result.Result = (totalsec < (double)Settings.GetValueByName(AnalyzerSettingsEnum.PBUPassFail)) ? AnalyzerResultValue.Passed : AnalyzerResultValue.Failed;
results.Add(result);
}
}
@@ -56,6 +56,10 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
{ points.Add(new OxyPlot.DataPoint(x.Index, x.Pressure)); }
});
}
+
+ public bool ShowChartAfterProcess { get { return true; } }
+
+ public bool AvailableCompareResults { get { return false; } }
}
}
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 315c384d6..aee0e1c4c 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PrimingAnalyzer.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PrimingAnalyzer.cs
@@ -55,6 +55,10 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
{ points.Add(new OxyPlot.DataPoint(x.Index, x.Pressure)); }
});
}
+
+ public bool ShowChartAfterProcess { get { return true; } }
+
+ public bool AvailableCompareResults { get { return false; } }
}
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
index 663b72228..be6a25a77 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/ProcessAnalyser.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/ProcessAnalyser.cs
@@ -19,6 +19,10 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
set { _reader = value; }
}
+ public bool ShowChartAfterProcess { get{ return false; } }
+
+ public bool AvailableCompareResults { get { return true; } }
+
public ProcessAnalyser()
{
Reader = new ProcessReader();
@@ -31,10 +35,12 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
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);
- int takePoints = endPoint > startPoint ? (endPoint - startPoint) : (csvRows.Count - 1 - startPoint);
+ double delta = (double)Settings.GetValueByName(AnalyzerSettingsEnum.TimeInterval);
+ int startPoint = delta == 0? 0 : (int)((double)Settings.GetValueByName(AnalyzerSettingsEnum.StartCalculation) / delta);
+ if (startPoint > csvRows.Count)
+ startPoint = 0;
+ int endPoint = delta == 0 ? (csvRows.Count -1) : (int)((double)Settings.GetValueByName(AnalyzerSettingsEnum.EndCalculation) / delta);
+ int takePoints = endPoint <= csvRows.Count ? (endPoint - startPoint) : (csvRows.Count - 1 - startPoint);
List<ProcessSample> rangeValues = csvRows.Skip(startPoint).Take(takePoints).ToList();
@@ -42,24 +48,11 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
result.MaxValue = rangeValues.Max(x => x.Value);
result.AverageValue = rangeValues.Average(x => x.Value);
result.StandardDeviation = ProcessAnalyser.StdDev(rangeValues.Select(x => x.Value));
+ result.StandardError = rangeValues.Count > 0 ? (result.StandardDeviation / (Math.Sqrt(rangeValues.Count))) : 0;
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());
+
+ Task.Run(() => { ProcessAnalyser.Filtering(csvRows); }).Wait();
result.CreateMovingAvgGraph(csvRows);
results.Add(result);
@@ -76,8 +69,8 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
}
public static void Filtering(List<ProcessSample> source)
{
- int periodAverage = (int)Settings.GetValueByName(AnalyzerSettingsEnum.MovingAvg);
- int count = (source.Count < periodAverage) ? source.Count : source.Count - periodAverage;
+ int periodAverage = (int)((double)Settings.GetValueByName(AnalyzerSettingsEnum.MovingAvg));
+ int count = source.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);
@@ -108,11 +101,14 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
[Description("Standard deviation value")]
public double StandardDeviation { get; set; }
+ [Description("Standard error value")]
+ public double StandardError { get; set; }
+
public ProcessAnalyzerResult()
{
- double from = Settings.GetValueByName(AnalyzerSettingsEnum.StartCalculation);
- double to = Settings.GetValueByName(AnalyzerSettingsEnum.EndCalculation);
+ double from = (double)Settings.GetValueByName(AnalyzerSettingsEnum.StartCalculation);
+ double to = (double)Settings.GetValueByName(AnalyzerSettingsEnum.EndCalculation);
Header = $"from {from} to {to} seconds";
AverageValue = MaxValue = MinValue = 0.0;
Result = AnalyzerResultValue.Undetermined;
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 841101b10..56a299f2e 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/SealingAnalyzer.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/SealingAnalyzer.cs
@@ -58,6 +58,11 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
{ points.Add(new OxyPlot.DataPoint(x.Index, x.Pressure)); }
});
}
+
+ public bool ShowChartAfterProcess { get { return true; } }
+
+ public bool AvailableCompareResults { get { return false; } }
+
}
public class SealingAnalyzerResult : AnalyzerResultBase
diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/App.config b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/App.config
index ddc8cb7a6..e4c7b4f99 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/App.config
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/App.config
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
+ <configSections>
+ </configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Converters/ObjectToBoolConverter.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Converters/ObjectToBoolConverter.cs
new file mode 100644
index 000000000..27b179021
--- /dev/null
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Converters/ObjectToBoolConverter.cs
@@ -0,0 +1,26 @@
+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;
+
+namespace Tango.DispenserAnalyzer.UI.Converters
+{
+ public class ObjectToBoolConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (!(value is bool))
+ return null;
+ return (bool)value;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return (bool)value;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Converters/ObjectToDoubleConverter.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Converters/ObjectToDoubleConverter.cs
new file mode 100644
index 000000000..e1bdb3486
--- /dev/null
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Converters/ObjectToDoubleConverter.cs
@@ -0,0 +1,45 @@
+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;
+
+namespace Tango.DispenserAnalyzer.UI.Converters
+{
+ public class ObjectToDoubleConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (!(value is double))
+ return null;
+ return (double)value;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if(value is string)
+ {
+ return GetDouble((string)value, 0.0);
+ }
+ return (double)value;
+ }
+ public double GetDouble(string value, double defaultValue)
+ {
+ double result;
+
+ // Try parsing in the current culture
+ if (!double.TryParse(value, System.Globalization.NumberStyles.Any, CultureInfo.CurrentCulture, out result) &&
+ // Then try in US english
+ !double.TryParse(value, System.Globalization.NumberStyles.Any, CultureInfo.GetCultureInfo("en-US"), out result) &&
+ // Then in neutral language
+ !double.TryParse(value, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out result))
+ {
+ result = defaultValue;
+ }
+ return result;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml
index 595d74e3d..a3ec370f2 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml
@@ -11,7 +11,7 @@
xmlns:local="clr-namespace:Tango.DispenserAnalyzer.UI"
xmlns:vm ="clr-namespace:Tango.DispenserAnalyzer.UI.ViewModels"
mc:Ignorable="d"
- Title="{Binding WindowTitle, RelativeSource={RelativeSource Mode=Self}}" Height="1000" Width="860" WindowStartupLocation="CenterScreen" WindowStyle="SingleBorderWindow" ResizeMode="CanResize" Foreground="#202020"
+ Title="{Binding WindowTitle, RelativeSource={RelativeSource Mode=Self}}" Height="1000" Width="860" WindowStartupLocation="Manual" Top="10" WindowStyle="SingleBorderWindow" ResizeMode="CanResize" Foreground="#202020" HorizontalAlignment="Center" HorizontalContentAlignment="Center"
d:DataContext="{d:DesignInstance Type=vm:MainWindowVM, IsDesignTimeCreatable=False}">
<Window.Resources>
<converters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter" />
@@ -84,8 +84,26 @@
<Border Visibility="Visible" BorderThickness="1" BorderBrush="Silver" CornerRadius="5" Margin="10" Grid.Row="3">
<DockPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
- <Label Height="30" Content="RESULT" Background="LightSkyBlue" Grid.Row="0" DockPanel.Dock="Top" />
-
+ <Grid DockPanel.Dock="Top" Height="35">
+ <Label Height="35" Content="RESULT" Background="LightSkyBlue" Grid.Row="0" />
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Visibility="{Binding IsCompareVisible}">
+ <ListBox ItemsSource="{Binding ResultsToCompare}" ScrollViewer.VerticalScrollBarVisibility="Auto" MaxWidth="660">
+ <ListBox.ItemsPanel>
+ <ItemsPanelTemplate>
+ <WrapPanel />
+ </ItemsPanelTemplate>
+ </ListBox.ItemsPanel>
+ <ListBox.ItemTemplate>
+ <DataTemplate>
+ <CheckBox VerticalAlignment="Center" HorizontalAlignment="Right" Style="{x:Null}" Margin="0 0 10 0" Visibility="Visible" IsChecked="{Binding IsAddedResult}" Content="{Binding ResultName}"/>
+ </DataTemplate>
+ </ListBox.ItemTemplate>
+ </ListBox>
+ <CheckBox VerticalAlignment="Center" HorizontalAlignment="Right" Style="{x:Null}" Margin="0 0 10 0" MinWidth="40" Visibility="Visible" IsChecked="{Binding AddToComare}" ToolTip="Add the result to compare">Add</CheckBox>
+
+ <Button BorderThickness="1" BorderBrush="Transparent" Margin="0 -1 5 0" Height="30" Command="{Binding CompareCommand}" MinWidth="60"> Compare</Button>
+ </StackPanel>
+ </Grid>
<ScrollViewer VerticalScrollBarVisibility="Auto" Visibility="Visible" Focusable="True" Foreground="Black" Margin="5"
Style="{StaticResource {x:Type ScrollViewer}}">
<ScrollViewer.Resources>
@@ -117,8 +135,8 @@
<oxy:ColumnSeries ItemsSource="{Binding RangeToCountChart.Points}" Color="#73B6EC" StrokeThickness="1" FillColor="#73B6EC" ValueField="Y" LabelFormatString="{}{0}" LabelPlacement="Base" />
</oxy:Plot.Series>
<oxy:Plot.Axes>
- <oxy:CategoryAxis Position="Bottom" Title = "Max-min \ range [mbar]" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" ItemsSource="{Binding RangeToCountChart.Points}" LabelField="X" IsZoomEnabled="False"/>
- <oxy:LinearAxis Position="Left" Title = "Count" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" Minimum="0" MinimumPadding="5" AbsoluteMinimum="0" IsZoomEnabled="False"/>
+ <oxy:CategoryAxis Position="Bottom" Title = "Max-min \ range [mbar]" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" ItemsSource="{Binding RangeToCountChart.Points}" LabelField="X" IsZoomEnabled="True"/>
+ <oxy:LinearAxis Position="Left" Title = "Count" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" Minimum="0" MinimumPadding="5" AbsoluteMinimum="0" IsZoomEnabled="True"/>
</oxy:Plot.Axes>
</oxy:Plot>
</StackPanel>
diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/CompareResultModel.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/CompareResultModel.cs
new file mode 100644
index 000000000..f36299b41
--- /dev/null
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/CompareResultModel.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Core;
+using Tango.DispenserAnalyzer.UI.Analysis;
+
+namespace Tango.DispenserAnalyzer.UI.Models
+{
+ public class CompareResultModel : ExtendedObject
+ {
+ public AnalyzerResultBase Result { get; set; }
+
+ private string _resultName;
+
+ public string ResultName
+ {
+ get
+ {
+ if (String.IsNullOrEmpty(_resultName))
+ return "Empty";
+ return _resultName;
+ }
+ set
+ {
+ _resultName = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private bool _isAddedResult;
+
+ public bool IsAddedResult
+ {
+ get { return _isAddedResult; }
+ set
+ {
+ _isAddedResult = value;
+ if(value == false)
+ {
+ RemoveCompareResultEvent.Invoke(this, new EventArgs());
+ }
+
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ public event EventHandler RemoveCompareResultEvent;
+
+ public CompareResultModel(EventHandler handler)
+ {
+ _isAddedResult = false;
+ ResultName = "";
+ RemoveCompareResultEvent += handler;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/SettingsModel.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/SettingsModel.cs
index 5540e4b25..cb9614559 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/SettingsModel.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Models/SettingsModel.cs
@@ -1,4 +1,5 @@
-using System;
+using Newtonsoft.Json;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -8,31 +9,35 @@ using Tango.Core.Commands;
namespace Tango.DispenserAnalyzer.UI.Models
{
- public interface ISettingsModel
+ public interface IBaseSettingModel
{
string PropertyName { get; set; }
- double PropertyValue { get; set; }
- double DefaultValue { get; set; }
+ object PropertyValue { get; set; }
+ object DefaultValue { get; set; }
string DefaultValueDisplay { get; set; }
double MinRangeValue { get; set; }
double MaxRangeValue { get; set; }
bool IsRangeVisible { get; set; }
}
-
- public class SettingsModel: ExtendedObject, ISettingsModel
+ [JsonObject(MemberSerialization.OptIn)]
+ public class BaseSettingModel: ExtendedObject, IBaseSettingModel
{
+ #region Properties
+
+ [JsonProperty]
public AnalyzerSettingsEnum _enumName;
- private string _propertyName;
+ private string _propertyName;
+ [JsonProperty]
public string PropertyName
{
get { return _propertyName; }
set { _propertyName = value; RaisePropertyChangedAuto(); }
}
- private double _propertyvalue;
-
- public double PropertyValue
+ private object _propertyvalue;
+ [JsonProperty]
+ public object PropertyValue
{
get { return _propertyvalue; }
set {
@@ -45,25 +50,28 @@ namespace Tango.DispenserAnalyzer.UI.Models
}
}
- private void OnPropertyvalueChanged()
+ [JsonProperty]
+ public bool IsShowCheckBox
{
- if(SettingValueEvent != null)
- {
- SettingValueEvent?.Invoke(this, new EventArgs());
+ get {
+ if(PropertyValue is bool)
+ {
+ return true;
+ }
+ return false;
}
-
}
-
- private double _defaultValue;
-
- public double DefaultValue
+
+ private object _defaultValue;
+ [JsonProperty]
+ public object DefaultValue
{
get { return _defaultValue; }
set { _defaultValue = value; RaisePropertyChangedAuto(); }
}
private string _defaultValueDisplay;
-
+ [JsonProperty]
public string DefaultValueDisplay
{
get { return _defaultValueDisplay; }
@@ -71,6 +79,7 @@ namespace Tango.DispenserAnalyzer.UI.Models
}
private double _minDefaultRangeValue;
+ [JsonProperty]
public double MinDefaultRangeValue
{
get { return _minDefaultRangeValue; }
@@ -78,6 +87,7 @@ namespace Tango.DispenserAnalyzer.UI.Models
}
private double _maxDefaultRangeValue;
+ [JsonProperty]
public double MaxDefaultRangeValue
{
get { return _maxDefaultRangeValue; }
@@ -85,6 +95,7 @@ namespace Tango.DispenserAnalyzer.UI.Models
}
private double _minRangeValue;
+ [JsonProperty]
public double MinRangeValue
{
get { return _minRangeValue; }
@@ -99,6 +110,7 @@ namespace Tango.DispenserAnalyzer.UI.Models
}
private double _maxRangeValue;
+ [JsonProperty]
public double MaxRangeValue
{
get { return _maxRangeValue; }
@@ -111,14 +123,20 @@ namespace Tango.DispenserAnalyzer.UI.Models
}
}
}
+
+ [JsonProperty]
public bool IsRangeVisible { get; set; }
+ #endregion
+
+ #region event and command
public event EventHandler SettingValueEvent;
public RelayCommand SetDefaultCommand { get; set; }
+ #endregion
- public SettingsModel(AnalyzerSettingsEnum enumName, string defaultValueDisplay, bool isrange = false)
+ public BaseSettingModel(AnalyzerSettingsEnum enumName, string defaultValueDisplay, bool isrange = false)
{
_enumName = enumName;
PropertyName = _enumName.ToDescription();
@@ -126,16 +144,21 @@ namespace Tango.DispenserAnalyzer.UI.Models
DefaultValue = Settings.GetDefaultValueByName(enumName);
PropertyValue = Settings.GetValueByName(enumName);
IsRangeVisible = isrange;
- MinDefaultRangeValue = IsRangeVisible ? Settings.GetDefaultValueByName(AnalyzerSettingsEnum.AvgMinValue) : 0.0;
- MaxDefaultRangeValue = IsRangeVisible ? Settings.GetDefaultValueByName(AnalyzerSettingsEnum.AvgMaxValue) : 0.0;
- MinRangeValue = IsRangeVisible? Settings.GetValueByName(AnalyzerSettingsEnum.AvgMinValue) : 0.0;
- MaxRangeValue = IsRangeVisible? Settings.GetValueByName(AnalyzerSettingsEnum.AvgMaxValue) : 0.0;
+ if (IsRangeVisible)
+ {
+ var b = Settings.GetDefaultValueByName(AnalyzerSettingsEnum.AvgMinValue);
+ double bf = (double)b;
+ }
+ MinDefaultRangeValue = IsRangeVisible ? (double)(Settings.GetDefaultValueByName(AnalyzerSettingsEnum.AvgMinValue)) : 0.0;
+ MaxDefaultRangeValue = IsRangeVisible ? (double)(Settings.GetDefaultValueByName(AnalyzerSettingsEnum.AvgMaxValue)) : 0.0;
+ MinRangeValue = IsRangeVisible ? (double)(Settings.GetValueByName(AnalyzerSettingsEnum.AvgMinValue)) : 0.0;
+ MaxRangeValue = IsRangeVisible ? (double)(Settings.GetValueByName(AnalyzerSettingsEnum.AvgMaxValue)) : 0.0;
SetDefaultCommand = new RelayCommand(SetDefault);
}
private void SetDefault()
{
- if(IsRangeVisible)
+ if (IsRangeVisible)
{
MinRangeValue = MinDefaultRangeValue;
MaxRangeValue = MaxDefaultRangeValue;
@@ -143,5 +166,13 @@ namespace Tango.DispenserAnalyzer.UI.Models
}
PropertyValue = DefaultValue;
}
+ private void OnPropertyvalueChanged()
+ {
+ if (SettingValueEvent != null)
+ {
+ SettingValueEvent?.Invoke(this, new EventArgs());
+ }
+
+ }
}
}
diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Properties/AssemblyInfo.cs
index 6438e7278..6a78631b7 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Properties/AssemblyInfo.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Properties/AssemblyInfo.cs
@@ -51,7 +51,7 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("3.1.1.3")]
+[assembly: AssemblyVersion("4.1.1.1")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: NeutralResourcesLanguage("en-AS")]
diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Settings.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Settings.cs
index d515a0940..ef45e654e 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Settings.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Settings.cs
@@ -1,6 +1,8 @@
-using System;
+using Newtonsoft.Json;
+using System;
using System.Collections.Generic;
using System.ComponentModel;
+using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -36,57 +38,79 @@ namespace Tango.DispenserAnalyzer.UI
[Description("Time point to end calculation [sec]")]
EndCalculation,
[Description("How many points to use for moving average")]
- MovingAvg
+ MovingAvg,
+ [Description("Cancel Moving AVG")]
+ CancelMovingAVG,
}
public static class Settings
{
- public static Dictionary<AnalyzerSettingsEnum, double> DefaultValues { get; set; }
- public static Dictionary<AnalyzerSettingsEnum, double> CurrentValues { get; set; }
+ public static Dictionary<AnalyzerSettingsEnum, object> DefaultValues { get; set; }
+ public static Dictionary<AnalyzerSettingsEnum, object> CurrentValues { get; set; }
static Settings()
{
- DefaultValues = new Dictionary<AnalyzerSettingsEnum, double>();
+ DefaultValues = new Dictionary<AnalyzerSettingsEnum, object>();
DefaultValues[AnalyzerSettingsEnum.PBUPassFail] = 4.5;
DefaultValues[AnalyzerSettingsEnum.FlowPBUPassFail] = 4.5;
- DefaultValues[AnalyzerSettingsEnum.ExcludeAnalysis] = 1800;
- DefaultValues[AnalyzerSettingsEnum.AvgMinValue] = 1400;
- DefaultValues[AnalyzerSettingsEnum.AvgMaxValue] = 1850;
- DefaultValues[AnalyzerSettingsEnum.MaxMinRange] = 450;
- DefaultValues[AnalyzerSettingsEnum.MaxMinIntervals] = 450;
+ DefaultValues[AnalyzerSettingsEnum.ExcludeAnalysis] = 1800.0;
+ DefaultValues[AnalyzerSettingsEnum.AvgMinValue] = 1400.0;
+ DefaultValues[AnalyzerSettingsEnum.AvgMaxValue] = 1850.0;
+ DefaultValues[AnalyzerSettingsEnum.MaxMinRange] = 450.0;
+ DefaultValues[AnalyzerSettingsEnum.MaxMinIntervals] = 450.0;
DefaultValues[AnalyzerSettingsEnum.MaxError] = 1.5;
- DefaultValues[AnalyzerSettingsEnum.TakeOffMaxMin] = 3;
+ DefaultValues[AnalyzerSettingsEnum.TakeOffMaxMin] = 3.0;
DefaultValues[AnalyzerSettingsEnum.TimeInterval] = 0.1;
- DefaultValues[AnalyzerSettingsEnum.StartCalculation] = 600;
- DefaultValues[AnalyzerSettingsEnum.EndCalculation] = 900;
- DefaultValues[AnalyzerSettingsEnum.MovingAvg] = 50;
+ DefaultValues[AnalyzerSettingsEnum.StartCalculation] = 600.0;
+ DefaultValues[AnalyzerSettingsEnum.EndCalculation] = 900.0;
+ DefaultValues[AnalyzerSettingsEnum.MovingAvg] = 50.0;
+ DefaultValues[AnalyzerSettingsEnum.CancelMovingAVG] = false;
- CurrentValues = new Dictionary<AnalyzerSettingsEnum, double>(DefaultValues);
+ CurrentValues = new Dictionary<AnalyzerSettingsEnum, object>(DefaultValues);
}
- public static double GetValueByName(AnalyzerSettingsEnum name)
+ public static object GetValueByName(AnalyzerSettingsEnum name)
{
- double value;
+ object value = 0.0;
if (CurrentValues.TryGetValue(name, out value))
{
return value;
}
- return 0.0;
+ return value;
}
- public static void SetValueByName(AnalyzerSettingsEnum name, double value)
+ public static void SetValueByName(AnalyzerSettingsEnum name, object value)
{
CurrentValues[name] = value;
}
- public static double GetDefaultValueByName(AnalyzerSettingsEnum name)
+ public static object GetDefaultValueByName(AnalyzerSettingsEnum name)
{
- double value;
+ object value = 0.0;
if (DefaultValues.TryGetValue(name, out value))
{
return value;
}
- return 0.0;
+ return value;
+ }
+
+ public static void SerializeSettings(string path)
+ {
+ string json = JsonConvert.SerializeObject(CurrentValues, Formatting.Indented);
+ File.WriteAllText(path, json);
+ }
+
+ public static void DeserializeSettings(string path)
+ {
+ if (File.Exists(path))
+ {
+ Dictionary<AnalyzerSettingsEnum, object> values = JsonConvert.DeserializeObject<Dictionary<AnalyzerSettingsEnum, object>>(File.ReadAllText(path));
+ foreach (KeyValuePair<AnalyzerSettingsEnum, object> entry in values)
+ {
+ CurrentValues[entry.Key] = entry.Value;
+ }
+
+ }
}
}
}
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 51d693d88..5ee33a8e9 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
@@ -29,8 +29,8 @@
<ProductName>Dispenser Analyser</ProductName>
<PublisherName>Twine</PublisherName>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
- <ApplicationRevision>4</ApplicationRevision>
- <ApplicationVersion>3.1.1.%2a</ApplicationVersion>
+ <ApplicationRevision>7</ApplicationRevision>
+ <ApplicationVersion>4.1.1.%2a</ApplicationVersion>
<UseApplicationTrust>true</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted>
@@ -83,6 +83,9 @@
<Reference Include="MathNet.Numerics, Version=4.9.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\MathNet.Numerics.4.9.0\lib\net461\MathNet.Numerics.dll</HintPath>
</Reference>
+ <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+ <HintPath>..\..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
+ </Reference>
<Reference Include="OxyPlot, Version=2.0.0.0, Culture=neutral, PublicKeyToken=638079a8f0bd61e9, processorArchitecture=MSIL">
<HintPath>..\..\packages\OxyPlot.Core.2.0.0\lib\net45\OxyPlot.dll</HintPath>
</Reference>
@@ -145,7 +148,10 @@
<Compile Include="Analyzers\ReliabilityTestAnalyser.cs" />
<Compile Include="Analyzers\SealingAnalyzer.cs" />
<Compile Include="Analysis\AnalyzerAttribute.cs" />
+ <Compile Include="Converters\ObjectToBoolConverter.cs" />
+ <Compile Include="Converters\ObjectToDoubleConverter.cs" />
<Compile Include="FileHelper.cs" />
+ <Compile Include="Models\CompareResultModel.cs" />
<Compile Include="Models\DispenserCsvRow.cs" />
<Compile Include="Models\DispenserSample.cs" />
<Compile Include="Models\DispenserSampleCommand.cs" />
@@ -154,8 +160,12 @@
<Compile Include="Models\ProcessSample.cs" />
<Compile Include="Models\SettingsModel.cs" />
<Compile Include="Settings.cs" />
+ <Compile Include="ViewModels\CompareResultsDlgVM.cs" />
<Compile Include="ViewModels\MainWindowVM.cs" />
<Compile Include="ViewModels\SettingsVM.cs" />
+ <Compile Include="View\CompareResultsDlg.xaml.cs">
+ <DependentUpon>CompareResultsDlg.xaml</DependentUpon>
+ </Compile>
<Compile Include="View\SettingsWnd.xaml.cs">
<DependentUpon>SettingsWnd.xaml</DependentUpon>
</Compile>
@@ -171,6 +181,10 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
+ <Page Include="View\CompareResultsDlg.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="View\SettingsWnd.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -223,9 +237,7 @@
<Name>Tango.SharedUI</Name>
</ProjectReference>
</ItemGroup>
- <ItemGroup>
- <Folder Include="Converters\" />
- </ItemGroup>
+ <ItemGroup />
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
<Visible>False</Visible>
diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/CompareResultsDlg.xaml b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/CompareResultsDlg.xaml
new file mode 100644
index 000000000..693cb0726
--- /dev/null
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/CompareResultsDlg.xaml
@@ -0,0 +1,31 @@
+<Window x:Class="Tango.DispenserAnalyzer.UI.View.CompareResultsDlg"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:oxy="http://oxyplot.org/wpf"
+ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+ xmlns:local="clr-namespace:Tango.DispenserAnalyzer.UI.View"
+ mc:Ignorable="d"
+ Title="Compare Results" Height="560" Width="800" FontSize="22" ResizeMode="NoResize" WindowStyle="ToolWindow">
+ <Grid>
+ <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">-->
+ <Canvas>
+
+ <oxy:Plot x:Name="ChartCompare" Title="{Binding Title}" LegendPosition="RightTop" LegendOrientation="Vertical" ClipToBounds="True" Width="750" Height="460" LegendItemAlignment="Center" LegendPlacement="Inside" Canvas.Left="0" Canvas.Top="0">
+ <!--<oxy:Plot.Series >
+ <oxy:LineSeries TrackerFormatString="{}{0}&#x0a;{1}: {2:0.0}&#x0a;{3}: {4:0.0}" ItemsSource="{Binding Points1}" Color="#439026" MarkerType="None"/>
+ <oxy:LineSeries TrackerFormatString="{}{0}&#x0a;{1}: {2:0.0}&#x0a;{3}: {4:0.0}" ItemsSource="{Binding Points2}" Color="#3181C1" MarkerType="None"/>
+ </oxy:Plot.Series>-->
+
+ <oxy:Plot.Axes>
+ <oxy:LinearAxis Position="Bottom" Title = "Time [sec]" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" Minimum="{Binding FromXAxis}" Maximum="{Binding ToXAxis}"/>
+ <oxy:LinearAxis Position="Left" Title = "Value" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" Minimum="{Binding FromYAxis}" Maximum="{Binding ToYAxis}"/>
+ </oxy:Plot.Axes>
+ </oxy:Plot>
+ <TextBlock Text="{Binding DifferenceText}" Canvas.Left="20" Canvas.Bottom="20" FontSize="14" Background="#EAFAFF"></TextBlock>
+ </Canvas>
+ </Border>
+ </Grid>
+</Window>
diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/CompareResultsDlg.xaml.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/CompareResultsDlg.xaml.cs
new file mode 100644
index 000000000..ef5b7f331
--- /dev/null
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/CompareResultsDlg.xaml.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+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.Analysis;
+using Tango.DispenserAnalyzer.UI.Models;
+using Tango.DispenserAnalyzer.UI.ViewModels;
+
+namespace Tango.DispenserAnalyzer.UI.View
+{
+ /// <summary>
+ /// Interaction logic for CompareResultsDlg.xaml
+ /// </summary>
+ public partial class CompareResultsDlg : Window
+ {
+ private CompareResultsDlgVM _vm;
+ public CompareResultsDlg(ObservableCollection<CompareResultModel> results)
+ {
+ InitializeComponent();
+ _vm = new CompareResultsDlgVM( results);
+ DataContext = _vm;
+ 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;
+ _vm.Init(ChartCompare);
+ }
+
+
+ }
+}
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 d8d4594b8..c054627a1 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/SettingsWnd.xaml
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/SettingsWnd.xaml
@@ -4,10 +4,16 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+ xmlns:conv="clr-namespace:Tango.DispenserAnalyzer.UI.Converters"
xmlns:local="clr-namespace:Tango.DispenserAnalyzer.UI.View"
mc:Ignorable="d"
Title="Settings" Height="690" Width="800" FontSize="22" ResizeMode="NoResize" WindowStyle="ToolWindow" Closing="Window_Closing">
<Window.Resources>
+
+ <conv:ObjectToBoolConverter x:Key="ObjectToBoolConverter" />
+ <conv:ObjectToDoubleConverter x:Key="ObjectToDoubleConverter" />
+
+
<Style TargetType="{x:Type TextBlock}" x:Key="WrapText">
<Setter Property="TextWrapping" Value="Wrap"/>
</Style>
@@ -76,14 +82,21 @@
<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 VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Style="{x:Null}">
<ScrollViewer.Resources>
- <Style TargetType="ScrollBar">
- <Setter Property="Width" Value="10"/>
- <Setter Property="MinWidth" Value="10" />
- </Style>
- </ScrollViewer.Resources>
- <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
+ <Style TargetType="ScrollBar">
+ <Style.Triggers>
+ <Trigger Property="Orientation" Value="Vertical">
+ <Setter Property="Width" Value="10"/>
+ </Trigger>
+ <Trigger Property="Orientation" Value="Horizontal">
+ <Setter Property="Width" Value="Auto"/>
+ <Setter Property="Height" Value="10"/>
+ </Trigger>
+ </Style.Triggers>
+ </Style>
+ </ScrollViewer.Resources>
+ <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</ScrollViewer>
</Border>
</ControlTemplate>
@@ -135,7 +148,7 @@
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
- <TextBox Text="{Binding PropertyValue, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" Width="50" VerticalAlignment="Top">
+ <TextBox Text="{Binding PropertyValue, Mode=TwoWay, UpdateSourceTrigger=LostFocus, Converter={StaticResource ObjectToDoubleConverter}}" Width="50" VerticalAlignment="Top">
<TextBox.Style>
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource MaterialDesignTextBox}">
<Setter Property="Visibility" Value="Visible"/>
@@ -143,10 +156,25 @@
<DataTrigger Binding="{Binding IsRangeVisible}" Value="true">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
+ <DataTrigger Binding="{Binding IsShowCheckBox}" Value="true">
+ <Setter Property="Visibility" Value="Collapsed"/>
+ </DataTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
+ <CheckBox Width="50" VerticalAlignment="Top" IsChecked="{Binding PropertyValue, Mode=TwoWay, UpdateSourceTrigger=LostFocus, Converter={StaticResource ObjectToBoolConverter}}">
+ <CheckBox.Style>
+ <Style TargetType="{x:Type CheckBox}" >
+ <Setter Property="Visibility" Value="Collapsed"/>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding IsShowCheckBox}" Value="true">
+ <Setter Property="Visibility" Value="Visible"/>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </CheckBox.Style>
+ </CheckBox>
<DockPanel HorizontalAlignment="Stretch" Width="150">
<DockPanel.Style>
<Style TargetType="{x:Type DockPanel}">
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
index 9879d8f7a..ac6c85f49 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/SettingsWnd.xaml.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/View/SettingsWnd.xaml.cs
@@ -29,7 +29,7 @@ namespace Tango.DispenserAnalyzer.UI.View
Loaded += Window_loaded;
}
- public Dictionary<AnalyzerSettingsEnum, double> GetChanges()
+ public Dictionary<AnalyzerSettingsEnum, object> GetChanges()
{
return vm.GetChanges();
}
diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/CompareResultsDlgVM.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/CompareResultsDlgVM.cs
new file mode 100644
index 000000000..258c32236
--- /dev/null
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/CompareResultsDlgVM.cs
@@ -0,0 +1,242 @@
+using OxyPlot;
+using OxyPlot.Axes;
+using OxyPlot.Wpf;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Input;
+using System.Windows.Media;
+using Tango.DispenserAnalyzer.UI.Analysis;
+using Tango.DispenserAnalyzer.UI.Models;
+using Tango.SharedUI;
+
+namespace Tango.DispenserAnalyzer.UI.ViewModels
+{
+ public class ComparePoint
+ {
+ public double X { get; set; }
+
+ public double Y { get; set; }
+ }
+ public class CompareResultsDlgVM : ViewModel
+ {
+ public Plot PlotControl { get; set; }
+ private Dictionary<int, Color> IndexToColor;
+
+ #region properties
+
+ List<ObservableCollection<DataPoint>> ChartPoints { get; set; }
+
+ /// <summary>
+ /// Gets or sets the results. Input values.
+ /// </summary>
+ public ObservableCollection<CompareResultModel> Results { 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(); }
+ }
+
+ /// <summary>
+ /// Gets or sets the last point on mouse click.
+ /// </summary>
+ private DataPoint LastPoint { get; set; }
+
+ /// <summary>
+ /// Gets or sets the arrow annotation to show difference from 2 clicks.
+ /// </summary>
+ ArrowAnnotation ArrowAnnot { get; set; }
+
+ public string _differenceText;
+ public string DifferenceText
+ {
+ get { return _differenceText; }
+ set { _differenceText = value;
+ RaisePropertyChangedAuto(); }
+ }
+ #endregion
+
+ public CompareResultsDlgVM(ObservableCollection<CompareResultModel> results)
+ {
+ Results = results;
+
+ Title = $"Compare Results Moving Average Values";
+
+ _toYAxis = _fromYAxis = _toXAxis = _fromXAxis = 0;
+ _step = 1;
+ LastPoint = DataPoint.Undefined;
+ ArrowAnnot = new ArrowAnnotation
+ {
+ FontSize = 12,
+ Color = Colors.OrangeRed,
+ TextColor = Colors.DarkBlue,
+ TextVerticalAlignment = System.Windows.VerticalAlignment.Center,
+ TextHorizontalAlignment = System.Windows.HorizontalAlignment.Center,
+ HeadLength = 14,
+ HeadWidth = 6,
+ Veeness = 4,
+ };
+
+ ChartPoints = new List<ObservableCollection<DataPoint>>();
+ foreach (var result in Results)
+ {
+ ChartPoints.Add(result.Result.LineChart.Points);
+ }
+ InitColors();
+
+ }
+
+ public void Init(Plot plotControl)
+ {
+ PlotControl = plotControl;
+
+ for (int index = 0; index < ChartPoints.Count; index++)
+ {
+ var points = ChartPoints[index];
+ LineSeries linePoints = new LineSeries();
+ if(index <Results.Count)
+ {
+ linePoints.Title = Results[index].ResultName;
+ }
+
+ linePoints.ItemsSource = points;
+ linePoints.Color = IndexToColor[index];
+ ToYAxis = Math.Max((points.Max(x => x.Y) + 2), _toYAxis);
+ FromYAxis = Math.Min(points.Min(x => x.Y), _fromYAxis);
+ ToXAxis = Math.Max((points.Max(x => x.X) + 2), _toXAxis);
+ FromXAxis = Math.Min(points.Min(x => x.X), _fromXAxis);
+ linePoints.TrackerFormatString = "{0} " + Environment.NewLine + "{1}: {2:0.0} " + Environment.NewLine + "{3}: {4:0.0} ";// "{}{0}&#x0a;{1}: {2:0.0}&#x0a;{3}: {4:0.0}";
+ PlotControl.Series.Add(linePoints);
+ }
+
+
+ OxyPlot.ElementCollection<OxyPlot.Axes.Axis> axisList = PlotControl.ActualModel.Axes;
+ OxyPlot.Axes.Axis xAxis = axisList.FirstOrDefault(ax => ax.Position == AxisPosition.Bottom);
+ OxyPlot.Axes.Axis yAxis = axisList.FirstOrDefault(ax => ax.Position == AxisPosition.Left);
+
+ //PlotControl.ActualModel.TrackerChanged += (sender, eventArgs) =>
+ // {
+ // string CurrentTrackerValue = "";
+ // CurrentTrackerValue = eventArgs.HitResult != null ? eventArgs.HitResult.Text : CurrentTrackerValue;
+ // if (!String.IsNullOrEmpty(CurrentTrackerValue))
+ // {
+ // var x = Regex.Matches(CurrentTrackerValue, "[0-9]+[.[0-9]+]?");
+ // if (x.Count == 2)
+ // {
+ // var CurrentTrackerValueX = x[0].Value;
+ // var CurrentTrackerValueY = x[1].Value;
+ // if (LastPoint.IsDefined())
+ // {
+ // LastPoint = DataPoint.Undefined;
+ // }
+ // else
+ // {
+
+ // }
+ // }
+ // };
+ // };
+ PlotControl.PreviewMouseLeftButtonUp += OnPrevMouseLeftButtonUp;
+ }
+
+ private void OnPrevMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+ {
+ ScreenPoint screenpoint = new ScreenPoint(e.GetPosition((IInputElement)e.Source).X, e.GetPosition((IInputElement)e.Source).Y); ;
+ OxyPlot.ElementCollection<OxyPlot.Axes.Axis> axisList = PlotControl.ActualModel.Axes;
+ OxyPlot.Axes.Axis xAxis = axisList.FirstOrDefault(ax => ax.Position == AxisPosition.Bottom);
+ OxyPlot.Axes.Axis yAxis = axisList.FirstOrDefault(ax => ax.Position == AxisPosition.Left);
+ if (LastPoint.IsDefined())
+ {
+ ArrowAnnot.EndPoint = OxyPlot.Axes.Axis.InverseTransform(screenpoint, xAxis, yAxis);
+ var difX = Math.Round(Math.Abs(ArrowAnnot.StartPoint.X - ArrowAnnot.EndPoint.X), 2);
+ var difY = Math.Round(Math.Abs(ArrowAnnot.StartPoint.Y - ArrowAnnot.EndPoint.Y), 2);
+ DifferenceText = String.Format($"Difference of coordinates of selected points X:{difX} Y:{difY}"); ;
+ //ArrowAnnot.Text = String.Format($"Difference of coordinates of selected points X:{difX} Y:{difY}");
+
+ var ta = new TextAnnotation
+ {
+ TextPosition = new DataPoint(ArrowAnnot.EndPoint.X, ArrowAnnot.EndPoint.Y),
+ Text = String.Format($"X:{Math.Round(ArrowAnnot.EndPoint.X, 2)} Y:{Math.Round(ArrowAnnot.EndPoint.Y, 2)}"),
+ Background = Color.FromArgb(255, 200, 253, 251),
+ Stroke = Colors.Transparent
+ };
+ PlotControl.Annotations.Add(ta);
+ PlotControl.Annotations.Add(ArrowAnnot);
+ PlotControl.InvalidatePlot(false);
+ LastPoint = DataPoint.Undefined;
+ }
+ else//start point
+ {
+
+ PlotControl.Annotations.Clear();
+ ArrowAnnot.StartPoint = OxyPlot.Axes.Axis.InverseTransform(screenpoint, xAxis, yAxis);
+ ArrowAnnot.EndPoint = ArrowAnnot.StartPoint;
+ var ta = new TextAnnotation
+ {
+ TextPosition = new DataPoint(ArrowAnnot.StartPoint.X, ArrowAnnot.StartPoint.Y),
+ Text = String.Format($"X:{Math.Round(ArrowAnnot.StartPoint.X, 2)} Y:{Math.Round(ArrowAnnot.StartPoint.Y, 2)}"),
+ Background = Color.FromArgb(255, 200, 253, 251),
+ Stroke = Colors.Transparent
+
+ };
+ PlotControl.Annotations.Add(ta);
+ DifferenceText = "";
+ ArrowAnnot.Text = "";
+ LastPoint = ArrowAnnot.StartPoint;
+ PlotControl.InvalidatePlot(false);
+
+ }
+
+ e.Handled = false;
+ }
+
+ private void InitColors()
+ {
+ IndexToColor = new Dictionary<int, Color>();
+ IndexToColor.Add(0, System.Windows.Media.Color.FromRgb(0, 255, 255));
+ IndexToColor.Add(1, System.Windows.Media.Color.FromRgb(0, 255, 0));
+ IndexToColor.Add(2, System.Windows.Media.Color.FromRgb(0, 0, 255));
+ IndexToColor.Add(3, System.Windows.Media.Color.FromRgb(255, 0, 0));
+ IndexToColor.Add(4, System.Windows.Media.Color.FromRgb(255, 255, 0));
+ IndexToColor.Add(5, System.Windows.Media.Color.FromRgb(255, 0, 255));
+ }
+ }
+}
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 48d426d23..9981166e2 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/MainWindowVM.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/MainWindowVM.cs
@@ -28,14 +28,16 @@ using PdfSharp;
using OxyPlot.Reporting;
using System.Threading;
using Tango.DispenserAnalyzer.UI.View;
-using Tango.Core.Helpers;
-using Tango.Documents;
+
namespace Tango.DispenserAnalyzer.UI.ViewModels
{
public class MainWindowVM: ViewModel
{
private const string FILE_EXTENSION = ".pdf";
+ private string _settingsFilepath = "";
+
+ #region Properties
public Plot PlotControl { get; set; }
@@ -141,9 +143,7 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels
get { return _titleAxisLeft; }
set { _titleAxisLeft = value; RaisePropertyChangedAuto(); }
}
-
-
-
+
private bool _isRunning;
/// <summary>
/// Gets or sets a value indicating whether this instance is running.
@@ -163,15 +163,102 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels
public Func<double, string> YFormatter { get; set; }
+ private Visibility _isCompareVisible;
+
+ public Visibility IsCompareVisible
+ {
+ get { return _isCompareVisible; }
+ set { _isCompareVisible = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private bool _addToComare;
+
+ public bool AddToComare
+ {
+ get { return _addToComare; }
+ set { _addToComare = value;
+ OnAddToCompareResults(value);
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private string _compareResText1;
+
+ public string CompareResText1
+ {
+ get {
+ if (String.IsNullOrEmpty(_compareResText1))
+ return "Empty";
+ return _compareResText1;
+ }
+ set {
+ _compareResText1 = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private string _compareResText2;
+
+ public string CompareResText2
+ {
+ get {
+ if (String.IsNullOrEmpty(_compareResText2))
+ return "Empty";
+ return _compareResText2; }
+ set { _compareResText2 = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private bool _isAddedRes1;
+
+ public bool IsAddedRes1
+ {
+ get { return _isAddedRes1; }
+ set { _isAddedRes1 = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private bool _isAddedRes2;
+
+ public bool IsAddedRes2
+ {
+ get { return _isAddedRes2; }
+ set { _isAddedRes2 = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private ObservableCollection<CompareResultModel> _resultsToCompare;
+
+ public ObservableCollection<CompareResultModel> ResultsToCompare
+ {
+ get { return _resultsToCompare; }
+ set { _resultsToCompare = value; }
+ }
+
+
+ #endregion
+
+ #region Commands
+
public RelayCommand OpenCSVFileCommand { get; set; }
public RelayCommand GenerateCommand { get; set; }
public RelayCommand OpenSettingWndCommand { get; set; }
+ public RelayCommand CompareCommand { get; set; }
+ #endregion
public MainWindowVM()
{
+ ResultsToCompare = new ObservableCollection<CompareResultModel>();
+
OpenCSVFileCommand = new RelayCommand(OpenCSVFile);
GenerateCommand = new RelayCommand(Generate, CanGenerate);
OpenSettingWndCommand = new RelayCommand(OpenSettingWnd);
+ CompareCommand = new RelayCommand(Compareresults, CanCompareresults);
YFormatter = value => value.ToString();
_from = 0;
@@ -182,9 +269,28 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels
TitleAxisBottom = "";
TitleAxisLeft = "";
this.Points = new List<DataPoint>();
+ IsCompareVisible = Visibility.Collapsed;
+ IsAddedRes1 = IsAddedRes2 = false;
+ InitUserSettings();
}
#region Settings
+
+ public void InitUserSettings()
+ {
+ string folderPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "DispenserAnalyzer");
+ Directory.CreateDirectory(folderPath);
+ _settingsFilepath = System.IO.Path.Combine(folderPath, "Settings.json");
+
+ try
+ {
+ Settings.DeserializeSettings(_settingsFilepath);
+ }
+ catch (IOException ex)
+ {
+ MessageBox.Show("Warning: " + ex.Message, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
+ }
+ }
public void OpenSettingWnd()
{
@@ -192,14 +298,40 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels
settings.Owner = System.Windows.Application.Current.MainWindow;
if(true == settings.ShowDialog())
{
- Dictionary<AnalyzerSettingsEnum, double> changes = settings.GetChanges();
- foreach (KeyValuePair<AnalyzerSettingsEnum, double> entry in changes)
+ Dictionary<AnalyzerSettingsEnum, object> changes = settings.GetChanges();
+ foreach (KeyValuePair<AnalyzerSettingsEnum, object> entry in changes)
{
Settings.SetValueByName(entry.Key, entry.Value);
}
+ try
+ {
+ Settings.SerializeSettings(_settingsFilepath);
+ }
+ catch (IOException ex)
+ {
+ MessageBox.Show("Warning: " + ex.Message, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
+ }
}
}
+ private void ClearResults()
+ {
+ IsCompareVisible = Visibility.Collapsed;
+ _addToComare = false;
+ RaisePropertyChanged("AddToComare");
+ Points.Clear();
+
+ AnalyzerResults.Clear();
+ TestName = "";
+ foreach (var ax in PlotControl.Axes)
+ {
+ ax.Maximum = ax.Minimum = Double.NaN;
+ PlotControl.ResetAllAxes();
+ }
+ PlotControl.Annotations.Clear();
+ PlotControl.InvalidatePlot(true);
+ }
+
#endregion
#region Read File
@@ -244,7 +376,7 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels
private void OnSelectedFileChanged()
{
- ResetSettings();
+ ClearResults();
if(File.Exists(OpenFilePath))
{
FileHelper.OpenFilePath = OpenFilePath;
@@ -267,7 +399,7 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels
{
if (false == File.Exists(OpenFilePath) || IsFileLocked(OpenFilePath))
return;
- ResetSettings();
+ ClearResults();
var analyzer = AnalysisService.GetAnalyzer(OpenFilePath);
if (analyzer == null)
@@ -281,19 +413,36 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels
}
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)
+ bool showChartAfterProcess = analyzer.ShowChartAfterProcess;
+ if (false == showChartAfterProcess)
{
- IsRunning = false;
- return;
+ analyzer.GetPoints(samples, Points);
+ if (Points.Count == 0)
+ {
+ IsRunning = false;
+ return;
+ }
}
+
+ //visible only for process type
+ IsCompareVisible = analyzer.AvailableCompareResults ? Visibility.Visible : Visibility.Collapsed;
+
annotations.ForEach(x => PlotControl.Annotations.Add(x));
To = 0;
From = 0;
List<IAnalyzerResult> res = await analyzer.Process(samples, false);
AnalyzerResults = new ObservableCollection<IAnalyzerResult>(res);
-
+ if (showChartAfterProcess)
+ {
+ analyzer.GetPoints(samples, Points);
+ if (Points.Count == 0)
+ {
+ IsRunning = false;
+ return;
+ }
+ }
+
_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);
@@ -344,29 +493,15 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels
{
return;
}
-
+
List<IAnalyzerResult> res = await analyzer.Process(samples, true);
AnalyzerResults = new ObservableCollection<IAnalyzerResult>(res);
await ExportResultsToTextFile();
}
- #endregion
-
- private void ResetSettings()
- {
- Points.Clear();
-
- AnalyzerResults.Clear();
- TestName = "";
- foreach (var ax in PlotControl.Axes)
- {
- ax.Maximum = ax.Minimum = Double.NaN;
- PlotControl.ResetAllAxes();
- }
- PlotControl.Annotations.Clear();
- PlotControl.InvalidatePlot(true);
- }
+ #endregion
+
#region SaveInXps file
private async Task PrintToXpsFile()
{
@@ -574,5 +709,59 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels
}
#endregion
+ #region CompareResults
+
+ private void Compareresults(object obj)
+ {
+ //List<string> names, List<AnalyzerResultBase> results
+ CompareResultsDlg resultsdlg = new CompareResultsDlg( ResultsToCompare);
+ resultsdlg.Owner = System.Windows.Application.Current.MainWindow;
+ resultsdlg.ShowDialog();
+
+ AddToComare = false;
+ ResultsToCompare.ToList().ForEach(x => x.RemoveCompareResultEvent -= OnCompareResultsChanged);
+ ResultsToCompare.Clear();
+ CompareCommand.RaiseCanExecuteChanged();
+ }
+
+ private bool CanCompareresults(object arg)
+ {
+ return ResultsToCompare.Count > 1;
+ }
+
+ private void OnAddToCompareResults(bool add)
+ {
+ if(add)
+ {
+ if (ResultsToCompare.Count == 3)
+ {
+ ResultsToCompare.RemoveAt(0);
+ }
+ ResultsToCompare.Add( new CompareResultModel(new EventHandler(OnCompareResultsChanged)) { Result= AnalyzerResults[0] as AnalyzerResultBase, IsAddedResult = true, ResultName = Path.GetFileNameWithoutExtension(FileName)});
+
+ }
+ if(add == false )
+ {
+ if (ResultsToCompare.Count > 0)
+ {
+ ResultsToCompare[ResultsToCompare.Count - 1].RemoveCompareResultEvent -= OnCompareResultsChanged;
+ ResultsToCompare.RemoveAt(ResultsToCompare.Count - 1);
+ }
+ }
+ CompareCommand.RaiseCanExecuteChanged();
+ }
+
+ public void OnCompareResultsChanged(object sender, EventArgs e)
+ {
+ CompareResultModel result = sender as CompareResultModel;
+ if(result != null && result.IsAddedResult == false)
+ {
+ result.RemoveCompareResultEvent -= OnCompareResultsChanged;
+ ResultsToCompare.Remove(result);
+ CompareCommand.RaiseCanExecuteChanged();
+ }
+ }
+
+ #endregion
}
}
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 b610d7652..fd21794f4 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/SettingsVM.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/SettingsVM.cs
@@ -1,61 +1,67 @@
-using System;
+using Newtonsoft.Json;
+using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Windows;
using Tango.DispenserAnalyzer.UI.Models;
using Tango.SharedUI;
namespace Tango.DispenserAnalyzer.UI.ViewModels
{
- public class SettingVM: ViewModel
+ [JsonObject(MemberSerialization.OptIn)]
+ public class CollectionSettings : ViewModel
{
private string _name;
-
+ [JsonProperty]
public string Name
{
get { return _name; }
set { _name = value; }
}
- private ObservableCollection<SettingsModel> _settings;
-
- public ObservableCollection<SettingsModel> Settings
+ private ObservableCollection<BaseSettingModel> _settings;
+ [JsonProperty]
+ public ObservableCollection<BaseSettingModel> Settings
{
get { return _settings; }
set { _settings = value; RaisePropertyChangedAuto(); }
}
- public SettingVM(string name)
+ public CollectionSettings(string name)
{
- _settings = new ObservableCollection<SettingsModel>();
+ _settings = new ObservableCollection<BaseSettingModel>();
Name = name;
}
- public void AddSettings(List<SettingsModel> settings)
+ public void AddSettings(List<BaseSettingModel> settings)
{
settings.ForEach(x => Settings.Add(x));
}
-
-
}
+
public class SettingsVM : ViewModel, IDisposable
{
- public Dictionary<AnalyzerSettingsEnum, double> ChangedValues { get; set; }
+ #region Properties
+ public Dictionary<AnalyzerSettingsEnum, object> ChangedValues { get; set; }
- private ObservableCollection<SettingVM> _settings;
+ private ObservableCollection<CollectionSettings> _settings;
- public ObservableCollection<SettingVM> Settings
+ public ObservableCollection<CollectionSettings> Settings
{
get { return _settings; }
set { _settings = value; RaisePropertyChangedAuto(); }
}
-
+
+ #endregion
+
public SettingsVM()
{
- _settings = new ObservableCollection<SettingVM>();
- ChangedValues = new Dictionary<AnalyzerSettingsEnum, double>();
+ _settings = new ObservableCollection<CollectionSettings>();
+ ChangedValues = new Dictionary<AnalyzerSettingsEnum, object>();
InitPBUTestSettings();
InitProcessSettings();
InitFlowTestSettings();
@@ -64,26 +70,27 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels
private void InitPBUTestSettings()
{
- SettingVM model = new SettingVM("Pressure build up");
- List<SettingsModel> list = new List<SettingsModel>();
- list.Add(new SettingsModel(AnalyzerSettingsEnum.PBUPassFail, "4.5 sec"));
+ CollectionSettings model = new CollectionSettings("Pressure build up");
+ List<BaseSettingModel> list = new List<BaseSettingModel>();
+ list.Add(new BaseSettingModel(AnalyzerSettingsEnum.PBUPassFail, "4.5 sec"));
model.AddSettings(list);
list.ForEach(x => x.SettingValueEvent += new EventHandler(OnSettingValueChanged));
Settings.Add(model);
}
-
+
private void InitFlowTestSettings()
{
- SettingVM model = new SettingVM("Flow test");
- List<SettingsModel> list = new List<SettingsModel>();
+ CollectionSettings model = new CollectionSettings("Flow test");
+ List<BaseSettingModel> list = new List<BaseSettingModel>();
- 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, "450 reads"));
- list.Add(new SettingsModel(AnalyzerSettingsEnum.MaxMinIntervals, "450 reads"));
- list.Add(new SettingsModel(AnalyzerSettingsEnum.MaxError, "1.5%"));
- list.Add(new SettingsModel(AnalyzerSettingsEnum.TakeOffMaxMin, "3"));
+ list.Add(new BaseSettingModel(AnalyzerSettingsEnum.FlowPBUPassFail, "4.5 sec"));
+ list.Add(new BaseSettingModel(AnalyzerSettingsEnum.ExcludeAnalysis, "1800 reads"));
+ list.Add(new BaseSettingModel(AnalyzerSettingsEnum.AvgMinValue, "1400-1850 [mbar]", true));
+ list.Add(new BaseSettingModel(AnalyzerSettingsEnum.MaxMinRange, "450 reads"));
+ list.Add(new BaseSettingModel(AnalyzerSettingsEnum.MaxMinIntervals, "450 reads"));
+ list.Add(new BaseSettingModel(AnalyzerSettingsEnum.MaxError, "1.5%"));
+ list.Add(new BaseSettingModel(AnalyzerSettingsEnum.TakeOffMaxMin, "3"));
+ list.Add(new BaseSettingModel(AnalyzerSettingsEnum.CancelMovingAVG, "False"));
list.ForEach(x => x.SettingValueEvent += new EventHandler(OnSettingValueChanged));
model.AddSettings(list);
Settings.Add(model);
@@ -91,12 +98,12 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels
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"));
+ CollectionSettings model = new CollectionSettings("Process");
+ List<BaseSettingModel> list = new List<BaseSettingModel>();
+ list.Add(new BaseSettingModel(AnalyzerSettingsEnum.TimeInterval, "0.1 sec"));
+ list.Add(new BaseSettingModel(AnalyzerSettingsEnum.StartCalculation, "600 sec"));
+ list.Add(new BaseSettingModel(AnalyzerSettingsEnum.EndCalculation, "900 sec"));
+ list.Add(new BaseSettingModel(AnalyzerSettingsEnum.MovingAvg, "50 points"));
list.ForEach(x => x.SettingValueEvent += new EventHandler(OnSettingValueChanged));
model.AddSettings(list);
Settings.Add(model);
@@ -104,9 +111,9 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels
private void OnSettingValueChanged(object sender, EventArgs e)
{
- if (sender is SettingsModel)
+ if (sender is BaseSettingModel)
{
- SettingsModel settingModel = sender as SettingsModel;
+ BaseSettingModel settingModel = sender as BaseSettingModel;
if (settingModel.IsRangeVisible)
{
ChangedValues[AnalyzerSettingsEnum.AvgMinValue] = settingModel.MinRangeValue;
@@ -117,7 +124,7 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels
}
}
- public Dictionary<AnalyzerSettingsEnum, double> GetChanges()
+ public Dictionary<AnalyzerSettingsEnum, object> GetChanges()
{
return ChangedValues;
}
diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/packages.config b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/packages.config
index 832cf227f..6b1e55209 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/packages.config
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/packages.config
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MathNet.Numerics" version="4.9.0" targetFramework="net461" />
+ <package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" />
<package id="OxyPlot.Core" version="2.0.0" targetFramework="net461" />
<package id="OxyPlot.Wpf" version="2.0.0" targetFramework="net461" />
<package id="PDFsharp" version="1.50.5147" targetFramework="net461" />