From f8e1ff79cc2fa09b52093c6e029392b3456ad8bb Mon Sep 17 00:00:00 2001 From: Roy Date: Sat, 10 Feb 2018 17:27:37 +0200 Subject: Added dispensers support on technician module. --- .../Editors/DispenserElementEditor.xaml | 288 +++++++++++++++++++++ .../Editors/DispenserElementEditor.xaml.cs | 181 +++++++++++++ .../Editors/MeterElementEditor.xaml | 6 +- .../Editors/MonitorElementEditor.xaml | 4 +- .../Editors/MotorElementEditor.xaml | 50 ++-- .../Editors/MultiGraphElementEditor.xaml | 4 +- .../Editors/SingleGraphElementEditor.xaml | 4 +- .../Images/dispenser-big.png | Bin 0 -> 1580 bytes .../Images/dispenser-line.png | Bin 0 -> 36326 bytes .../Images/volume.png | Bin 0 -> 1929 bytes .../PropertiesTemplates/DispenserTemplate.xaml | 44 ++++ .../PropertiesTemplates/DispenserTemplate.xaml.cs | 28 ++ .../PropertiesTemplates/MotorTemplate.xaml | 44 ++++ .../PropertiesTemplates/MotorTemplate.xaml.cs | 28 ++ .../Tango.MachineStudio.Technician.csproj | 47 ++++ .../TechItems/DispenserItem.cs | 127 +++++++++ .../TechItems/MeterItem.cs | 2 +- .../TechItems/MotorItem.cs | 10 + .../ViewModels/MachineTechViewVM.cs | 122 +++++++-- .../Views/MachineTechView.xaml | 33 ++- .../Tango.MachineStudio.Technician/packages.config | 6 + .../Controls/RealTimeGraphControl.xaml | 2 +- .../Controls/RealTimeGraphMultiControl.xaml | 2 +- 23 files changed, 987 insertions(+), 45 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/dispenser-big.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/dispenser-line.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/volume.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/DispenserTemplate.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/DispenserTemplate.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MotorTemplate.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MotorTemplate.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/DispenserItem.cs (limited to 'Software/Visual_Studio/MachineStudio') 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 new file mode 100644 index 000000000..b84da3b42 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml @@ -0,0 +1,288 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 new file mode 100644 index 000000000..ef6e4c47c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml.cs @@ -0,0 +1,181 @@ +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.Animation; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.Editors; +using Tango.Integration.Observables; +using Tango.MachineStudio.Technician.TechItems; + +namespace Tango.MachineStudio.Technician.Editors +{ + [ContentProperty("InnerContent")] + public partial class DispenserElementEditor : ElementEditor + { + /// + /// Initializes a new instance of the class. + /// + public DispenserElementEditor() + : base() + { + InitializeComponent(); + } + + /// + /// Initializes a new instance of the class. + /// + /// The framework element. + public DispenserElementEditor(DispenserItem dispenserItem) + : this() + { + DispenserItem = dispenserItem; + DataContext = DispenserItem; + } + + /// + /// Initializes a new instance of the class. + /// + /// The framework element. + /// The bounds. + public DispenserElementEditor(DispenserItem monitorItem, Rect bounds) + : this(monitorItem) + { + Left = bounds.Left; + Top = bounds.Top; + Width = bounds.Width; + Height = bounds.Height; + } + + private DispenserItem _monitorItem; + + public DispenserItem DispenserItem + { + get { return _monitorItem; } + set + { + _monitorItem = value; RaisePropertyChanged(nameof(DispenserItem)); + + if (_monitorItem != null) + { + _monitorItem.HomingCompleted -= _monitorItem_HomingCompleted; + _monitorItem.HomingCompleted += _monitorItem_HomingCompleted; + } + } + } + + private void _monitorItem_HomingCompleted(object sender, EventArgs e) + { + StopAnimation(); + } + + + /// + /// Clones this instance. + /// + /// + public override IElementEditor Clone() + { + try + { + var clonedItem = DispenserItem.Clone() as DispenserItem; + DispenserElementEditor cloned = new DispenserElementEditor(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 DispenserItem; } + } + + private void OnForwardPressed(object sender, MouseButtonEventArgs e) + { + DispenserItem.RaiseAction(MotorActionType.ForwardPressed); + AnimateRight(); + } + + private void OnForwardReleased(object sender, MouseButtonEventArgs e) + { + DispenserItem.RaiseAction(MotorActionType.ForwardReleased); + StopAnimation(); + } + + private void OnBackwardPressed(object sender, MouseButtonEventArgs e) + { + DispenserItem.RaiseAction(MotorActionType.BackwardPressed); + AnimateLeft(); + } + + private void OnBackwardReleased(object sender, MouseButtonEventArgs e) + { + DispenserItem.RaiseAction(MotorActionType.BackwardReleased); + StopAnimation(); + } + + private void OnHomingStarted(object sender, RoutedEventArgs e) + { + DispenserItem.RaiseAction(MotorActionType.HomingStarted); + AnimateLeft(); + } + + private void OnHomingStopped(object sender, RoutedEventArgs e) + { + DispenserItem.RaiseAction(MotorActionType.HomingStopped); + StopAnimation(); + } + + private void AnimateRight() + { + DoubleAnimation ani = new DoubleAnimation(); + ani.Duration = TimeSpan.FromSeconds(1); + ani.RepeatBehavior = RepeatBehavior.Forever; + ani.FillBehavior = FillBehavior.HoldEnd; + ani.To = 360; + propRotate.BeginAnimation(RotateTransform.AngleProperty, ani); + } + + private void AnimateLeft() + { + DoubleAnimation ani = new DoubleAnimation(); + ani.Duration = TimeSpan.FromSeconds(1); + ani.RepeatBehavior = RepeatBehavior.Forever; + ani.FillBehavior = FillBehavior.HoldEnd; + ani.To = -360; + propRotate.BeginAnimation(RotateTransform.AngleProperty, ani); + } + + public void StopAnimation() + { + this.Dispatcher.Invoke(() => + { + propRotate.BeginAnimation(RotateTransform.AngleProperty, null); + }); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MeterElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MeterElementEditor.xaml index 8a9345fa9..98ace7816 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MeterElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MeterElementEditor.xaml @@ -3,6 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + 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" @@ -12,6 +13,7 @@ + @@ -26,13 +28,13 @@ - + - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml index 8e4520cc5..081a853bb 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml @@ -5,12 +5,14 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems" xmlns:converters="clr-namespace:Tango.Editors.Converters;assembly=Tango.Editors" + xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:local="clr-namespace:Tango.Editors;assembly=Tango.Editors" mc:Ignorable="d" d:DesignHeight="250" d:DesignWidth="300" Background="Transparent" ClipToBounds="False" BorderThickness="0" MinWidth="1" MinHeight="1" RenderTransformOrigin="0.5,0.5" d:DataContext="{d:DesignInstance Type=items:MonitorItem, IsDesignTimeCreatable=False}"> + @@ -25,7 +27,7 @@ - + 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 bf7aaeff4..a69f81538 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 @@ -5,6 +5,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems" + xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" 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" @@ -13,6 +14,7 @@ + @@ -20,10 +22,12 @@ - - + + + @@ -42,7 +46,7 @@ - + @@ -55,27 +59,35 @@ - + - - - - - + + + + + + + + + + + + + - + - + - + - + @@ -158,13 +170,13 @@ - + + + + + + + + Selected Motor + + + Speed + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/DispenserTemplate.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/DispenserTemplate.xaml.cs new file mode 100644 index 000000000..dd3a21b07 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/DispenserTemplate.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 DispenserTemplate : UserControl + { + public DispenserTemplate() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MotorTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MotorTemplate.xaml new file mode 100644 index 000000000..0d92230ad --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MotorTemplate.xaml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + Selected Motor + + + Speed + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MotorTemplate.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MotorTemplate.xaml.cs new file mode 100644 index 000000000..3ac58ce5d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MotorTemplate.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 MotorTemplate : UserControl + { + public MotorTemplate() + { + 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 0f92b6275..34208aded 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 @@ -60,6 +60,22 @@ + + ..\..\..\packages\System.Reactive.Core.3.1.1\lib\net46\System.Reactive.Core.dll + + + ..\..\..\packages\System.Reactive.Interfaces.3.1.1\lib\net45\System.Reactive.Interfaces.dll + + + ..\..\..\packages\System.Reactive.Linq.3.1.1\lib\net46\System.Reactive.Linq.dll + + + ..\..\..\packages\System.Reactive.PlatformServices.3.1.1\lib\net46\System.Reactive.PlatformServices.dll + + + ..\..\..\packages\System.Reactive.Windows.Threading.3.1.1\lib\net45\System.Reactive.Windows.Threading.dll + + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll @@ -81,6 +97,9 @@ + + DispenserElementEditor.xaml + MotorElementEditor.xaml @@ -100,6 +119,12 @@ MeterTemplate.xaml + + DispenserTemplate.xaml + + + MotorTemplate.xaml + MonitorTemplate.xaml @@ -111,6 +136,7 @@ + @@ -141,6 +167,10 @@ GlobalVersionInfo.cs + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -165,6 +195,14 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + Designer MSBuild:Compile @@ -311,5 +349,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/DispenserItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/DispenserItem.cs new file mode 100644 index 000000000..3cea8d127 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/DispenserItem.cs @@ -0,0 +1,127 @@ +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.Core.Commands; +using Tango.Integration.Observables; +using Tango.SharedUI.Helpers; + +namespace Tango.MachineStudio.Technician.TechItems +{ + public class DispenserItem : TechItem + { + public event EventHandler ActionExecuted; + public event EventHandler HomingCompleted; + + private TechDispenser _techDispenser; + [XmlIgnore] + public TechDispenser TechDispenser + { + get { return _techDispenser; } + set { _techDispenser = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(Data)); } + } + + private bool _isHoming; + [XmlIgnore] + public bool IsHoming + { + get { return _isHoming; } + set + { + _isHoming = value; + RaisePropertyChangedAuto(); + } + } + + private bool _isHomingCompleted; + + public bool IsHomingCompleted + { + get { return _isHomingCompleted; } + set + { + _isHomingCompleted = value; + RaisePropertyChangedAuto(); + + if (value) + { + HomingCompleted?.Invoke(this, new EventArgs()); + } + } + } + + private double _homingProgress; + [XmlIgnore] + public double HomingProgress + { + get { return _homingProgress; } + set + { + _homingProgress = value; + RaisePropertyChangedAuto(); + } + } + + private double _homingMaximumProgress; + [XmlIgnore] + public double HomingMaximumProgress + { + get { return _homingMaximumProgress; } + set { _homingMaximumProgress = value; RaisePropertyChangedAuto(); } + } + + private bool _isForwardPressed; + [XmlIgnore] + public bool IsForwardPressed + { + get { return _isForwardPressed; } + set { _isForwardPressed = value; RaisePropertyChangedAuto(); } + } + + private bool _isBackwardPressed; + [XmlIgnore] + public bool IsBackwardPressed + { + get { return _isBackwardPressed; } + set { _isBackwardPressed = value; RaisePropertyChangedAuto(); } + } + + private double _speed; + public double Speed + { + get { return _speed; } + set { _speed = value; RaisePropertyChangedAuto(); } + } + + + public override object Data => TechDispenser; + + public DispenserItem() : base() + { + Name = "Dispenser"; + Description = "Dispenser Controller"; + Image = ResourceHelper.GetImageFromResources("Images/dispenser-big.png"); + Color = Colors.White; + } + + public DispenserItem(TechDispenser techDispenser) : this() + { + TechDispenser = techDispenser; + } + + public override TechItem Clone() + { + DispenserItem cloned = base.Clone() as DispenserItem; + cloned.TechDispenser = TechDispenser; + return cloned; + } + + public void RaiseAction(MotorActionType action) + { + ActionExecuted?.Invoke(this, action); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MeterItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MeterItem.cs index 9d4fd9d60..7cc2913eb 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MeterItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MeterItem.cs @@ -67,7 +67,7 @@ namespace Tango.MachineStudio.Technician.TechItems { Name = "VU Monitor"; Description = "VU Meter monitor"; - Image = ResourceHelper.GetImageFromResources("Images/analog.png"); + Image = ResourceHelper.GetImageFromResources("Images/volume.png"); LastUpdateTime = DateTime.Now; UpdateInterval = 10; LedCount = 14; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorItem.cs index a7088ac3f..272aedf44 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorItem.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Media; using System.Xml.Serialization; using Tango.Core.Commands; using Tango.Integration.Observables; @@ -88,6 +89,14 @@ namespace Tango.MachineStudio.Technician.TechItems set { _isBackwardPressed = value; RaisePropertyChangedAuto(); } } + private double _speed; + public double Speed + { + get { return _speed; } + set { _speed = value; RaisePropertyChangedAuto(); } + } + + public override object Data => TechMotor; public MotorItem() : base() @@ -95,6 +104,7 @@ namespace Tango.MachineStudio.Technician.TechItems Name = "Motor"; Description = "Motor Controller"; Image = ResourceHelper.GetImageFromResources("Images/engine.png"); + Color = Colors.White; } public MotorItem(TechMotor techMotor) : this() 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 7bed3f441..8ed8a4a80 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 @@ -253,6 +253,13 @@ namespace Tango.MachineStudio.Technician.ViewModels Elements.Add(editor); InitMotorItem(motorItem); } + else if (SelectedTechItem is DispenserItem) + { + var dispenserItem = new DispenserItem(Adapter.TechDispensers.FirstOrDefault()); + DispenserElementEditor editor = new DispenserElementEditor(dispenserItem, bounds); + Elements.Add(editor); + InitDispenserItem(dispenserItem); + } } public void OnElementsRemoved(List elements) @@ -319,56 +326,139 @@ namespace Tango.MachineStudio.Technician.ViewModels { item.ActionExecuted += async (x, action) => { - if (action == MotorActionType.HomingStarted) + if (action == MotorActionType.ForwardPressed) + { + await MachineOperator.StartMotorJogging(new MotorJoggingRequest() + { + Code = item.TechMotor.Code, + Direction = MotorDirection.Forward, + }); + } + else if (action == MotorActionType.ForwardReleased) + { + await MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest() + { + Code = item.TechMotor.Code, + }); + } + else if (action == MotorActionType.BackwardPressed) + { + await MachineOperator.StartMotorJogging(new MotorJoggingRequest() + { + Code = item.TechMotor.Code, + Direction = MotorDirection.Backward, + }); + } + else if (action == MotorActionType.BackwardReleased) + { + await MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest() + { + Code = item.TechMotor.Code, + }); + } + else if (action == MotorActionType.HomingStarted) { item.HomingProgress = 0; item.IsHoming = true; item.IsHomingCompleted = false; - await Task.Factory.StartNew(() => + MachineOperator.StartMotorHoming(new MotorHomingRequest() + { + Code = item.TechMotor.Code + }) + .Subscribe((response) => { - for (int i = 0; i < 101; i++) - { - item.HomingMaximumProgress = 100; - item.HomingProgress++; - Thread.Sleep(60); - } + item.HomingMaximumProgress = response.Message.MaxProgress; + item.HomingProgress = response.Message.Progress; + + }, () => + { item.IsHoming = false; item.IsHomingCompleted = true; + }); } - else if (action == MotorActionType.ForwardPressed) + else if (action == MotorActionType.HomingStopped) { - await MachineOperator.StartMotorJogging(new MotorJoggingRequest() + await MachineOperator.StopMotorHoming(new MotorAbortHomingRequest() { Code = item.TechMotor.Code, + }); + + item.IsHoming = false; + } + }; + } + + private void InitDispenserItem(DispenserItem item) + { + item.ActionExecuted += async (x, action) => + { + if (action == MotorActionType.ForwardPressed) + { + await MachineOperator.StartDispenserJogging(new DispenserJoggingRequest() + { + Code = item.TechDispenser.Code, Direction = MotorDirection.Forward, }); } else if (action == MotorActionType.ForwardReleased) { - await MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest() + await MachineOperator.StopDispenserJogging(new DispenserAbortJoggingRequest() { - Code = item.TechMotor.Code, + Code = item.TechDispenser.Code, }); } else if (action == MotorActionType.BackwardPressed) { - await MachineOperator.StartMotorJogging(new MotorJoggingRequest() + await MachineOperator.StartDispenserJogging(new DispenserJoggingRequest() { - Code = item.TechMotor.Code, + Code = item.TechDispenser.Code, Direction = MotorDirection.Backward, }); } else if (action == MotorActionType.BackwardReleased) { - await MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest() + await MachineOperator.StopDispenserJogging(new DispenserAbortJoggingRequest() { - Code = item.TechMotor.Code, + Code = item.TechDispenser.Code, + }); + } + else if (action == MotorActionType.HomingStarted) + { + item.HomingProgress = 0; + item.IsHoming = true; + item.IsHomingCompleted = false; + + MachineOperator.StartDispenserHoming(new DispenserHomingRequest() + { + Code = item.TechDispenser.Code + }) + .Subscribe((response) => + { + + item.HomingMaximumProgress = response.Message.MaxProgress; + item.HomingProgress = response.Message.Progress; + + }, () => + { + + item.IsHoming = false; + item.IsHomingCompleted = true; + }); } + else if (action == MotorActionType.HomingStopped) + { + await MachineOperator.StopDispenserHoming(new DispenserAbortHomingRequest() + { + Code = item.TechDispenser.Code, + }); + + item.IsHoming = false; + } }; } } 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 7cdd92e06..9e3970719 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 @@ -50,15 +50,38 @@ - + @@ -177,6 +200,12 @@ + + + + + + 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 1d449350a..61695a8c5 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/packages.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/packages.config @@ -7,4 +7,10 @@ + + + + + + \ No newline at end of file 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 8c364dde9..2f43869d5 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml @@ -53,7 +53,7 @@ - + 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 2055e282c..5548c452e 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml @@ -53,7 +53,7 @@ - + -- cgit v1.3.1