From 453565753c012a087f402fc55eee528c132b7c8c Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 7 May 2018 14:45:31 +0300 Subject: New Hardware designer module. --- .../HardwareDesignerModule.cs | 2 +- .../Images/components.png | Bin 0 -> 170824 bytes .../Tango.MachineStudio.HardwareDesigner.csproj | 3 + .../ViewModels/MainViewVM.cs | 292 ++++++++++++---- .../Views/MainView.xaml | 374 ++++----------------- .../Views/MainView.xaml.cs | 61 ---- 6 files changed, 299 insertions(+), 433 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/components.png (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/HardwareDesignerModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/HardwareDesignerModule.cs index 3c4d6e36a..4bd266f4c 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/HardwareDesignerModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/HardwareDesignerModule.cs @@ -35,7 +35,7 @@ namespace Tango.MachineStudio.HardwareDesigner { get { - return ResourceHelper.GetImageFromResources("Images/hardware-module.png"); + return ResourceHelper.GetImageFromResources("Images/components.png"); } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/components.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/components.png new file mode 100644 index 000000000..fc51d2acf Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/components.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 b3b2f6ba9..cfebe1305 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 @@ -160,5 +160,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 a2c7e4460..ee5e0e39c 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 @@ -9,6 +9,7 @@ using Tango.BL.Entities; using Tango.MachineStudio.Common.Notifications; using Tango.SharedUI; using Tango.BL; +using Tango.SharedUI.Components; namespace Tango.MachineStudio.HardwareDesigner.ViewModels { @@ -24,6 +25,62 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels set { _adapter = value; RaisePropertyChangedAuto(); } } + private SelectedObjectCollection _motorTypes; + public SelectedObjectCollection MotorTypes + { + get { return _motorTypes; } + set { _motorTypes = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection _selectedMotorTypes; + public ObservableCollection SelectedMotorTypes + { + get { return _selectedMotorTypes; } + set { _selectedMotorTypes = value; RaisePropertyChangedAuto(); } + } + + private SelectedObjectCollection _dancerTypes; + public SelectedObjectCollection DancerTypes + { + get { return _dancerTypes; } + set { _dancerTypes = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection _selectedDancerTypes; + public ObservableCollection SelectedDancerTypes + { + get { return _selectedDancerTypes; } + set { _selectedDancerTypes = value; RaisePropertyChangedAuto(); } + } + + private SelectedObjectCollection _pidControlTypes; + public SelectedObjectCollection PidControlTypes + { + get { return _pidControlTypes; } + set { _pidControlTypes = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection _selectedPidControlTypes; + public ObservableCollection SelectedPidControlTypes + { + get { return _selectedPidControlTypes; } + set { _selectedPidControlTypes = value; RaisePropertyChangedAuto(); } + } + + private SelectedObjectCollection _winderTypes; + public SelectedObjectCollection WinderTypes + { + get { return _winderTypes; } + set { _winderTypes = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection _selectedWinderTypes; + public ObservableCollection SelectedWinderTypes + { + get { return _selectedWinderTypes; } + set { _selectedWinderTypes = value; RaisePropertyChangedAuto(); } + } + private HardwareVersion _selectedVersion; public HardwareVersion SelectedVersion { @@ -51,6 +108,20 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels } } + private Object _selectedHardwareObjectType; + public Object SelectedHardwareObjectType + { + get { return _selectedHardwareObjectType; } + set + { + _selectedHardwareObjectType = null; + RaisePropertyChangedAuto(); + _selectedHardwareObjectType = value; + RaisePropertyChangedAuto(); + OnSelectedHardwareObjectTypeChanged(); + } + } + public RelayCommand SaveCommand { get; set; } public RelayCommand DeleteCommand { get; set; } @@ -65,77 +136,115 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels SaveCommand = new RelayCommand(Save, () => CurrentVersion != null); NewCommand = new RelayCommand(New); DeleteCommand = new RelayCommand(Delete, () => !_isNew && CurrentVersion != null); - } - - private void OnSelectedVersionChanged() - { - if (SelectedVersion != null) - { - _isNew = false; - CurrentVersion = SelectedVersion.Clone(); - } - - InvalidateRelayCommands(); - } - public void OnRemoveDancer(HardwareDancer dancer) - { - CurrentVersion.HardwareDancers.Remove(dancer); + CurrentVersion = new HardwareVersion(); + CreateTemplate(CurrentVersion); } - public void OnRemoveMotor(HardwareMotor motor) + private void OnSelectedHardwareObjectTypeChanged() { - CurrentVersion.HardwareMotors.Remove(motor); - } + if (SelectedHardwareObjectType != null) + { + if (SelectedHardwareObjectType is SelectedObject) + { + var type = (SelectedHardwareObjectType as SelectedObject).Data; + var hardwareObj = CurrentVersion.HardwareMotors.SingleOrDefault(x => x.HardwareMotorType == type); - public void OnRemovePidControl(HardwarePidControl pidControl) - { - CurrentVersion.HardwarePidControls.Remove(pidControl); - } + if (hardwareObj != null) + { + SelectedHardwareObject = hardwareObj; + } + else + { + hardwareObj = new HardwareMotor() { HardwareMotorType = type }; + CurrentVersion.HardwareMotors.Add(hardwareObj); + SelectedHardwareObject = hardwareObj; + } + } + else if (SelectedHardwareObjectType is SelectedObject) + { + var type = (SelectedHardwareObjectType as SelectedObject).Data; + var hardwareObj = CurrentVersion.HardwareDancers.SingleOrDefault(x => x.HardwareDancerType == type); - public void OnRemoveWinder(HardwareWinder hardwareWinder) - { - CurrentVersion.HardwareWinders.Remove(hardwareWinder); - } + if (hardwareObj != null) + { + SelectedHardwareObject = hardwareObj; + } + else + { + hardwareObj = new HardwareDancer() { HardwareDancerType = type }; + CurrentVersion.HardwareDancers.Add(hardwareObj); + SelectedHardwareObject = hardwareObj; + } + } + else if (SelectedHardwareObjectType is SelectedObject) + { + var type = (SelectedHardwareObjectType as SelectedObject).Data; + var hardwareObj = CurrentVersion.HardwarePidControls.SingleOrDefault(x => x.HardwarePidControlType == type); - public void OnMotorDrop(HardwareMotorType motorType) - { - if (CheckCurrentVersionNull()) return; + if (hardwareObj != null) + { + SelectedHardwareObject = hardwareObj; + } + else + { + hardwareObj = new HardwarePidControl() { HardwarePidControlType = type }; + CurrentVersion.HardwarePidControls.Add(hardwareObj); + SelectedHardwareObject = hardwareObj; + } + } + else if (SelectedHardwareObjectType is SelectedObject) + { + var type = (SelectedHardwareObjectType as SelectedObject).Data; + var hardwareObj = CurrentVersion.HardwareWinders.SingleOrDefault(x => x.HardwareWinderType == type); - if (!CurrentVersion.HardwareMotors.ToList().Exists(x => x.HardwareMotorType == motorType)) - { - CurrentVersion.HardwareMotors.Add(new HardwareMotor() { HardwareMotorType = motorType }); + if (hardwareObj != null) + { + SelectedHardwareObject = hardwareObj; + } + else + { + hardwareObj = new HardwareWinder() { HardwareWinderType = type }; + CurrentVersion.HardwareWinders.Add(hardwareObj); + SelectedHardwareObject = hardwareObj; + } + } } } - public void OnDropDancer(HardwareDancerType dancerType) + private void CreateTemplate(HardwareVersion version) { - if (CheckCurrentVersionNull()) return; - - if (!CurrentVersion.HardwareDancers.ToList().Exists(x => x.HardwareDancerType == dancerType)) + if (version == null) { - CurrentVersion.HardwareDancers.Add(new HardwareDancer() { HardwareDancerType = dancerType }); + SelectedMotorTypes = new ObservableCollection(); + SelectedDancerTypes = new ObservableCollection(); + SelectedPidControlTypes = new ObservableCollection(); + SelectedWinderTypes = new ObservableCollection(); } - } - - public void OnDropPidControl(HardwarePidControlType pidControlType) - { - if (CheckCurrentVersionNull()) return; - - if (!CurrentVersion.HardwarePidControls.ToList().Exists(x => x.HardwarePidControlType == pidControlType)) + else { - CurrentVersion.HardwarePidControls.Add(new HardwarePidControl() { HardwarePidControlType = pidControlType }); + SelectedMotorTypes = version.HardwareMotors.Select(x => x.HardwareMotorType).ToObservableCollection(); + SelectedDancerTypes = version.HardwareDancers.Select(x => x.HardwareDancerType).ToObservableCollection(); + SelectedPidControlTypes = version.HardwarePidControls.Select(x => x.HardwarePidControlType).ToObservableCollection(); + SelectedWinderTypes = version.HardwareWinders.Select(x => x.HardwareWinderType).ToObservableCollection(); } + + MotorTypes = new SelectedObjectCollection(Adapter.HardwareMotorTypes, SelectedMotorTypes); + DancerTypes = new SelectedObjectCollection(Adapter.HardwareDancerTypes, SelectedDancerTypes); + PidControlTypes = new SelectedObjectCollection(Adapter.HardwarePidControlTypes, SelectedPidControlTypes); + WinderTypes = new SelectedObjectCollection(Adapter.HardwareWinderTypes, SelectedWinderTypes); } - public void OnDropWinder(HardwareWinderType hardwareWinderType) + private void OnSelectedVersionChanged() { - if (CheckCurrentVersionNull()) return; - - if (!CurrentVersion.HardwareWinders.ToList().Exists(x => x.HardwareWinderType == hardwareWinderType)) + if (SelectedVersion != null) { - CurrentVersion.HardwareWinders.Add(new HardwareWinder() { HardwareWinderType = hardwareWinderType }); + _isNew = false; + CurrentVersion = SelectedVersion.Clone(); + CreateTemplate(CurrentVersion); } + + InvalidateRelayCommands(); } private bool CheckCurrentVersionNull() @@ -159,7 +268,7 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels CurrentVersion = new HardwareVersion(); CurrentVersion.Version = Adapter.HardwareVersions.Max(x => x.Version) + 1; CurrentVersion.Name = name; - + CreateTemplate(CurrentVersion); _isNew = true; InvalidateRelayCommands(); } @@ -175,7 +284,12 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels if (_isNew) { - realVersion = CurrentVersion; + realVersion = CurrentVersion.Clone(); + + realVersion.HardwareMotors.ToList().Where(x => !SelectedMotorTypes.Contains(x.HardwareMotorType)).ToList().ForEach(x => realVersion.HardwareMotors.Remove(x)); + realVersion.HardwareDancers.ToList().Where(x => !SelectedDancerTypes.Contains(x.HardwareDancerType)).ToList().ForEach(x => realVersion.HardwareDancers.Remove(x)); + realVersion.HardwarePidControls.ToList().Where(x => !SelectedPidControlTypes.Contains(x.HardwarePidControlType)).ToList().ForEach(x => realVersion.HardwarePidControls.Remove(x)); + realVersion.HardwareWinders.ToList().Where(x => !SelectedWinderTypes.Contains(x.HardwareWinderType)).ToList().ForEach(x => realVersion.HardwareWinders.Remove(x)); } else { @@ -193,28 +307,76 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels realVersion.HardwarePidControls.Clear(); realVersion.HardwareWinders.Clear(); - - foreach (var item in CurrentVersion.HardwareDancers.ToList().Select(x => x.Clone())) + foreach (var type in SelectedDancerTypes) { - item.HardwareVersionGuid = realVersion.Guid; - realVersion.HardwareDancers.Add(item); + var item = CurrentVersion.HardwareDancers.SingleOrDefault(x => x.HardwareDancerType == type); + if (item != null) + { + item.HardwareVersionGuid = realVersion.Guid; + realVersion.HardwareDancers.Add(item); + } + else + { + realVersion.HardwareDancers.Add(new HardwareDancer() + { + HardwareVersionGuid = realVersion.Guid, + HardwareDancerType = type + }); + } } - foreach (var item in CurrentVersion.HardwareMotors.ToList().Select(x => x.Clone())) + foreach (var type in SelectedMotorTypes) { - item.HardwareVersionGuid = realVersion.Guid; - realVersion.HardwareMotors.Add(item); + var item = CurrentVersion.HardwareMotors.SingleOrDefault(x => x.HardwareMotorType == type); + if (item != null) + { + item.HardwareVersionGuid = realVersion.Guid; + realVersion.HardwareMotors.Add(item); + } + else + { + realVersion.HardwareMotors.Add(new HardwareMotor() + { + HardwareVersionGuid = realVersion.Guid, + HardwareMotorType = type + }); + } } - foreach (var item in CurrentVersion.HardwarePidControls.ToList().Select(x => x.Clone())) + foreach (var type in SelectedPidControlTypes) { - item.HardwareVersionGuid = realVersion.Guid; - realVersion.HardwarePidControls.Add(item); + var item = CurrentVersion.HardwarePidControls.SingleOrDefault(x => x.HardwarePidControlType == type); + if (item != null) + { + item.HardwareVersionGuid = realVersion.Guid; + realVersion.HardwarePidControls.Add(item); + } + else + { + realVersion.HardwarePidControls.Add(new HardwarePidControl() + { + HardwareVersionGuid = realVersion.Guid, + HardwarePidControlType = type + }); + } } - foreach (var item in CurrentVersion.HardwareWinders.ToList().Select(x => x.Clone())) + + foreach (var type in SelectedWinderTypes) { - item.HardwareVersionGuid = realVersion.Guid; - realVersion.HardwareWinders.Add(item); + var item = CurrentVersion.HardwareWinders.SingleOrDefault(x => x.HardwareWinderType == type); + if (item != null) + { + item.HardwareVersionGuid = realVersion.Guid; + realVersion.HardwareWinders.Add(item); + } + else + { + realVersion.HardwareWinders.Add(new HardwareWinder() + { + HardwareVersionGuid = realVersion.Guid, + HardwareWinderType = type + }); + } } } 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 55b3580fe..335ce809e 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 @@ -8,12 +8,13 @@ xmlns:mahApps="http://metro.mahapps.com/winfx/xaml/controls" xmlns:editors="clr-namespace:Tango.SharedUI.Editors;assembly=Tango.SharedUI" xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:entities="clr-namespace:Tango.BL.Entities;assembly=Tango.BL" xmlns:local="clr-namespace:Tango.MachineStudio.HardwareDesigner.Views" xmlns:vm="clr-namespace:Tango.MachineStudio.HardwareDesigner.ViewModels" xmlns:observables="clr-namespace:Tango.BL.Entities;assembly=Tango.BL" xmlns:global="clr-namespace:Tango.MachineStudio.HardwareDesigner" mc:Ignorable="d" - d:DesignHeight="720" Background="Transparent" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + d:DesignHeight="720" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> @@ -25,22 +26,17 @@ - + - - - - - - + HARDWARE DESIGNER @@ -56,202 +52,76 @@ - - - - - - - + - - - - DRAG & DROP DANCERS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DRAG & DROP MOTORS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + MOTORS + + + + + + + + + + + - - - DRAG & DROP PID CONTROLS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + DANCERS + + + + + + + + + + + - - - DRAG & DROP WINDERS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + PID CONTROLS + + + + + + + + + + + + + + + WINDERS + + + + + + + + + + + + + - - - - - DROP HERE TO DELETE - - - - + @@ -261,7 +131,7 @@ - + @@ -276,114 +146,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml.cs index dad105a43..14593327b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml.cs @@ -25,72 +25,11 @@ namespace Tango.MachineStudio.HardwareDesigner.Views { private MainViewVM _vm; - public DraggingSurface DraggingSurface - { - get { return (DraggingSurface)GetValue(DraggingSurfaceProperty); } - set { SetValue(DraggingSurfaceProperty, value); } - } - public static readonly DependencyProperty DraggingSurfaceProperty = - DependencyProperty.Register("DraggingSurface", typeof(DraggingSurface), typeof(MainView), new PropertyMetadata(null)); - public MainView() { InitializeComponent(); - DraggingSurface = dragSufrace; Loaded += (x, y) => _vm = DataContext as MainViewVM; } - - private void OnMotorsDrop(object sender, DropEventArgs e) - { - if (e.Draggable.DataContext is HardwareMotorType) - { - _vm.OnMotorDrop(e.Draggable.DataContext as HardwareMotorType); - } - } - - private void OnDancerDrop(object sender, DropEventArgs e) - { - if (e.Draggable.DataContext is HardwareDancerType) - { - _vm.OnDropDancer(e.Draggable.DataContext as HardwareDancerType); - } - } - - private void OnPidControlDrop(object sender, DropEventArgs e) - { - if (e.Draggable.DataContext is HardwarePidControlType) - { - _vm.OnDropPidControl(e.Draggable.DataContext as HardwarePidControlType); - } - } - - private void OnDropWinder(object sender, DropEventArgs e) - { - if (e.Draggable.DataContext is HardwareWinderType) - { - _vm.OnDropWinder(e.Draggable.DataContext as HardwareWinderType); - } - } - - private void OnTrashDrop(object sender, DropEventArgs e) - { - if (e.Draggable.DataContext is HardwareMotor) - { - _vm.OnRemoveMotor(e.Draggable.DataContext as HardwareMotor); - } - else if (e.Draggable.DataContext is HardwareDancer) - { - _vm.OnRemoveDancer(e.Draggable.DataContext as HardwareDancer); - } - else if (e.Draggable.DataContext is HardwarePidControl) - { - _vm.OnRemovePidControl(e.Draggable.DataContext as HardwarePidControl); - } - else if (e.Draggable.DataContext is HardwareWinder) - { - _vm.OnRemoveWinder(e.Draggable.DataContext as HardwareWinder); - } - } } } -- cgit v1.3.1 From cdba3267d2a47b3bff8cf3ec0219223e36e234ff Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 7 May 2018 15:36:03 +0300 Subject: Added machine studio modules order. Implemented delayed GetInstance for TangoIOC. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 1572864 -> 1572864 bytes .../Tango.MachineStudio.ColorLab/ColorLabModule.cs | 1 + .../Modules/Tango.MachineStudio.DB/DBModule.cs | 1 + .../DataCaptureModule.cs | 1 + .../DeveloperModule.cs | 3 +- .../ViewModels/MainViewVM.cs | 9 +++-- .../HardwareDesignerModule.cs | 5 +-- .../Tango.MachineStudio.Logging/LoggingModule.cs | 1 + .../MachineDesignerModule.cs | 1 + .../Tango.MachineStudio.Stubs/StubsModule.cs | 1 + .../SynchronizationModule.cs | 1 + .../TechnicianModule.cs | 3 +- .../UsersAndRolesModule.cs | 1 + .../StudioModuleAttribute.cs | 19 ++++++++++ .../Tango.MachineStudio.Common.csproj | 1 + .../Modules/DefaultStudioModuleLoader.cs | 2 ++ Software/Visual_Studio/Tango.Core/DI/ITangoIOC.cs | 8 +++++ Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs | 39 +++++++++++++++++++++ 19 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleAttribute.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 145210882..20b095e26 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index a9198ae95..aebf877af 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ColorLabModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ColorLabModule.cs index bdb7b136f..2805e5d60 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ColorLabModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ColorLabModule.cs @@ -12,6 +12,7 @@ using Tango.SharedUI.Helpers; namespace Tango.MachineStudio.ColorLab { + [StudioModule(7)] public class ColorLabModule : StudioModuleBase { public override string Name diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/DBModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/DBModule.cs index 4b2fe4074..7477c8d63 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/DBModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/DBModule.cs @@ -16,6 +16,7 @@ namespace Tango.MachineStudio.DB /// Represents a Machine Studio database module. /// /// + [StudioModule(8)] public class DBModule : StudioModuleBase { /// diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/DataCaptureModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/DataCaptureModule.cs index eb463e3c2..23d743aeb 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/DataCaptureModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/DataCaptureModule.cs @@ -17,6 +17,7 @@ namespace Tango.MachineStudio.DataCapture /// Represents the machine studio data capturing and playing module. /// /// + [StudioModule(4)] public class DataCaptureModule : StudioModuleBase { /// diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs index 166a3212a..be6b93726 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs @@ -17,12 +17,13 @@ namespace Tango.MachineStudio.Developer /// Represents the Machine Studio developer module. /// /// + [StudioModule(0)] public class DeveloperModule : StudioModuleBase { /// /// Gets the module name. /// - public override string Name => "Developer"; + public override string Name => "Research"; /// /// Gets the module description. diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index f557e2923..ab0df302e 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -652,8 +652,11 @@ namespace Tango.MachineStudio.Developer.ViewModels LogManager.Log("Initializing relay commands..."); - _dataCaptureVM = TangoIOC.Default.GetInstance(); - _dataCaptureVM.RelayCommandsInvalidated += (_, __) => StartJobAndRecordCommand.RaiseCanExecuteChanged(); + TangoIOC.Default.GetInstanceWhenAvailable((vm) => + { + _dataCaptureVM = vm; + _dataCaptureVM.RelayCommandsInvalidated += (_, __) => StartJobAndRecordCommand.RaiseCanExecuteChanged(); + }); //Initialize Commands... EditMachineCommand = new RelayCommand(EditMachine, () => SelectedMachine != null); @@ -669,7 +672,7 @@ namespace Tango.MachineStudio.Developer.ViewModels SaveJobCommand = new RelayCommand(SaveActiveJob, () => SelectedMachine != null); DiscardJobCommand = new RelayCommand(BackToJobs, () => SelectedMachine != null); StartJobCommand = new RelayCommand(StartJob, () => ActiveJob != null && !IsJobRunning && MachineOperator != null && !MachineOperator.MachineEventsStateProvider.Events.ToList().Exists(x => x.ActionTypes.Contains(BL.Enumerations.ActionTypes.PreventJobExecution))); - StartJobAndRecordCommand = new RelayCommand(StartJobAndRecord, () => !_dataCaptureVM.Recorder.IsRecording && !_dataCaptureVM.Player.IsPlaying && ActiveJob != null && !IsJobRunning && MachineOperator != null && !MachineOperator.MachineEventsStateProvider.Events.ToList().Exists(x => x.ActionTypes.Contains(BL.Enumerations.ActionTypes.PreventJobExecution))); + StartJobAndRecordCommand = new RelayCommand(StartJobAndRecord, () => _dataCaptureVM != null && !_dataCaptureVM.Recorder.IsRecording && !_dataCaptureVM.Player.IsPlaying && ActiveJob != null && !IsJobRunning && MachineOperator != null && !MachineOperator.MachineEventsStateProvider.Events.ToList().Exists(x => x.ActionTypes.Contains(BL.Enumerations.ActionTypes.PreventJobExecution))); StopJobCommand = new RelayCommand(StopJob, () => IsJobRunning); CloseJobCompletionStatusCommand = new RelayCommand(CloseJobCompletionStatusBar); LoadJobCommand = new RelayCommand(LoadSelectedJob, () => SelectedMachineJob != null); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/HardwareDesignerModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/HardwareDesignerModule.cs index 4bd266f4c..4b67e6a72 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/HardwareDesignerModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/HardwareDesignerModule.cs @@ -13,13 +13,14 @@ using Tango.SharedUI.Helpers; namespace Tango.MachineStudio.HardwareDesigner { + [StudioModule(3)] public class HardwareDesignerModule : StudioModuleBase { public override string Name { get { - return "Hardware Designer"; + return "Hardware Versions"; } } @@ -27,7 +28,7 @@ namespace Tango.MachineStudio.HardwareDesigner { get { - return "Design a specific hardware version using a drag & drop interface. Hardware versions can be assigned to a machine configuration using the Machine Designer module."; + return "Select and configure hardware versions using the available hardware components. Hardware versions can be assigned to a machine configuration using the Machine Designer module."; } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/LoggingModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/LoggingModule.cs index b389c121e..ea3e01c39 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/LoggingModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/LoggingModule.cs @@ -12,6 +12,7 @@ using Tango.SharedUI.Helpers; namespace Tango.MachineStudio.Logging { + [StudioModule(5)] public class LoggingModule : StudioModuleBase { public override string Name diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/MachineDesignerModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/MachineDesignerModule.cs index 9b37303c7..35aea14a4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/MachineDesignerModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/MachineDesignerModule.cs @@ -17,6 +17,7 @@ namespace Tango.MachineStudio.MachineDesigner /// Represents a machine designer Machine Studio module providing an interactive GUI for managing machine configurations. /// /// + [StudioModule(2)] public class MachineDesignerModule : StudioModuleBase { /// diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs index aa8041669..b0c5d643a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs @@ -17,6 +17,7 @@ namespace Tango.MachineStudio.Stubs /// Represents a stubs execution Machine Studio module capable of executing stubs against the current connected machine using a C# script engine. /// /// + [StudioModule(10)] public class StubsModule : StudioModuleBase { /// diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/SynchronizationModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/SynchronizationModule.cs index 29fc95aec..862ee9a6a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/SynchronizationModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/SynchronizationModule.cs @@ -17,6 +17,7 @@ namespace Tango.MachineStudio.Synchronization /// Represents a Machine Studio module capable of comparing and synchronizing machines data against Twine remote database. /// /// + [StudioModule(6)] public class SynchronizationModule : StudioModuleBase { /// diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechnicianModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechnicianModule.cs index 4ced0fb30..ae423c938 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechnicianModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechnicianModule.cs @@ -17,12 +17,13 @@ namespace Tango.MachineStudio.Technician /// Represents a machine studio technician module. /// /// + [StudioModule(1)] public class TechnicianModule : StudioModuleBase { /// /// Gets the module name. /// - public override string Name => "Technician"; + public override string Name => "Tech Board"; /// /// Gets the module description. diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.UsersAndRoles/UsersAndRolesModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.UsersAndRoles/UsersAndRolesModule.cs index ac471db06..21b41137d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.UsersAndRoles/UsersAndRolesModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.UsersAndRoles/UsersAndRolesModule.cs @@ -12,6 +12,7 @@ using Tango.SharedUI.Helpers; namespace Tango.MachineStudio.UsersAndRoles { + [StudioModule(9)] public class UsersAndRolesModule : StudioModuleBase { public override string Name diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleAttribute.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleAttribute.cs new file mode 100644 index 000000000..b9212a9e3 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleAttribute.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common +{ + [AttributeUsage(AttributeTargets.Class)] + public class StudioModuleAttribute : Attribute + { + public int Index { get; set; } + + public StudioModuleAttribute(int index) + { + Index = index; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index ac6f84618..df1ee23dc 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -109,6 +109,7 @@ + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs index 4afddae69..26a789d0f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs @@ -125,6 +125,8 @@ namespace Tango.MachineStudio.UI.Modules _loaded = true; } + AllModules = AllModules.OrderBy(x => x.GetType().GetCustomAttribute().Index).ToObservableCollection(); + UserModules.Clear(); if (_authenticationProvider.CurrentUser != null) diff --git a/Software/Visual_Studio/Tango.Core/DI/ITangoIOC.cs b/Software/Visual_Studio/Tango.Core/DI/ITangoIOC.cs index 3d386035d..145e9988a 100644 --- a/Software/Visual_Studio/Tango.Core/DI/ITangoIOC.cs +++ b/Software/Visual_Studio/Tango.Core/DI/ITangoIOC.cs @@ -96,6 +96,14 @@ namespace Tango.Core.DI /// T GetInstance(); + /// + /// Executes the specified action when type T is available. if already available action will be executed immediately. + /// + /// + /// The callback. + /// + void GetInstanceWhenAvailable(Action callback); + /// /// Gets all instances by the specified base type. /// diff --git a/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs b/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs index afda3d8bf..b6ee79324 100644 --- a/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs +++ b/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs @@ -45,6 +45,7 @@ namespace Tango.Core.DI } private Dictionary _registeredTypes; + private List>> _waitingRetrivals; /// /// Initializes a new instance of the class. @@ -52,6 +53,7 @@ namespace Tango.Core.DI public TangoIOC() { _registeredTypes = new Dictionary(); + _waitingRetrivals = new List>>(); } /// @@ -166,6 +168,11 @@ namespace Tango.Core.DI if (registeredType.Instance == null) { registeredType.Instance = CreateInstance(registeredType.ImplementationType); + + //Notify waiting retrievals. + var toNotify = _waitingRetrivals.Where(x => x.Item1 == registeredType.InterfaceType).ToList(); + toNotify.ForEach(x => x.Item2(registeredType.Instance)); + _waitingRetrivals.RemoveAll(x => toNotify.Contains(x)); } return registeredType.Instance; @@ -176,6 +183,38 @@ namespace Tango.Core.DI } } + /// + /// Executes the specified action when type T is available. if already available action will be executed immediately. + /// + /// + /// The callback. + /// + public void GetInstanceWhenAvailable(Action callback) + { + GetInstanceWhenAvailable(typeof(T), (x) => callback((T)x)); + } + + /// + /// Executes the specified action when type T is available. if already available action will be executed immediately. + /// + /// The callback. + /// + public virtual void GetInstanceWhenAvailable(Type type, Action callback) + { + RegisteredType registeredType = null; + + if (_registeredTypes.TryGetValue(type, out registeredType)) + { + if (registeredType.Instance != null) + { + callback(registeredType.Instance); + return; + } + } + + _waitingRetrivals.Add(new Tuple>(type, callback)); + } + /// /// Determines whether the specified type is registered. /// -- cgit v1.3.1