aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-09-14 13:47:34 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-09-14 13:47:34 +0300
commit89ffc630471605c4757b5854af3d73b5b75e98d6 (patch)
treed83f1196b233560edd37d08d7d00810a7e6d5a32 /Software/Visual_Studio/PPC
parent0cfa44b16e412c7fbe1069d0cc83dfed486403b3 (diff)
downloadTango-89ffc630471605c4757b5854af3d73b5b75e98d6.tar.gz
Tango-89ffc630471605c4757b5854af3d73b5b75e98d6.zip
New thread loading wizard.
Diffstat (limited to 'Software/Visual_Studio/PPC')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Tango.PPC.Maintenance.csproj2
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs8
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Views/MaintenanceView.xaml2
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs7
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj3
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/ThreadLoading/IThreadLoadingService.cs13
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingView.xaml162
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingViewVM - Copy.cs176
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingViewVM.cs255
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Images/thread_loading_preview.pngbin0 -> 529370 bytes
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj6
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ThreadLoading/DefaultThreadLoadingService.cs50
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs4
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs97
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest2
15 files changed, 571 insertions, 216 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Tango.PPC.Maintenance.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Tango.PPC.Maintenance.csproj
index c43b4fb7f..21b2eeb0a 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Tango.PPC.Maintenance.csproj
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Tango.PPC.Maintenance.csproj
@@ -293,7 +293,7 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
+ <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
</VisualStudio>
</ProjectExtensions>
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs
index 17051b773..f8535ad35 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs
@@ -83,6 +83,8 @@ namespace Tango.PPC.Maintenance.ViewModels
public RelayCommand HeadCleaningCommand { get; set; }
+ public RelayCommand StartThreadLoadingCommand { get; set; }
+
public MaintenanceViewVM()
{
Guides = new ObservableCollection<GuideBase>(GuideHelper.CreateAllGuides());
@@ -96,6 +98,7 @@ namespace Tango.PPC.Maintenance.ViewModels
OpenCloseRightLeadingWheelsCommand = new OpenCloseRightLeadingWheelsCommand();
ResetThreadLoadingCommand = new ResetThreadLoadingCommand();
HeadCleaningCommand = new RelayCommand(PerformHeadCleaning,() => MachineProvider.MachineOperator.CanPrint);
+ StartThreadLoadingCommand = new RelayCommand(StartThreadLoading, () => MachineProvider.MachineOperator.CanPrint);
}
public override void OnApplicationStarted()
@@ -239,5 +242,10 @@ namespace Tango.PPC.Maintenance.ViewModels
{
await NotificationProvider.ShowDialog<HeadCleaningViewVM>();
}
+
+ private void StartThreadLoading()
+ {
+ ThreadLoadingService.StartThreadLoading();
+ }
}
}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Views/MaintenanceView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Views/MaintenanceView.xaml
index d51f0eb38..6c48888af 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Views/MaintenanceView.xaml
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Views/MaintenanceView.xaml
@@ -207,6 +207,8 @@
<touch:TouchButton Margin="20" CornerRadius="25" Height="50" FontSize="18" Style="{StaticResource TangoHollowButton}" Command="{Binding HeadCleaningCommand}">RUN HEAD CLEANING</touch:TouchButton>
+ <touch:TouchButton Margin="20" CornerRadius="25" Height="50" FontSize="18" Style="{StaticResource TangoHollowButton}" Command="{Binding StartThreadLoadingCommand}">THREAD LOADING WIZARD</touch:TouchButton>
+
<touch:TouchButton Margin="20" CornerRadius="25" Height="50" FontSize="18" Style="{StaticResource TangoHollowButton}" Command="{Binding ExportLogsCommand}" Visibility="{Binding ApplicationManager.IsInTechnicianMode,Converter={StaticResource BooleanToVisibilityConverter}}">EXPORT SYSTEM LOGS</touch:TouchButton>
</UniformGrid>
</StackPanel>
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs
index 85de1c7f8..98eef6883 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs
@@ -19,6 +19,7 @@ using Tango.PPC.Common.RemoteAssistance;
using Tango.PPC.Common.RemoteDesktop;
using Tango.PPC.Common.Storage;
using Tango.PPC.Common.Synchronization;
+using Tango.PPC.Common.ThreadLoading;
using Tango.Settings;
using Tango.SharedUI;
using static Tango.SharedUI.Controls.NavigationControl;
@@ -123,6 +124,12 @@ namespace Tango.PPC.Common
[TangoInject]
public IRemoteDesktopService RemoteDesktopService { get; set; }
+ /// <summary>
+ /// Gets or sets the thread loading service.
+ /// </summary>
+ [TangoInject]
+ public IThreadLoadingService ThreadLoadingService { get; set; }
+
private PPCSettings _settings;
/// <summary>
/// Gets the main PPC settings.
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj
index bdb337dc2..14666f16a 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj
@@ -190,6 +190,7 @@
<Compile Include="Synchronization\SynchronizationStatusChangedEventArgs.cs" />
<Compile Include="SystemInfo\DefaultSystemInfoService.cs" />
<Compile Include="SystemInfo\ISystemInfoService.cs" />
+ <Compile Include="ThreadLoading\IThreadLoadingService.cs" />
<Compile Include="UpdatePackages\DefaultPackageRunner.cs" />
<Compile Include="UpdatePackages\IPackageRunner.cs" />
<Compile Include="UpdatePackages\IPPCPackage.cs" />
@@ -488,7 +489,7 @@
</Target>
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
+ <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
</VisualStudio>
</ProjectExtensions>
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/ThreadLoading/IThreadLoadingService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/ThreadLoading/IThreadLoadingService.cs
new file mode 100644
index 000000000..ac878ed07
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/ThreadLoading/IThreadLoadingService.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.PPC.Common.ThreadLoading
+{
+ public interface IThreadLoadingService
+ {
+ void StartThreadLoading();
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingView.xaml
index d6db3d124..a88d7a598 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingView.xaml
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingView.xaml
@@ -4,51 +4,135 @@
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:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI"
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}">
+ Background="{StaticResource TangoPrimaryBackgroundBrush}" d:DesignHeight="555" d:DesignWidth="560" Width="700" Height="1150" 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 IsPreparing,Converter={StaticResource BooleanToVisibilityInverseConverter}}">
- <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 thread loading. Please load the thread as instructed and press 'continue'.
- </TextBlock>
- <touch:TouchComboBox Margin="0 40 0 0" Width="300" ItemsSource="{Binding Rmls}" SelectedItem="{Binding SelectedRml}" DisplayMemberPath="Name" Title="Select thread type"></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>
- </StackPanel>
- <StackPanel Visibility="{Binding IsPreparing,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 preparing for thread loading. please wait...
- </TextBlock>
- <touch:TouchBusyIndicator Margin="0 100 0 0" Width="100" Height="100" IsIndeterminate="True" />
- </StackPanel>
- </Grid>
+ <StackPanel DockPanel.Dock="Top" Margin="0 30 0 0">
+ <Image HorizontalAlignment="Center" Source="/Images/thread_loading.png" Stretch="None"></Image>
+ <TextBlock HorizontalAlignment="Center" FontSize="{StaticResource TangoHeaderFontSize}" Margin="0 30 0 0">Thread Loading</TextBlock>
</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 Margin="0 20 0 0">
+ <controls:NavigationControl Margin="0 5 0 0" SelectedObject="{Binding Stage}" TransitionType="Slide" TransitionAlwaysFades="False" TransitionDuration="00:00:0.1" SelectedIndex="0">
+ <Grid controls:NavigationControl.NavigationName="Welcome" Background="{StaticResource TangoPrimaryBackgroundBrush}">
+ <DockPanel>
+ <UniformGrid Margin="20" Columns="2" DockPanel.Dock="Bottom" Height="55">
+ <touch:TouchButton Style="{StaticResource TangoHollowButton}" Width="250" HorizontalAlignment="Left" Command="{Binding AbortCommand}">CLOSE</touch:TouchButton>
+ <touch:TouchButton Style="{StaticResource TangoHollowButton}" Width="250" HorizontalAlignment="Right" Command="{Binding ContinueCommand}">CONTINUE</touch:TouchButton>
+ </UniformGrid>
+ <DockPanel Margin="0 50 0 0" >
+ <StackPanel DockPanel.Dock="Top">
+ <TextBlock HorizontalAlignment="Center" FontSize="{StaticResource TangoTitleFontSize}">Welcome to the automatic thread loading wizard.</TextBlock>
+ <DockPanel HorizontalAlignment="Center" Margin="0 20 0 0">
+ <touch:TouchIcon Icon="Alert" VerticalAlignment="Center" Foreground="{StaticResource TangoWarningBrush}" />
+ <TextBlock TextWrapping="Wrap" TextAlignment="Center" VerticalAlignment="Center" Margin="10 0 0 0">Please ensure there are no thread residue in the system and press 'continue'.</TextBlock>
+ </DockPanel>
+ </StackPanel>
+ <Image Stretch="Uniform" Source="/Images/thread_loading_preview.png" VerticalAlignment="Bottom"></Image>
+ </DockPanel>
+ </DockPanel>
+ </Grid>
+ <Grid controls:NavigationControl.NavigationName="Preparing" Background="{StaticResource TangoPrimaryBackgroundBrush}">
+ <DockPanel>
+ <UniformGrid Margin="20" Columns="2" DockPanel.Dock="Bottom" Height="55">
+ <touch:TouchButton Style="{StaticResource TangoHollowButton}" Width="250" HorizontalAlignment="Left" Command="{Binding AbortCommand}">CLOSE</touch:TouchButton>
+ <touch:TouchButton Style="{StaticResource TangoHollowButton}" Width="250" HorizontalAlignment="Right" Command="{Binding ContinueCommand}">CONTINUE</touch:TouchButton>
+ </UniformGrid>
+ <DockPanel Margin="0 20 0 0">
+ <StackPanel VerticalAlignment="Center" DockPanel.Dock="Top">
+ <TextBlock Margin="0 50 0 0" FontSize="{StaticResource TangoTitleFontSize}" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center">
+ The system is now preparing...
+ </TextBlock>
+ <touch:TouchProgressBar Margin="50 10 50 0" Height="10" IsIndeterminate="{Binding IsVisible}" />
+ </StackPanel>
+ <Image VerticalAlignment="Bottom" Stretch="Uniform" Source="/Images/thread_loading_preview.png"></Image>
+ </DockPanel>
+ </DockPanel>
+ </Grid>
+ <Grid controls:NavigationControl.NavigationName="ReadyForLoading" Background="{StaticResource TangoPrimaryBackgroundBrush}">
+ <DockPanel>
+ <UniformGrid Margin="20" Columns="2" DockPanel.Dock="Bottom" Height="55">
+ <touch:TouchButton Style="{StaticResource TangoHollowButton}" Width="250" HorizontalAlignment="Left" Command="{Binding AbortCommand}">CLOSE</touch:TouchButton>
+ <touch:TouchButton Style="{StaticResource TangoHollowButton}" Width="250" HorizontalAlignment="Right" Command="{Binding ContinueCommand}">CONTINUE</touch:TouchButton>
+ </UniformGrid>
+ <DockPanel Margin="0 50 0 0">
+ <StackPanel DockPanel.Dock="Top">
+ <TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center">
+ Please select the thread type you are going to load and press 'continue'.
+ </TextBlock>
+ <touch:TouchComboBox Margin="0 40 0 0" Width="500" ItemsSource="{Binding Rmls}" SelectedItem="{Binding SelectedRml}" DisplayMemberPath="Name" Title="Select thread type"></touch:TouchComboBox>
+ </StackPanel>
+ <touch:TouchGifAnimation Margin="10" Source="/Images/thread_loading.gif" VerticalAlignment="Bottom" Stretch="Uniform" EnableAnimation="{Binding IsVisible}" />
+ </DockPanel>
+ </DockPanel>
+ </Grid>
+ <Grid controls:NavigationControl.NavigationName="Finalizing" Background="{StaticResource TangoPrimaryBackgroundBrush}">
+ <DockPanel>
+ <UniformGrid Margin="20" Columns="2" DockPanel.Dock="Bottom" Height="55">
+ <touch:TouchButton Style="{StaticResource TangoHollowButton}" Width="250" HorizontalAlignment="Left" Command="{Binding AbortCommand}">CLOSE</touch:TouchButton>
+ <touch:TouchButton Style="{StaticResource TangoHollowButton}" Width="250" HorizontalAlignment="Right" Command="{Binding ContinueCommand}">CONTINUE</touch:TouchButton>
+ </UniformGrid>
+ <DockPanel Margin="0 20 0 0">
+ <StackPanel VerticalAlignment="Center" DockPanel.Dock="Top">
+ <TextBlock Margin="0 50 0 0" FontSize="{StaticResource TangoTitleFontSize}" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center">
+ The system is now loading the thread...
+ </TextBlock>
+ <touch:TouchProgressBar Margin="50 10 50 0" Height="10" IsIndeterminate="{Binding IsVisible}" />
+ </StackPanel>
+ <Image VerticalAlignment="Bottom" Stretch="Uniform" Source="/Images/thread_loading_preview.png"></Image>
+ </DockPanel>
+ </DockPanel>
+ </Grid>
+ <Grid controls:NavigationControl.NavigationName="Completed" Background="{StaticResource TangoPrimaryBackgroundBrush}">
+ <DockPanel>
+ <UniformGrid Margin="20" DockPanel.Dock="Bottom" Height="55">
+ <touch:TouchButton Style="{StaticResource TangoHollowButton}" Width="250" HorizontalAlignment="Right" Command="{Binding AbortCommand}">CLOSE</touch:TouchButton>
+ </UniformGrid>
+ <DockPanel Margin="0 50 0 0" >
+ <StackPanel DockPanel.Dock="Top">
+ <touch:TouchIcon Icon="Check" HorizontalAlignment="Center" Foreground="{StaticResource TangoSuccessBrush}" Width="100" Height="100" />
+ <TextBlock HorizontalAlignment="Center" FontSize="{StaticResource TangoTitleFontSize}">Thread loading completed successfully!</TextBlock>
+ </StackPanel>
+ <Image Stretch="Uniform" Source="/Images/thread_loading_preview.png" VerticalAlignment="Bottom"></Image>
+ </DockPanel>
+ </DockPanel>
+ </Grid>
+ <Grid controls:NavigationControl.NavigationName="PreparationError" Background="{StaticResource TangoPrimaryBackgroundBrush}">
+ <DockPanel>
+ <UniformGrid Margin="20" Columns="2" DockPanel.Dock="Bottom" Height="55">
+ <touch:TouchButton Style="{StaticResource TangoHollowButton}" Width="250" HorizontalAlignment="Left" Command="{Binding AbortCommand}">CLOSE</touch:TouchButton>
+ <touch:TouchButton Style="{StaticResource TangoHollowButton}" Width="250" HorizontalAlignment="Right" Command="{Binding ContinueCommand}">RETRY</touch:TouchButton>
+ </UniformGrid>
+ <DockPanel Margin="0 50 0 0" >
+ <StackPanel DockPanel.Dock="Top">
+ <touch:TouchIcon Icon="Alert" HorizontalAlignment="Center" Foreground="{StaticResource TangoErrorBrush}" Width="100" Height="100" />
+ <TextBlock HorizontalAlignment="Center" FontSize="{StaticResource TangoTitleFontSize}">Something went wrong</TextBlock>
+ <TextBlock Margin="0 5 0 0" FontSize="{StaticResource TangoSmallFontSize}" TextAlignment="Center" TextWrapping="Wrap" HorizontalAlignment="Center" Foreground="{StaticResource TangoGrayTextBrush}" Text="{Binding Error}"></TextBlock>
+ </StackPanel>
+ <Image Stretch="Uniform" Source="/Images/thread_loading_preview.png" VerticalAlignment="Bottom"></Image>
+ </DockPanel>
+ </DockPanel>
+ </Grid>
+ <Grid controls:NavigationControl.NavigationName="FinalizationError" Background="{StaticResource TangoPrimaryBackgroundBrush}">
+ <DockPanel>
+ <UniformGrid Margin="20" Columns="2" DockPanel.Dock="Bottom" Height="55">
+ <touch:TouchButton Style="{StaticResource TangoHollowButton}" Width="250" HorizontalAlignment="Left" Command="{Binding AbortCommand}">CLOSE</touch:TouchButton>
+ <touch:TouchButton Style="{StaticResource TangoHollowButton}" Width="250" HorizontalAlignment="Right" Command="{Binding ContinueCommand}">RETRY</touch:TouchButton>
+ </UniformGrid>
+ <DockPanel Margin="0 50 0 0" >
+ <StackPanel DockPanel.Dock="Top">
+ <touch:TouchIcon Icon="Alert" HorizontalAlignment="Center" Foreground="{StaticResource TangoErrorBrush}" Width="100" Height="100" />
+ <TextBlock HorizontalAlignment="Center" FontSize="{StaticResource TangoTitleFontSize}">Something went wrong</TextBlock>
+ <TextBlock Margin="0 5 0 0" FontSize="{StaticResource TangoSmallFontSize}" TextAlignment="Center" TextWrapping="Wrap" HorizontalAlignment="Center" Foreground="{StaticResource TangoGrayTextBrush}" Text="{Binding Error}"></TextBlock>
+ </StackPanel>
+ <Image Stretch="Uniform" Source="/Images/thread_loading_preview.png" VerticalAlignment="Bottom"></Image>
+ </DockPanel>
+ </DockPanel>
+ </Grid>
+ </controls:NavigationControl>
</Grid>
</DockPanel>
</Grid>
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingViewVM - Copy.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingViewVM - Copy.cs
new file mode 100644
index 000000000..95fb77e48
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingViewVM - Copy.cs
@@ -0,0 +1,176 @@
+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(); }
+ }
+
+ private bool _isPreparing;
+ public bool IsPreparing
+ {
+ get { return _isPreparing; }
+ set { _isPreparing = 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)
+ {
+ CanClose = false;
+ IsPreparing = true;
+ ContinueCommand = new RelayCommand(ContinueThreadLoading, () => !IsFinalizing && SelectedRml != null);
+ MachineProvider = machineProvider;
+ MachineProvider.MachineOperator.ThreadLoadingStatusChanged += MachineOperator_ThreadLoadingStatusChanged;
+ MachineProvider.MachineOperator.ThreadLoadingCompleted += MachineOperator_ThreadLoadingCompleted;
+ MachineProvider.MachineOperator.ThreadLoadingFailed += MachineOperator_ThreadLoadingFailed;
+ MachineProvider.MachineOperator.ThreadLoadingConfirmationRequired += MachineOperator_ThreadLoadingConfirmationRequired;
+ }
+
+ public ThreadLoadingViewVM(IMachineProvider machineProvider, ThreadLoadingConfirmationRequiredEventArgs confirmationArgs) : this(machineProvider)
+ {
+ _confirmationArgs = confirmationArgs;
+ IsPreparing = false;
+ }
+
+ private void MachineOperator_ThreadLoadingConfirmationRequired(object sender, ThreadLoadingConfirmationRequiredEventArgs e)
+ {
+ _confirmationArgs = e;
+ IsPreparing = false;
+ }
+
+ 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;
+ MachineProvider.MachineOperator.ThreadLoadingConfirmationRequired -= MachineOperator_ThreadLoadingConfirmationRequired;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingViewVM.cs
index 5c4d003a1..75354caf2 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingViewVM.cs
@@ -3,28 +3,41 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tango.BL;
+using Tango.BL.Builders;
using Tango.BL.Entities;
using Tango.Core.Commands;
+using Tango.Core.DI;
using Tango.Integration.Operation;
using Tango.PMR.ThreadLoading;
+using Tango.PPC.Common;
using Tango.PPC.Common.Connection;
+using Tango.PPC.Common.Notifications;
+using Tango.Settings;
using Tango.SharedUI;
namespace Tango.PPC.UI.Dialogs
{
public class ThreadLoadingViewVM : DialogViewVM
{
- public class ThreadLoadingResult
+ public enum ThreadLoadingStage
{
- public bool IsCompleted { get; set; }
- public Exception FailedException { get; set; }
+ Welcome,
+ Preparing,
+ ReadyForLoading,
+ Finalizing,
+ Completed,
+ PreparationError,
+ FinalizationError,
}
- private ThreadLoadingConfirmationRequiredEventArgs _confirmationArgs;
+ [TangoInject]
+ private IMachineProvider MachineProvider { get; set; }
- public ThreadLoadingResult Result { get; set; }
+ [TangoInject]
+ private INotificationProvider NotificationProvider { get; set; }
- public IMachineProvider MachineProvider { get; set; }
+ private PPCSettings _settings;
private StartThreadLoadingResponse _status;
public StartThreadLoadingResponse Status
@@ -33,22 +46,13 @@ namespace Tango.PPC.UI.Dialogs
set { _status = value; RaisePropertyChangedAuto(); }
}
- private bool _isFinalizing;
- public bool IsFinalizing
+ private List<Rml> _rmls;
+ public List<Rml> Rmls
{
- get { return _isFinalizing; }
- set { _isFinalizing = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
+ get { return _rmls; }
+ set { _rmls = value; RaisePropertyChangedAuto(); }
}
- private bool _isPreparing;
- public bool IsPreparing
- {
- get { return _isPreparing; }
- set { _isPreparing = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
- }
-
- public List<Rml> Rmls { get; set; }
-
private Rml _selectedRml;
public Rml SelectedRml
{
@@ -56,121 +60,210 @@ namespace Tango.PPC.UI.Dialogs
set { _selectedRml = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
}
+ private ThreadLoadingStage _stage;
+ public ThreadLoadingStage Stage
+ {
+ get { return _stage; }
+ set { _stage = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
+ }
+
+ private String _error;
+ public String Error
+ {
+ get { return _error; }
+ set { _error = value; RaisePropertyChangedAuto(); }
+ }
+
+
public RelayCommand ContinueCommand { get; set; }
+ public RelayCommand AbortCommand { get; set; }
- public ThreadLoadingViewVM(IMachineProvider machineProvider)
+ public ThreadLoadingViewVM(bool userInvoked = false)
{
- CanClose = true;
- IsPreparing = true;
- ContinueCommand = new RelayCommand(ContinueThreadLoading, () => !IsFinalizing && SelectedRml != null);
- MachineProvider = machineProvider;
+ CanClose = false;
+
+ TangoIOC.Default.Inject(this);
+ _settings = SettingsManager.Default.GetOrCreate<PPCSettings>();
+
MachineProvider.MachineOperator.ThreadLoadingStatusChanged += MachineOperator_ThreadLoadingStatusChanged;
- MachineProvider.MachineOperator.ThreadLoadingCompleted += MachineOperator_ThreadLoadingCompleted;
- MachineProvider.MachineOperator.ThreadLoadingFailed += MachineOperator_ThreadLoadingFailed;
- MachineProvider.MachineOperator.ThreadLoadingConfirmationRequired += MachineOperator_ThreadLoadingConfirmationRequired;
+
+ ContinueCommand = new RelayCommand(Continue, CanContinue);
+ AbortCommand = new RelayCommand(Abort);
+
+ AdaptToState(userInvoked);
}
- public ThreadLoadingViewVM(IMachineProvider machineProvider, ThreadLoadingConfirmationRequiredEventArgs confirmationArgs) : this(machineProvider)
+ private void AdaptToState(bool userInvoked = false)
{
- _confirmationArgs = confirmationArgs;
- IsPreparing = false;
+ var status = MachineProvider.MachineOperator.ThreadLoadingStatus;
+
+ if (status != null)
+ {
+ if (status.State == ThreadLoadingState.Preparing)
+ {
+ Stage = ThreadLoadingStage.Preparing;
+ }
+ else if (status.State == ThreadLoadingState.ReadyForLoading)
+ {
+ Stage = ThreadLoadingStage.ReadyForLoading;
+ }
+ else if (status.State == ThreadLoadingState.Finalizing)
+ {
+ Stage = ThreadLoadingStage.Finalizing;
+ }
+ else if (status.State == ThreadLoadingState.PreparationError)
+ {
+ OnPreparationError(status.ErrorReason);
+ }
+ else if (status.State == ThreadLoadingState.FinalizationError)
+ {
+ OnFinalizationError(status.ErrorReason);
+ }
+ else if (status.State == ThreadLoadingState.Completed)
+ {
+ if (userInvoked)
+ {
+ Stage = ThreadLoadingStage.Welcome;
+ }
+ else
+ {
+ Stage = ThreadLoadingStage.Completed;
+ }
+ }
+ }
}
- private void MachineOperator_ThreadLoadingConfirmationRequired(object sender, ThreadLoadingConfirmationRequiredEventArgs e)
+ private void MachineOperator_ThreadLoadingStatusChanged(object sender, StartThreadLoadingResponse e)
{
- _confirmationArgs = e;
- IsPreparing = false;
+ Status = e;
+ AdaptToState();
}
- private async void ContinueThreadLoading()
+ private void Continue()
{
- IsFinalizing = true;
+ if (Stage == ThreadLoadingStage.Welcome)
+ {
+ Stage = ThreadLoadingStage.Preparing;
+ StartPreparing();
+ }
+ else if (Stage == ThreadLoadingStage.ReadyForLoading)
+ {
+ ContinueThreadLoading();
+ }
+ else if (Stage == ThreadLoadingStage.Completed)
+ {
+ Accept();
+ }
+ else if (Stage == ThreadLoadingStage.PreparationError)
+ {
+ Stage = ThreadLoadingStage.Preparing;
+ StartPreparing();
+ }
+ else if (Stage == ThreadLoadingStage.FinalizationError)
+ {
+ ContinueThreadLoading();
+ }
+ }
+ private async void StartPreparing()
+ {
try
{
- await Task.Factory.StartNew(() => { _confirmationArgs.Confirm(SelectedRml.GetActiveProcessGroup().ProcessParametersTables.FirstOrDefault()); });
+ await MachineProvider.MachineOperator.StartThreadLoading();
}
catch (Exception ex)
{
- Result = new ThreadLoadingResult()
- {
- FailedException = ex,
- };
-
- IsFinalizing = false;
-
- if (IsVisible)
- {
- InvokeUI(() =>
- {
- Accept();
- });
- }
+ OnPreparationError(ex.Message);
}
}
- private void MachineOperator_ThreadLoadingCompleted(object sender, StartThreadLoadingResponse e)
+ private async void ContinueThreadLoading()
{
- Result = new ThreadLoadingResult()
+ try
{
- IsCompleted = true
- };
-
- if (IsVisible)
+ Stage = ThreadLoadingStage.Finalizing;
+ await MachineProvider.MachineOperator.ContinueThreadLoading(SelectedRml.GetActiveProcessGroup().ProcessParametersTables.FirstOrDefault());
+ }
+ catch (Exception ex)
{
- InvokeUI(() =>
- {
- Accept();
- });
+ OnFinalizationError(ex.Message);
}
}
- private void MachineOperator_ThreadLoadingFailed(object sender, StartThreadLoadingResponse e)
+ private bool CanContinue()
{
- Result = new ThreadLoadingResult()
+ bool canContinue = false;
+
+ if (Stage != ThreadLoadingStage.Preparing && Stage != ThreadLoadingStage.Finalizing)
{
- FailedException = new Exception(e.ErrorReason),
- };
+ canContinue = true;
+ }
- if (IsVisible)
+ if (Stage == ThreadLoadingStage.ReadyForLoading && SelectedRml == null)
{
- InvokeUI(() =>
- {
- Accept();
- });
+ canContinue = false;
}
+
+ return canContinue;
}
- private void MachineOperator_ThreadLoadingStatusChanged(object sender, StartThreadLoadingResponse e)
+ private void OnPreparationError(String error)
{
- Status = e;
+ Error = error;
+ Stage = ThreadLoadingStage.PreparationError;
+ }
+
+ private void OnFinalizationError(String error)
+ {
+ Error = error;
+ Stage = ThreadLoadingStage.FinalizationError;
+ }
+
+ private void Abort()
+ {
+ Cancel();
+ }
+
+ public async override void OnShow()
+ {
+ base.OnShow();
+
+ LogManager.Log("Loading site RMLS...");
+
+ List<Rml> rmls = new List<Rml>();
- if (Status.State == ThreadLoadingState.Finalizing)
+ using (ObservablesContext db = ObservablesContext.CreateDefault())
{
- IsFinalizing = true;
+ rmls = await new RmlsCollectionBuilder(db).SetAll().ForHeadType(MachineProvider.Machine.MachineHeadType).ForSite(MachineProvider.Machine.SiteGuid).WithActiveParametersGroup().BuildListAsync();
}
+
+ var selectedRml = rmls.SingleOrDefault(x => x.Guid == _settings.LoadedRmlGuid);
+
+ Rmls = rmls;
+ SelectedRml = selectedRml != null ? selectedRml : rmls.FirstOrDefault();
}
protected override void Cancel()
{
- IsFinalizing = false;
- ClearEvents();
+ CleanUp();
base.Cancel();
}
protected override void Accept()
{
- IsFinalizing = false;
- ClearEvents();
+ CleanUp();
base.Accept();
}
- private void ClearEvents()
+ private void CleanUp()
{
MachineProvider.MachineOperator.ThreadLoadingStatusChanged -= MachineOperator_ThreadLoadingStatusChanged;
- MachineProvider.MachineOperator.ThreadLoadingCompleted -= MachineOperator_ThreadLoadingCompleted;
- MachineProvider.MachineOperator.ThreadLoadingFailed -= MachineOperator_ThreadLoadingFailed;
- MachineProvider.MachineOperator.ThreadLoadingConfirmationRequired -= MachineOperator_ThreadLoadingConfirmationRequired;
+
+ if (SelectedRml != null)
+ {
+ _settings.LoadedRmlGuid = SelectedRml.Guid;
+ _settings.Save();
+ }
}
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/thread_loading_preview.png b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/thread_loading_preview.png
new file mode 100644
index 000000000..9bbea3368
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/thread_loading_preview.png
Binary files differ
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj
index bfb16f10d..6b6934ce5 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj
@@ -160,6 +160,7 @@
</Compile>
<Compile Include="Dialogs\ScreenLockViewVM.cs" />
<Compile Include="Dialogs\TechnicianModeLoginViewVM.cs" />
+ <None Include="Dialogs\ThreadLoadingViewVM - Copy.cs" />
<Compile Include="Dialogs\ThreadLoadingViewVM.cs" />
<Compile Include="Dialogs\FirmwareUpgradeFromFileView.xaml.cs">
<DependentUpon>FirmwareUpgradeFromFileView.xaml</DependentUpon>
@@ -183,6 +184,7 @@
<Compile Include="Printing\DefaultPrintingManager.cs" />
<Compile Include="RemoteActions\DefaultRemoteActionsService.cs" />
<Compile Include="Threading\DefaultDispatcherProvider.cs" />
+ <Compile Include="ThreadLoading\DefaultThreadLoadingService.cs" />
<Compile Include="ViewModelLocator.cs" />
<Compile Include="ViewModels\EmergencyViewVM.cs" />
<Compile Include="ViewModels\ExternalBridgeViewVM.cs" />
@@ -450,6 +452,7 @@
<Content Include="..\..\Build\ColorLib\Debug\Tango.ColorLib_v4.dll">
<Link>Tango.ColorLib_v4.dll</Link>
</Content>
+ <Resource Include="Images\thread_loading_preview.png" />
<Content Include="Manifests\release.xml" />
<Content Include="Manifests\debug.xml" />
<None Include="firmware_package.tfp">
@@ -641,6 +644,7 @@
<Resource Include="Images\machine-update.png" />
<Resource Include="Images\home.png" />
</ItemGroup>
+ <ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
@@ -721,7 +725,7 @@ if $(ConfigurationName) == Debug copy /Y "$(TargetDir)Packages" "$(TargetDir)"</
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
+ <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
</VisualStudio>
</ProjectExtensions>
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ThreadLoading/DefaultThreadLoadingService.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ThreadLoading/DefaultThreadLoadingService.cs
new file mode 100644
index 000000000..5656300a7
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ThreadLoading/DefaultThreadLoadingService.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Integration.Operation;
+using Tango.PPC.Common.Connection;
+using Tango.PPC.Common.Notifications;
+using Tango.PPC.Common.Threading;
+using Tango.PPC.Common.ThreadLoading;
+using Tango.PPC.UI.Dialogs;
+
+namespace Tango.PPC.UI.ThreadLoading
+{
+ public class DefaultThreadLoadingService : IThreadLoadingService
+ {
+ private INotificationProvider _notificationsProvider;
+ private IMachineProvider _machineProvider;
+ private IDispatcherProvider _dispatcher;
+ private bool _dialogShown;
+
+ public DefaultThreadLoadingService(INotificationProvider notificationsProvider, IMachineProvider machineProvider, IDispatcherProvider dispatcher)
+ {
+ _notificationsProvider = notificationsProvider;
+ _machineProvider = machineProvider;
+ _dispatcher = dispatcher;
+ _machineProvider.MachineOperator.ThreadLoadingStatusChanged += MachineOperator_ThreadLoadingStatusChanged;
+ }
+
+ private void MachineOperator_ThreadLoadingStatusChanged(object sender, PMR.ThreadLoading.StartThreadLoadingResponse e)
+ {
+ if (!_dialogShown && e.State != PMR.ThreadLoading.ThreadLoadingState.None)
+ {
+ _dialogShown = true;
+ _dispatcher.Invoke(async () =>
+ {
+ await _notificationsProvider.ShowDialog<ThreadLoadingViewVM>(new ThreadLoadingViewVM());
+ _dialogShown = false;
+ });
+ }
+ }
+
+ public async void StartThreadLoading()
+ {
+ _dialogShown = true;
+ await _notificationsProvider.ShowDialog<ThreadLoadingViewVM>(new ThreadLoadingViewVM(true));
+ _dialogShown = false;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs
index 7011cd3be..181f70d4d 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs
@@ -33,6 +33,7 @@ using Tango.PPC.Common.Storage;
using Tango.PPC.Common.Synchronization;
using Tango.PPC.Common.SystemInfo;
using Tango.PPC.Common.Threading;
+using Tango.PPC.Common.ThreadLoading;
using Tango.PPC.Common.UpdatePackages;
using Tango.PPC.Common.UWF;
using Tango.PPC.Common.Web;
@@ -45,6 +46,7 @@ using Tango.PPC.UI.PPCApplication;
using Tango.PPC.UI.Printing;
using Tango.PPC.UI.RemoteActions;
using Tango.PPC.UI.Threading;
+using Tango.PPC.UI.ThreadLoading;
using Tango.PPC.UI.ViewModels;
using Tango.PPC.UI.Views;
using Tango.PPC.UI.ViewsContracts;
@@ -97,6 +99,7 @@ namespace Tango.PPC.UI
TangoIOC.Default.Unregister<IRemoteSqlService>();
TangoIOC.Default.Unregister<IInsightsService>();
TangoIOC.Default.Unregister<IRemoteActionsService>();
+ TangoIOC.Default.Unregister<IThreadLoadingService>();
if (App.StartupArgs != null && App.StartupArgs.Contains("-webDebug"))
{
@@ -139,6 +142,7 @@ namespace Tango.PPC.UI
TangoIOC.Default.Register<IRemoteSqlService, DefaultRemoteSqlService>();
TangoIOC.Default.Register<IInsightsService, DefaultInsightsService>();
TangoIOC.Default.Register<IRemoteActionsService, DefaultRemoteActionsService>();
+ TangoIOC.Default.Register<IThreadLoadingService, DefaultThreadLoadingService>();
TangoIOC.Default.Register<LoadingViewVM>();
TangoIOC.Default.Register<MainViewVM>();
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs
index 3b45a0c2b..05fb610c8 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs
@@ -236,102 +236,15 @@ namespace Tango.PPC.UI.ViewModels
private void MachineOperator_ThreadLoadingStatusChanged(object sender, PMR.ThreadLoading.StartThreadLoadingResponse e)
{
- if (e.State == PMR.ThreadLoading.ThreadLoadingState.Preparing)
- {
- DisplayThreadLoading();
- }
+ //if (e.State == PMR.ThreadLoading.ThreadLoadingState.Preparing)
+ //{
+ // DisplayThreadLoading();
+ //}
}
private void MachineOperator_ThreadLoadingConfirmationRequired(object sender, ThreadLoadingConfirmationRequiredEventArgs e)
{
- DisplayThreadLoading(e);
- }
-
- private async void DisplayThreadLoading(ThreadLoadingConfirmationRequiredEventArgs confirmationArgs = null)
- {
- if (_isThreadLoadingShown) return;
-
- _isThreadLoadingShown = true;
-
- LogManager.Log("Thread loading preparation/finalization detected, showing thread loading screen...");
-
- if (!Settings.DisplayAutomaticThreadLoadingScreen)
- {
- _isThreadLoadingShown = false;
- LogManager.Log("Thread loading screen disabled. skipping...");
- return;
- }
-
- ThreadLoadingViewVM vm;
-
- try
- {
- LogManager.Log("Loading site rmls...");
-
- List<Rml> rmls = new List<Rml>();
-
- using (ObservablesContext db = ObservablesContext.CreateDefault())
- {
- rmls = await new RmlsCollectionBuilder(db).SetAll().ForHeadType(MachineProvider.Machine.MachineHeadType).ForSite(MachineProvider.Machine.SiteGuid).WithActiveParametersGroup().BuildListAsync();
- }
-
- var selectedRml = rmls.SingleOrDefault(x => x.Guid == Settings.LoadedRmlGuid);
-
- if (confirmationArgs == null)
- {
- vm = new ThreadLoadingViewVM(MachineProvider);
- }
- else
- {
- vm = new ThreadLoadingViewVM(MachineProvider, confirmationArgs);
- }
-
- vm.Rmls = rmls;
- vm.SelectedRml = selectedRml != null ? selectedRml : rmls.FirstOrDefault();
- }
- catch (Exception ex)
- {
- _isThreadLoadingShown = false;
- LogManager.Log(ex, "Error initializing thread loading screen.");
- return;
- }
-
- InvokeUI(async () =>
- {
- await NotificationProvider.ShowDialog<ThreadLoadingViewVM>(vm);
-
- _isThreadLoadingShown = false;
-
- LogManager.Log("Thread loading screen closed.");
-
- if (!vm.DialogResult)
- {
- LogManager.Log("Thread loading screen aborted by user. No operation was performed.");
- return;
- }
-
- try
- {
- if (vm.Result.IsCompleted)
- {
- await NotificationProvider.ShowSuccess("Thread loading completed successfully.");
- }
- else
- {
- await NotificationProvider.ShowError($"Thread loading failed due to the following reason:\n{vm.Result.FailedException.FlattenException()}");
- }
-
- if (vm.SelectedRml != null)
- {
- Settings.LoadedRmlGuid = vm.SelectedRml.Guid;
- Settings.Save();
- }
- }
- catch (Exception ex)
- {
- LogManager.Log(ex, "Error occurred after thread loading screen closed.");
- }
- });
+// DisplayThreadLoading(e);
}
#endregion
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest
index d72e75011..efc5f8179 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest
@@ -16,7 +16,7 @@
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
- <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
+ <!--<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />-->
</requestedPrivileges>
</security>
</trustInfo>