diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2023-05-10 14:57:24 +0300 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2023-05-10 14:57:24 +0300 |
| commit | edd7e8af06fe0e70e78ce2de9423ec49a799b78a (patch) | |
| tree | 87ed11cd060ea9e562277df8063a4e7bc19a5cd0 /Software/Visual_Studio/PPC/Tango.PPC.UI/Models | |
| parent | 41463773c087d7aa8d085edf78613530d948e950 (diff) | |
| download | Tango-edd7e8af06fe0e70e78ce2de9423ec49a799b78a.tar.gz Tango-edd7e8af06fe0e70e78ce2de9423ec49a799b78a.zip | |
add values to UI dashboard indicators
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Models')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/Models/MachineOverviewItem.cs | 59 | ||||
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/Models/MachineOverviewModel.cs | 178 |
2 files changed, 237 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Models/MachineOverviewItem.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Models/MachineOverviewItem.cs new file mode 100644 index 000000000..ded7e33e8 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Models/MachineOverviewItem.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using Tango.Core; + +namespace Tango.PPC.UI.Models +{ + public class MachineOverviewItem : ExtendedObject + { + private String _displayValue; + public String DisplayValue + { + get { return _displayValue; } + set { _displayValue = value; RaisePropertyChangedAuto(); } + } + + private String _status; + public String Status + { + get { return _status; } + set { _status = value; RaisePropertyChangedAuto(); } + } + + private Color _color; + public Color Color + { + get { return _color; } + set { _color = value; RaisePropertyChangedAuto(); } + } + + private double _maxValue; + + public double MaxValue + { + get { return _maxValue; } + set { _maxValue = value; RaisePropertyChangedAuto(); } + } + + private double _value; + + public double Value + { + get { return _value; } + set { _value = value; RaisePropertyChangedAuto(); } + } + + public MachineOverviewItem() + { + Color = Colors.Gray; + DisplayValue = "--"; + Value = 0; + MaxValue = 100; + } + + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Models/MachineOverviewModel.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Models/MachineOverviewModel.cs new file mode 100644 index 000000000..d5d8407b7 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Models/MachineOverviewModel.cs @@ -0,0 +1,178 @@ +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 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 =140; + 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) + { + 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.CurrentValue > state.SetPoint) + { + item.Status = "Over-temperature"; + item.Color = Colors.Red; + item.DisplayValue = $"{state.CurrentValue} / {state.SetPoint}"; + item.MaxValue = state.SetPoint; + item.Value = state.CurrentValue; + } + else if (state.IsInSetPoint) + { + item.Status = "Operational"; + item.Color = Colors.Green; + item.DisplayValue = $" {state.SetPoint}"; + item.MaxValue = state.SetPoint; + item.Value = state.CurrentValue; + } + else + { + item.Color = Colors.Gray; + item.MaxValue = 100; + item.Value = 0; + } + } + } + + private void UpdateDryerAirItem(double currentvalue) + { + if (currentvalue < 140) + { + DryerAir.Status = "Heating Up"; + DryerAir.Color = Colors.Orange; + DryerAir.DisplayValue = $"{currentvalue}"; + } + else if (currentvalue >= 140) + { + 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; + } + } +} |
