diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-11-13 18:03:13 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-11-13 18:03:13 +0200 |
| commit | d846db14084016e877563a20175e1516183baaa1 (patch) | |
| tree | f066e338f15cc225e85f7d66172bdcb8b1ead106 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer | |
| parent | b0fe0a84b041dca551c2112a4bac29b61031fa95 (diff) | |
| parent | 1d022e2c2de474a714e26413101b8ab4586e7987 (diff) | |
| download | Tango-d846db14084016e877563a20175e1516183baaa1.tar.gz Tango-d846db14084016e877563a20175e1516183baaa1.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer')
4 files changed, 140 insertions, 105 deletions
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 fec02529b..fd20a0b1c 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 @@ -1479,39 +1479,15 @@ namespace Tango.MachineStudio.Developer.ViewModels JobHandler.Failed += (x, ex) => { - if (ex is InsufficientLiquidQuantityException) - { - InvokeUI(() => - { - _notification.ShowModalDialog<InsufficientLiquidQuantityViewVM, InsufficientLiquidQuantityView>(new InsufficientLiquidQuantityViewVM(ex as InsufficientLiquidQuantityException), (_) => - { - - MachineOperator.EnableJobLiquidQuantityValidation = false; - StartJob(); + LogManager.Log(ex, String.Format("Job {0} has failed.", RunningJob.Name)); + _eventLogger.Log(ex, String.Format("Job {0} has failed.", RunningJob.Name)); + SetJobFailed(); - }, () => - { - SetJobFailed(); - - InvokeUI(() => - { - StopRecordingIfInProgress(); - }); - }); - }); - } - else + InvokeUI(() => { - LogManager.Log(ex, String.Format("Job {0} has failed.", RunningJob.Name)); - _eventLogger.Log(ex, String.Format("Job {0} has failed.", RunningJob.Name)); - SetJobFailed(); - - InvokeUI(() => - { - _notification.ShowError("Job failed. " + ex.FlattenMessage()); - StopRecordingIfInProgress(); - }); - } + _notification.ShowError("Job failed. " + ex.FlattenMessage()); + StopRecordingIfInProgress(); + }); }; JobHandler.Finalizing += (_, __) => @@ -1543,6 +1519,16 @@ namespace Tango.MachineStudio.Developer.ViewModels //Finally Canceled.. }; } + catch (InsufficientLiquidQuantityException ex) + { + _notification.ShowModalDialog<InsufficientLiquidQuantityViewVM, InsufficientLiquidQuantityView>(new InsufficientLiquidQuantityViewVM(ex), (x) => + { + + MachineOperator.EnableJobLiquidQuantityValidation = false; + StartJob(); + + }, () => { }); + } catch (Exception ex) { LogManager.Log(ex); @@ -1920,50 +1906,60 @@ namespace Tango.MachineStudio.Developer.ViewModels { CanWork = false; - using (_notification.PushTaskItem("Saving job details...")) + try { - await Task.Factory.StartNew(() => + using (_notification.PushTaskItem("Saving job details...")) { - LogManager.Log(String.Format("Saving the active job {0}...", ActiveJob.Name)); - ActiveJob.LastUpdated = DateTime.UtcNow; - ActiveJob.Rml = SelectedRML; - ActiveJob.EstimatedDurationMili = (int)EstimatedDuration.TotalMilliseconds; - _activeJobDbContext.SaveChanges(); - - _machineDbContext.Entry(SelectedMachineJob).Reload(); + await Task.Factory.StartNew(() => + { + LogManager.Log(String.Format("Saving the active job {0}...", ActiveJob.Name)); + ActiveJob.LastUpdated = DateTime.UtcNow; + ActiveJob.Rml = SelectedRML; + ActiveJob.EstimatedDurationMili = (int)EstimatedDuration.TotalMilliseconds; + _activeJobDbContext.SaveChanges(); + _machineDbContext.Entry(SelectedMachineJob).Reload(); - _machineDbContext.Entry(SelectedMachineJob).Collection(x => x.Segments).Load(); - foreach (var segment in SelectedMachineJob.Segments.ToList()) - { - _machineDbContext.Entry(segment).Collection(x => x.BrushStops).Load(); + _machineDbContext.Entry(SelectedMachineJob).Collection(x => x.Segments).Load(); - foreach (var brushStop in segment.BrushStops.ToList()) + foreach (var segment in SelectedMachineJob.Segments.ToList()) { - _machineDbContext.Entry(brushStop).Reload(); - } + _machineDbContext.Entry(segment).Collection(x => x.BrushStops).Load(); - _machineDbContext.Entry(segment).Reload(); - } + foreach (var brushStop in segment.BrushStops.ToList()) + { + _machineDbContext.Entry(brushStop).Reload(); + } - InvokeUI(() => - { - SelectedMachineJob.Segments = SelectedMachineJob.Segments; - }); + _machineDbContext.Entry(segment).Reload(); + } - var settings = SettingsManager.Default.GetOrCreate<DeveloperModuleSettings>(); - settings.DefaultJobRmlGuid = ActiveJob.RmlGuid; - settings.Save(); + InvokeUI(() => + { + SelectedMachineJob.Segments = SelectedMachineJob.Segments; + }); - if (ActiveJob != null) - { - _current_job_string = ActiveJob.ToJobFileWhenLoaded().ToString(); - } - }); - } + var settings = SettingsManager.Default.GetOrCreate<DeveloperModuleSettings>(); + settings.DefaultJobRmlGuid = ActiveJob.RmlGuid; + settings.Save(); - CanWork = true; + if (ActiveJob != null) + { + _current_job_string = ActiveJob.ToJobFileWhenLoaded().ToString(); + } + }); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error saving active job."); + _notification.ShowError($"An error occurred while trying to save the current job.\n{ex.FlattenMessage()}"); + } + finally + { + CanWork = true; + } } } @@ -2273,6 +2269,7 @@ namespace Tango.MachineStudio.Developer.ViewModels return; } SelectedSegment.BrushStops.Remove(x); + _activeJobDbContext.BrushStops.Remove(x); }); ArrangeBrushStopsIndices(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/InsufficientLiquidQuantityView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/InsufficientLiquidQuantityView.xaml index f0e9dc29c..fa85ea598 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/InsufficientLiquidQuantityView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/InsufficientLiquidQuantityView.xaml @@ -5,8 +5,10 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:vm="clr-namespace:Tango.MachineStudio.Developer.ViewModels" xmlns:local="clr-namespace:Tango.MachineStudio.Developer.Views" + xmlns:material="http://materialdesigninxaml.net/winfx/xaml/themes" mc:Ignorable="d" - Height="450" Width="800" Background="{StaticResource WhiteBackgroundBrush}" d:DataContext="{d:DesignInstance Type=vm:InsufficientLiquidQuantityViewVM, IsDesignTimeCreatable=False}"> + Height="590" Width="800" d:DataContext="{d:DesignInstance Type=vm:InsufficientLiquidQuantityViewVM, IsDesignTimeCreatable=False}" Foreground="{StaticResource Dialog.Foreground}" + Background="{StaticResource Dialog.Background}"> <Grid Margin="10"> <DockPanel> <StackPanel DockPanel.Dock="Top"> @@ -23,28 +25,53 @@ <Button HorizontalAlignment="Right" DockPanel.Dock="Bottom" Height="40" Width="140" Command="{Binding CloseCommand}" Margin="10 0 0 0">CLOSE</Button> </Grid> - <Border Margin="0 40 0 0" BorderThickness="1" BorderBrush="{StaticResource BorderBrushGainsboro}" CornerRadius="3"> - <ItemsControl ItemsSource="{Binding Exception.IdsPackLevels}"> + <Border Margin="0 20 0 0" BorderThickness="1" BorderBrush="{StaticResource BorderBrushGainsboro}" CornerRadius="3"> + <ItemsControl ItemsSource="{Binding Exception.IdsPackLevels}" VerticalAlignment="Top"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> - <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal" IsItemsHost="True"></StackPanel> + <StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Vertical" IsItemsHost="True"></StackPanel> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> - <StackPanel Margin="15 0"> - <TextBlock HorizontalAlignment="Center" Text="{Binding IdsPack.LiquidType.Name}"></TextBlock> - <Border Margin="0 5 0 0" Height="150" Width="50" CornerRadius="3" BorderThickness="1" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <Grid Margin="15 2"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="40" /> + <ColumnDefinition Width="160" /> + <ColumnDefinition Width="1*" /> + </Grid.ColumnDefinitions> + <material:PackIcon VerticalAlignment="Center" Width="24" Height="24"> + <material:PackIcon.Style> + <Style TargetType="material:PackIcon"> + <Setter Property="Kind" Value="CheckCircle"></Setter> + <Setter Property="Foreground" Value="{StaticResource GreenBrush100}"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding IsValid}" Value="False"> + <Setter Property="Kind" Value="Alert"></Setter> + <Setter Property="Foreground" Value="{StaticResource OrangeBrush}"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding IsOverMax}" Value="True"> + <Setter Property="Kind" Value="AlertOctagon"></Setter> + <Setter Property="Foreground" Value="{StaticResource RedBrush100}"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </material:PackIcon.Style> + + </material:PackIcon> + <material:PackIcon Kind="AlertOctagon" VerticalAlignment="Center" Width="24" Height="24" Visibility="{Binding IsValid,Converter={StaticResource BoolToVisConverter}}" /> + + <Border Grid.Column="1" Margin="5 0 0 0" Height="45" Width="150" CornerRadius="3" BorderThickness="1" BorderBrush="{StaticResource BorderBrushGainsboro}"> <Grid> - <Border CornerRadius="3" VerticalAlignment="Bottom" Loaded="IdsPackLoaded" MinHeight="5"> + <Border VerticalAlignment="Center" CornerRadius="3" Loaded="IdsPackLoaded" MinHeight="45" HorizontalAlignment="Left" MinWidth="5"> <Border.Background> - <LinearGradientBrush> - <GradientStop Offset="0" Color="#4DFFFFFF" /> + <LinearGradientBrush StartPoint="0,0" EndPoint="1,1"> <GradientStop Offset="0.5" Color="{Binding IdsPack.LiquidType.LiquidTypeColor}" /> + <GradientStop Offset="1" Color="#4EFFFFFF" /> </LinearGradientBrush> </Border.Background> </Border> - <Rectangle Loaded="Limit_Loaded" Stroke="Red" StrokeThickness="2" VerticalAlignment="Bottom"> + <Rectangle Loaded="Limit_Loaded" Stroke="Red" StrokeThickness="2" HorizontalAlignment="Left"> <Rectangle.Style> <Style TargetType="Rectangle"> <Style.Triggers> @@ -69,9 +96,16 @@ </Style> </Rectangle.Style> </Rectangle> + + <TextBlock Foreground="White" HorizontalAlignment="Center" Text="{Binding IdsPack.LiquidType.Name}" VerticalAlignment="Center"> + <TextBlock.Effect> + <DropShadowEffect ShadowDepth="0" BlurRadius="5" Color="Black" /> + </TextBlock.Effect> + </TextBlock> </Grid> </Border> - </StackPanel> + <TextBlock Grid.Column="2" HorizontalAlignment="Left" Text="{Binding Message}" VerticalAlignment="Center" Margin="20,0,0,0"></TextBlock> + </Grid> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/InsufficientLiquidQuantityView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/InsufficientLiquidQuantityView.xaml.cs index 171cb754e..51cfb1e73 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/InsufficientLiquidQuantityView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/InsufficientLiquidQuantityView.xaml.cs @@ -33,7 +33,7 @@ namespace Tango.MachineStudio.Developer.Views Grid parent = border.Parent as Grid; IDSPackLevel packLevel = border.DataContext as IDSPackLevel; - border.Height = ((double)packLevel.Current / (double)MachineOperator.MAX_DISPENSER_NANOLITER) * parent.ActualHeight; + border.Width = ((double)packLevel.Current / (double)MachineOperator.MAX_DISPENSER_NANOLITER) * parent.ActualWidth; } private void Limit_Loaded(object sender, RoutedEventArgs e) @@ -42,8 +42,8 @@ namespace Tango.MachineStudio.Developer.Views Grid parent = rect.Parent as Grid; IDSPackLevel packLevel = rect.DataContext as IDSPackLevel; - var top = ((double)packLevel.Required / (double)MachineOperator.MAX_DISPENSER_NANOLITER) * parent.ActualHeight; - rect.Margin = new Thickness(0, 0, 0, top); + var left = ((double)packLevel.Required / (double)MachineOperator.MAX_DISPENSER_NANOLITER) * parent.ActualWidth; + rect.Margin = new Thickness(left, 0, 0, 0); if (packLevel.IsValid) { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml index abea6aec9..d0caa2447 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml @@ -330,31 +330,36 @@ <Rectangle Height="30" Margin="0 10 0 0" VerticalAlignment="Center" Fill="{Binding SegmentBrush}"> </Rectangle> - <Canvas Height="30" HorizontalAlignment="Center" Width="80"> - <Label Padding="0" Margin="0"> - <Label.Style> - <Style TargetType="Label"> - <Setter Property="Content" Value="{x:Null}"></Setter> - <Style.Triggers> - <DataTrigger Binding="{Binding Started}" Value="True"> - <Setter Property="Content"> - <Setter.Value> - <TextBlock Text="{Binding RemainingTime,StringFormat=hh\\:mm\\:ss}" Foreground="{StaticResource RedBrush300}" FontFamily="{StaticResource digital-7}" HorizontalAlignment="Center" Margin="10" FontSize="20"></TextBlock> - </Setter.Value> - </Setter> - </DataTrigger> - <DataTrigger Binding="{Binding Completed}" Value="True"> - <Setter Property="Content"> - <Setter.Value> - <materialDesign:PackIcon Margin="30 10 0 0" HorizontalAlignment="Center" Width="24" Height="24" Kind="Check" Foreground="#47FF00" /> - </Setter.Value> - </Setter> - </DataTrigger> - </Style.Triggers> - </Style> - </Label.Style> - </Label> - </Canvas> + + <Grid Height="30"> + <TextBlock Visibility="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=DataContext.RunningJobStatus.IsFinalizing, Converter={StaticResource BooleanToVisibilityConverter}}" VerticalAlignment="Center" Background="Transparent" FontSize="12" Foreground="{StaticResource RedBrush100}">Finalizing...</TextBlock> + <Canvas Height="30" HorizontalAlignment="Center" Width="80"> + <Label Padding="0" Margin="0"> + <Label.Style> + <Style TargetType="Label"> + <Setter Property="Content" Value="{x:Null}"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding Started}" Value="True"> + <Setter Property="Content"> + <Setter.Value> + <TextBlock Text="{Binding RemainingTime,StringFormat=hh\\:mm\\:ss}" Foreground="{StaticResource RedBrush300}" FontFamily="{StaticResource digital-7}" HorizontalAlignment="Center" Margin="10" FontSize="20"></TextBlock> + </Setter.Value> + </Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Completed}" Value="True"> + <Setter Property="Content"> + <Setter.Value> + <materialDesign:PackIcon Margin="30 10 0 0" HorizontalAlignment="Center" Width="24" Height="24" Kind="Check" Foreground="#47FF00" /> + </Setter.Value> + </Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Label.Style> + </Label> + </Canvas> + </Grid> + </StackPanel> <Rectangle HorizontalAlignment="Right" Stroke="White" Margin="0 35 0 25" ></Rectangle> @@ -408,8 +413,7 @@ </Grid> </DockPanel> - <TextBlock Visibility="{Binding RunningJobStatus.IsFinalizing,Converter={StaticResource BooleanToVisibilityConverter}}" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="-170 0 0 0" Background="{StaticResource DarkGrayBrush}" FontSize="14" Height="30" Foreground="{StaticResource RedBrush100}">Finalizing...</TextBlock> - </Grid> + </Grid> </Border> <ProgressBar IsIndeterminate="True" VerticalAlignment="Bottom" Height="3" Visibility="{Binding IsJobRunning,Converter={StaticResource BooleanToVisibilityConverter}}"></ProgressBar> |
