diff options
| author | Roy <roy.mail.net@gmail.com> | 2018-02-10 02:13:37 +0200 |
|---|---|---|
| committer | Roy <roy.mail.net@gmail.com> | 2018-02-10 02:13:37 +0200 |
| commit | 07e686eb253ffd29f36dbe530b3a17633e02b353 (patch) | |
| tree | d9663f1c92a400349dffc743adb0114ee1a7f618 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems | |
| parent | c8c9606e545f49aae3d9f0524775436adbdf27e9 (diff) | |
| download | Tango-07e686eb253ffd29f36dbe530b3a17633e02b353.tar.gz Tango-07e686eb253ffd29f36dbe530b3a17633e02b353.zip | |
Added support for motor controllers.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems')
2 files changed, 135 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorActionType.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorActionType.cs new file mode 100644 index 000000000..319345926 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorActionType.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Technician.TechItems +{ + public enum MotorActionType + { + ForwardPressed, + ForwardReleased, + BackwardPressed, + BackwardReleased, + HomingStarted, + HomingStopped, + } +} 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 new file mode 100644 index 000000000..a7088ac3f --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorItem.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; +using Tango.Core.Commands; +using Tango.Integration.Observables; +using Tango.SharedUI.Helpers; + +namespace Tango.MachineStudio.Technician.TechItems +{ + public class MotorItem : TechItem + { + public event EventHandler<MotorActionType> ActionExecuted; + public event EventHandler HomingCompleted; + + private TechMotor _techMotor; + [XmlIgnore] + public TechMotor TechMotor + { + get { return _techMotor; } + set { _techMotor = 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(); } + } + + public override object Data => TechMotor; + + public MotorItem() : base() + { + Name = "Motor"; + Description = "Motor Controller"; + Image = ResourceHelper.GetImageFromResources("Images/engine.png"); + } + + public MotorItem(TechMotor techMotor) : this() + { + TechMotor = techMotor; + } + + public override TechItem Clone() + { + MotorItem cloned = base.Clone() as MotorItem; + cloned.TechMotor = TechMotor; + return cloned; + } + + public void RaiseAction(MotorActionType action) + { + ActionExecuted?.Invoke(this, action); + } + } +} |
