From 1e5d6d1b458aa963e6ddcd9b15d692a274acd561 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 20 Sep 2018 17:35:49 +0300 Subject: Implemented Heater widget on tech board! --- .../ViewModels/MachineTechViewVM.cs | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs index 6575bd53c..5f439e1ca 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs @@ -444,6 +444,17 @@ namespace Tango.MachineStudio.Technician.ViewModels digitalInItem.Value = digitalPin.Value; } } + else if (item.GetType() == typeof(HeaterItem)) + { + HeaterItem heaterItem = item as HeaterItem; + + var heaterState = data.HeatersStates.SingleOrDefault(x => x.HeaterType == (HeaterType)heaterItem.TechHeater.Code); + + if (heaterState != null) + { + heaterItem.HeaterState = heaterState; + } + } else if (item.GetType() == typeof(ControllerItem)) { ControllerItem controllerItem = item as ControllerItem; @@ -557,6 +568,11 @@ namespace Tango.MachineStudio.Technician.ViewModels { CreateElement(bounds, Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault()); } + else if (item is HeaterItem) + { + var editor = CreateElement(bounds, Adapter.TechHeaters.FirstOrDefault()); + InitTechHeater(editor.HeaterItem); + } else if (item is SingleGraphItem) { var editor = CreateElement(bounds, Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault()); @@ -682,6 +698,11 @@ namespace Tango.MachineStudio.Technician.ViewModels (item as MonitorItem).TechMonitor = Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault(x => x.Guid == item.ItemGuid); CreateElement(item); } + else if (item is HeaterItem) + { + (item as HeaterItem).TechHeater = Adapter.TechHeaters.FirstOrDefault(x => x.Guid == item.ItemGuid); + CreateElement(item); + } else if (item is MeterItem) { (item as MeterItem).TechMonitor = Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault(x => x.Guid == item.ItemGuid); @@ -894,6 +915,27 @@ namespace Tango.MachineStudio.Technician.ViewModels #region Init Tech Items + /// + /// Initializes the tech heater. + /// + /// The item. + private void InitTechHeater(HeaterItem item) + { + item.SetCommandClicked += async () => + { + try + { + CheckMachineOperator(); + await MachineOperator.SetHeaterState((HeaterType)item.TechHeater.Code, item.SetPoint); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error executing SetHeaterState command for heater {item.TechHeater.Name}."); + _eventLogger.Log(ex, $"Error executing SetHeaterState command for heater {item.TechHeater.Name}."); + } + }; + } + /// /// Initializes the motor item. /// -- cgit v1.3.1