diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-09-24 12:07:14 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-09-24 12:07:14 +0300 |
| commit | cb769a96ca8841ced9cff6ed4a6c99939e139610 (patch) | |
| tree | c1e3e51f1ce32961592abd0b98223575cdf8a29d /Software/Visual_Studio/MachineStudio/Modules | |
| parent | b5c5758e431077d84fb53a3ff62f8e751fca2731 (diff) | |
| download | Tango-cb769a96ca8841ced9cff6ed4a6c99939e139610.tar.gz Tango-cb769a96ca8841ced9cff6ed4a6c99939e139610.zip | |
Implemented auto process selection on Research module.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
4 files changed, 114 insertions, 40 deletions
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<ParameterIndex>(); 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(); } } + /// <summary> + /// Gets or sets the authentication provider. + /// </summary> public IAuthenticationProvider AuthenticationProvider { get; set; } + /// <summary> + /// Gets or sets the module settings. + /// </summary> public DeveloperModuleSettings Settings { get { return _settings; } set { _settings = value; RaisePropertyChangedAuto(); } } + private bool _autoProcessSelection; + /// <summary> + /// Gets or sets a value indicating whether [automatic process selection]. + /// </summary> + 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<InsufficientLiquidQuantityViewVM, InsufficientLiquidQuantityView>(new InsufficientLiquidQuantityViewVM(ex), (x) => + _notification.ShowModalDialog<InsufficientLiquidQuantityViewVM, InsufficientLiquidQuantityView>(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 @@ </DockPanel> </Border> - <ListBox ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Background="Transparent" BorderThickness="0" Style="{x:Null}" HorizontalContentAlignment="Stretch" ItemsSource="{Binding RmlProcessParametersTableGroup.ProcessParametersTables}" SelectedItem="{Binding SelectedProcessParametersTable}" IsEnabled="{Binding RmlProcessParametersTableGroup.Active}"> + <ListBox ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Background="Transparent" BorderThickness="0" Style="{x:Null}" HorizontalContentAlignment="Stretch" ItemsSource="{Binding RmlProcessParametersTableGroup.ProcessParametersTables}" SelectedItem="{Binding SelectedProcessParametersTable}"> <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem" BasedOn="{StaticResource basicListBoxItem}"> </Style> </ListBox.ItemContainerStyle> - <!--<ListBox.ItemsPanel> - <ItemsPanelTemplate> - <WrapPanel IsItemsHost="True"></WrapPanel> - </ItemsPanelTemplate> - </ListBox.ItemsPanel>--> <ListBox.ItemTemplate> <DataTemplate DataType="{x:Type observables:ProcessParametersTable}"> - <Border Padding="5" CornerRadius="5" BorderThickness="1" Margin="5"> + <Border Padding="5" CornerRadius="5" BorderThickness="1" Margin="5" IsEnabled="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.RmlProcessParametersTableGroup.Active}"> <Border.Style> <Style TargetType="Border"> <Setter Property="BorderBrush" Value="{StaticResource borderBrush}"></Setter> @@ -1456,6 +1451,11 @@ <Setter Property="Background" Value="{StaticResource TransparentBackgroundBrush300}"></Setter> <Setter Property="Opacity" Value="1"></Setter> </DataTrigger> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.AutoProcessSelection}" Value="True"> + <Setter Property="BorderBrush" Value="{StaticResource AccentColorBrush}"></Setter> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="Opacity" Value="1"></Setter> + </DataTrigger> </Style.Triggers> </Style> </Border.Style> @@ -1526,7 +1526,8 @@ </WrapPanel> </DockPanel> - <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="5" Visibility="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem},Path=IsSelected,Converter={StaticResource BooleanToVisibilityConverter}}"> + <Grid HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="5"> + <StackPanel Orientation="Horizontal" Visibility="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem},Path=IsSelected,Converter={StaticResource BooleanToVisibilityConverter}}"> <TextBlock Text="Active" FontWeight="Bold" FontStyle="Italic" FontSize="13" VerticalAlignment="Center"></TextBlock> <materialDesign:PackIcon Foreground="{StaticResource GreenBrush400}" Kind="CheckboxBlankCircle" VerticalAlignment="Center" Margin="5 0 0 0"> <materialDesign:PackIcon.Style> @@ -1559,6 +1560,7 @@ </materialDesign:PackIcon.Style> </materialDesign:PackIcon> </StackPanel> + </Grid> </StackPanel> </Grid> </Border> @@ -1566,24 +1568,32 @@ </ListBox.ItemTemplate> </ListBox> - <StackPanel Margin="10 20" VerticalAlignment="Bottom" Orientation="Horizontal" HorizontalAlignment="Right"> - <Button Height="40" Width="105" Command="{Binding ResetProcessParametersCommand}" Background="Transparent" BorderBrush="{StaticResource DarkGrayBrush200}" Foreground="{StaticResource DarkGrayBrush200}" Margin="0 2 10 0" ToolTip="Resets the current process parameters in the embedded device"> - <TextBlock TextWrapping="Wrap" TextAlignment="Center"> + <StackPanel Margin="10 10" VerticalAlignment="Bottom"> + + <StackPanel Orientation="Horizontal"> + <ToggleButton IsChecked="{Binding AutoProcessSelection}" /> + <TextBlock Margin="5 0 0 0">Use Recommended Process Parameters (auto)</TextBlock> + </StackPanel> + + <StackPanel Margin="0 40 0 0" Orientation="Horizontal" HorizontalAlignment="Right"> + <Button Height="40" Width="105" Command="{Binding ResetProcessParametersCommand}" Background="Transparent" BorderBrush="{StaticResource DarkGrayBrush200}" Foreground="{StaticResource DarkGrayBrush200}" Margin="0 2 10 0" ToolTip="Resets the current process parameters in the embedded device"> + <TextBlock TextWrapping="Wrap" TextAlignment="Center"> TEMP OFF - </TextBlock> - </Button> - <Button Height="40" Command="{Binding SaveProcessParametersCommand}" HorizontalAlignment="Left" IsEnabled="{Binding AuthenticationProvider.CurrentUser,Converter={StaticResource UserRoleToBooleanConverter},ConverterParameter='Researcher'}"> - <StackPanel Orientation="Horizontal"> - <materialDesign:PackIcon VerticalAlignment="Center" Kind="ContentSave"></materialDesign:PackIcon> - <TextBlock Margin="10 0 0 0">SAVE PARAMETERS</TextBlock> - </StackPanel> - </Button> - <Button Height="40" Margin="10 0 0 0" Command="{Binding PushProcessParametersCommand}" HorizontalAlignment="Left"> - <StackPanel Orientation="Horizontal"> - <materialDesign:PackIcon VerticalAlignment="Center" Kind="ArrowRightBold"></materialDesign:PackIcon> - <TextBlock Margin="10 0 0 0">PUSH PARAMETERS</TextBlock> - </StackPanel> - </Button> + </TextBlock> + </Button> + <Button Height="40" Command="{Binding SaveProcessParametersCommand}" HorizontalAlignment="Left" IsEnabled="{Binding AuthenticationProvider.CurrentUser,Converter={StaticResource UserRoleToBooleanConverter},ConverterParameter='Researcher'}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon VerticalAlignment="Center" Kind="ContentSave"></materialDesign:PackIcon> + <TextBlock Margin="10 0 0 0">SAVE PARAMETERS</TextBlock> + </StackPanel> + </Button> + <Button Height="40" Margin="10 0 0 0" Command="{Binding PushProcessParametersCommand}" HorizontalAlignment="Left"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon VerticalAlignment="Center" Kind="ArrowRightBold"></materialDesign:PackIcon> + <TextBlock Margin="10 0 0 0">PUSH PARAMETERS</TextBlock> + </StackPanel> + </Button> + </StackPanel> </StackPanel> </StackPanel> </Grid> 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<Color?> 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<double?> 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) |
