From f8fc1e8e52e9758c23607b5e9e2dd1c379a37117 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Wed, 11 Dec 2019 15:35:18 +0200 Subject: Implement alphanumeric sorting on hw comparison and hw configuration in MachineStudio. Related Work Items: #1619 --- .../ViewModels/HardwareConfigurationViewVM.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/HardwareConfigurationViewVM.cs') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/HardwareConfigurationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/HardwareConfigurationViewVM.cs index f7ae88f68..42984a82d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/HardwareConfigurationViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/HardwareConfigurationViewVM.cs @@ -124,6 +124,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels collection.Components.Add(componentResult); } } + collection.Components = collection.Components.OrderByAlphaNumeric(x => x.Description).ToSynchronizedObservableCollection(); return collection; } private HardwareCollection CreateDancerCollection(HardwareVersion hardwareVersion) @@ -146,6 +147,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels collection.Components.Add(componentResult); } } + collection.Components = collection.Components.OrderByAlphaNumeric(x => x.Description).ToSynchronizedObservableCollection(); return collection; } private HardwareCollection CreatePidCollection(HardwareVersion hardwareVersion) @@ -168,6 +170,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels collection.Components.Add(componentResult); } } + collection.Components = collection.Components.OrderByAlphaNumeric(x => x.Description).ToSynchronizedObservableCollection(); return collection; } private HardwareCollection CreateWindersCollection(HardwareVersion hardwareVersion) @@ -190,6 +193,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels collection.Components.Add(componentResult); } } + collection.Components = collection.Components.OrderByAlphaNumeric(x => x.Description).ToSynchronizedObservableCollection(); return collection; } private HardwareCollection CreateSpeedSensorsCollection(HardwareVersion hardwareVersion) @@ -212,6 +216,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels collection.Components.Add(componentResult); } } + collection.Components = collection.Components.OrderByAlphaNumeric(x => x.Description).ToSynchronizedObservableCollection(); return collection; } private HardwareCollection CreateBlowersCollection(HardwareVersion hardwareVersion) @@ -234,6 +239,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels collection.Components.Add(componentResult); } } + collection.Components= collection.Components.OrderByAlphaNumeric(x => x.Description).ToSynchronizedObservableCollection(); return collection; } private HardwareCollection CreateBreakSensorCollection(HardwareVersion hardwareVersion) @@ -256,6 +262,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels collection.Components.Add(componentResult); } } + collection.Components = collection.Components.OrderByAlphaNumeric(x => x.Description).ToSynchronizedObservableCollection(); return collection; } private HardwareComponent CreateComponent(String name, String description, List properties, Object component) @@ -265,7 +272,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels Description = description, ComponentName = name }; - + foreach (var prop in properties) { var hProp = new HardwareParameter(); @@ -279,6 +286,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels hProp.ActualValue = configParam != null ? configParam.Value : null; hwComponent.Properties.Add(hProp); } + hwComponent.Properties = hwComponent.Properties.OrderByAlphaNumeric(x => x.PropertyName).ToSynchronizedObservableCollection(); return hwComponent; } -- cgit v1.3.1 From 633c35f15e95240117af791a7343a0ba68556fcf Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Wed, 18 Dec 2019 13:47:32 +0200 Subject: Removed sorting for component properties. Related Work Items: #1619 --- .../ViewModels/ComparisonWizardViewVM.cs | 1 - .../ViewModels/HardwareConfigurationViewVM.cs | 1 - 2 files changed, 2 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/HardwareConfigurationViewVM.cs') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/ComparisonWizardViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/ComparisonWizardViewVM.cs index 3c71cc949..a58d69a93 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/ComparisonWizardViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/ComparisonWizardViewVM.cs @@ -439,7 +439,6 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels result.Properties.Add(hProp); } - result.Properties = result.Properties.OrderByAlphaNumeric(x => x.PropertyName).ToSynchronizedObservableCollection(); return result; } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/HardwareConfigurationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/HardwareConfigurationViewVM.cs index 42984a82d..51d88c3f9 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/HardwareConfigurationViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/HardwareConfigurationViewVM.cs @@ -286,7 +286,6 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels hProp.ActualValue = configParam != null ? configParam.Value : null; hwComponent.Properties.Add(hProp); } - hwComponent.Properties = hwComponent.Properties.OrderByAlphaNumeric(x => x.PropertyName).ToSynchronizedObservableCollection(); return hwComponent; } -- cgit v1.3.1 From a4761335999936b8e1bd0091861b3b08ad3f6343 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Mon, 20 Jan 2020 13:11:40 +0200 Subject: Fixed main menu style. Fixed issues with machine prototype creation. Implemented "make prototype". --- .../ViewModels/HardwareConfigurationViewVM.cs | 23 ++++--- .../ViewModels/MainViewVM.cs | 73 ++++++++++++++++++++-- .../Views/MachineDetailsView.xaml | 2 +- .../Views/MachineSettingsView.xaml | 45 ++++++++----- .../Tango.MachineStudio.UI/Views/MainView.xaml | 2 +- .../Tango.BL/Entities/MachineVersion.cs | 23 ++++++- 6 files changed, 133 insertions(+), 35 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/HardwareConfigurationViewVM.cs') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/HardwareConfigurationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/HardwareConfigurationViewVM.cs index 51d88c3f9..e29ba3b6f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/HardwareConfigurationViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/HardwareConfigurationViewVM.cs @@ -92,16 +92,19 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { HardwareVersion hardwareVersion = configuration.HardwareVersion; - _hwConfig = configuration.GetHardwareConfiguration(); - - Collections.Clear(); - Collections.Add(CreateMotorsCollection(hardwareVersion)); - Collections.Add(CreateDancerCollection(hardwareVersion)); - Collections.Add(CreatePidCollection(hardwareVersion)); - Collections.Add(CreateWindersCollection(hardwareVersion)); - Collections.Add(CreateSpeedSensorsCollection(hardwareVersion)); - Collections.Add(CreateBlowersCollection(hardwareVersion)); - Collections.Add(CreateBreakSensorCollection(hardwareVersion)); + if (hardwareVersion != null) + { + _hwConfig = configuration.GetHardwareConfiguration(); + + Collections.Clear(); + Collections.Add(CreateMotorsCollection(hardwareVersion)); + Collections.Add(CreateDancerCollection(hardwareVersion)); + Collections.Add(CreatePidCollection(hardwareVersion)); + Collections.Add(CreateWindersCollection(hardwareVersion)); + Collections.Add(CreateSpeedSensorsCollection(hardwareVersion)); + Collections.Add(CreateBlowersCollection(hardwareVersion)); + Collections.Add(CreateBreakSensorCollection(hardwareVersion)); + } } private HardwareCollection CreateMotorsCollection(HardwareVersion hardwareVersion) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs index 7b6ae7ef0..8b0401dc7 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs @@ -228,6 +228,11 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels /// public RelayCommand ResetDeviceRegistrationCommand { get; set; } + /// + /// Gets or sets the make prototype command. + /// + public RelayCommand MakePrototypeCommand { get; set; } + #endregion #region Constructors @@ -261,6 +266,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels RemoveSpoolCommand = new RelayCommand(RemoveSpool, () => SelectedSpool != null); CloneMachineCommand = new RelayCommand(CloneMachine, () => SelectedMachine != null); ResetDeviceRegistrationCommand = new RelayCommand(ResetDeviceRegistration); + MakePrototypeCommand = new RelayCommand(MakePrototype); MachineUpdatesViewVM = new MachineUpdatesViewVM(_notification); TupViewVM = new TupViewVM(_notification); @@ -470,6 +476,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels ActiveMachineAdapter.MachineVersions = (await ActiveMachineAdapter.Context.MachineVersions.ToListAsync()).ToObservableCollection(); ActiveMachineAdapter.Organizations = (await ActiveMachineAdapter.Context.Organizations.ToListAsync()).ToObservableCollection(); + bool initHwConfig = true; + if (!newMachine) { ActiveMachine = (await new MachineBuilder(ActiveMachineAdapter.Context).Set(SelectedMachine.Guid).WithOrganization().WithConfiguration().WithSpools().BuildAsync()); @@ -500,8 +508,22 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } else { - ActiveMachine = selectedVersion.CreatePrototypeMachine(ActiveMachineAdapter.Context); - ActiveMachineAdapter.Context.Machines.Add(ActiveMachine); + try + { + initHwConfig = false; + ActiveMachine = selectedVersion.CreatePrototypeMachine(ActiveMachineAdapter.Context); + ActiveMachineAdapter.Context.Machines.Add(ActiveMachine); + + HardwareConfigurationViewVM = new HardwareConfigurationViewVM(_notification); + var version = await new HardwareVersionBuilder(ActiveMachineAdapter.Context).Set(ActiveMachine.Configuration.HardwareVersionGuid).WithHardwareComponents().BuildAsync(); + HardwareConfigurationViewVM.Init(ActiveMachine.Configuration); + } + catch (Exception ex) + { + _notification.ShowError($"Invalid machine version prototype.\n{ex.FlattenMessage()}"); + View.NavigateTo(MachineDesignerNavigationView.MachinesView); + return; + } } } @@ -516,8 +538,11 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels SelectedRML = ActiveMachineAdapter.Rmls.FirstOrDefault(), }; - HardwareConfigurationViewVM = new HardwareConfigurationViewVM(_notification); - HardwareConfigurationViewVM.Init(ActiveMachine.Configuration); + if (initHwConfig) + { + HardwareConfigurationViewVM = new HardwareConfigurationViewVM(_notification); + HardwareConfigurationViewVM.Init(ActiveMachine.Configuration); + } await MachineUpdatesViewVM.Init(ActiveMachine, ActiveMachineAdapter.Context); TupViewVM.Init(ActiveMachine); @@ -549,6 +574,11 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { try { + if (HardwareConfigurationViewVM == null) + { + HardwareConfigurationViewVM = new HardwareConfigurationViewVM(_notification); + } + version = await new HardwareVersionBuilder(ActiveMachineAdapter.Context).Set(version.Guid).WithHardwareComponents().BuildAsync(); HardwareConfigurationViewVM.Init(ActiveMachine.Configuration); } @@ -775,6 +805,41 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } } + private async void MakePrototype() + { + if (ActiveMachine.MachineVersion == null) + { + _notification.ShowError("Machine version must be selected in order to make a prototype."); + return; + } + + if (_notification.ShowQuestion($"Are you sure you wish to make this machine configuration as a prototype for version '{ActiveMachine.MachineVersion.Name}' ?")) + { + using (_notification.PushTaskItem($"Making prototype machine for '{ActiveMachine.MachineVersion.Name}'...")) + { + try + { + IsFree = false; + + using (var db = ObservablesContext.CreateDefault()) + { + var machineVersion = await db.MachineVersions.SingleOrDefaultAsync(x => x.Guid == ActiveMachine.MachineVersionGuid); + await machineVersion.ApplyPrototypeMachine(ActiveMachine, db); + await db.SaveChangesAsync(); + } + } + catch (Exception ex) + { + _notification.ShowError($"Error making machine version prototype\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } + } + } + #endregion private void CloneMachine() diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml index bcca83ca5..b3cef3083 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml @@ -23,7 +23,7 @@ - + - Device COM Port - - Auto Login @@ -109,7 +120,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml index 2d5a5c3aa..15f2a30e0 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml @@ -70,7 +70,7 @@ -