diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-12-19 18:01:01 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-12-19 18:01:01 +0200 |
| commit | 1208554e06da8aec1b074932df488769572ffcfb (patch) | |
| tree | 9858ededeb8badda5fc8b3052ef9745e419f35fd /Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs | |
| parent | 690604e6167bfa4fea0ab02f8b24a68142e8b546 (diff) | |
| download | Tango-1208554e06da8aec1b074932df488769572ffcfb.tar.gz Tango-1208554e06da8aec1b074932df488769572ffcfb.zip | |
Implemented auto thread loading.
Implemented advanced settings for technician.
Implemented thread loading on emulator.
Removed PowerUpSelectedRML from settings.
Now using LoadedRml settings for ThreadLoading and PowerUp.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs')
4 files changed, 231 insertions, 1 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/PowerUpView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/PowerUpView.xaml index 776233955..28f922898 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/PowerUpView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/PowerUpView.xaml @@ -20,7 +20,7 @@ <TextBlock VerticalAlignment="Center" Margin="20 0 0 0">Minimal temperature</TextBlock> </DockPanel> - <touch:TouchButton Command="{Binding OKCommand}" Margin="0 150 0 0" Style="{StaticResource TangoHollowButton}" HorizontalAlignment="Center" Padding="60 15">CONTINUE</touch:TouchButton> + <touch:TouchButton Command="{Binding OKCommand}" Margin="0 150 0 0" Style="{StaticResource TangoHollowButton}" HorizontalAlignment="Center" Padding="60 15" CornerRadius="25">CONTINUE</touch:TouchButton> <TextBlock HorizontalAlignment="Center" Margin="0 10 0 0" Visibility="{Binding IsTimeoutEnabled,Converter={StaticResource BooleanToVisibilityConverter}}"> <Run>auto select in</Run> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingView.xaml new file mode 100644 index 000000000..98f2e1381 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingView.xaml @@ -0,0 +1,47 @@ +<UserControl x:Class="Tango.PPC.UI.Dialogs.ThreadLoadingView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:local="clr-namespace:Tango.PPC.UI.Dialogs" + mc:Ignorable="d" + Background="{StaticResource TangoPrimaryBackgroundBrush}" d:DesignHeight="555" d:DesignWidth="560" Width="600" Height="900" d:DataContext="{d:DesignInstance Type=local:ThreadLoadingViewVM, IsDesignTimeCreatable=False}"> + <Grid> + <DockPanel> + <StackPanel Margin="0 30 0 0" HorizontalAlignment="Center" DockPanel.Dock="Top"> + <Image Source="/Images/thread_loading.png" Stretch="None"></Image> + <TextBlock HorizontalAlignment="Center" FontSize="{StaticResource TangoTitleFontSize}" Margin="0 30 0 0">Thread Loading</TextBlock> + + <Grid Height="283"> + <StackPanel Visibility="{Binding IsFinalizing,Converter={StaticResource BooleanToVisibilityInverseConverter}}"> + <TextBlock HorizontalAlignment="Center" FontSize="{StaticResource TangoDefaultFontSize}" Margin="40 10 40 0" Foreground="{StaticResource TangoGrayTextBrush}" TextWrapping="Wrap" TextAlignment="Center"> + The machine is ready for loading the thread. Please load the selected thread below and press 'continue'. + </TextBlock> + <touch:TouchComboBox Margin="0 40 0 0" Width="300" ItemsSource="{Binding Rmls}" SelectedItem="{Binding SelectedRml}" DisplayMemberPath="Name"></touch:TouchComboBox> + <touch:TouchButton Command="{Binding ContinueCommand}" Margin="0 50 0 50" Style="{StaticResource TangoHollowButton}" HorizontalAlignment="Center" Padding="60 15" CornerRadius="25">CONTINUE</touch:TouchButton> + </StackPanel> + <StackPanel Visibility="{Binding IsFinalizing,Converter={StaticResource BooleanToVisibilityConverter}}"> + <TextBlock HorizontalAlignment="Center" FontSize="{StaticResource TangoDefaultFontSize}" Margin="40 10 40 0" Foreground="{StaticResource TangoPrimaryAccentBrush}" TextWrapping="Wrap" TextAlignment="Center"> + The machine is now loading the thread. please wait... + </TextBlock> + <touch:TouchBusyIndicator Margin="0 100 0 0" Width="100" Height="100" IsIndeterminate="True" /> + </StackPanel> + </Grid> + </StackPanel> + + <Grid> + <touch:TouchGifAnimation Margin="10" Source="/Images/thread_loading.gif" VerticalAlignment="Bottom" Stretch="UniformToFill" EnableAnimation="{Binding IsVisible}" /> + + <!--<Grid VerticalAlignment="Top" Height="100"> + <Grid.Background> + <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> + <GradientStop Offset="0.3" Color="{StaticResource TangoPrimaryBackgroundColor}" /> + <GradientStop Offset="0.5" Color="Transparent" /> + </LinearGradientBrush> + </Grid.Background> + </Grid>--> + </Grid> + </DockPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingView.xaml.cs new file mode 100644 index 000000000..d4c737bcc --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.UI.Dialogs +{ + /// <summary> + /// Interaction logic for PowerUpView.xaml + /// </summary> + public partial class ThreadLoadingView : UserControl + { + public ThreadLoadingView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingViewVM.cs new file mode 100644 index 000000000..5e5370416 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingViewVM.cs @@ -0,0 +1,155 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.Core.Commands; +using Tango.Integration.Operation; +using Tango.PMR.ThreadLoading; +using Tango.PPC.Common.Connection; +using Tango.SharedUI; + +namespace Tango.PPC.UI.Dialogs +{ + public class ThreadLoadingViewVM : DialogViewVM + { + public class ThreadLoadingResult + { + public bool IsCompleted { get; set; } + public Exception FailedException { get; set; } + } + + private ThreadLoadingConfirmationRequiredEventArgs _confirmationArgs; + + public ThreadLoadingResult Result { get; set; } + + public IMachineProvider MachineProvider { get; set; } + + private StartThreadLoadingResponse _status; + public StartThreadLoadingResponse Status + { + get { return _status; } + set { _status = value; RaisePropertyChangedAuto(); } + } + + private bool _isFinalizing; + public bool IsFinalizing + { + get { return _isFinalizing; } + set { _isFinalizing = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + public List<Rml> Rmls { get; set; } + + private Rml _selectedRml; + public Rml SelectedRml + { + get { return _selectedRml; } + set { _selectedRml = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + public RelayCommand ContinueCommand { get; set; } + + public ThreadLoadingViewVM(IMachineProvider machineProvider, ThreadLoadingConfirmationRequiredEventArgs confirmationArgs) + { + CanClose = true; + _confirmationArgs = confirmationArgs; + ContinueCommand = new RelayCommand(ContinueThreadLoading, () => !IsFinalizing && SelectedRml != null); + MachineProvider = machineProvider; + MachineProvider.MachineOperator.ThreadLoadingStatusChanged += MachineOperator_ThreadLoadingStatusChanged; + MachineProvider.MachineOperator.ThreadLoadingCompleted += MachineOperator_ThreadLoadingCompleted; + MachineProvider.MachineOperator.ThreadLoadingFailed += MachineOperator_ThreadLoadingFailed; + } + + private async void ContinueThreadLoading() + { + IsFinalizing = true; + + try + { + await Task.Factory.StartNew(() => { _confirmationArgs.Confirm(SelectedRml.GetActiveProcessGroup().ProcessParametersTables.FirstOrDefault()); }); + } + catch (Exception ex) + { + Result = new ThreadLoadingResult() + { + FailedException = ex, + }; + + IsFinalizing = false; + + if (IsVisible) + { + InvokeUI(() => + { + Accept(); + }); + } + } + } + + private void MachineOperator_ThreadLoadingCompleted(object sender, StartThreadLoadingResponse e) + { + Result = new ThreadLoadingResult() + { + IsCompleted = true + }; + + if (IsVisible) + { + InvokeUI(() => + { + Accept(); + }); + } + } + + private void MachineOperator_ThreadLoadingFailed(object sender, StartThreadLoadingResponse e) + { + Result = new ThreadLoadingResult() + { + FailedException = new Exception(e.ErrorReason), + }; + + if (IsVisible) + { + InvokeUI(() => + { + Accept(); + }); + } + } + + private void MachineOperator_ThreadLoadingStatusChanged(object sender, StartThreadLoadingResponse e) + { + Status = e; + + if(Status.State == ThreadLoadingState.Finalizing) + { + IsFinalizing = true; + } + } + + protected override void Cancel() + { + IsFinalizing = false; + ClearEvents(); + base.Cancel(); + } + + protected override void Accept() + { + IsFinalizing = false; + ClearEvents(); + base.Accept(); + } + + private void ClearEvents() + { + MachineProvider.MachineOperator.ThreadLoadingStatusChanged -= MachineOperator_ThreadLoadingStatusChanged; + MachineProvider.MachineOperator.ThreadLoadingCompleted -= MachineOperator_ThreadLoadingCompleted; + MachineProvider.MachineOperator.ThreadLoadingFailed -= MachineOperator_ThreadLoadingFailed; + } + } +} |
