From 2bef1ef7fb1d5cd57e2af3f47a648e512cfcd4f2 Mon Sep 17 00:00:00 2001 From: Roy Date: Mon, 12 Feb 2018 09:40:08 +0200 Subject: Implemented motor group. --- .../TechItems/MotorGroupItem.cs | 158 +++++++++++++++++++++ .../TechItems/TechItem.cs | 1 + 2 files changed, 159 insertions(+) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorGroupItem.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorGroupItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorGroupItem.cs new file mode 100644 index 000000000..35aae5cd7 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorGroupItem.cs @@ -0,0 +1,158 @@ +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.Xml.Serialization; +using Tango.Integration.Observables; +using Tango.SharedUI.Components; +using Tango.SharedUI.Helpers; + +namespace Tango.MachineStudio.Technician.TechItems +{ + public class MotorGroupItem : TechItem + { + public event EventHandler ActionExecuted; + public event EventHandler HomingCompleted; + + private SelectedObjectCollection _selectedMotors; + [XmlIgnore] + public SelectedObjectCollection SelectedMotors + { + get { return _selectedMotors; } + set { _selectedMotors = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection _techMotors; + [XmlIgnore] + public ObservableCollection TechMotors + { + get { return _techMotors; } + set { _techMotors = value; RaisePropertyChangedAuto(); SetSelectedMotors(); } + } + + private void SetSelectedMotors() + { + if (TechMotors != null) + { + SelectedMotors = new SelectedObjectCollection(ObservablesEntitiesAdapter.Instance.TechMotors.ToObservableCollection(), TechMotors); + } + } + + public List ItemsGuids { get; set; } + + private String _groupName; + + public String GroupName + { + get { return _groupName; } + set { _groupName = value; RaisePropertyChangedAuto(); TechName = value; } + } + + + 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 MotorGroupItem() : base() + { + ItemsGuids = new List(); + TechMotors = new ObservableCollection(); + Name = "Motor Group"; + Description = "Motor Group Controller"; + Image = ResourceHelper.GetImageFromResources("Images/motor-group.png"); + Color = Colors.White; + GroupName = "Motor Group"; + } + + public MotorGroupItem(object dummyConstructor) : this() + { + + } + + public override TechItem Clone() + { + MotorGroupItem cloned = base.Clone() as MotorGroupItem; + cloned.TechMotors = new ObservableCollection(TechMotors); + cloned.Speed = Speed; + cloned.ItemsGuids = ItemsGuids; + cloned.TechMotors = cloned.TechMotors.ToObservableCollection(); + return cloned; + } + + public void RaiseAction(MotorActionType action) + { + ActionExecuted?.Invoke(this, action); + } + } +} 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 8361b6ef7..a7b5ae5b9 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 @@ -21,6 +21,7 @@ namespace Tango.MachineStudio.Technician.TechItems [XmlInclude(typeof(MultiGraphItem))] [XmlInclude(typeof(SingleGraphItem))] [XmlInclude(typeof(ThreadMotionItem))] + [XmlInclude(typeof(MotorGroupItem))] public abstract class TechItem : ExtendedObject { public TechItem() -- cgit v1.3.1