From 7d61c30b400b62069d1e69893ebe196412b2df2b Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 27 Feb 2018 14:25:58 +0200 Subject: Added PID Control. --- .../Tango.MachineStudio.DB.csproj | 15 ++ .../Tango.MachineStudio.DB/ViewModelLocator.cs | 10 ++ .../ViewModels/PidControlsViewVM.cs | 19 +++ .../Views/DBViews/PidControlView.xaml | 73 ++++++++ .../Views/DBViews/PidControlView.xaml.cs | 28 ++++ .../Views/DBViews/PidControlsView.xaml | 48 ++++++ .../Views/DBViews/PidControlsView.xaml.cs | 32 ++++ .../Images/balance.png | Bin 0 -> 1844 bytes .../Tango.MachineStudio.HardwareDesigner.csproj | 3 + .../ViewModels/MainViewVM.cs | 43 ++++- .../Views/MainView.xaml | 184 ++++++++++++++++++--- .../Views/MainView.xaml.cs | 12 ++ 12 files changed, 440 insertions(+), 27 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/PidControlsViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlsView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/balance.png (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj index 189c7ee0d..fa567697d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj @@ -134,6 +134,7 @@ + @@ -148,9 +149,15 @@ ActionTypeView.xaml + + PidControlsView.xaml + DancerTypesView.xaml + + PidControlView.xaml + DancerTypeView.xaml @@ -402,10 +409,18 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs index 13fd85122..0889be54e 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs @@ -67,6 +67,8 @@ namespace Tango.MachineStudio.DB SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); + + SimpleIoc.Default.Register(); } public static MainViewVM MainViewVM @@ -404,5 +406,13 @@ namespace Tango.MachineStudio.DB return ServiceLocator.Current.GetInstance(); } } + + public static PidControlsViewVM PidControlsViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } } } \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/PidControlsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/PidControlsViewVM.cs new file mode 100644 index 000000000..7fe342da5 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/PidControlsViewVM.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Integration.Observables; +using Tango.MachineStudio.Common.Notifications; +using Tango.SharedUI; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class PidControlsViewVM : DbTableViewModel + { + public PidControlsViewVM(INotificationProvider notification) : base(notification) + { + + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlView.xaml new file mode 100644 index 000000000..5459fbbff --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlView.xaml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlView.xaml.cs new file mode 100644 index 000000000..df45fb1ff --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlView.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.DB.Views.DBViews +{ + /// + /// Interaction logic for MachineView.xaml + /// + public partial class PidControlView : UserControl + { + public PidControlView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlsView.xaml new file mode 100644 index 000000000..0a7d6d4df --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlsView.xaml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlsView.xaml.cs new file mode 100644 index 000000000..9ac44d396 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PidControlsView.xaml.cs @@ -0,0 +1,32 @@ +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; +using Tango.MachineStudio.DB.CustomAttributes; +using Tango.MachineStudio.DB.Managers; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachinesView.xaml + /// + [DBView] + public partial class PidControlsView : UserControl + { + public PidControlsView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/balance.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/balance.png new file mode 100644 index 000000000..46255b3ed Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/balance.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Tango.MachineStudio.HardwareDesigner.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Tango.MachineStudio.HardwareDesigner.csproj index 15186d65b..12c32df08 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Tango.MachineStudio.HardwareDesigner.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Tango.MachineStudio.HardwareDesigner.csproj @@ -155,5 +155,8 @@ + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs index 4becc0b04..0da894aba 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs @@ -4,6 +4,7 @@ using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Core.Commands; using Tango.Integration.Observables; using Tango.SharedUI; @@ -46,10 +47,20 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels set { _currentVersionDancerTypes = value; RaisePropertyChangedAuto(); } } + private ObservableCollection _currentVersionPidControls; + public ObservableCollection CurrentVersionPidControls + { + get { return _currentVersionPidControls; } + set { _currentVersionPidControls = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand SaveCommand { get; set; } public MainViewVM() { Adapter = ObservablesEntitiesAdapter.Instance; + + SaveCommand = new RelayCommand(Save); } private void OnSelectedVersionChanged() @@ -57,6 +68,7 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels CurrentVersion = SelectedVersion.Clone(); CurrentVersionDancerTypes = CurrentVersion.HardwareVersionsDancerTypes.Select(x => x.DancerType).ToObservableCollection(); CurrentVersionMotorTypes = CurrentVersion.HardwareVersionsMotorTypes.Select(x => x.MotorType).ToObservableCollection(); + CurrentVersionPidControls = CurrentVersion.HardwareVersionsPidControls.Select(x => x.PidControl).ToObservableCollection(); } public void OnRemoveDancer(DancerType dancerType) @@ -69,14 +81,41 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels CurrentVersionMotorTypes.Remove(motorType); } + public void OnRemovePidControl(PidControl pidControl) + { + CurrentVersionPidControls.Remove(pidControl); + } + public void OnMotorDrop(MotorType motorType) { - CurrentVersionMotorTypes.Add(motorType); + if (!CurrentVersionMotorTypes.Contains(motorType)) + { + CurrentVersionMotorTypes.Add(motorType); + } } public void OnDropDancer(DancerType dancerType) { - CurrentVersionDancerTypes.Add(dancerType); + if (!CurrentVersionDancerTypes.Contains(dancerType)) + { + CurrentVersionDancerTypes.Add(dancerType); + } + } + + public void OnDropPidControl(PidControl pidControl) + { + if (!CurrentVersionPidControls.Contains(pidControl)) + { + CurrentVersionPidControls.Add(pidControl); + } + } + + private void Save() + { + if (CurrentVersion != null) + { + + } } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml index 77ace3e63..e73ba2a1f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml @@ -60,10 +60,10 @@ - + DRAG & DROP DANCERS - + @@ -72,22 +72,23 @@ - - - - - - - - : - - - - - - - - + + + + + + + + + + @@ -102,10 +103,10 @@ - + DRAG & DROP MOTORS - + @@ -129,7 +130,23 @@ - + + + + + + + + + + @@ -143,6 +160,49 @@ + + + + DRAG & DROP PID CONTROLS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -209,7 +269,11 @@ - + + + + + @@ -238,10 +302,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -281,7 +375,7 @@ - + @@ -317,11 +411,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - +