blob: 83a079700aba500944c74b2c76cf6ca33c046d01 (
plain)
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
using LiteDB;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using Tango.BL.Enumerations;
using Tango.Core;
using Tango.Core.ExtensionMethods;
using Tango.Core.Helpers;
using Tango.CSV;
namespace Tango.BL.Entities
{
public partial class ProcessParametersTable : ProcessParametersTableBase
{
public event EventHandler DyeingSpeedMinInkUptakeChanged;
private static List<ProcessParameterCsvModel> _csvModels;
[NotMapped]
[JsonIgnore]
public static MachineTypes DryerBufferMode { get; set; }
public const double DRYER_METERS_PER_CYCLE = 0.76;
public const double DRYER_TO_SPOOL_LENGTH_METERS = 0.9;
protected override void RaisePropertyChanged(string propName)
{
base.RaisePropertyChanged(propName);
if (propName == nameof(DyeingSpeed) || propName == nameof(MinInkUptake))
{
OnDyeingSpeedMinInkUptakeChanged();
}
}
protected virtual void OnDyeingSpeedMinInkUptakeChanged()
{
DyeingSpeedMinInkUptakeChanged?.Invoke(this, new EventArgs());
}
[NotMapped]
[JsonIgnore]
public double DryerBufferLengthMeters
{
get
{
if (DryerBufferMode == MachineTypes.TS1800)
{
return (DryerBufferLength * DRYER_METERS_PER_CYCLE) + DRYER_TO_SPOOL_LENGTH_METERS;
}
else
{
return DryerBufferLength;
}
}
}
/// <summary>
/// Initializes a new instance of the <see cref="ProcessParametersTable" /> class.
/// </summary>
public ProcessParametersTable() : base()
{
}
public double GetAverageTemperature()
{
List<double> heaters = new List<double>();
heaters.Add(HeadZone1Temp);
heaters.Add(HeadZone2Temp);
heaters.Add(HeadZone3Temp);
heaters.Add(HeadZone4Temp);
heaters.Add(HeadZone5Temp);
heaters.Add(HeadZone6Temp);
heaters.Add(HeadZone7Temp);
heaters.Add(HeadZone8Temp);
heaters.Add(HeadZone9Temp);
heaters.Add(HeadZone10Temp);
heaters.Add(HeadZone11Temp);
heaters.Add(HeadZone12Temp);
heaters.Add(LBlowerTemp);
heaters.Add(RBlowerTemp);
return heaters.Average();
}
public PMR.Printing.ProcessParameters ToProcessParametersPMR()
{
PMR.Printing.ProcessParameters p = new PMR.Printing.ProcessParameters();
this.MapPrimitivesTo(p);
return p;
}
#region Visual Representation
public class ProcessParameterCsvModel
{
public String Name { get; set; }
public String Description { get; set; }
public List<MachineTypes> MachineTypes { get; set; }
public String Group { get; set; }
public int Index { get; set; }
public String StringFormat { get; set; }
public ProcessParameterCsvModel()
{
MachineTypes = new List<MachineTypes>();
}
}
public class ProcessParameter : ExtendedObject
{
private ParameterItem _parameterItem;
private ProcessParametersTable _table;
public String Name { get; set; }
public List<MachineTypes> MachineTypes { get; set; }
public String Group { get; set; }
public int Index { get; set; }
public String StringFormat { get; set; }
public bool HasDiff
{
get
{
if (_table == null) return false;
if (_table.ProcessParametersTablesGroup == null) return false;
foreach (var otherTable in _table.ProcessParametersTablesGroup.ProcessParametersTables.Where(x => x != _table).ToList())
{
var otherValue = otherTable.VisualParameters.FirstOrDefault(x => x.Name == Name);
if (otherValue != null)
{
if (otherValue.Value != Value) return true;
}
}
return false;
}
}
public double Value
{
get { return (double)_parameterItem.Value; }
set
{
_parameterItem.Value = value;
RaisePropertyChangedAuto();
RaisePropertyChanged(nameof(HasDiff));
if (_table == null) return;
if (_table.ProcessParametersTablesGroup == null) return;
foreach (var otherTable in _table.ProcessParametersTablesGroup.ProcessParametersTables.Where(x => x != _table).ToList())
{
var otherValue = otherTable.VisualParameters.FirstOrDefault(x => x.Name == Name);
if (otherValue != null)
{
otherValue.Invalidate();
}
}
}
}
public ProcessParameter(ParameterItem parameterItem, ProcessParametersTable table)
{
MachineTypes = new List<MachineTypes>();
_parameterItem = parameterItem;
_table = table;
}
public void Invalidate()
{
RaisePropertyChanged(nameof(HasDiff));
}
}
public class ProcessParameterGroup
{
public String Name { get; set; }
public List<ProcessParameter> Parameters { get; set; }
public ProcessParameterGroup()
{
Parameters = new List<ProcessParameter>();
}
}
[NotMapped]
[XmlIgnore]
[BsonIgnore]
[JsonIgnore]
[ParameterIgnore]
public List<ProcessParameterGroup> ParametersGroups
{
get
{
List<ProcessParameterGroup> groups = new List<ProcessParameterGroup>();
foreach (var g in VisualParameters.GroupBy(x => x.Group))
{
ProcessParameterGroup group = new ProcessParameterGroup();
group.Name = g.First().Group;
group.Parameters.AddRange(g);
groups.Add(group);
}
return groups;
}
}
private List<ProcessParameter> _visualParameters;
[NotMapped]
[XmlIgnore]
[BsonIgnore]
[JsonIgnore]
[ParameterIgnore]
public List<ProcessParameter> VisualParameters
{
get
{
if (_visualParameters != null)
{
return _visualParameters;
}
if (_csvModels == null)
{
var csv = EmbeddedResourceHelper.GetEmbeddedResourceText("Tango.BL.ProcessParameters.csv");
CsvDynamicReader reader = CsvDynamicReader.FromString(csv);
_csvModels = new List<ProcessParameterCsvModel>();
foreach (var row in reader.Rows)
{
ProcessParameterCsvModel csvModel = new ProcessParameterCsvModel();
csvModel.Name = row.Read("Name", "N/A");
csvModel.Description = row.Read("Description", "N/A");
csvModel.Group = row.Read("Group", "N/A");
csvModel.Index = row.Read("Index", 0);
csvModel.StringFormat = row.Read("StringFormat", "0.0");
String machineType = row.Read("MachineType", "ALL");
switch (machineType)
{
case "ALL":
csvModel.MachineTypes.AddRange(Enum.GetValues(typeof(MachineTypes)).Cast<MachineTypes>());
break;
case "TS-1800":
csvModel.MachineTypes.Add(MachineTypes.TS1800);
break;
case "X1":
csvModel.MachineTypes.Add(MachineTypes.X1);
break;
case "X4":
csvModel.MachineTypes.Add(MachineTypes.Eureka);
break;
case "X":
csvModel.MachineTypes.Add(MachineTypes.X1);
csvModel.MachineTypes.Add(MachineTypes.Eureka);
break;
}
_csvModels.Add(csvModel);
}
}
var parameters = this.Parameters.Where(x => x.Type == typeof(Double)).ToList();
_visualParameters = new List<ProcessParameter>();
foreach (var p in parameters)
{
var csvModel = _csvModels.SingleOrDefault(x => x.Name.Replace("_", "").ToLower() == p.Name.Replace(" ", "").ToLower());
if (csvModel.MachineTypes.Count > 0)
{
ProcessParameter parameter = new ProcessParameter(p, this);
parameter.Name = csvModel.Description;
parameter.MachineTypes = csvModel.MachineTypes;
parameter.Group = csvModel.Group;
parameter.Index = csvModel.Index;
parameter.StringFormat = csvModel.StringFormat;
_visualParameters.Add(parameter);
}
}
_visualParameters = _visualParameters.OrderBy(x => x.Index).ToList();
_visualParameters.ForEach(x => x.Invalidate());
return _visualParameters;
}
}
#endregion
}
}
|