From cb769a96ca8841ced9cff6ed4a6c99939e139610 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 24 Sep 2019 12:07:14 +0300 Subject: Implemented auto process selection on Research module. --- .../DeveloperModuleSettings.cs | 2 + .../ViewModels/MainViewVM.cs | 60 +++++++++++++++++++++- .../Views/JobView.xaml | 60 +++++++++++++--------- .../Views/JobView.xaml.cs | 32 +++++++----- 4 files changed, 114 insertions(+), 40 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModuleSettings.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModuleSettings.cs index 3d0ee2461..ce2c02fe7 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModuleSettings.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModuleSettings.cs @@ -44,6 +44,8 @@ namespace Tango.MachineStudio.Developer set { _usePreferredLiquidVolumeIndex = value; RaisePropertyChangedAuto(); } } + public bool AutoProcessSelection { get; set; } + public DeveloperModuleSettings() { ProcessParametersIndices = new List(); 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 c2fad9d87..f5313d4cd 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 @@ -552,14 +552,35 @@ namespace Tango.MachineStudio.Developer.ViewModels set { _enableColorConversion = value; RaisePropertyChangedAuto(); } } + /// + /// Gets or sets the authentication provider. + /// public IAuthenticationProvider AuthenticationProvider { get; set; } + /// + /// Gets or sets the module settings. + /// public DeveloperModuleSettings Settings { get { return _settings; } set { _settings = value; RaisePropertyChangedAuto(); } } + private bool _autoProcessSelection; + /// + /// Gets or sets a value indicating whether [automatic process selection]. + /// + public bool AutoProcessSelection + { + get { return _autoProcessSelection; } + set + { + _autoProcessSelection = value; + RaisePropertyChangedAuto(); + Settings.AutoProcessSelection = _autoProcessSelection; + } + } + #endregion #region Commands @@ -864,6 +885,23 @@ namespace Tango.MachineStudio.Developer.ViewModels catch { } } + if (AutoProcessSelection) + { + try + { + var recommendedProcess = _converter.GetRecommendedProcessParameters(ActiveJob, RmlProcessParametersTableGroup); + + if (recommendedProcess != null && recommendedProcess != SelectedProcessParametersTable) + { + SelectedProcessParametersTable = recommendedProcess; + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error resolving recommended process parameters."); + } + } + Thread.Sleep(500); } } @@ -1338,6 +1376,26 @@ namespace Tango.MachineStudio.Developer.ViewModels stop.SetLiquidVolumes(SelectedMachine.Configuration, SelectedRML, SelectedProcessParametersTable); } + if (AutoProcessSelection) + { + LogManager.Log("Auto process parameters selection enabled. Trying to resolve the recommended process parameters..."); + try + { + var recommendedProcess = _converter.GetRecommendedProcessParameters(ActiveJob, RmlProcessParametersTableGroup); + + if (recommendedProcess != null && recommendedProcess != SelectedProcessParametersTable) + { + SelectedProcessParametersTable = recommendedProcess; + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error resolving recommended process parameters."); + _notification.ShowError("An error occurred while trying to resolve the recommended process parameters.Please try to disable the auto selection."); + return; + } + } + JobEvents.Clear(); IsJobFailed = false; IsJobCanceled = false; @@ -1448,7 +1506,7 @@ namespace Tango.MachineStudio.Developer.ViewModels } catch (InsufficientLiquidQuantityException ex) { - _notification.ShowModalDialog(new InsufficientLiquidQuantityViewVM(ex), (x) => + _notification.ShowModalDialog(new InsufficientLiquidQuantityViewVM(ex), (x) => { MachineOperator.EnableJobLiquidQuantityValidation = false; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml index 742798ce4..3bda86036 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml @@ -1431,20 +1431,15 @@ - + - - + @@ -1526,7 +1526,8 @@ - + + @@ -1559,6 +1560,7 @@ + @@ -1566,24 +1568,32 @@ - - - - + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs index 18dc795bd..28e488aae 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs @@ -251,7 +251,7 @@ namespace Tango.MachineStudio.Developer.Views private void BrushPicker_ColorChanged(object sender, BrushPicker.ColorChangedEventArgs e) { - + } private void ColorCanvas_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs e) @@ -284,7 +284,7 @@ namespace Tango.MachineStudio.Developer.Views private void listBoxSegments_PreviewMouseDown(object sender, MouseButtonEventArgs e) { - + } private void listBoxSegments_MouseEnter(object sender, MouseEventArgs e) @@ -295,22 +295,26 @@ namespace Tango.MachineStudio.Developer.Views private void OnBrushStopFieldValueChanged(object sender, RoutedPropertyChangedEventArgs e) { - BrushStop stop = null; - var dataContext = (sender as FrameworkElement).DataContext; - - if (dataContext != null) + try { - if (dataContext is BrushStop) - { - stop = dataContext as BrushStop; - } - else + BrushStop stop = null; + var dataContext = (sender as FrameworkElement).DataContext; + + if (dataContext != null) { - stop = (dataContext as LiquidVolume).BrushStop; - } + if (dataContext is BrushStop) + { + stop = dataContext as BrushStop; + } + else + { + stop = (dataContext as LiquidVolume).BrushStop; + } - _vm.OnBrushStopFieldValueChanged(stop); + _vm.OnBrushStopFieldValueChanged(stop); + } } + catch { } } private void OnBrushStopMouseDown(object sender, MouseButtonEventArgs e) -- cgit v1.3.1