aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Utilities
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2020-08-25 10:08:01 +0300
committerAvi Levkovich <avi@twine-s.com>2020-08-25 10:08:01 +0300
commit338edba081dba2a2aefb634811be1cc84ec93d64 (patch)
tree0021538796c254a8eab8527e8461a2e831e68c1c /Software/Visual_Studio/Utilities
parent49ddda1cc22d6cbb72f499b37e5db32c95252dfa (diff)
downloadTango-338edba081dba2a2aefb634811be1cc84ec93d64.tar.gz
Tango-338edba081dba2a2aefb634811be1cc84ec93d64.zip
merge
Diffstat (limited to 'Software/Visual_Studio/Utilities')
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/AnalyzerResultBase.cs2
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IAnalyzer.cs2
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IAnalyzerResult.cs4
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/DynamicSealingAnalyzer.cs2
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/FlowAnalyser.cs34
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PressureBuildUpAnalyser.cs2
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PrimingAnalyzer.cs2
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/SealingAnalyzer.cs2
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/App.xaml.cs13
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml.cs22
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Tango.DispenserAnalyzer.UI.csproj2
-rw-r--r--Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/MainWindowVM.cs146
-rw-r--r--Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs31
13 files changed, 212 insertions, 52 deletions
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 fcbda73e2..d3d217409 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/AnalyzerResultBase.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/AnalyzerResultBase.cs
@@ -55,6 +55,7 @@ namespace Tango.DispenserAnalyzer.UI.Analysis
public bool IsShowPlotResult { get; set; }
public AnalyzerResultPlotData RangeToCountChart { get; set; }
public AnalyzerResultPlotData RangeToTimeChart { get; set; }
+ public bool BackgroundMode { get; set; }
public AnalyzerResultBase()
{
@@ -63,6 +64,7 @@ namespace Tango.DispenserAnalyzer.UI.Analysis
IsShowPlotResult = false;
RangeToCountChart = new AnalyzerResultPlotData();
RangeToTimeChart = new AnalyzerResultPlotData();
+ BackgroundMode = false;
}
}
}
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 6a07e3a42..6d522da82 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IAnalyzer.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IAnalyzer.cs
@@ -10,6 +10,6 @@ namespace Tango.DispenserAnalyzer.UI.Analysis
[Analyzer("INTERFACE")]
public interface IAnalyzer
{
- Task<List<IAnalyzerResult>> Process(List<DispenserSample> csvRows);
+ 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 6b404d2a5..60f7fcb36 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IAnalyzerResult.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/IAnalyzerResult.cs
@@ -56,8 +56,10 @@ namespace Tango.DispenserAnalyzer.UI.Analysis
public interface IAnalyzerResult
{
AnalyzerResultValue Result { get; set; }
+
+ bool BackgroundMode { get; set; }
List<AnalysisPlotValue> PlotValues { get; set; }
- // ObservableCollection<DataPoint> Points { get; set; }
+
AnalyzerResultPlotData RangeToCountChart { get; set; }
AnalyzerResultPlotData RangeToTimeChart { get; set; }
}
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 2cf38fdd6..8acd1651c 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/DynamicSealingAnalyzer.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/DynamicSealingAnalyzer.cs
@@ -12,7 +12,7 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
[Analyzer("dynamic")]
public class DynamicSealingAnalzyer : IAnalyzer
{
- public Task<List<IAnalyzerResult>> Process(List<DispenserSample> csvRows)
+ public Task<List<IAnalyzerResult>> Process(List<DispenserSample> csvRows, bool backgroundMode)
{
return Task.Factory.StartNew<List<IAnalyzerResult>>(() =>
{
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 41b7983a7..492fb3e6a 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/FlowAnalyser.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/FlowAnalyser.cs
@@ -21,7 +21,7 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
public class FlowAnalyser : IAnalyzer
{
- public Task<List<IAnalyzerResult>> Process(List<DispenserSample> csvRows)
+ public Task<List<IAnalyzerResult>> Process(List<DispenserSample> csvRows, bool backgroundMode)
{
return Task.Factory.StartNew<List<IAnalyzerResult>>(() =>
{
@@ -74,11 +74,13 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
differenceMaxMinToLocationArr.Add(++location_index);
}
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;
results.Add(averageResult);
FlowAnalyzerResult result = new FlowAnalyzerResult(++flowtestNumber);
+ result.BackgroundMode = backgroundMode;
result.AverageValue = averageResult.AverageValue;
result.SetLocalErrors(differenceMaxMin, differenceMaxMinToLocationArr);
results.Add(result);
@@ -86,6 +88,7 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
else//testing PBU
{
PrimingAnalyzerResult result = new PrimingAnalyzerResult();
+ result.BackgroundMode = backgroundMode;
int avgMinIndex = rangeTestValues.Select(x => x.Index).Min();
int avgMaxIndex = rangeTestValues.Select(x => x.Index).Max();
double totalsec = TimeSpan.FromMilliseconds((avgMaxIndex - avgMinIndex) * 100).TotalSeconds;
@@ -138,27 +141,34 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
{
// int count = differenceMaxMin.Where(x => x > 25 ).Count();
int max_key = FindMaxErrorObject(differenceMaxMin);
- var points = RangeToCountChart.Points;
- points.Clear();
- for (int i = 0; i <= max_key; i++)
+ if (!BackgroundMode)
{
- int val = differenceMaxMin.Count(x => x == i);
- if(val > 0 || points.Count > 0)
+ var points = RangeToCountChart.Points;
+ points.Clear();
+ for (int i = 0; i <= max_key; i++)
{
- points.Add(new DataPoint(i, val));
+ int val = differenceMaxMin.Count(x => x == i);
+ if(val > 0 || points.Count > 0)
+ {
+ points.Add(new DataPoint(i, val));
+ }
}
+ this.IsShowPlotResult = true;
+ RangeToCountChart.Title = $"Flow Range To Count {TestNumber}";
+ RangeToCountChart.UpdateData();
}
- this.IsShowPlotResult = true;
- RangeToCountChart.Title = $"Flow Range To Count {TestNumber}";
- RangeToCountChart.UpdateData();
var rangeToTimePoints = RangeToTimeChart.Points;
rangeToTimePoints.Clear();
for(int y = 0; y < differenceMaxMinToLocationArr.Count && y < differenceMaxMin.Count; y++)
{
rangeToTimePoints.Add(new DataPoint(differenceMaxMinToLocationArr.ElementAt(y), differenceMaxMin.ElementAt(y)));
}
- RangeToTimeChart.Title = $"Flow Time Location To Range {TestNumber}";
- RangeToTimeChart.UpdateData();
+ if (!BackgroundMode)
+ {
+ RangeToTimeChart.Title = $"Flow Time Location To Range {TestNumber}";
+ RangeToTimeChart.UpdateData();
+ }
+
string filename = FileHelper.GetFileToSaveFlowRangeToTimeData(TestNumber);
if(filename.IsNotNullOrEmpty() && rangeToTimePoints.Count > 0)
{
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 c4c5f6c65..79b643294 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PressureBuildUpAnalyser.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PressureBuildUpAnalyser.cs
@@ -11,7 +11,7 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
[Analyzer("pressure build up")]
public class PressureBuildUpAnalyser : IAnalyzer
{
- public Task<List<IAnalyzerResult>> Process(List<DispenserSample> csvRows)
+ public Task<List<IAnalyzerResult>> Process(List<DispenserSample> csvRows, bool backgroundMode)
{
return Task.Factory.StartNew<List<IAnalyzerResult>>(() =>
{
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 0a0e35371..cfd4a7b55 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PrimingAnalyzer.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PrimingAnalyzer.cs
@@ -13,7 +13,7 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
[Analyzer("priming")]
public class PrimingAnalyzer : IAnalyzer
{
- public Task<List<IAnalyzerResult>> Process(List<DispenserSample> csvRows)
+ public Task<List<IAnalyzerResult>> Process(List<DispenserSample> csvRows, bool backgroundMode)
{
return Task.Factory.StartNew<List<IAnalyzerResult>>(() =>
{
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 e725ee25d..e1fe232c3 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/SealingAnalyzer.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/SealingAnalyzer.cs
@@ -12,7 +12,7 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers
[Analyzer("sealtest")]
public class SealingAnalyzer : IAnalyzer
{
- public Task<List<IAnalyzerResult>> Process(List<DispenserSample> csvRows)
+ public Task<List<IAnalyzerResult>> Process(List<DispenserSample> csvRows, bool backgroundMode)
{
return Task.Factory.StartNew<List<IAnalyzerResult>>(() =>
{
diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/App.xaml.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/App.xaml.cs
index c1876d806..d70c2e7a8 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/App.xaml.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/App.xaml.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
using System.Windows;
@@ -16,9 +17,15 @@ namespace Tango.DispenserAnalyzer.UI
private void Application_Startup(object sender, StartupEventArgs e)
{
MainWindow wnd = new MainWindow();
- if (e.Args.Length >= 1)
- wnd.SetOpenFileFromArgument(e.Args[0]);
- wnd.Show();
+ if (e.Args.Length > 0)
+ {
+ wnd.GenerateResultsInBackground(e.Args);
+ //Current.Shutdown();
+ }
+ else
+ {
+ wnd.Show();
+ }
}
}
}
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 43a573a7d..d328ea8a5 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml.cs
@@ -1,20 +1,8 @@
using OxyPlot;
using OxyPlot.Axes;
using System;
-using System.Collections.Generic;
-using System.IO;
-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.Navigation;
-using System.Windows.Shapes;
using Tango.DispenserAnalyzer.UI.ViewModels;
namespace Tango.DispenserAnalyzer.UI
@@ -48,13 +36,17 @@ namespace Tango.DispenserAnalyzer.UI
ax.Maximum = ax.Minimum = Double.NaN;
}
- public void SetOpenFileFromArgument( string openFilePath)
+ public async void GenerateResultsInBackground( string[] filePathArr)
{
if(_vm != null)
{
- _vm.OpenFilePath = openFilePath;
- _vm.Generate();
+ for (int index = 0; index < filePathArr.Length; index++)
+ {
+ await _vm.GenerateInBackground(filePathArr[index]);
+ }
}
+ await Task.Delay(500);
+ Application.Current.Shutdown();
}
private void TextBlock_PreviewDrop(object sender, DragEventArgs e)
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 3e85dc80b..b7db85ef8 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,7 +29,7 @@
<ProductName>Dispenser Analyser</ProductName>
<PublisherName>Twine</PublisherName>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
- <ApplicationRevision>3</ApplicationRevision>
+ <ApplicationRevision>4</ApplicationRevision>
<ApplicationVersion>2.1.1.%2a</ApplicationVersion>
<UseApplicationTrust>true</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
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 70034b6e7..38f8dee81 100644
--- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/MainWindowVM.cs
+++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/MainWindowVM.cs
@@ -28,6 +28,8 @@ 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
{
@@ -134,6 +136,7 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels
get { return _isRunning; }
set { _isRunning = value; RaisePropertyChangedAuto(); }
}
+
private ObservableCollection<IAnalyzerResult> _analyzerResults;
public ObservableCollection<IAnalyzerResult> AnalyzerResults
{
@@ -233,13 +236,18 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels
#endregion
#region Generate
+
public bool CanGenerate()
{
return (OpenFilePath!= null && OpenFilePath.Length != 0 && File.Exists(OpenFilePath));
}
+
+ /// <summary>
+ /// Generates all results.
+ /// </summary>
public async void Generate()
{
- if (false == File.Exists(OpenFilePath) || IsFileLocked(OpenFilePath) )
+ if (false == File.Exists(OpenFilePath) || IsFileLocked(OpenFilePath))
return;
ResetSettings();
@@ -248,17 +256,18 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels
return;
IsRunning = true;
- AnalyzerAttribute attribute = (AnalyzerAttribute)analyzer.GetType().GetCustomAttributes(typeof(AnalyzerAttribute),true).FirstOrDefault();
-
+ AnalyzerAttribute attribute = (AnalyzerAttribute)analyzer.GetType().GetCustomAttributes(typeof(AnalyzerAttribute), true).FirstOrDefault();
+
TestName = attribute.Name;
- List<DispenserCsvRow> data = CsvFile.Read<DispenserCsvRow>(new CsvSource(OpenFilePath)).ToList();
+ 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)
{
double pressure = 0;
@@ -269,6 +278,7 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels
if (last_labelIndex == 0 || last_labelIndex < (index + 5))
{
last_labelIndex = index;
+
OxyPlot.Wpf.LineAnnotation _line = new OxyPlot.Wpf.LineAnnotation()
{
StrokeThickness = 1,
@@ -278,11 +288,13 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels
X = index,
};
PlotControl.Annotations.Add(_line);
+
}
}
if (double.TryParse(item.Pressure, out pressure) || !String.IsNullOrWhiteSpace(item.Command))
{
- samples.Add(new DispenserSample(){
+ samples.Add(new DispenserSample()
+ {
Pressure = pressure,
Command = String.IsNullOrWhiteSpace(item.Command) ? null : item.Command,
Index = index
@@ -290,27 +302,84 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels
index++;
}
}
- List<IAnalyzerResult> res = await analyzer.Process(samples);
+ List<IAnalyzerResult> res = await analyzer.Process(samples, false);
AnalyzerResults = new ObservableCollection<IAnalyzerResult>(res);
-
- samples.ForEach(x => { if (x.Pressure != 0.0)
+
+ 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);
+ _to = Points.Max(x => x.Y);
+ _from = TestName.Contains("sealtest") ? Points.FirstOrDefault(x => x.X == 0).Y : Points.Min(x => x.Y);
data.Clear();
_to += 100;
RaisePropertyChanged("To");
- if(_from != 0)
+ if (_from != 0)
_from -= 100;
RaisePropertyChanged("From");
XStep = (int)(Points.Count / 5);
-
+
IsRunning = false;
PlotControl.InvalidatePlot(true);
-
+
await PrintToXpsFile();
+
+ }
+
+ /// <summary>
+ /// Generates all results from command line and close application.
+ /// </summary>
+ public async Task GenerateInBackground(string openFilePath)
+ {
+ OpenFilePath = openFilePath;
+
+ if (false == File.Exists(OpenFilePath) || IsFileLocked(OpenFilePath))
+ return;
+
+ IAnalyzer 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;
+
+
+ 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;
+ }
+ }
+ 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++;
+ }
+ }
+
+ List<IAnalyzerResult> res = await analyzer.Process(samples, true);
+ AnalyzerResults = new ObservableCollection<IAnalyzerResult>(res);
+
+ await ExportResultsToTextFile();
}
#endregion
@@ -487,5 +556,54 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels
}
#endregion
+
+ #region ExportToExel
+
+ public async Task ExportResultsToTextFile()
+ {
+ var resultFile = FileHelper.GetResultFilePath();
+ var dir = Path.GetDirectoryName(resultFile);
+ var name = Path.GetFileNameWithoutExtension(resultFile);
+ string fileNameWithoutExtension = Path.Combine(dir, name);
+ String sourceFile = String.Format($"{fileNameWithoutExtension}s.txt");
+ File.Delete(sourceFile);
+
+ await Task.Factory.StartNew(() =>
+ {
+ try
+ {
+ List<IAnalyzerResult> results = AnalyzerResults.ToList();
+
+ using (StreamWriter outputFile = new StreamWriter(sourceFile))
+ {
+ outputFile.WriteLine(String.Format($" {TestName.ToUpper()} RESULTS: "));
+ outputFile.WriteLine("");
+ outputFile.WriteLine("");
+ foreach (var res in results)
+ {
+ if (res.GetType().IsSubclassOf(typeof(AnalyzerResultBase)))
+ {
+ List<AnalyzerResultProperty> properties = (res as AnalyzerResultBase).Properties;
+ foreach (var prop in properties)
+ {
+ outputFile.WriteLine(String.Format($" {prop.Name} : {prop.Value}"));
+ }
+ string resV = String.Format($" RESULT = {res.Result.ToString()}");
+ outputFile.WriteLine(resV);
+ outputFile.WriteLine("");
+ }
+ }
+ outputFile.Flush();
+ }
+ }
+ catch (Exception ex)
+ {
+ Debug.WriteLine(ex);
+ }
+ });
+
+ }
+ #endregion
+
}
}
diff --git a/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs b/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs
index c4c16b416..a86454e26 100644
--- a/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs
+++ b/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs
@@ -56,6 +56,7 @@ namespace Tango.PMRGenerator.CLI
GenerateColorLabLiquidTypes(db, pmrFolder);
GenerateDiagnosticsValueComponents(db, pmrFolder);
GenerateDiagnosticsMonitors(db, pmrFolder);
+ GenerateInsightsMonitors(db, pmrFolder);
GenerateEventTypes(db, pmrFolder);
GenerateInterfaceIOs(db, pmrFolder);
}
@@ -641,7 +642,7 @@ namespace Tango.PMRGenerator.CLI
private static void GenerateDiagnosticsMonitors(ObservablesContext db, String pmrFolder)
{
- Console.WriteLine("Generating Monitors...");
+ Console.WriteLine("Generating Diagnostics Monitors...");
ProtoMessageFile messageFile = new ProtoMessageFile();
messageFile.Name = "DiagnosticsMonitors";
@@ -674,6 +675,34 @@ namespace Tango.PMRGenerator.CLI
File.WriteAllText(Path.Combine(pmrFolder, "Diagnostics", messageFile.Name + ".proto"), messageString);
}
+ private static void GenerateInsightsMonitors(ObservablesContext db, string pmrFolder)
+ {
+ Console.WriteLine("Generating Insights Monitors...");
+
+ ProtoMessageFile messageFile = new ProtoMessageFile();
+ messageFile.Name = "InsightsMonitors";
+ messageFile.Package = "Tango.PMR.Insights";
+
+ foreach (var monitor in db.TechMonitors.ToList().OrderBy(x => x.Code))
+ {
+ var prop = new ProtoProperty();
+ prop.Name = monitor.Name.Replace(" ", "");
+ prop.Description = monitor.Description;
+ prop.Type = "double";
+
+ if (monitor.MultiChannel)
+ {
+ prop.Repeated = true;
+ }
+
+ messageFile.Properties.Add(prop);
+ }
+
+ String messageString = messageFile.GenerateCode();
+
+ File.WriteAllText(Path.Combine(pmrFolder, "Insights", messageFile.Name + ".proto"), messageString);
+ }
+
private static void GenerateInterfaceIOs(ObservablesContext db, String pmrFolder)
{
Console.WriteLine("Generating Interface IOs...");