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 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. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 15400960 -> 15400960 bytes Software/PMR/Messages/Common/MessageType.proto | 2 + .../Diagnostics/SetBlowerStateRequest.proto | 13 + .../Diagnostics/SetBlowerStateResponse.proto | 9 + .../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 ++- .../Controls/RealTimeGraphControl.xaml | 20 +- .../Controls/RealTimeGraphMultiControl.xaml | 20 +- .../Resources/MaterialDesign.xaml | 109 +++++++- .../Tango.Emulations/Emulators/MachineEmulator.cs | 34 ++- .../Operation/IMachineOperator.cs | 9 + .../Tango.Integration/Operation/MachineOperator.cs | 32 +++ .../Visual_Studio/Tango.PMR/Common/MessageType.cs | 43 ++-- .../Tango.PMR/Diagnostics/SetBlowerStateRequest.cs | 218 ++++++++++++++++ .../Diagnostics/SetBlowerStateResponse.cs | 131 ++++++++++ Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj | 2 + 27 files changed, 1033 insertions(+), 670 deletions(-) create mode 100644 Software/PMR/Messages/Diagnostics/SetBlowerStateRequest.proto create mode 100644 Software/PMR/Messages/Diagnostics/SetBlowerStateResponse.proto create mode 100644 Software/Visual_Studio/Tango.PMR/Diagnostics/SetBlowerStateRequest.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Diagnostics/SetBlowerStateResponse.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index db7b9f4f8..a0ba6351e 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 78312551b..7d419821a 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/PMR/Messages/Common/MessageType.proto b/Software/PMR/Messages/Common/MessageType.proto index 595a167ad..85ad16999 100644 --- a/Software/PMR/Messages/Common/MessageType.proto +++ b/Software/PMR/Messages/Common/MessageType.proto @@ -162,6 +162,8 @@ enum MessageType StopEventsNotificationResponse = 2033; SetHeaterStateRequest = 2034; SetHeaterStateResponse = 2035; + SetBlowerStateRequest = 2036; + SetBlowerStateResponse = 2037; //Printing diff --git a/Software/PMR/Messages/Diagnostics/SetBlowerStateRequest.proto b/Software/PMR/Messages/Diagnostics/SetBlowerStateRequest.proto new file mode 100644 index 000000000..f89c18269 --- /dev/null +++ b/Software/PMR/Messages/Diagnostics/SetBlowerStateRequest.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; + +import "HardwareBlowerType.proto"; + +package Tango.PMR.Diagnostics; +option java_package = "com.twine.tango.pmr.diagnostics"; + +message SetBlowerStateRequest +{ + PMR.Hardware.HardwareBlowerType BlowerType = 1; + double Voltage = 2; + bool IsActive = 3; +} \ No newline at end of file diff --git a/Software/PMR/Messages/Diagnostics/SetBlowerStateResponse.proto b/Software/PMR/Messages/Diagnostics/SetBlowerStateResponse.proto new file mode 100644 index 000000000..2409077e5 --- /dev/null +++ b/Software/PMR/Messages/Diagnostics/SetBlowerStateResponse.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Diagnostics; +option java_package = "com.twine.tango.pmr.diagnostics"; + +message SetBlowerStateResponse +{ + +} \ No newline at end of file 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) diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml index 33755f909..74ce549bf 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml @@ -56,29 +56,29 @@ - + - + - - + + - - - + + + - - + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml index 45b4aa9fb..c5ecf60d5 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml @@ -56,29 +56,29 @@ - + - + - - + + - - - + + + - - + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml index 6fcf6dd72..eea369dfe 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml @@ -199,7 +199,7 @@ Silver - #FFE9E9E9 + #FF464646 Gray #03A9F4 @@ -222,18 +222,18 @@ - - + + - - + + - - + + @@ -302,7 +302,7 @@ - + @@ -484,7 +484,100 @@ + + + + diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs index abeb1238b..d39842531 100644 --- a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs +++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs @@ -59,6 +59,7 @@ namespace Tango.Emulations.Emulators private bool _diagnostics_enabled; private bool _debug_logs_enabled; private bool _events_enabled; + private List _blower_states; #region Properties @@ -109,6 +110,7 @@ namespace Tango.Emulations.Emulators { EventsStates = MachineEventState.GetAllEventsStates(); + _blower_states = new List(); _heater_states = new List(); _continousResponseTokens = new List(); _motorJoggingRequestTypes = new List(); @@ -148,6 +150,14 @@ namespace Tango.Emulations.Emulators }); } + foreach (var item in adapter.HardwareBlowerTypes) + { + _blower_states.Add(new SetBlowerStateRequest() + { + BlowerType = (PMR.Hardware.HardwareBlowerType)item.Code, + }); + } + ResetGraphFactors(); } @@ -274,6 +284,9 @@ namespace Tango.Emulations.Emulators case MessageType.SetHeaterStateRequest: HandleSetHeaterStateRequest(MessageFactory.ParseTangoMessageFromContainer(container)); break; + case MessageType.SetBlowerStateRequest: + HandleSetBlowerStateRequest(MessageFactory.ParseTangoMessageFromContainer(container)); + break; } } @@ -331,7 +344,13 @@ namespace Tango.Emulations.Emulators { value++; monitors.Dancer1Angle.Add((int)(150 + _graphAmplitude * Math.Sin(2 * 3.14 * ((int)_graphFrequency) * value))); - monitors.BlowerVoltage.Add((int)(150 + _graphAmplitude * Math.Sin(2 * 3.14 * ((int)_graphFrequency) * value))); + } + + var blower_state = _blower_states.FirstOrDefault(); + + if (blower_state != null) + { + monitors.BlowerVoltage.Add(blower_state.IsActive ? blower_state.Voltage : 0); } monitors.Dancer2Angle.Add(Cursor.Position.Y); @@ -816,6 +835,19 @@ namespace Tango.Emulations.Emulators Transporter.SendResponse(new SetHeaterStateResponse(), request.Container.Token); } + private void HandleSetBlowerStateRequest(TangoMessage request) + { + var blower_state = _blower_states.FirstOrDefault(); + + if (blower_state != null) + { + blower_state.Voltage = request.Message.Voltage; + blower_state.IsActive = request.Message.IsActive; + } + + Transporter.SendResponse(new SetBlowerStateResponse(), request.Container.Token); + } + #endregion #region Public Methods diff --git a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs index ba8d0e085..01de74f5d 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs @@ -273,6 +273,15 @@ namespace Tango.Integration.Operation /// Task SetHeaterState(HeaterType heater, double setPoint); + /// + /// Sets the state of the specified blower. + /// + /// The blower. + /// Blower on/off. + /// The voltage in millivolts. + /// + Task SetBlowerState(PMR.Hardware.HardwareBlowerType blower, bool isActive, double voltage); + /// /// Resolves the specified event type. /// diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index ac264a8a4..01af2b3e3 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -1217,6 +1217,38 @@ namespace Tango.Integration.Operation return response; } + /// + /// Sets the state of the specified blower. + /// + /// The blower. + /// Blower on/off. + /// The voltage in millivolts. + /// + public async Task SetBlowerState(PMR.Hardware.HardwareBlowerType blower, bool isActive, double voltage) + { + SetBlowerStateResponse response = null; + SetBlowerStateRequest request = new SetBlowerStateRequest() + { + BlowerType = blower, + Voltage = voltage, + IsActive = isActive, + }; + + try + { + LogRequestSent(request); + response = await SendRequest(request); + LogResponseReceived(response); + } + catch (Exception ex) + { + LogRequestFailed(request, ex); + throw ex; + } + + return response; + } + /// /// Resolves the specified event type. /// diff --git a/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs b/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs index fbf6299d1..99697250d 100644 --- a/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs +++ b/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs @@ -22,7 +22,7 @@ namespace Tango.PMR.Common { static MessageTypeReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "ChFNZXNzYWdlVHlwZS5wcm90bxIQVGFuZ28uUE1SLkNvbW1vbirtJgoLTWVz", + "ChFNZXNzYWdlVHlwZS5wcm90bxIQVGFuZ28uUE1SLkNvbW1vbiqmJwoLTWVz", "c2FnZVR5cGUSCAoETm9uZRAAEhEKDUVycm9yUmVzcG9uc2UQARIUChBDYWxj", "dWxhdGVSZXF1ZXN0EAMSFQoRQ2FsY3VsYXRlUmVzcG9uc2UQBBITCg9Qcm9n", "cmVzc1JlcXVlc3QQBRIUChBQcm9ncmVzc1Jlc3BvbnNlEAYSHAoYU3R1YkNh", @@ -116,25 +116,26 @@ namespace Tango.PMR.Common { "Ch9TdGFydEV2ZW50c05vdGlmaWNhdGlvblJlc3BvbnNlEO8PEiIKHVN0b3BF", "dmVudHNOb3RpZmljYXRpb25SZXF1ZXN0EPAPEiMKHlN0b3BFdmVudHNOb3Rp", "ZmljYXRpb25SZXNwb25zZRDxDxIaChVTZXRIZWF0ZXJTdGF0ZVJlcXVlc3QQ", - "8g8SGwoWU2V0SGVhdGVyU3RhdGVSZXNwb25zZRDzDxIPCgpKb2JSZXF1ZXN0", - "ELgXEhAKC0pvYlJlc3BvbnNlELkXEhQKD0Fib3J0Sm9iUmVxdWVzdBC6FxIV", - "ChBBYm9ydEpvYlJlc3BvbnNlELsXEiMKHlVwbG9hZFByb2Nlc3NQYXJhbWV0", - "ZXJzUmVxdWVzdBC8FxIkCh9VcGxvYWRQcm9jZXNzUGFyYW1ldGVyc1Jlc3Bv", - "bnNlEL0XEhkKFFN0YXJ0RGVidWdMb2dSZXF1ZXN0EKAfEhoKFVN0YXJ0RGVi", - "dWdMb2dSZXNwb25zZRChHxIYChNTdG9wRGVidWdMb2dSZXF1ZXN0EKIfEhkK", - "FFN0b3BEZWJ1Z0xvZ1Jlc3BvbnNlEKMfEicKIlVwbG9hZEhhcmR3YXJlQ29u", - "ZmlndXJhdGlvblJlcXVlc3QQiCcSKAojVXBsb2FkSGFyZHdhcmVDb25maWd1", - "cmF0aW9uUmVzcG9uc2UQiScSFwoSU3lzdGVtUmVzZXRSZXF1ZXN0EIonEhgK", - "E1N5c3RlbVJlc2V0UmVzcG9uc2UQiycSFQoQS2VlcEFsaXZlUmVxdWVzdBDw", - "LhIWChFLZWVwQWxpdmVSZXNwb25zZRDxLhITCg5Db25uZWN0UmVxdWVzdBDy", - "LhIUCg9Db25uZWN0UmVzcG9uc2UQ8y4SFgoRRGlzY29ubmVjdFJlcXVlc3QQ", - "9C4SFwoSRGlzY29ubmVjdFJlc3BvbnNlEPUuEhYKEUZpbGVVcGxvYWRSZXF1", - "ZXN0ENg2EhcKEkZpbGVVcGxvYWRSZXNwb25zZRDZNhIbChZGaWxlQ2h1bmtV", - "cGxvYWRSZXF1ZXN0ENo2EhwKF0ZpbGVDaHVua1VwbG9hZFJlc3BvbnNlENs2", - "EhoKFUV4ZWN1dGVQcm9jZXNzUmVxdWVzdBDcNhIbChZFeGVjdXRlUHJvY2Vz", - "c1Jlc3BvbnNlEN02EhcKEktpbGxQcm9jZXNzUmVxdWVzdBDeNhIYChNLaWxs", - "UHJvY2Vzc1Jlc3BvbnNlEN82QhwKGmNvbS50d2luZS50YW5nby5wbXIuY29t", - "bW9uYgZwcm90bzM=")); + "8g8SGwoWU2V0SGVhdGVyU3RhdGVSZXNwb25zZRDzDxIaChVTZXRCbG93ZXJT", + "dGF0ZVJlcXVlc3QQ9A8SGwoWU2V0Qmxvd2VyU3RhdGVSZXNwb25zZRD1DxIP", + "CgpKb2JSZXF1ZXN0ELgXEhAKC0pvYlJlc3BvbnNlELkXEhQKD0Fib3J0Sm9i", + "UmVxdWVzdBC6FxIVChBBYm9ydEpvYlJlc3BvbnNlELsXEiMKHlVwbG9hZFBy", + "b2Nlc3NQYXJhbWV0ZXJzUmVxdWVzdBC8FxIkCh9VcGxvYWRQcm9jZXNzUGFy", + "YW1ldGVyc1Jlc3BvbnNlEL0XEhkKFFN0YXJ0RGVidWdMb2dSZXF1ZXN0EKAf", + "EhoKFVN0YXJ0RGVidWdMb2dSZXNwb25zZRChHxIYChNTdG9wRGVidWdMb2dS", + "ZXF1ZXN0EKIfEhkKFFN0b3BEZWJ1Z0xvZ1Jlc3BvbnNlEKMfEicKIlVwbG9h", + "ZEhhcmR3YXJlQ29uZmlndXJhdGlvblJlcXVlc3QQiCcSKAojVXBsb2FkSGFy", + "ZHdhcmVDb25maWd1cmF0aW9uUmVzcG9uc2UQiScSFwoSU3lzdGVtUmVzZXRS", + "ZXF1ZXN0EIonEhgKE1N5c3RlbVJlc2V0UmVzcG9uc2UQiycSFQoQS2VlcEFs", + "aXZlUmVxdWVzdBDwLhIWChFLZWVwQWxpdmVSZXNwb25zZRDxLhITCg5Db25u", + "ZWN0UmVxdWVzdBDyLhIUCg9Db25uZWN0UmVzcG9uc2UQ8y4SFgoRRGlzY29u", + "bmVjdFJlcXVlc3QQ9C4SFwoSRGlzY29ubmVjdFJlc3BvbnNlEPUuEhYKEUZp", + "bGVVcGxvYWRSZXF1ZXN0ENg2EhcKEkZpbGVVcGxvYWRSZXNwb25zZRDZNhIb", + "ChZGaWxlQ2h1bmtVcGxvYWRSZXF1ZXN0ENo2EhwKF0ZpbGVDaHVua1VwbG9h", + "ZFJlc3BvbnNlENs2EhoKFUV4ZWN1dGVQcm9jZXNzUmVxdWVzdBDcNhIbChZF", + "eGVjdXRlUHJvY2Vzc1Jlc3BvbnNlEN02EhcKEktpbGxQcm9jZXNzUmVxdWVz", + "dBDeNhIYChNLaWxsUHJvY2Vzc1Jlc3BvbnNlEN82QhwKGmNvbS50d2luZS50", + "YW5nby5wbXIuY29tbW9uYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Tango.PMR.Common.MessageType), }, null)); @@ -302,6 +303,8 @@ namespace Tango.PMR.Common { [pbr::OriginalName("StopEventsNotificationResponse")] StopEventsNotificationResponse = 2033, [pbr::OriginalName("SetHeaterStateRequest")] SetHeaterStateRequest = 2034, [pbr::OriginalName("SetHeaterStateResponse")] SetHeaterStateResponse = 2035, + [pbr::OriginalName("SetBlowerStateRequest")] SetBlowerStateRequest = 2036, + [pbr::OriginalName("SetBlowerStateResponse")] SetBlowerStateResponse = 2037, /// ///Printing /// diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/SetBlowerStateRequest.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/SetBlowerStateRequest.cs new file mode 100644 index 000000000..f0d22b881 --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/SetBlowerStateRequest.cs @@ -0,0 +1,218 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: SetBlowerStateRequest.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Diagnostics { + + /// Holder for reflection information generated from SetBlowerStateRequest.proto + public static partial class SetBlowerStateRequestReflection { + + #region Descriptor + /// File descriptor for SetBlowerStateRequest.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static SetBlowerStateRequestReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChtTZXRCbG93ZXJTdGF0ZVJlcXVlc3QucHJvdG8SFVRhbmdvLlBNUi5EaWFn", + "bm9zdGljcxoYSGFyZHdhcmVCbG93ZXJUeXBlLnByb3RvInYKFVNldEJsb3dl", + "clN0YXRlUmVxdWVzdBI6CgpCbG93ZXJUeXBlGAEgASgOMiYuVGFuZ28uUE1S", + "LkhhcmR3YXJlLkhhcmR3YXJlQmxvd2VyVHlwZRIPCgdWb2x0YWdlGAIgASgB", + "EhAKCElzQWN0aXZlGAMgASgIQiEKH2NvbS50d2luZS50YW5nby5wbXIuZGlh", + "Z25vc3RpY3NiBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { global::Tango.PMR.Hardware.HardwareBlowerTypeReflection.Descriptor, }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Diagnostics.SetBlowerStateRequest), global::Tango.PMR.Diagnostics.SetBlowerStateRequest.Parser, new[]{ "BlowerType", "Voltage", "IsActive" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class SetBlowerStateRequest : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SetBlowerStateRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Diagnostics.SetBlowerStateRequestReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SetBlowerStateRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SetBlowerStateRequest(SetBlowerStateRequest other) : this() { + blowerType_ = other.blowerType_; + voltage_ = other.voltage_; + isActive_ = other.isActive_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SetBlowerStateRequest Clone() { + return new SetBlowerStateRequest(this); + } + + /// Field number for the "BlowerType" field. + public const int BlowerTypeFieldNumber = 1; + private global::Tango.PMR.Hardware.HardwareBlowerType blowerType_ = 0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Tango.PMR.Hardware.HardwareBlowerType BlowerType { + get { return blowerType_; } + set { + blowerType_ = value; + } + } + + /// Field number for the "Voltage" field. + public const int VoltageFieldNumber = 2; + private double voltage_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double Voltage { + get { return voltage_; } + set { + voltage_ = value; + } + } + + /// Field number for the "IsActive" field. + public const int IsActiveFieldNumber = 3; + private bool isActive_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool IsActive { + get { return isActive_; } + set { + isActive_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as SetBlowerStateRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(SetBlowerStateRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (BlowerType != other.BlowerType) return false; + if (Voltage != other.Voltage) return false; + if (IsActive != other.IsActive) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (BlowerType != 0) hash ^= BlowerType.GetHashCode(); + if (Voltage != 0D) hash ^= Voltage.GetHashCode(); + if (IsActive != false) hash ^= IsActive.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (BlowerType != 0) { + output.WriteRawTag(8); + output.WriteEnum((int) BlowerType); + } + if (Voltage != 0D) { + output.WriteRawTag(17); + output.WriteDouble(Voltage); + } + if (IsActive != false) { + output.WriteRawTag(24); + output.WriteBool(IsActive); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (BlowerType != 0) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) BlowerType); + } + if (Voltage != 0D) { + size += 1 + 8; + } + if (IsActive != false) { + size += 1 + 1; + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(SetBlowerStateRequest other) { + if (other == null) { + return; + } + if (other.BlowerType != 0) { + BlowerType = other.BlowerType; + } + if (other.Voltage != 0D) { + Voltage = other.Voltage; + } + if (other.IsActive != false) { + IsActive = other.IsActive; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + blowerType_ = (global::Tango.PMR.Hardware.HardwareBlowerType) input.ReadEnum(); + break; + } + case 17: { + Voltage = input.ReadDouble(); + break; + } + case 24: { + IsActive = input.ReadBool(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/SetBlowerStateResponse.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/SetBlowerStateResponse.cs new file mode 100644 index 000000000..9c5670f07 --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/SetBlowerStateResponse.cs @@ -0,0 +1,131 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: SetBlowerStateResponse.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Diagnostics { + + /// Holder for reflection information generated from SetBlowerStateResponse.proto + public static partial class SetBlowerStateResponseReflection { + + #region Descriptor + /// File descriptor for SetBlowerStateResponse.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static SetBlowerStateResponseReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChxTZXRCbG93ZXJTdGF0ZVJlc3BvbnNlLnByb3RvEhVUYW5nby5QTVIuRGlh", + "Z25vc3RpY3MiGAoWU2V0Qmxvd2VyU3RhdGVSZXNwb25zZUIhCh9jb20udHdp", + "bmUudGFuZ28ucG1yLmRpYWdub3N0aWNzYgZwcm90bzM=")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Diagnostics.SetBlowerStateResponse), global::Tango.PMR.Diagnostics.SetBlowerStateResponse.Parser, null, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class SetBlowerStateResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SetBlowerStateResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Diagnostics.SetBlowerStateResponseReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SetBlowerStateResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SetBlowerStateResponse(SetBlowerStateResponse other) : this() { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SetBlowerStateResponse Clone() { + return new SetBlowerStateResponse(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as SetBlowerStateResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(SetBlowerStateResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(SetBlowerStateResponse other) { + if (other == null) { + return; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj index c2480d8c0..06aebdb3e 100644 --- a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj +++ b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj @@ -99,6 +99,8 @@ + + -- cgit v1.3.1 From 3e4bec71b356231134ccb1b52d8faf264c57c6a1 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 26 Sep 2018 11:07:32 +0300 Subject: Working on new tech module tabs. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 15400960 -> 15400960 bytes .../Project/MachineTechViewProject.cs | 4 +- .../Project/MachineTechViewProjectTab.cs | 20 + .../Tango.MachineStudio.Technician.csproj | 9 + .../ViewModels/MachineTechTabVM.cs | 62 +++ .../ViewModels/MachineTechViewVM.cs | 84 ++-- .../Views/MachineTechTabView.xaml | 13 + .../Views/MachineTechTabView.xaml.cs | 28 ++ .../Views/MachineTechView.xaml | 435 ++++++++++++--------- .../Views/MachineTechView.xaml.cs | 10 +- .../Tango.Editors/ElementsEditor.xaml | 12 +- .../Tango.Editors/ElementsEditor.xaml.cs | 12 +- 13 files changed, 456 insertions(+), 233 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Project/MachineTechViewProjectTab.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechTabVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechTabView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechTabView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index a0ba6351e..15b63d95f 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 7d419821a..d14575ea3 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Project/MachineTechViewProject.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Project/MachineTechViewProject.cs index 700e04f7d..0837fde53 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Project/MachineTechViewProject.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Project/MachineTechViewProject.cs @@ -10,11 +10,11 @@ namespace Tango.MachineStudio.Technician.Project { public class MachineTechViewProject { - public List Items { get; set; } + public List Tabs { get; set; } public MachineTechViewProject() { - Items = new List(); + Tabs = new List(); } public void Save(String fileName) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Project/MachineTechViewProjectTab.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Project/MachineTechViewProjectTab.cs new file mode 100644 index 000000000..c86e1ae55 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Project/MachineTechViewProjectTab.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.MachineStudio.Technician.TechItems; + +namespace Tango.MachineStudio.Technician.Project +{ + public class MachineTechViewProjectTab + { + public String Name { get; set; } + public List Items { get; set; } + + public MachineTechViewProjectTab() + { + Items = new List(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj index 2c6a08554..4df317c6a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj @@ -171,6 +171,7 @@ + HeaterTemplate.xaml @@ -261,7 +262,11 @@ + + + MachineTechTabView.xaml + MachineTechView.xaml @@ -437,6 +442,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechTabVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechTabVM.cs new file mode 100644 index 000000000..4e04a078c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechTabVM.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Editors; +using Tango.SharedUI; + +namespace Tango.MachineStudio.Technician.ViewModels +{ + public class MachineTechTabVM : ViewModel + { + private ElementsEditor _editor; + + public ElementsEditor Editor + { + get { return _editor; } + set { _editor = value; RaisePropertyChangedAuto(); } + } + + private String _name; + /// + /// Gets or sets the name. + /// + public String Name + { + get { return _name; } + set { _name = value; RaisePropertyChangedAuto(); } + } + + private bool _isSelected; + /// + /// Gets or sets a value indicating whether this instance is selected. + /// + public bool IsSelected + { + get { return _isSelected; } + set { _isSelected = value; RaisePropertyChangedAuto(); } + } + + + private ObservableCollection _elements; + /// + /// Gets or sets the visual elements. + /// + public ObservableCollection Elements + { + get { return _elements; } + set { _elements = value; RaisePropertyChangedAuto(); } + } + + /// + /// Initializes a new instance of the class. + /// + public MachineTechTabVM() + { + Name = "untitled"; + Elements = new ObservableCollection(); + } + } +} 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 6a9725106..85a431594 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 @@ -61,14 +61,35 @@ namespace Tango.MachineStudio.Technician.ViewModels #region Properties - private ObservableCollection _elements; + private ObservableCollection _tabs; /// - /// Gets or sets the visual elements. + /// Gets or sets the elements tabs. /// - public ObservableCollection Elements + public ObservableCollection Tabs { - get { return _elements; } - set { _elements = value; RaisePropertyChangedAuto(); } + get { return _tabs; } + set { _tabs = value; RaisePropertyChangedAuto(); } + } + + private MachineTechTabVM _selectedTab; + /// + /// Gets or sets the selected tab. + /// + public MachineTechTabVM SelectedTab + { + get { return _selectedTab; } + set + { + _selectedTab = value; + RaisePropertyChangedAuto(); + + foreach (var tab in Tabs.Where(x => x != _selectedTab)) + { + tab.IsSelected = false; + } + + _selectedTab.IsSelected = true; + } } private ObservableCollection _availableTechItems; @@ -223,6 +244,10 @@ namespace Tango.MachineStudio.Technician.ViewModels /// The notification provider. public MachineTechViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IEventLogger eventLogger) { + Tabs = new ObservableCollection(); + Tabs.Add(new MachineTechTabVM() { IsSelected = true }); + SelectedTab = Tabs.First(); + _settings = SettingsManager.Default.GetOrCreate(); _single_graphs_recordings = new List>(); @@ -242,7 +267,6 @@ namespace Tango.MachineStudio.Technician.ViewModels ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; Adapter = ObservablesStaticCollections.Instance; - Elements = new ObservableCollection(); OpenProjectCommand = new RelayCommand(OpenProject); SaveAsProjectCommand = new RelayCommand(SaveAsProject); @@ -325,7 +349,7 @@ namespace Tango.MachineStudio.Technician.ViewModels lock (_elementsLock) { - var elements = Elements.ToList(); + var elements = Tabs.SelectMany(x => x.Elements).ToList(); foreach (var item in elements.Select(x => x.HostedElement as TechItem)) { @@ -680,7 +704,7 @@ namespace Tango.MachineStudio.Technician.ViewModels { TechItem item = Activator.CreateInstance(typeof(Tech), new object[] { value }) as TechItem; IElementEditor editor = Activator.CreateInstance(typeof(Editor), new object[] { ((Tech)item), bounds }) as IElementEditor; - Elements.Add(editor); + SelectedTab.Elements.Add(editor); return (Editor)editor; } @@ -693,7 +717,7 @@ namespace Tango.MachineStudio.Technician.ViewModels private Editor CreateElement(TechItem item) where Editor : IElementEditor { IElementEditor editor = Activator.CreateInstance(typeof(Editor), new object[] { item, item.GetBounds() }) as IElementEditor; - Elements.Add(editor); + SelectedTab.Elements.Add(editor); return (Editor)editor; } @@ -1555,18 +1579,26 @@ namespace Tango.MachineStudio.Technician.ViewModels { using (_notification.PushTaskItem("Loading technician project file...")) { - Elements.Clear(); + Tabs.Clear(); _singleControllers.Clear(); _multiControllers.Clear(); - foreach (var item in project.Items) + foreach (var tab in project.Tabs) { - if (item is MotorGroupItem) + MachineTechTabVM t = new MachineTechTabVM(); + t.Name = tab.Name; + t.IsSelected = true; + Tabs.Add(t); + + foreach (var item in tab.Items) { - (item as MotorGroupItem).TechMotors = ObservablesStaticCollections.Instance.HardwareMotorTypes.Where(x => (item as MotorGroupItem).ItemsGuids.Contains(x.Guid)).ToObservableCollection(); - } + if (item is MotorGroupItem) + { + (item as MotorGroupItem).TechMotors = ObservablesStaticCollections.Instance.HardwareMotorTypes.Where(x => (item as MotorGroupItem).ItemsGuids.Contains(x.Guid)).ToObservableCollection(); + } - AddTechItem(item); + AddTechItem(item); + } } } } @@ -1623,16 +1655,24 @@ namespace Tango.MachineStudio.Technician.ViewModels { MachineTechViewProject project = new MachineTechViewProject(); - foreach (var element in Elements) + foreach (var tab in Tabs) { - if (element.HostedElement is MotorGroupItem) + MachineTechViewProjectTab pTab = new MachineTechViewProjectTab(); + pTab.Name = tab.Name; + + foreach (var element in tab.Elements) { - var group = element.HostedElement as MotorGroupItem; - group.ItemsGuids = group.TechMotors.Select(x => x.Guid).ToList(); + if (element.HostedElement is MotorGroupItem) + { + var group = element.HostedElement as MotorGroupItem; + group.ItemsGuids = group.TechMotors.Select(x => x.Guid).ToList(); + } + + (element.HostedElement as TechItem).SetBounds(element.GetBounds()); + pTab.Items.Add(element.HostedElement as TechItem); } - (element.HostedElement as TechItem).SetBounds(element.GetBounds()); - project.Items.Add(element.HostedElement as TechItem); + project.Tabs.Add(pTab); } return project; @@ -1673,7 +1713,7 @@ namespace Tango.MachineStudio.Technician.ViewModels private void SyncHardwareConfiguration() { - var elements = Elements.ToList(); + var elements = Tabs.SelectMany(x => x.Elements).ToList(); if (MachineOperator != null && MachineOperator.CurrentHardwareConfiguration != null) { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechTabView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechTabView.xaml new file mode 100644 index 000000000..fc14343a2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechTabView.xaml @@ -0,0 +1,13 @@ + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechTabView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechTabView.xaml.cs new file mode 100644 index 000000000..38b1ae045 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechTabView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.Technician.Views +{ + /// + /// Interaction logic for MachineTechTabView.xaml + /// + public partial class MachineTechTabView : UserControl + { + public MachineTechTabView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml index ea833db99..99ecf72f2 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml @@ -22,6 +22,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -192,7 +287,7 @@ - + @@ -258,210 +353,160 @@ - - - - - + + + + + - + + + + + + + + + + + + + + + + + + - + - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - + + + + + + + + Left + + + + Top + + + - - - - - - - - Left - - - - Top - - - + + + + Width + + + + Height + + + - - - - Width - - - - Height - - - + + + + + + + Angle + + + + + + + - - - - - - - Angle - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs index 977974f8a..694debd26 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs @@ -32,8 +32,6 @@ namespace Tango.MachineStudio.Technician.Views { _vm = DataContext as MachineTechViewVM; }; - - (editor.UndoRedoStatesProvider as ElementsEditorUndoRedoStatesProvider).StateExecuted += MachineTechView_StateExecuted; } private void MachineTechView_StateExecuted(object sender, UndoRedoStateExecutedEventArgs e) @@ -61,5 +59,13 @@ namespace Tango.MachineStudio.Technician.Views { //editor.DeselectElements(); } + + private void Editor_Loaded(object sender, RoutedEventArgs e) + { + ElementsEditor editor = sender as ElementsEditor; + (editor.DataContext as MachineTechTabVM).Editor = editor; + + (editor.UndoRedoStatesProvider as ElementsEditorUndoRedoStatesProvider).StateExecuted += MachineTechView_StateExecuted; + } } } diff --git a/Software/Visual_Studio/Tango.Editors/ElementsEditor.xaml b/Software/Visual_Studio/Tango.Editors/ElementsEditor.xaml index 19db3992d..3d1bedc46 100644 --- a/Software/Visual_Studio/Tango.Editors/ElementsEditor.xaml +++ b/Software/Visual_Studio/Tango.Editors/ElementsEditor.xaml @@ -7,7 +7,7 @@ xmlns:converters="clr-namespace:Tango.Editors.Converters" xmlns:core="clr-namespace:Tango.Editors" mc:Ignorable="d" - x:Name="editor" Foreground="White" Background="#151515" FontSize="8" FocusVisualStyle="{x:Null}"> + x:Name="editor" FontSize="8" FocusVisualStyle="{x:Null}"> @@ -129,7 +129,7 @@ - + @@ -137,13 +137,13 @@ - - + - + @@ -181,7 +181,7 @@ - + + + + + + + + + + + + + - - - - - - - - - - - + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml index 74ce549bf..bf2e41afa 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml @@ -56,13 +56,13 @@ - + - + @@ -72,8 +72,8 @@ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml index c5ecf60d5..4976739e4 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml @@ -56,13 +56,13 @@ - + - + @@ -72,8 +72,8 @@ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml index eea369dfe..acddeec6e 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml @@ -251,7 +251,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.xaml.cs index d774c14eb..bc11dfd18 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.xaml.cs @@ -26,6 +26,14 @@ namespace Tango.MachineStudio.UI.Notifications { InitializeComponent(); this.Loaded += TextInputBoxWindow_Loaded; + + ContentRendered += TextInputBoxWindow_ContentRendered; + } + + private void TextInputBoxWindow_ContentRendered(object sender, EventArgs e) + { + txtText.Focus(); + txtText.SelectAll(); } private void TextInputBoxWindow_Loaded(object sender, RoutedEventArgs e) @@ -34,12 +42,8 @@ namespace Tango.MachineStudio.UI.Notifications ani.To = 1; ani.Duration = TimeSpan.FromSeconds(0.5); this.BeginAnimation(Window.OpacityProperty, ani); - - txtText.Focus(); } - - public String Hint { get { return (String)GetValue(HintProperty); } -- cgit v1.3.1 From 62aaf350dd5645c3778a0a40ea3ff66280e1bf8c Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 26 Sep 2018 19:55:00 +0300 Subject: Implemented Monitor Recorder element !!! --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 15400960 -> 15400960 bytes Software/Graphics/csv.png | Bin 0 -> 1650 bytes .../Editors/MonitorRecorderElementEditor.xaml | 167 +++++++++++++++++++++ .../Editors/MonitorRecorderElementEditor.xaml.cs | 103 +++++++++++++ .../Tango.MachineStudio.Technician/Images/csv.png | Bin 0 -> 1650 bytes .../Models/MultiTechRecordingData.cs | 6 +- .../Models/SingleTechRecordingData.cs | 6 +- .../Models/TechRecordingData.cs | 23 ++- .../MonitorRecorderTemplate.xaml | 42 ++++++ .../MonitorRecorderTemplate.xaml.cs | 28 ++++ .../Tango.MachineStudio.Technician.csproj | 27 ++++ .../TechItems/MonitorRecorderItem.cs | 131 ++++++++++++++++ .../TechItems/MultiGraphItem.cs | 20 ++- .../TechItems/SingleGraphItem.cs | 20 ++- .../TechItems/TechItem.cs | 1 + .../ViewModels/MachineTechViewVM.cs | 155 ++++++++++++++----- .../Views/MachineTechView.xaml | 3 + .../Tango.MachineStudio.Technician/packages.config | 2 + .../Tango.MachineStudio.UI/App.config | 28 ++++ 20 files changed, 696 insertions(+), 66 deletions(-) create mode 100644 Software/Graphics/csv.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorRecorderElementEditor.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorRecorderElementEditor.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/csv.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorRecorderTemplate.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorRecorderTemplate.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorRecorderItem.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 6cabf0be2..fb69b7a48 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 8bca8ebd2..0487b6d9c 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Graphics/csv.png b/Software/Graphics/csv.png new file mode 100644 index 000000000..5f03ac6bd Binary files /dev/null and b/Software/Graphics/csv.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorRecorderElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorRecorderElementEditor.xaml new file mode 100644 index 000000000..ce9675103 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorRecorderElementEditor.xaml @@ -0,0 +1,167 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + selected monitors to record + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorRecorderElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorRecorderElementEditor.xaml.cs new file mode 100644 index 000000000..213fa78e0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorRecorderElementEditor.xaml.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.Editors; +using Tango.BL.Entities; +using Tango.MachineStudio.Technician.TechItems; +using Tango.Core; + +namespace Tango.MachineStudio.Technician.Editors +{ + [ContentProperty("InnerContent")] + public partial class MonitorRecorderElementEditor : ElementEditor + { + /// + /// Initializes a new instance of the class. + /// + public MonitorRecorderElementEditor() + : base() + { + InitializeComponent(); + } + + /// + /// Initializes a new instance of the class. + /// + /// The framework element. + public MonitorRecorderElementEditor(MonitorRecorderItem monitorRecorderItem) + : this() + { + MonitorRecorderItem = monitorRecorderItem; + DataContext = MonitorRecorderItem; + } + + /// + /// Initializes a new instance of the class. + /// + /// The framework element. + /// The bounds. + public MonitorRecorderElementEditor(MonitorRecorderItem monitorRecorderItem, Rect bounds) + : this(monitorRecorderItem) + { + Left = bounds.Left; + Top = bounds.Top; + Width = bounds.Width; + Height = bounds.Height; + } + + private MonitorRecorderItem _monitorRecorderItem; + + public MonitorRecorderItem MonitorRecorderItem + { + get { return _monitorRecorderItem; } + set { _monitorRecorderItem = value; RaisePropertyChanged(nameof(MonitorRecorderItem)); } + } + + + /// + /// Clones this instance. + /// + /// + public override IElementEditor Clone() + { + try + { + var clonedItem = MonitorRecorderItem.Clone() as MonitorRecorderItem; + MonitorRecorderElementEditor cloned = new MonitorRecorderElementEditor(clonedItem); + cloned.Top = Top; + cloned.Left = Left; + cloned.Width = Width; + cloned.Height = Height; + cloned.Angle = Angle; + return cloned; + } + catch (Exception ex) + { + throw new InvalidOperationException("Could not clone this editor. You may have to create a custom editor and implement a custom Clone method.", ex); + } + } + + /// + /// Gets the hosted element. + /// + [ParameterIgnore] + public override Object HostedElement + { + get { return MonitorRecorderItem; } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/csv.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/csv.png new file mode 100644 index 000000000..5f03ac6bd Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/csv.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/MultiTechRecordingData.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/MultiTechRecordingData.cs index e9471fa74..ad3ea1352 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/MultiTechRecordingData.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/MultiTechRecordingData.cs @@ -11,11 +11,11 @@ using Tango.MachineStudio.Technician.TechItems; namespace Tango.MachineStudio.Technician.Models { - public class MultiTechRecordingData : TechRecordingData where T : TechItem + public class MultiTechRecordingData : TechRecordingData { public int ChannelCount { get; set; } - public MultiTechRecordingData(T techItem, int channel_count) : base(techItem) + public MultiTechRecordingData(String name, int channel_count, String fileName) : base(name, fileName) { ChannelCount = channel_count; Init(); @@ -54,7 +54,7 @@ namespace Tango.MachineStudio.Technician.Models protected override List GetColumnNames() { - return Enumerable.Range(1, ChannelCount).Select(x => TechItem.TechName + " " + x).ToList(); + return Enumerable.Range(1, ChannelCount).Select(x => Name + " " + x).ToList(); } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/SingleTechRecordingData.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/SingleTechRecordingData.cs index 7aa9a2b3f..8b480bbf3 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/SingleTechRecordingData.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/SingleTechRecordingData.cs @@ -7,9 +7,9 @@ using Tango.MachineStudio.Technician.TechItems; namespace Tango.MachineStudio.Technician.Models { - public class SingleTechRecordingData : TechRecordingData where T : TechItem + public class SingleTechRecordingData : TechRecordingData { - public SingleTechRecordingData(T techItem) : base(techItem) + public SingleTechRecordingData(String name, String fileName) : base(name, fileName) { Init(); } @@ -35,7 +35,7 @@ namespace Tango.MachineStudio.Technician.Models protected override List GetColumnNames() { - return new List() { TechItem.TechName }; + return new List() { Name }; } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/TechRecordingData.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/TechRecordingData.cs index 8024a1375..7b6439dbf 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/TechRecordingData.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Models/TechRecordingData.cs @@ -11,7 +11,7 @@ using Tango.MachineStudio.Technician.TechItems; namespace Tango.MachineStudio.Technician.Models { - public abstract class TechRecordingData : ExtendedObject, IDisposable where T : TechItem where TValue : TechRecordingValue + public abstract class TechRecordingData : ExtendedObject, IDisposable where TValue : TechRecordingValue { protected bool _initialized; @@ -20,16 +20,18 @@ namespace Tango.MachineStudio.Technician.Models public CsvFile CsvFile { get; set; } - public TemporaryFile TemporaryFile { get; set; } + public String File { get; set; } - public T TechItem { get; set; } + public String Name { get; set; } - public TechRecordingData(T techItem) + public Object Tag { get; set; } + + public TechRecordingData(String name, String fileName) { + File = fileName; _start_time = DateTime.Now; _last_time = DateTime.Now; - TechItem = techItem; - TemporaryFile = TemporaryManager.CreateFile(".csv"); + Name = name; } protected void Init() @@ -37,20 +39,13 @@ namespace Tango.MachineStudio.Technician.Models CsvDefinition definition = new CsvDefinition(); definition.Columns = new List() { "Time" }.Concat(GetColumnNames()); - CsvFile = new CsvFile(new CsvDestination(TemporaryFile), definition); + CsvFile = new CsvFile(new CsvDestination(File), definition); _initialized = true; } - public void Save(String fileName) - { - CsvFile.Dispose(); - File.Copy(TemporaryFile.Path, fileName, true); - } - public void Dispose() { CsvFile.Dispose(); - TemporaryFile.Delete(); } protected abstract List GetColumnNames(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorRecorderTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorRecorderTemplate.xaml new file mode 100644 index 000000000..023191656 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorRecorderTemplate.xaml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorRecorderTemplate.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorRecorderTemplate.xaml.cs new file mode 100644 index 000000000..011e108cb --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorRecorderTemplate.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.Technician.PropertiesTemplates +{ + /// + /// Interaction logic for MonitorTemplate.xaml + /// + public partial class MonitorRecorderTemplate : UserControl + { + public MonitorRecorderTemplate() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj index 0d9cd5b63..d937ca15b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj @@ -52,6 +52,15 @@ ..\..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll + + ..\..\..\packages\Microsoft.WindowsAPICodePack-Core.1.1.0.0\lib\Microsoft.WindowsAPICodePack.dll + + + ..\..\..\packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.Shell.dll + + + ..\..\..\packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.ShellExtensions.dll + @@ -101,6 +110,9 @@ + + MonitorRecorderElementEditor.xaml + HeaterElementEditor.xaml @@ -173,6 +185,9 @@ + + MonitorRecorderTemplate.xaml + HeaterTemplate.xaml @@ -244,6 +259,7 @@ + @@ -268,6 +284,10 @@ MachineTechView.xaml + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -352,6 +372,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -658,6 +682,9 @@ + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorRecorderItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorRecorderItem.cs new file mode 100644 index 000000000..e2b62092d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorRecorderItem.cs @@ -0,0 +1,131 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using System.Windows.Threading; +using System.Xml.Serialization; +using Tango.BL.Entities; +using Tango.Core.Commands; +using Tango.SharedUI.Components; +using Tango.SharedUI.Helpers; + +namespace Tango.MachineStudio.Technician.TechItems +{ + [TechItem(25)] + public class MonitorRecorderItem : TechItem + { + private DispatcherTimer _timer; + private DateTime _recording_start_time; + + public event Action RecordingStarted; + public event Action RecordingStopped; + + /// + /// Gets or sets the monitors. + /// + [XmlIgnore] + public SelectedObjectCollection Monitors { get; set; } + + private bool _isRecording; + /// + /// Gets or sets a value indicating whether this instance is recording. + /// + [XmlIgnore] + public bool IsRecording + { + get { return _isRecording; } + set { _isRecording = value; RaisePropertyChangedAuto(); } + } + + private TimeSpan _recordingTime; + [XmlIgnore] + public TimeSpan RecordingTime + { + get { return _recordingTime; } + set { _recordingTime = value; RaisePropertyChangedAuto(); } + } + + private bool _isPaused; + [XmlIgnore] + public bool IsPaused + { + get { return _isPaused; } + set { _isPaused = value; RaisePropertyChangedAuto(); } + } + + + /// + /// Gets or sets the toggle recording command. + /// + [XmlIgnore] + public RelayCommand ToggleRecordingCommand { get; set; } + + [XmlIgnore] + public RelayCommand TogglePauseCommand { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public MonitorRecorderItem() : base() + { + _timer = new DispatcherTimer(); + _timer.Tick += _timer_Tick; + _timer.Interval = TimeSpan.FromSeconds(1); + + Monitors = new SelectedObjectCollection(Adapter.TechMonitors.ToObservableCollection(), new ObservableCollection()); + Name = "CSV Recorder"; + Description = "Record multiple monitors to a CSV file"; + Image = ResourceHelper.GetImageFromResources("Images/csv.png"); + Color = Colors.White; + + ToggleRecordingCommand = new RelayCommand(ToggleRecording); + TogglePauseCommand = new RelayCommand(() => { IsPaused = !IsPaused; }); + } + + public MonitorRecorderItem(object dummy) : this() + { + + } + + private void _timer_Tick(object sender, EventArgs e) + { + RecordingTime = DateTime.Now - _recording_start_time; + } + + private void ToggleRecording() + { + if (!IsRecording) + { + RecordingStarted?.Invoke(); + } + else + { + RecordingStopped?.Invoke(); + } + } + + public void StartRecording() + { + _recording_start_time = DateTime.Now; + IsRecording = true; + IsPaused = false; + _timer.Start(); + } + + public void StopRecording() + { + _timer.Stop(); + IsPaused = false; + IsRecording = false; + RecordingTime = TimeSpan.FromSeconds(0); + } + + public List GetSelectedMonitors() + { + return Monitors.SynchedSource.ToList(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MultiGraphItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MultiGraphItem.cs index 5a3bd0327..a935ee5a6 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MultiGraphItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MultiGraphItem.cs @@ -191,20 +191,28 @@ namespace Tango.MachineStudio.Technician.TechItems { if (!IsRecording) { - _recording_start_time = DateTime.Now; - IsRecording = true; - _timer.Start(); RecordingStarted?.Invoke(); } else { - _timer.Stop(); - IsRecording = false; - RecordingTime = TimeSpan.FromSeconds(0); RecordingStopped?.Invoke(); } } + public void StartRecording() + { + _recording_start_time = DateTime.Now; + IsRecording = true; + _timer.Start(); + } + + public void StopRecording() + { + _timer.Stop(); + IsRecording = false; + RecordingTime = TimeSpan.FromSeconds(0); + } + /// /// Initializes a new instance of the class. /// diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/SingleGraphItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/SingleGraphItem.cs index aa404b215..87d971233 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/SingleGraphItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/SingleGraphItem.cs @@ -184,20 +184,28 @@ namespace Tango.MachineStudio.Technician.TechItems { if (!IsRecording) { - _recording_start_time = DateTime.Now; - IsRecording = true; - _timer.Start(); RecordingStarted?.Invoke(); } else { - _timer.Stop(); - IsRecording = false; - RecordingTime = TimeSpan.FromSeconds(0); RecordingStopped?.Invoke(); } } + public void StartRecording() + { + _recording_start_time = DateTime.Now; + IsRecording = true; + _timer.Start(); + } + + public void StopRecording() + { + _timer.Stop(); + IsRecording = false; + RecordingTime = TimeSpan.FromSeconds(0); + } + /// /// Initializes a new instance of the class. /// diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs index 0d7568d68..6fa00ae0a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/TechItem.cs @@ -40,6 +40,7 @@ namespace Tango.MachineStudio.Technician.TechItems [XmlInclude(typeof(JobRunnerItem))] [XmlInclude(typeof(TextItem))] [XmlInclude(typeof(HeaterItem))] + [XmlInclude(typeof(MonitorRecorderItem))] public abstract class TechItem : ExtendedObject { /// 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 738e871c9..9051b5fa9 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 @@ -34,6 +34,7 @@ using Tango.Core.Commands; using Tango.MachineStudio.Technician.Helpers; using Tango.MachineStudio.Technician.Models; using Tango.Logging; +using Microsoft.WindowsAPICodePack.Dialogs; namespace Tango.MachineStudio.Technician.ViewModels { @@ -56,8 +57,10 @@ namespace Tango.MachineStudio.Technician.ViewModels private const int MIN_DIAGNOSTICS_UPDATE_MILI = 500; private TechnicianModuleSettings _settings; - private List> _single_graphs_recordings; - private List> _multi_graph_recordings; + private List _single_graphs_recordings; + private List _multi_graph_recordings; + private List _single_monitors_recordings; + private List _multi_monitors_recordings; #region Properties @@ -276,8 +279,11 @@ namespace Tango.MachineStudio.Technician.ViewModels _settings = SettingsManager.Default.GetOrCreate(); - _single_graphs_recordings = new List>(); - _multi_graph_recordings = new List>(); + _single_graphs_recordings = new List(); + _multi_graph_recordings = new List(); + + _single_monitors_recordings = new List(); + _multi_monitors_recordings = new List(); GraphsDurationSeconds = _settings.GraphsDuration; TempGraphsDurationSeconds = GraphsDurationSeconds; @@ -378,6 +384,28 @@ namespace Tango.MachineStudio.Technician.ViewModels } + foreach (var sr in _single_monitors_recordings) + { + var prop = _diagnoticsMonitorsDataProperties.SingleOrDefault(x => x.Name == (sr.Tag as TechMonitor).Name); + + if (prop != null) + { + var points = GetDataArray((sr.Tag as TechMonitor), prop.GetValue(data.Monitors)); + sr.PushData(points); + } + } + + foreach (var mr in _multi_monitors_recordings) + { + var prop = _diagnoticsMonitorsDataProperties.SingleOrDefault(x => x.Name == (mr.Tag as TechMonitor).Name); + + if (prop != null) + { + var points = GetDataMatrix((mr.Tag as TechMonitor), prop.GetValue(data.Monitors)); + mr.PushData(points); + } + } + lock (_elementsLock) { var elements = Tabs.SelectMany(x => x.Elements).ToList(); @@ -435,7 +463,7 @@ namespace Tango.MachineStudio.Technician.ViewModels controller.PushData(points); - var _graph_recording = _single_graphs_recordings.SingleOrDefault(x => x.TechItem == graphItem); + var _graph_recording = _single_graphs_recordings.SingleOrDefault(x => x.Tag == graphItem); if (_graph_recording != null) { _graph_recording.PushData(points); @@ -469,7 +497,7 @@ namespace Tango.MachineStudio.Technician.ViewModels controller.PushData(points); - var _graph_recording = _multi_graph_recordings.SingleOrDefault(x => x.TechItem == graphItem); + var _graph_recording = _multi_graph_recordings.SingleOrDefault(x => x.Tag == graphItem); if (_graph_recording != null) { _graph_recording.PushData(points); @@ -720,6 +748,11 @@ namespace Tango.MachineStudio.Technician.ViewModels { CreateElement(bounds, null); } + else if (item is MonitorRecorderItem) + { + var editor = CreateElement(bounds, null); + InitMonitorRecorderItem(editor.MonitorRecorderItem); + } } /// @@ -869,6 +902,10 @@ namespace Tango.MachineStudio.Technician.ViewModels { CreateElement(item); } + else if (item is MonitorRecorderItem) + { + CreateElement(item); + } } /// @@ -881,20 +918,24 @@ namespace Tango.MachineStudio.Technician.ViewModels { if (element.HostedElement is SingleGraphItem) { - var _graph_recording = _single_graphs_recordings.SingleOrDefault(x => x.TechItem == element.HostedElement); + var _graph_recording = _single_graphs_recordings.SingleOrDefault(x => x.Tag == element.HostedElement); if (_graph_recording != null) { + (_graph_recording.Tag as SingleGraphItem).StopRecording(); _single_graphs_recordings.Remove(_graph_recording); + _graph_recording.Dispose(); } } else if (element.HostedElement is MultiGraphItem) { - var _graph_recording = _multi_graph_recordings.SingleOrDefault(x => x.TechItem == element.HostedElement); + var _graph_recording = _multi_graph_recordings.SingleOrDefault(x => x.Tag == element.HostedElement); if (_graph_recording != null) { + (_graph_recording.Tag as MultiGraphItem).StopRecording(); _multi_graph_recordings.Remove(_graph_recording); + _graph_recording.Dispose(); } } } @@ -981,6 +1022,50 @@ namespace Tango.MachineStudio.Technician.ViewModels #region Init Tech Items + private void InitMonitorRecorderItem(MonitorRecorderItem item) + { + item.RecordingStarted += () => + { + CommonOpenFileDialog dlg = new CommonOpenFileDialog(); + dlg.Title = "Select a folder to place all CSV files."; + dlg.IsFolderPicker = true; + if (dlg.ShowDialog() == CommonFileDialogResult.Ok) + { + foreach (var monitor in item.GetSelectedMonitors()) + { + if (!monitor.MultiChannel) + { + _single_monitors_recordings.Add(new SingleTechRecordingData(monitor.Name, dlg.FileName + "\\" + monitor.Name + ".csv") { Tag = monitor }); + } + else + { + _multi_monitors_recordings.Add(new MultiTechRecordingData(monitor.Name, monitor.ChannelCount, dlg.FileName + "\\" + monitor.Name + ".csv") { Tag = monitor }); + } + item.StartRecording(); + } + } + }; + + item.RecordingStopped += () => + { + item.StopRecording(); + + foreach (var sr in _single_monitors_recordings) + { + sr.Dispose(); + } + + _single_monitors_recordings.Clear(); + + foreach (var mr in _multi_monitors_recordings) + { + mr.Dispose(); + } + + _multi_monitors_recordings.Clear(); + }; + } + /// /// Initializes the blower item. /// @@ -1222,29 +1307,30 @@ namespace Tango.MachineStudio.Technician.ViewModels item.RecordingStarted += () => { - _single_graphs_recordings.Add(new SingleTechRecordingData(item)); + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Title = "Save graph data as csv file"; + dlg.Filter = "CSV Files|*.csv"; + dlg.DefaultExt = ".csv"; + dlg.FileName = item.TechName; + if (dlg.ShowDialog().Value) + { + _single_graphs_recordings.Add(new SingleTechRecordingData(item.TechName, dlg.FileName) { Tag = item }); + item.StartRecording(); + } }; item.RecordingStopped += () => { try { - var graph_recording = _single_graphs_recordings.SingleOrDefault(x => x.TechItem == item); + item.StopRecording(); + + var graph_recording = _single_graphs_recordings.SingleOrDefault(x => x.Tag == item); if (graph_recording != null) { _single_graphs_recordings.Remove(graph_recording); - - SaveFileDialog dlg = new SaveFileDialog(); - dlg.Title = "Save graph data as csv file"; - dlg.Filter = "CSV Files|*.csv"; - dlg.DefaultExt = ".csv"; - dlg.FileName = item.TechName; - if (dlg.ShowDialog().Value) - { - graph_recording.Save(dlg.FileName); - graph_recording.Dispose(); - } + graph_recording.Dispose(); } } catch (Exception ex) @@ -1282,29 +1368,30 @@ namespace Tango.MachineStudio.Technician.ViewModels item.RecordingStarted += () => { - _multi_graph_recordings.Add(new MultiTechRecordingData(item, item.TechMonitor.ChannelCount)); + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Title = "Save graph data as csv file"; + dlg.Filter = "CSV Files|*.csv"; + dlg.DefaultExt = ".csv"; + dlg.FileName = item.TechName; + if (dlg.ShowDialog().Value) + { + _multi_graph_recordings.Add(new MultiTechRecordingData(item.TechName, item.TechMonitor.ChannelCount, dlg.FileName) { Tag = item }); + item.StartRecording(); + } }; item.RecordingStopped += () => { try { - var graph_recording = _multi_graph_recordings.SingleOrDefault(x => x.TechItem == item); + item.StopRecording(); + + var graph_recording = _multi_graph_recordings.SingleOrDefault(x => x.Tag == item); if (graph_recording != null) { _multi_graph_recordings.Remove(graph_recording); - - SaveFileDialog dlg = new SaveFileDialog(); - dlg.Title = "Save graph data as csv file"; - dlg.Filter = "CSV Files|*.csv"; - dlg.DefaultExt = ".csv"; - dlg.FileName = item.TechName; - if (dlg.ShowDialog().Value) - { - graph_recording.Save(dlg.FileName); - graph_recording.Dispose(); - } + graph_recording.Dispose(); } } catch (Exception ex) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml index 9e675b2ff..ac207fc55 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml @@ -489,6 +489,9 @@ + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/packages.config index ea48e62ff..adee6f7b4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/packages.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/packages.config @@ -8,6 +8,8 @@ + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config index 4147a78ec..0395c36bb 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config @@ -87,6 +87,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.3.1 From 79be5ab4903b98e2960913d7b07ec49d14410b27 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 27 Sep 2018 17:59:51 +0300 Subject: Working on RML module. Fixed issue with CSV trying to add rows after dispose was called. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 15400960 -> 15400960 bytes .../Tango.MachineStudio.RML.csproj | 14 +++++++++++ .../ViewModels/MainViewVM.cs | 14 ++++++----- .../Tango.MachineStudio.RML/Views/RmlView.xaml | 14 +++++++++++ .../Tango.MachineStudio.RML/Views/RmlView.xaml.cs | 28 +++++++++++++++++++++ .../Tango.MachineStudio.RML/Views/RmlsView.xaml | 14 +++++++++++ .../Tango.MachineStudio.RML/Views/RmlsView.xaml.cs | 28 +++++++++++++++++++++ .../ViewModels/MachineTechViewVM.cs | 17 +++++++------ Software/Visual_Studio/Tango.CSV/CsvFile.cs | 11 +++++--- 10 files changed, 124 insertions(+), 16 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 1202fb0bd..fdf00e2cd 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index fa9d8431c..62a4048b7 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj index d9e0d5cf1..fcd933f4b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj @@ -85,6 +85,12 @@ MainView.xaml + + RmlsView.xaml + + + RmlView.xaml + ResXFileCodeGenerator Resources.Designer.cs @@ -138,6 +144,14 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs index ff42d870c..9e108d0a8 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs @@ -50,12 +50,15 @@ namespace Tango.MachineStudio.RML.ViewModels LoadRmls(); } - private void LoadRmls() + private async void LoadRmls() { - using (_rmls_context = ObservablesContext.CreateDefault()) - { - Rmls = _rmls.ToList().ToObservableCollection(); - } + //using (_rmls_context = ObservablesContext.CreateDefault()) + //{ + // await Task.Factory.StartNew(() => + // { + // Rmls = _rmls.ToList().ToObservableCollection(); + // }); + //} } private void OnSelectedRmlChanged() @@ -89,7 +92,6 @@ namespace Tango.MachineStudio.RML.ViewModels ActiveRML = await new RmlBuilder(_active_context) .Set(guid) .WithAllParametersGroup() - .WithCCT() .WithLiquidFactors() .BuildAsync(); } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml new file mode 100644 index 000000000..92b8506f5 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml @@ -0,0 +1,14 @@ + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml.cs new file mode 100644 index 000000000..e01654243 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.RML.Views +{ + /// + /// Interaction logic for RmlView.xaml + /// + public partial class RmlView : UserControl + { + public RmlView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml new file mode 100644 index 000000000..2ba5e44c9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml @@ -0,0 +1,14 @@ + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml.cs new file mode 100644 index 000000000..66f52d8c8 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.RML.Views +{ + /// + /// Interaction logic for RmlsView.xaml + /// + public partial class RmlsView : UserControl + { + public RmlsView() + { + InitializeComponent(); + } + } +} 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 9051b5fa9..2ca5aa43b 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 @@ -383,25 +383,28 @@ namespace Tango.MachineStudio.Technician.ViewModels CurrentDiagnosticsResponseSize = data.CalculateSize(); } - foreach (var sr in _single_monitors_recordings) { - var prop = _diagnoticsMonitorsDataProperties.SingleOrDefault(x => x.Name == (sr.Tag as TechMonitor).Name); + var techMonitor = (sr.Tag as TechMonitor); + + var prop = _diagnoticsMonitorsDataProperties.SingleOrDefault(x => x.Name == techMonitor.Name); if (prop != null) { - var points = GetDataArray((sr.Tag as TechMonitor), prop.GetValue(data.Monitors)); + var points = GetDataArray(techMonitor, prop.GetValue(data.Monitors)); sr.PushData(points); } } foreach (var mr in _multi_monitors_recordings) { - var prop = _diagnoticsMonitorsDataProperties.SingleOrDefault(x => x.Name == (mr.Tag as TechMonitor).Name); + var techMonitor = (mr.Tag as TechMonitor); + + var prop = _diagnoticsMonitorsDataProperties.SingleOrDefault(x => x.Name == techMonitor.Name); if (prop != null) { - var points = GetDataMatrix((mr.Tag as TechMonitor), prop.GetValue(data.Monitors)); + var points = GetDataMatrix(techMonitor, prop.GetValue(data.Monitors)); mr.PushData(points); } } @@ -1035,11 +1038,11 @@ namespace Tango.MachineStudio.Technician.ViewModels { if (!monitor.MultiChannel) { - _single_monitors_recordings.Add(new SingleTechRecordingData(monitor.Name, dlg.FileName + "\\" + monitor.Name + ".csv") { Tag = monitor }); + _single_monitors_recordings.Add(new SingleTechRecordingData(monitor.Name, dlg.FileName + "\\" + monitor.Description + ".csv") { Tag = monitor }); } else { - _multi_monitors_recordings.Add(new MultiTechRecordingData(monitor.Name, monitor.ChannelCount, dlg.FileName + "\\" + monitor.Name + ".csv") { Tag = monitor }); + _multi_monitors_recordings.Add(new MultiTechRecordingData(monitor.Name, monitor.ChannelCount, dlg.FileName + "\\" + monitor.Description + ".csv") { Tag = monitor }); } item.StartRecording(); } diff --git a/Software/Visual_Studio/Tango.CSV/CsvFile.cs b/Software/Visual_Studio/Tango.CSV/CsvFile.cs index 8a908b6d8..d180f0139 100644 --- a/Software/Visual_Studio/Tango.CSV/CsvFile.cs +++ b/Software/Visual_Studio/Tango.CSV/CsvFile.cs @@ -19,6 +19,8 @@ namespace Tango.CSV /// public class CsvFile : IDisposable { + protected bool _is_disposed; + internal protected Stream BaseStream; protected static DateTime DateTimeZero = new DateTime(); @@ -190,6 +192,7 @@ namespace Tango.CSV { if (disposing) { + _is_disposed = true; // free managed resources addAsyncTask.Wait(); if (csvLinesToWrite != null) @@ -243,15 +246,17 @@ namespace Tango.CSV /// The record. public void Append(T record) { - if (CsvFile.UseTasks) { var linesWaiting = Interlocked.Increment(ref this.linesToWrite); Action addRecord = (t) => { - var csvLine = this.ToCsv(record); - this.csvLinesToWrite.Add(csvLine); + if (!_is_disposed) + { + var csvLine = this.ToCsv(record); + this.csvLinesToWrite.Add(csvLine); + } }; if (linesWaiting < 10000) -- cgit v1.3.1