1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
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;
namespace Tango.DispenserAnalyzer.UI
{
public enum AnalyzerSettingsEnum
{
[Description("Print Results to PDF file")]
PrintResultsToPDF,
[Description("PBU Pass fail")]
PBUPassFail,
[Description("PBU Pass fail")]
FlowPBUPassFail,
[Description("Exclude from analysis")]
ExcludeAnalysis,
[Description("Avg value")]
AvgMaxValue,
[Description("Avg value")]
AvgMinValue,
[Description("Max-Min range")]
MaxMinRange,
[Description("Max Min intervals")]
MaxMinIntervals,
[Description("Max error")]
MaxError,
[Description("Take off 'Max-min' values(out of highest results)")]
TakeOffMaxMin,
[Description("Time gap between data point [sec]")]
TimeInterval,
[Description("Time point to start calculation [sec]")]
StartCalculation,
[Description("Time point to end calculation [sec]")]
EndCalculation,
[Description("How many points to use for moving average")]
MovingAvg,
[Description("Cancel Moving AVG")]
CancelMovingAVG,
}
public static class Settings
{
public static Dictionary<AnalyzerSettingsEnum, object> DefaultValues { get; set; }
public static Dictionary<AnalyzerSettingsEnum, object> CurrentValues { get; set; }
static Settings()
{
DefaultValues = new Dictionary<AnalyzerSettingsEnum, object>();
DefaultValues[AnalyzerSettingsEnum.PBUPassFail] = 4.5;
DefaultValues[AnalyzerSettingsEnum.FlowPBUPassFail] = 4.5;
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.0;
DefaultValues[AnalyzerSettingsEnum.TimeInterval] = 0.1;
DefaultValues[AnalyzerSettingsEnum.StartCalculation] = 600.0;
DefaultValues[AnalyzerSettingsEnum.EndCalculation] = 900.0;
DefaultValues[AnalyzerSettingsEnum.MovingAvg] = 50.0;
DefaultValues[AnalyzerSettingsEnum.CancelMovingAVG] = false;
CurrentValues = new Dictionary<AnalyzerSettingsEnum, object>(DefaultValues);
}
public static object GetValueByName(AnalyzerSettingsEnum name)
{
object value = 0.0;
if (CurrentValues.TryGetValue(name, out value))
{
return value;
}
return value;
}
public static void SetValueByName(AnalyzerSettingsEnum name, object value)
{
CurrentValues[name] = value;
}
public static object GetDefaultValueByName(AnalyzerSettingsEnum name)
{
object value = 0.0;
if (DefaultValues.TryGetValue(name, out value))
{
return value;
}
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;
}
}
}
}
}
|