From c6b01f3e683b83fb0d6bf080efbd24a9a732b9f5 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 15 Jul 2018 13:22:53 +0300 Subject: Implemented process parameters item on machine studio tech board. --- .../Editors/ControllerElementEditor.xaml.cs | 1 + .../Editors/DancerElementEditor.xaml.cs | 1 + .../Editors/DigitalInElementEditor.xaml.cs | 1 + .../Editors/DigitalOutElementEditor.xaml.cs | 1 + .../Editors/DispenserElementEditor.xaml.cs | 1 + .../Editors/MeterElementEditor.xaml.cs | 1 + .../Editors/MonitorElementEditor.xaml.cs | 1 + .../Editors/MotorElementEditor.xaml.cs | 1 + .../Editors/MotorGroupElementEditor.xaml.cs | 1 + .../Editors/MultiGraphElementEditor.xaml.cs | 1 + .../Editors/PidElementEditor.xaml.cs | 1 + .../Editors/ProcessParametersElementEditor.xaml | 114 +++++++++++++ .../Editors/ProcessParametersElementEditor.xaml.cs | 182 +++++++++++++++++++++ .../Editors/SingleGraphElementEditor.xaml.cs | 1 + .../Editors/SpeedSensorElementEditor.xaml.cs | 1 + .../Editors/ThreadMotionElementEditor.xaml.cs | 1 + .../Editors/WinderElementEditor.xaml.cs | 1 + .../Images/process-params.png | Bin 0 -> 1491 bytes .../ProcessParametersTemplate.xaml | 45 +++++ .../ProcessParametersTemplate.xaml.cs | 28 ++++ .../Tango.MachineStudio.Technician.csproj | 22 +++ .../TechItems/ProcessParametersItem.cs | 133 +++++++++++++++ .../TechItems/TechItem.cs | 1 + .../ViewModels/MachineTechViewVM.cs | 46 +++++- .../Views/MachineTechView.xaml | 9 +- .../Tango.MachineStudio.UI/Resources/BuildDate.txt | 2 +- .../Visual_Studio/Tango.BL/ObservableEntity.cs | 24 +-- .../Visual_Studio/Tango.Core/IParameterized.cs | 2 +- .../Tango.Editors/CustomScrollViewer.cs | 5 +- .../Visual_Studio/Tango.Editors/ElementEditor.cs | 1 + .../Tango.Editors/FrameworkElementEditor.xaml.cs | 1 + .../Visual_Studio/Tango.Editors/IElementEditor.cs | 1 + .../Visual_Studio/Tango.Editors/IParameterized.cs | 52 ------ .../Tango.Editors/IParameterizedExtensions.cs | 124 -------------- .../Tango.Editors/ParameterIgnoreAttribute.cs | 17 -- .../Visual_Studio/Tango.Editors/ParameterItem.cs | 152 ----------------- .../Tango.Editors/ParameterItemAttribute.cs | 140 ---------------- .../Tango.Editors/ParameterItemMode.cs | 23 --- .../Tango.Editors/Tango.Editors.csproj | 6 - .../Editors/ParameterizedEditor.xaml | 2 +- 40 files changed, 613 insertions(+), 534 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ProcessParametersElementEditor.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ProcessParametersElementEditor.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/process-params.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/ProcessParametersTemplate.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/ProcessParametersTemplate.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/ProcessParametersItem.cs delete mode 100644 Software/Visual_Studio/Tango.Editors/IParameterized.cs delete mode 100644 Software/Visual_Studio/Tango.Editors/IParameterizedExtensions.cs delete mode 100644 Software/Visual_Studio/Tango.Editors/ParameterIgnoreAttribute.cs delete mode 100644 Software/Visual_Studio/Tango.Editors/ParameterItem.cs delete mode 100644 Software/Visual_Studio/Tango.Editors/ParameterItemAttribute.cs delete mode 100644 Software/Visual_Studio/Tango.Editors/ParameterItemMode.cs (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ControllerElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ControllerElementEditor.xaml.cs index 4d183dac6..af116a3f2 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ControllerElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ControllerElementEditor.xaml.cs @@ -18,6 +18,7 @@ using System.Windows.Shapes; using Tango.Editors; using Tango.BL.Entities; using Tango.MachineStudio.Technician.TechItems; +using Tango.Core; namespace Tango.MachineStudio.Technician.Editors { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DancerElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DancerElementEditor.xaml.cs index a83050194..4023f3334 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DancerElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DancerElementEditor.xaml.cs @@ -18,6 +18,7 @@ using System.Windows.Shapes; using Tango.Editors; using Tango.BL.Entities; using Tango.MachineStudio.Technician.TechItems; +using Tango.Core; namespace Tango.MachineStudio.Technician.Editors { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DigitalInElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DigitalInElementEditor.xaml.cs index 11a7a63ee..f1c6f69fa 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DigitalInElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DigitalInElementEditor.xaml.cs @@ -18,6 +18,7 @@ using System.Windows.Shapes; using Tango.Editors; using Tango.BL.Entities; using Tango.MachineStudio.Technician.TechItems; +using Tango.Core; namespace Tango.MachineStudio.Technician.Editors { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DigitalOutElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DigitalOutElementEditor.xaml.cs index 7738f5eb3..1a64e0483 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DigitalOutElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DigitalOutElementEditor.xaml.cs @@ -18,6 +18,7 @@ using System.Windows.Shapes; using Tango.Editors; using Tango.BL.Entities; using Tango.MachineStudio.Technician.TechItems; +using Tango.Core; namespace Tango.MachineStudio.Technician.Editors { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml.cs index 98bd4313b..ca686d3e2 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml.cs @@ -19,6 +19,7 @@ using System.Windows.Shapes; using Tango.Editors; using Tango.BL.Entities; using Tango.MachineStudio.Technician.TechItems; +using Tango.Core; namespace Tango.MachineStudio.Technician.Editors { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MeterElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MeterElementEditor.xaml.cs index 79a1e4c38..a4a56e13d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MeterElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MeterElementEditor.xaml.cs @@ -18,6 +18,7 @@ using System.Windows.Shapes; using Tango.Editors; using Tango.BL.Entities; using Tango.MachineStudio.Technician.TechItems; +using Tango.Core; namespace Tango.MachineStudio.Technician.Editors { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml.cs index 54fb2dc69..e1b7f9709 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml.cs @@ -18,6 +18,7 @@ using System.Windows.Shapes; using Tango.Editors; using Tango.BL.Entities; using Tango.MachineStudio.Technician.TechItems; +using Tango.Core; namespace Tango.MachineStudio.Technician.Editors { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml.cs index 7dacfddde..da65b9ab4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml.cs @@ -19,6 +19,7 @@ using System.Windows.Shapes; using Tango.Editors; using Tango.BL.Entities; using Tango.MachineStudio.Technician.TechItems; +using Tango.Core; namespace Tango.MachineStudio.Technician.Editors { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorGroupElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorGroupElementEditor.xaml.cs index f8cb5aab9..eaee03c2b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorGroupElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorGroupElementEditor.xaml.cs @@ -20,6 +20,7 @@ using Tango.Editors; using Tango.BL.Entities; using Tango.MachineStudio.Technician.TechItems; using Tango.SharedUI.Components; +using Tango.Core; namespace Tango.MachineStudio.Technician.Editors { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MultiGraphElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MultiGraphElementEditor.xaml.cs index d7c0da879..f24c77f1c 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MultiGraphElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MultiGraphElementEditor.xaml.cs @@ -18,6 +18,7 @@ using System.Windows.Shapes; using Tango.Editors; using Tango.BL.Entities; using Tango.MachineStudio.Technician.TechItems; +using Tango.Core; namespace Tango.MachineStudio.Technician.Editors { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/PidElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/PidElementEditor.xaml.cs index 7e7f9c131..f8cabca59 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/PidElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/PidElementEditor.xaml.cs @@ -18,6 +18,7 @@ using System.Windows.Shapes; using Tango.Editors; using Tango.BL.Entities; using Tango.MachineStudio.Technician.TechItems; +using Tango.Core; namespace Tango.MachineStudio.Technician.Editors { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ProcessParametersElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ProcessParametersElementEditor.xaml new file mode 100644 index 000000000..c1a76fe8a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ProcessParametersElementEditor.xaml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ProcessParametersElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ProcessParametersElementEditor.xaml.cs new file mode 100644 index 000000000..5f3cda494 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ProcessParametersElementEditor.xaml.cs @@ -0,0 +1,182 @@ +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; +using static Tango.MachineStudio.Technician.TechItems.ProcessParametersItem; +using Tango.SharedUI.Editors; + +namespace Tango.MachineStudio.Technician.Editors +{ + [ContentProperty("InnerContent")] + public partial class ProcessParametersElementEditor : ElementEditor + { + /// + /// Initializes a new instance of the class. + /// + public ProcessParametersElementEditor() + : base() + { + InitializeComponent(); + } + + /// + /// Initializes a new instance of the class. + /// + /// The framework element. + public ProcessParametersElementEditor(ProcessParametersItem processParametersItem) + : this() + { + ProcessParametersItem = processParametersItem; + DataContext = ProcessParametersItem; + } + + /// + /// Initializes a new instance of the class. + /// + /// The framework element. + /// The bounds. + public ProcessParametersElementEditor(ProcessParametersItem processParametersItem, Rect bounds) + : this(processParametersItem) + { + Left = bounds.Left; + Top = bounds.Top; + Width = bounds.Width; + Height = bounds.Height; + } + + private ProcessParametersItem _processParametersItem; + + public ProcessParametersItem ProcessParametersItem + { + get { return _processParametersItem; } + set { _processParametersItem = value; RaisePropertyChanged(nameof(ProcessParametersItem)); } + } + + + /// + /// Clones this instance. + /// + /// + public override IElementEditor Clone() + { + try + { + var clonedItem = ProcessParametersItem.Clone() as ProcessParametersItem; + ProcessParametersElementEditor cloned = new ProcessParametersElementEditor(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 ProcessParametersItem; } + } + + private void OnProcessParametersDropped(object sender, DragAndDrop.DropEventArgs e) + { + ParameterItem draggedItem = e.Draggable.DataContext as ParameterItem; + ParameterItem droppedItem = e.Droppable.DataContext as ParameterItem; + + if (draggedItem != null && droppedItem != null && draggedItem.ParameterizedObject == droppedItem.ParameterizedObject) + { + var parameters = draggedItem.ParameterizedObject.Parameters; + + var draggedSettingItem = ProcessParametersItem.ParametersIndices.FirstOrDefault(x => x.Name == draggedItem.Name); + var droppedSettingItem = ProcessParametersItem.ParametersIndices.FirstOrDefault(x => x.Name == droppedItem.Name); + + if (draggedSettingItem != null && droppedSettingItem != null) + { + if (draggedSettingItem.Index > droppedSettingItem.Index) + { + draggedSettingItem.Index = droppedSettingItem.Index - 1; + } + else + { + draggedSettingItem.Index = droppedSettingItem.Index + 1; + } + + int index = 1; + + foreach (var settingItem in ProcessParametersItem.ParametersIndices.OrderBy(x => x.Index)) + { + settingItem.Index = index++; + } + } + } + + var editor = e.Draggable.FindAncestor(); + + if (editor != null) + { + editor.ParameterizedObject = null; + editor.ParameterizedObject = draggedItem.ParameterizedObject; + } + } + + private void ParameterizedEditor_GeneratingItems(object sender, SharedUI.Editors.ParameterizedEditor.GeneratingItemsEventArgs e) + { + List items = e.Result.ToList(); + + if (ProcessParametersItem.ParametersIndices.Count > 0) + { + items.Clear(); + + foreach (var item in ProcessParametersItem.ParametersIndices.OrderBy(x => x.Index)) + { + var p = e.Source.SingleOrDefault(x => x.Name == item.Name); + + if (p != null) + { + items.Add(p); + } + } + } + else + { + ProcessParametersTable p = new ProcessParametersTable(); + var pp = p.CreateParametersCollection(Core.ParameterItemMode.Binding); + + foreach (var item in pp) + { + ProcessParametersItem.ParametersIndices.Add(new ParameterIndex() + { + Index = pp.IndexOf(item), + Name = item.Name + }); + } + } + + e.Result = items; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml.cs index 8ead4b6ee..694aaf5eb 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml.cs @@ -18,6 +18,7 @@ using System.Windows.Shapes; using Tango.Editors; using Tango.BL.Entities; using Tango.MachineStudio.Technician.TechItems; +using Tango.Core; namespace Tango.MachineStudio.Technician.Editors { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SpeedSensorElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SpeedSensorElementEditor.xaml.cs index 2909b52bc..d5855fe70 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SpeedSensorElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SpeedSensorElementEditor.xaml.cs @@ -18,6 +18,7 @@ using System.Windows.Shapes; using Tango.Editors; using Tango.BL.Entities; using Tango.MachineStudio.Technician.TechItems; +using Tango.Core; namespace Tango.MachineStudio.Technician.Editors { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ThreadMotionElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ThreadMotionElementEditor.xaml.cs index 6fca820b6..f5565a796 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ThreadMotionElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ThreadMotionElementEditor.xaml.cs @@ -19,6 +19,7 @@ using System.Windows.Shapes; using Tango.Editors; using Tango.BL.Entities; using Tango.MachineStudio.Technician.TechItems; +using Tango.Core; namespace Tango.MachineStudio.Technician.Editors { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/WinderElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/WinderElementEditor.xaml.cs index 5ccb05fc5..57aa30872 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/WinderElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/WinderElementEditor.xaml.cs @@ -18,6 +18,7 @@ using System.Windows.Shapes; using Tango.Editors; using Tango.BL.Entities; using Tango.MachineStudio.Technician.TechItems; +using Tango.Core; namespace Tango.MachineStudio.Technician.Editors { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/process-params.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/process-params.png new file mode 100644 index 000000000..f20eeb16c Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/process-params.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/ProcessParametersTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/ProcessParametersTemplate.xaml new file mode 100644 index 000000000..5e5a6d46d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/ProcessParametersTemplate.xaml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + Reset to RML + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/ProcessParametersTemplate.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/ProcessParametersTemplate.xaml.cs new file mode 100644 index 000000000..e1ad2f4ad --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/ProcessParametersTemplate.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 ProcessParametersTemplate : UserControl + { + public ProcessParametersTemplate() + { + 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 fb9b8869b..4c596e21e 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 @@ -96,6 +96,9 @@ ControllerElementEditor.xaml + + ProcessParametersElementEditor.xaml + DigitalInElementEditor.xaml @@ -161,6 +164,9 @@ DancerTemplate.xaml + + ProcessParametersTemplate.xaml + SpeedSensorTemplate.xaml @@ -192,6 +198,7 @@ + @@ -214,6 +221,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -298,6 +309,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -386,6 +401,10 @@ {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} Tango.Core + + {b112d89a-a106-41ae-a0c1-4abc84c477f5} + Tango.DragAndDrop + {de2f2b86-025b-4f26-83a4-38bd48224ed5} Tango.Editors @@ -519,5 +538,8 @@ + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/ProcessParametersItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/ProcessParametersItem.cs new file mode 100644 index 000000000..a6d3ae8f0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/ProcessParametersItem.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +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 +{ + /// + /// Represents a process parameters table item. + /// + /// + [TechItem(20)] + public class ProcessParametersItem : TechItem + { + public class ParameterIndex + { + public String Name { get; set; } + public int Index { get; set; } + } + + private static int _counter = 0; + + public event EventHandler PushParametersPressed; + + private String _displayName; + /// + /// Gets or sets the display name. + /// + public String DisplayName + { + get { return _displayName; } + set { _displayName = value; RaisePropertyChangedAuto(); } + } + + private ProcessParametersTable _processParameters; + /// + /// Gets or sets the process parameters. + /// + public ProcessParametersTable ProcessParameters + { + get { return _processParameters; } + set { _processParameters = value; RaisePropertyChangedAuto(); } + } + + /// + /// Gets or sets the parameters indices. + /// + public List ParametersIndices { get; set; } + + /// + /// Gets or sets the push parameters command. + /// + [XmlIgnore] + public RelayCommand PushParametersCommand { get; set; } + + private Rml _selectedResetRml; + /// + /// Gets or sets the selected reset RML. + /// + [XmlIgnore] + public Rml SelectedResetRML + { + get { return _selectedResetRml; } + set { _selectedResetRml = value; RaisePropertyChangedAuto(); ResetToRMLCommand.RaiseCanExecuteChanged(); } + } + + + /// + /// Gets or sets the push parameters command. + /// + [XmlIgnore] + public RelayCommand ResetToRMLCommand { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public ProcessParametersItem() : base() + { + ParametersIndices = new List(); + DisplayName = "Process parameters " + _counter++; + Name = "Process Parameters"; + Description = "Process parameters table"; + Image = ResourceHelper.GetImageFromResources("Images/process-params.png"); + ProcessParameters = new ProcessParametersTable(); + Color = Colors.DodgerBlue; + PushParametersCommand = new RelayCommand(() => PushParametersPressed?.Invoke(this, ProcessParameters)); + + ResetToRMLCommand = new RelayCommand(ResetToRml, () => SelectedResetRML != null); + } + + private void ResetToRml() + { + if (SelectedResetRML != null) + { + var group = SelectedResetRML.ProcessParametersTablesGroups.FirstOrDefault(x => x.Active); + + if (group != null) + { + var table = group.ProcessParametersTables.OrderBy(x => x.TableIndex).FirstOrDefault(); + + if (table != null) + { + ProcessParameters = table.Clone(); + } + } + } + } + + /// + /// Initializes a new instance of the class. + /// + /// The process parameters. + public ProcessParametersItem(ProcessParametersTable processParameters) : this() + { + + } + + public override TechItem Clone() + { + ProcessParametersItem cloned = base.Clone() as ProcessParametersItem; + cloned.ProcessParameters = ProcessParameters.Clone(); + cloned.ParametersIndices = ParametersIndices.Select(x => new ParameterIndex() { Index = x.Index, Name = x.Name }).ToList(); + return cloned; + } + + } +} 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 24ca57a4a..ff75c1644 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 @@ -34,6 +34,7 @@ namespace Tango.MachineStudio.Technician.TechItems [XmlInclude(typeof(WinderItem))] [XmlInclude(typeof(DancerItem))] [XmlInclude(typeof(SpeedSensorItem))] + [XmlInclude(typeof(ProcessParametersItem))] 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 381101c7e..41fff94d9 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 @@ -52,7 +52,7 @@ namespace Tango.MachineStudio.Technician.ViewModels private DateTime _lastDiagnosticsResponseUpdate; private const int MIN_DIAGNOSTICS_UPDATE_MILI = 500; private TechnicianModuleSettings _settings; - + #region Properties @@ -535,6 +535,11 @@ namespace Tango.MachineStudio.Technician.ViewModels { CreateElement(bounds, Adapter.HardwareSpeedSensorTypes.FirstOrDefault()); } + else if (item is ProcessParametersItem) + { + var editor = CreateElement(bounds, null); + InitProcessParameterItem(editor.ProcessParametersItem); + } } /// @@ -654,6 +659,11 @@ namespace Tango.MachineStudio.Technician.ViewModels (item as SpeedSensorItem).HardwareSpeedSensorType = Adapter.HardwareSpeedSensorTypes.FirstOrDefault(x => x.Guid == item.ItemGuid); CreateElement(item); } + else if (item is ProcessParametersItem) + { + var editor = CreateElement(item); + InitProcessParameterItem(editor.ProcessParametersItem); + } } /// @@ -1138,6 +1148,40 @@ namespace Tango.MachineStudio.Technician.ViewModels }; } + /// + /// Initializes the process parameter item. + /// + /// The item. + private void InitProcessParameterItem(ProcessParametersItem item) + { + item.PushParametersPressed += async (x, parameters) => + { + try + { + CheckMachineOperator(); + + using (_notification.PushTaskItem("Uploading process parameters...")) + { + try + { + await MachineOperator.UploadProcessParameters(parameters); + } + catch (Exception ex) + { + String msg = "Error uploading process parameters:" + Environment.NewLine + parameters.ToJsonString(); + _eventLogger.Log(ex,msg); + LogManager.Log(ex, msg); + _notification.ShowError("Could not upload process parameters." + Environment.NewLine + ex.Message); + } + } + } + catch (Exception ex) + { + _notification.ShowError(ex.Message); + } + }; + } + /// /// Checks the machine operator. /// 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 9843162de..5807341b7 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 @@ -155,7 +155,7 @@ -