From aeb14d2d27e479a88cb638c91be77454d250e19b Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 25 Sep 2018 15:58:28 +0300 Subject: Implemented new single value controller widget. Implemented new blower controller. Changed tech board styles to dark. --- .../Editors/BlowerElementEditor.xaml | 64 ++++- .../Editors/ControllerElementEditor.xaml | 75 ++++-- .../Editors/DispenserElementEditor.xaml | 273 +++++++-------------- .../Editors/HeaterElementEditor.xaml | 4 +- .../Editors/MotorElementEditor.xaml | 251 ++++++------------- .../Editors/MotorGroupElementEditor.xaml | 221 +++++------------ .../Editors/TextElementEditor.xaml | 2 +- .../Editors/ThreadMotionElementEditor.xaml | 75 +----- .../TechItems/BlowerItem.cs | 40 +++ .../TechItems/ControllerItem.cs | 15 +- .../TechItems/HeaterItem.cs | 1 + .../ViewModels/MachineTechViewVM.cs | 40 ++- 12 files changed, 440 insertions(+), 621 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/BlowerElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/BlowerElementEditor.xaml index e06d1f559..e5545ca61 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/BlowerElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/BlowerElementEditor.xaml @@ -2,13 +2,15 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems" xmlns:converters="clr-namespace:Tango.Editors.Converters;assembly=Tango.Editors" xmlns:visuals="clr-namespace:Tango.Visuals;assembly=Tango.Visuals" xmlns:local="clr-namespace:Tango.Editors;assembly=Tango.Editors" - mc:Ignorable="d" Background="Transparent" ClipToBounds="False" BorderThickness="0" MinWidth="1" MinHeight="1" RenderTransformOrigin="0.5,0.5" d:DataContext="{d:DesignInstance Type=items:BlowerItem, IsDesignTimeCreatable=False}" Height="99.188" Width="163.459"> + mc:Ignorable="d" Background="Transparent" ClipToBounds="False" BorderThickness="0" MinWidth="1" MinHeight="1" RenderTransformOrigin="0.5,0.5" d:DataContext="{d:DesignInstance Type=items:BlowerItem, IsDesignTimeCreatable=False}" Height="101.188" Width="352.459"> @@ -29,7 +31,65 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MV + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ControllerElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ControllerElementEditor.xaml index de604625d..999c03e78 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ControllerElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ControllerElementEditor.xaml @@ -8,8 +8,9 @@ xmlns:gauge="clr-namespace:Tango.CircularGauge;assembly=Tango.CircularGauge" xmlns:converters="clr-namespace:Tango.Editors.Converters;assembly=Tango.Editors" xmlns:visuals="clr-namespace:Tango.Visuals;assembly=Tango.Visuals" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" xmlns:local="clr-namespace:Tango.Editors;assembly=Tango.Editors" - mc:Ignorable="d" Background="Transparent" ClipToBounds="False" BorderThickness="0" MinWidth="1" MinHeight="1" RenderTransformOrigin="0.5,0.5" d:DataContext="{d:DesignInstance Type=items:ControllerItem, IsDesignTimeCreatable=False}" Height="245.074" Width="321.75"> + mc:Ignorable="d" Background="Transparent" ClipToBounds="False" BorderThickness="0" MinWidth="1" MinHeight="1" RenderTransformOrigin="0.5,0.5" d:DataContext="{d:DesignInstance Type=items:ControllerItem, IsDesignTimeCreatable=False}" Height="245.074" Width="500.75"> @@ -30,15 +31,17 @@ - + - - + + + - + - + + + + + + + + + + + + + + PV + + + + + + + + + + + SV + + + + + - - - - - - - - - + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml index 1fa1c6c48..630dddec7 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml @@ -32,7 +32,7 @@ - + @@ -45,205 +45,106 @@ - - - - - - - - - - - - - - - - - + + + + + + + - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - + + + + + + + - - - - - + + + + + + + - - - - + + + + + + + - - - - - - - - - - - - - + - - + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml index ca9f6140c..3ffeaaa77 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml @@ -61,7 +61,7 @@ - PV + PV @@ -83,7 +83,7 @@ - SV + SV diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml index 80bfe8f96..25907fd8f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml @@ -34,7 +34,7 @@ - + @@ -47,192 +47,93 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - - - - - + + + + - - - - - + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorGroupElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorGroupElementEditor.xaml index 3adee13d6..ac07f1390 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorGroupElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorGroupElementEditor.xaml @@ -34,7 +34,7 @@ - + @@ -47,178 +47,79 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + + + + + + - - - - + - - - - - + + + + + + + - - + + + + + - + + + + + + + + + + + + + + + + + + + + + + - + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/TextElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/TextElementEditor.xaml index 33b0645ab..2d6c61c5e 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/TextElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/TextElementEditor.xaml @@ -28,7 +28,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ThreadMotionElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ThreadMotionElementEditor.xaml index 6e2315dc8..51de5dc95 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ThreadMotionElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ThreadMotionElementEditor.xaml @@ -56,9 +56,6 @@ - - - @@ -67,83 +64,19 @@ - - - - + - + - - - - + - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/BlowerItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/BlowerItem.cs index 6b532204e..f581988f7 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/BlowerItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/BlowerItem.cs @@ -7,6 +7,7 @@ using System.Windows.Media; using System.Xml.Serialization; using Tango.BL; using Tango.BL.Entities; +using Tango.Core.Commands; using Tango.SharedUI.Helpers; namespace Tango.MachineStudio.Technician.TechItems @@ -18,6 +19,8 @@ namespace Tango.MachineStudio.Technician.TechItems [TechItem(16)] public class BlowerItem : TechItem { + public event EventHandler SetCommandClicked; + private static List _BlowerConfigurations; /// /// Gets or sets the Blower configurations. @@ -68,6 +71,36 @@ namespace Tango.MachineStudio.Technician.TechItems set { _hardwareBlower = value; RaisePropertyChangedAuto(); } } + private bool _isActive; + [XmlIgnore] + public bool IsActive + { + get { return _isActive; } + set { _isActive = value; RaisePropertyChangedAuto(); } + } + + private bool _effectiveActive; + [XmlIgnore] + public bool EffectiveActive + { + get { return _effectiveActive; } + set + { + _effectiveActive = value; + RaisePropertyChangedAuto(); + IsActive = _effectiveActive; + } + } + + /// + /// Gets or sets the set command. + /// + [XmlIgnore] + public RelayCommand SetCommand { get; set; } + + [XmlIgnore] + public RelayCommand ToggleActiveCommand { get; set; } + /// /// Initializes a new instance of the class. /// @@ -78,6 +111,13 @@ namespace Tango.MachineStudio.Technician.TechItems Image = ResourceHelper.GetImageFromResources("Images/blower.png"); Color = Colors.White; HardwareBlower = new HardwareBlower(); + + SetCommand = new RelayCommand(() => { SetCommandClicked?.Invoke(this, _isActive); }); + + ToggleActiveCommand = new RelayCommand(() => + { + SetCommandClicked?.Invoke(this, _isActive); + }); } /// diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/ControllerItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/ControllerItem.cs index 8a9cba883..2d8763f74 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/ControllerItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/ControllerItem.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using System.Windows.Media; using System.Xml.Serialization; using Tango.BL.Entities; +using Tango.Core.Commands; using Tango.SharedUI.Helpers; namespace Tango.MachineStudio.Technician.TechItems @@ -17,10 +18,7 @@ namespace Tango.MachineStudio.Technician.TechItems [TechItem(10)] public class ControllerItem : TechItem { - /// - /// Occurs when the controller value has changed. - /// - public event EventHandler ValueChanged; + public event EventHandler SetCommandClicked; private TechController _techController; /// @@ -56,7 +54,6 @@ namespace Tango.MachineStudio.Technician.TechItems set { _value = value; RaisePropertyChangedAuto(); - ValueChanged?.Invoke(this, _value); } } @@ -119,6 +116,12 @@ namespace Tango.MachineStudio.Technician.TechItems public bool IsSetToDefault { get; set; } + /// + /// Gets or sets the set command. + /// + [XmlIgnore] + public RelayCommand SetCommand { get; set; } + /// /// Initializes a new instance of the class. /// @@ -130,6 +133,8 @@ namespace Tango.MachineStudio.Technician.TechItems Color = Colors.DodgerBlue; LastUpdateTime = DateTime.Now; UpdateInterval = 10; + + SetCommand = new RelayCommand(() => { SetCommandClicked?.Invoke(this, new EventArgs()); }); } /// diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/HeaterItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/HeaterItem.cs index c1b876e9b..e91c3f185 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/HeaterItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/HeaterItem.cs @@ -35,6 +35,7 @@ namespace Tango.MachineStudio.Technician.TechItems /// /// Gets or sets the set command. /// + [XmlIgnore] public RelayCommand SetCommand { get; set; } /// 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 5f439e1ca..6a9725106 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 @@ -455,6 +455,15 @@ namespace Tango.MachineStudio.Technician.ViewModels heaterItem.HeaterState = heaterState; } } + else if (item.GetType() == typeof(BlowerItem)) + { + BlowerItem blowerItem = item as BlowerItem; + + if (data.Monitors.BlowerVoltage.Count > 0) + { + blowerItem.EffectiveActive = data.Monitors.BlowerVoltage.Last() > 0; + } + } else if (item.GetType() == typeof(ControllerItem)) { ControllerItem controllerItem = item as ControllerItem; @@ -635,7 +644,8 @@ namespace Tango.MachineStudio.Technician.ViewModels } else if (item is BlowerItem) { - CreateElement(bounds, Adapter.HardwareBlowerTypes.FirstOrDefault()); + var editor = CreateElement(bounds, Adapter.HardwareBlowerTypes.FirstOrDefault()); + InitBlowerItem(editor.BlowerItem); } else if (item is BreakSensorItem) { @@ -782,7 +792,8 @@ namespace Tango.MachineStudio.Technician.ViewModels else if (item is BlowerItem) { (item as BlowerItem).HardwareBlowerType = Adapter.HardwareBlowerTypes.FirstOrDefault(x => x.Guid == item.ItemGuid); - CreateElement(item); + var editor = CreateElement(item); + InitBlowerItem(editor.BlowerItem); } else if (item is BreakSensorItem) { @@ -915,6 +926,27 @@ namespace Tango.MachineStudio.Technician.ViewModels #region Init Tech Items + /// + /// Initializes the blower item. + /// + /// The blower item. + private void InitBlowerItem(BlowerItem item) + { + item.SetCommandClicked += async (_, isActive) => + { + try + { + CheckMachineOperator(); + await MachineOperator.SetBlowerState((PMR.Hardware.HardwareBlowerType)item.HardwareBlower.HardwareBlowerType.Code, isActive, item.HardwareBlower.Voltage); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error executing SetBlowerState command for blower {item.HardwareBlower.HardwareBlowerType.Name}."); + _eventLogger.Log(ex, $"Error executing SetBlowerState command for blower {item.HardwareBlower.HardwareBlowerType.Name}."); + } + }; + } + /// /// Initializes the tech heater. /// @@ -1377,7 +1409,7 @@ namespace Tango.MachineStudio.Technician.ViewModels /// The controller item. private void InitControllerItem(ControllerItem item) { - item.ValueChanged += async (x, value) => + item.SetCommandClicked += async (_, __) => { try { @@ -1385,7 +1417,7 @@ namespace Tango.MachineStudio.Technician.ViewModels await MachineOperator.SetComponentValue(new SetComponentValueRequest() { Component = (ValueComponent)item.TechController.Code, - Value = value + Value = item.Value }); } catch (Exception ex) -- cgit v1.3.1