blob: bd34122c65e557865b7c962fc9d6d6f5ecc4d664 (
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using Tango.BL.Entities;
using Tango.Core;
using Tango.PMR.Diagnostics;
using Tango.PPC.Common;
using Tango.Settings;
namespace Tango.PPC.UI.Models
{
public class MachineOverviewModel : ExtendedObject
{
public static double DryerAirMaxValue = 120.0;
public MachineOverviewItem DryerZone3 { get; set; }
public MachineOverviewItem DryerAir { get; set; }
public MachineOverviewItem Tunnel { get; set; }
public MachineOverviewItem PumpsPressure { get; set; }
public MachineOverviewItem Lubricant { get; set; }
private PPCSettings _settings;
/// <summary>
/// Gets the main PPC settings.
/// </summary>
public PPCSettings Settings
{
get
{
if (_settings == null)
{
_settings = SettingsManager.Default.GetOrCreate<PPCSettings>();
}
return _settings;
}
private set { _settings = value; }
}
public MachineOverviewModel()
{
DryerZone3 = new MachineOverviewItem();
DryerAir = new MachineOverviewItem();
DryerAir.MaxValue = DryerAirMaxValue;
Tunnel = new MachineOverviewItem();
PumpsPressure = new MachineOverviewItem();
PumpsPressure.MaxValue = 6;
Lubricant = new MachineOverviewItem();
Lubricant.MaxValue = 100;
Lubricant.Value = 100;
}
public void Update(StartDiagnosticsResponse diagnostics, Rml rml, ProcessParametersTable processParameters)
{
//Dryer Zone 3
var dryerZone3State = diagnostics.HeatersStates.FirstOrDefault(x => x.HeaterType == HeaterType.HeaterZone3);
UpdateHeaterItem(DryerZone3, dryerZone3State);
//Dryer Air
var dryerAirState = diagnostics.Monitors.EuSpare1.FirstOrDefault();
UpdateDryerAirItem(dryerAirState);
//diagnostics.HeatersStates.FirstOrDefault(x => x.HeaterType == HeaterType.DryerAirHeater);
//Tunnel
var tunnelState = diagnostics.HeatersStates.FirstOrDefault(x => x.HeaterType == HeaterType.ETunnelHeater);
UpdateHeaterItem(Tunnel, tunnelState);
//Pumps Pressure
if (diagnostics.Monitors.EuInkLinesPressure.Count > 0 && diagnostics.Monitors.EuInkLinesPressure.Any(x => x.Data.Count > 0))
{
var pumpsPressuerValue = diagnostics.Monitors.EuInkLinesPressure.SelectMany(x => x.Data).Max();
UpdatePumpsPressureItem(pumpsPressuerValue);
}
//Lubricant
var lubricantValue = diagnostics.Monitors.EuLubricantCurrent.FirstOrDefault();
UpdateLubricantItem( rml, lubricantValue);
}
private void UpdateHeaterItem(MachineOverviewItem item, HeaterState state)
{
if (state != null)
{
if (state.IsRampingUp &&
(state.SetPoint != 0
&& (state.CurrentValue <= (state.SetPoint - 10))))
{
item.Status = "Heating Up";
item.Color = Colors.Orange;
item.DisplayValue = $"{state.CurrentValue} / {state.SetPoint}";
item.MaxValue = state.SetPoint;
item.Value = state.CurrentValue;
}
else if (state.SetPoint == 0 || (state.CurrentValue >= (state.SetPoint - 10) || state.CurrentValue <= (state.SetPoint + 10)))
{
item.Status = "Operational";
item.Color = Colors.Green;
item.DisplayValue = $" {state.SetPoint}";
item.MaxValue = state.SetPoint;
item.Value = state.CurrentValue;
}
else if (!state.IsRampingUp && (state.CurrentValue < (state.SetPoint - 10) || state.CurrentValue > (state.SetPoint + 10)))
{
item.Status = "Over-temperature";
item.Color = Colors.Red;
item.DisplayValue = $"{state.CurrentValue} / {state.SetPoint}";
item.MaxValue = state.SetPoint;
item.Value = state.CurrentValue > state.SetPoint? state.SetPoint : state.CurrentValue;
}
else
{
item.Color = Colors.Gray;
item.MaxValue = 100;
item.Value = 0;
}
}
}
private void UpdateDryerAirItem(double currentvalue)
{
if (currentvalue < DryerAirMaxValue)
{
DryerAir.Status = "Heating Up";
DryerAir.Color = Colors.Orange;
DryerAir.DisplayValue = $"{currentvalue}";
}
else if (currentvalue >= DryerAirMaxValue)
{
DryerAir.Status = "Operational";
DryerAir.Color = Colors.Green;
DryerAir.DisplayValue = $"{currentvalue}";
}
DryerAir.Value = currentvalue;
}
private void UpdatePumpsPressureItem(double maxValue)
{
if (maxValue > 6)
{
PumpsPressure.Status = "Overpressure";
PumpsPressure.Color = Colors.Red;
PumpsPressure.DisplayValue = maxValue.ToString();
}
else
{
PumpsPressure.Status = "Operational";
PumpsPressure.Color = Colors.Green;
PumpsPressure.DisplayValue = maxValue.ToString();
}
PumpsPressure.Value = maxValue;
}
private void UpdateLubricantItem(Rml rml, double lubricantValue)
{
if (rml != null)
{
var rmlLubrication = Settings.LubricationLevels.FirstOrDefault(x => x.RmlGuid == rml.Guid);
if (( rml.Lubricant == false)
|| (rmlLubrication != null && rmlLubrication.LubricationLevel == Common.Lubrication.LubricationLevel.No))
{
Lubricant.Status = "NotActive";
Lubricant.DisplayValue = "None";
Lubricant.Color = Colors.Gray;
return;
}
Lubricant.Status = "Active";
Lubricant.DisplayValue = lubricantValue.ToString();
Lubricant.Color = Colors.Green;
}
Lubricant.Status = "NotActive";
Lubricant.DisplayValue = "None";
Lubricant.Color = Colors.Gray;
}
}
}
|