From 1208554e06da8aec1b074932df488769572ffcfb Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 19 Dec 2019 18:01:01 +0200 Subject: 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. --- .../Tango.PPC.MachineSettings/Views/MainView.xaml | 62 ++++++++- .../Connection/DefaultMachineProvider.cs | 3 +- .../PPC/Tango.PPC.Common/PPCSettings.cs | 25 +++- .../PPC/Tango.PPC.UI/Dialogs/PowerUpView.xaml | 2 +- .../Tango.PPC.UI/Dialogs/ThreadLoadingView.xaml | 47 +++++++ .../Tango.PPC.UI/Dialogs/ThreadLoadingView.xaml.cs | 28 ++++ .../Tango.PPC.UI/Dialogs/ThreadLoadingViewVM.cs | 155 +++++++++++++++++++++ .../PPC/Tango.PPC.UI/Images/thread_loading.gif | Bin 0 -> 4467469 bytes .../PPC/Tango.PPC.UI/Images/thread_loading.png | Bin 0 -> 7209 bytes .../PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 12 +- .../PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs | 76 +++++++++- 11 files changed, 397 insertions(+), 13 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingView.xaml create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Images/thread_loading.gif create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Images/thread_loading.png (limited to 'Software/Visual_Studio/PPC') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml index 4a2f1e253..5f453c874 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml @@ -11,7 +11,7 @@ xmlns:global="clr-namespace:Tango.PPC.MachineSettings" xmlns:local="clr-namespace:Tango.PPC.MachineSettings.Views" mc:Ignorable="d" - d:DesignHeight="3000" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + d:DesignHeight="3600" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> @@ -242,12 +242,70 @@ - Once enabled, synchronization occurres automatically in the background. you can choose to synchronize right now. + Once enabled, synchronization occurs automatically in the background. you can choose to synchronize right now. Synchronize Now + + + + + + + Embedded COM Port + + + + + Emergency COM Port + + + + + Enable Emergency Screen + + + + + Enable Embedded Debug Logs + + + + + Enable Automatic Thread Loading Support + + + + + Display PowerUp Screen + + + + + Enable Job Liquid Quantity Validation + + + + + Always Start in Technician Mode + + + + + Gradient Resolution CM + + + + + + + Please restart the application for advanced settings to take effect. + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs index eae09a7e7..6d90ece73 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs @@ -82,7 +82,8 @@ namespace Tango.PPC.Common.Connection MachineOperator.UseKeepAlive = true; MachineOperator.EnableMachineStatusUpdates = true; MachineOperator.EnableDiagnostics = false; - MachineOperator.EnableEmbeddedDebugging = true; + MachineOperator.EnableEmbeddedDebugging = settings.EnableEmbeddedDebugLogs; + MachineOperator.EnableAutomaticThreadLoading = settings.EnableAutomaticThreadLoading; MachineOperator.FirmwareUpgradeMode = Integration.Upgrade.FirmwareUpgradeModes.DFU | Integration.Upgrade.FirmwareUpgradeModes.TFP_PACKAGE; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index cb17f5be3..96fe39a9b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -199,11 +199,6 @@ namespace Tango.PPC.Common /// public String FirmwareVersion { get; set; } - /// - /// Gets or sets the last power up selected RML. - /// - public String LastPowerUpSelectedRmlGuid { get; set; } - /// /// Gets or sets a value indicating whether to display the power up screen. /// @@ -219,6 +214,21 @@ namespace Tango.PPC.Common /// public bool AutoCheckForUpdates { get; set; } + /// + /// Gets or sets a value indicating whether to enable the automatic thread loading support. + /// + public bool EnableAutomaticThreadLoading { get; set; } + + /// + /// Gets or sets a value indicating whether to display the thread loading screen. + /// + public bool DisplayAutomaticThreadLoadingScreen { get; set; } + + /// + /// Gets or sets a value indicating whether to enable embedded debug logs. + /// + public bool EnableEmbeddedDebugLogs { get; set; } + /// /// Gets the machine service address. /// @@ -259,8 +269,11 @@ namespace Tango.PPC.Common SynchronizationInterval = TimeSpan.FromMinutes(60); FirmwareVersion = "1.0.0.0"; DisplayPowerUpScreen = true; - PowerUpScreenTimeout = TimeSpan.FromSeconds(20); + PowerUpScreenTimeout = TimeSpan.FromSeconds(60); AutoCheckForUpdates = true; + EnableAutomaticThreadLoading = true; + DisplayAutomaticThreadLoadingScreen = true; + EnableEmbeddedDebugLogs = true; } } } 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 @@ Minimal temperature - CONTINUE + CONTINUE auto select in 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 @@ + + + + + + Thread Loading + + + + + The machine is ready for loading the thread. Please load the selected thread below and press 'continue'. + + + CONTINUE + + + + The machine is now loading the thread. please wait... + + + + + + + + + + + + + + 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 +{ + /// + /// Interaction logic for PowerUpView.xaml + /// + 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 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; + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/thread_loading.gif b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/thread_loading.gif new file mode 100644 index 000000000..a89f37004 Binary files /dev/null and b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/thread_loading.gif differ diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/thread_loading.png b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/thread_loading.png new file mode 100644 index 000000000..5d536e7ae Binary files /dev/null and b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/thread_loading.png 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 49b0c81d1..0dbabbf56 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 @@ -136,6 +136,9 @@ InsufficientLiquidQuantityView.xaml + + ThreadLoadingView.xaml + PowerUpView.xaml @@ -149,6 +152,7 @@ + UpdateFromFileView.xaml @@ -246,6 +250,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + Designer MSBuild:Compile @@ -409,6 +417,8 @@ + + @@ -671,7 +681,7 @@ if $(ConfigurationName) == Debug copy /Y "$(TargetDir)Packages" "$(TargetDir)" - + \ No newline at end of file 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 8a4d20b76..eeb11ffab 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs @@ -63,6 +63,7 @@ namespace Tango.PPC.UI.ViewModels base.OnApplicationReady(); MachineProvider.MachineOperator.CartridgeValidationRequestReceived += MachineOperator_CartridgeValidationRequestReceived; MachineProvider.MachineOperator.PowerUpStarted += MachineOperator_PowerUpStarted; + MachineProvider.MachineOperator.ThreadLoadingConfirmationRequired += MachineOperator_ThreadLoadingConfirmationRequired; } #region Event Handlers @@ -120,7 +121,7 @@ namespace Tango.PPC.UI.ViewModels rmls = await new RmlsCollectionBuilder(db).SetAll().WithSite(MachineProvider.Machine.SiteGuid).BuildListAsync(); } - var selectedRml = rmls.SingleOrDefault(x => x.Guid == Settings.LastPowerUpSelectedRmlGuid); + var selectedRml = rmls.SingleOrDefault(x => x.Guid == Settings.LoadedRmlGuid); vm = new PowerUpViewVM(); vm.Rmls = rmls; @@ -165,7 +166,7 @@ namespace Tango.PPC.UI.ViewModels LogManager.Log("Uploading process parameters..."); var r = MachineProvider.MachineOperator.UploadProcessParameters(processToLoad).Result; - Settings.LastPowerUpSelectedRmlGuid = vm.IsSelectedRml ? vm.SelectedRml.Guid : null; + Settings.LoadedRmlGuid = vm.IsSelectedRml ? vm.SelectedRml.Guid : null; Settings.Save(); } } @@ -177,6 +178,77 @@ namespace Tango.PPC.UI.ViewModels }); } + private async void MachineOperator_ThreadLoadingConfirmationRequired(object sender, ThreadLoadingConfirmationRequiredEventArgs e) + { + LogManager.Log("Thread loading confirmation detected, showing thread loading screen..."); + + if (!Settings.DisplayAutomaticThreadLoadingScreen) + { + LogManager.Log("Thread loading screen disabled. skipping..."); + return; + } + + ThreadLoadingViewVM vm; + + try + { + LogManager.Log("Loading site rmls..."); + + List rmls = new List(); + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + rmls = await new RmlsCollectionBuilder(db).SetAll().WithSite(MachineProvider.Machine.SiteGuid).WithActiveParametersGroup().BuildListAsync(); + } + + var selectedRml = rmls.SingleOrDefault(x => x.Guid == Settings.LoadedRmlGuid); + + vm = new ThreadLoadingViewVM(MachineProvider, e); + vm.Rmls = rmls; + vm.SelectedRml = selectedRml != null ? selectedRml : rmls.FirstOrDefault(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error initializing thread loading screen."); + return; + } + + InvokeUI(async () => + { + await NotificationProvider.ShowDialog(vm); + + 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."); + } + }); + } + #endregion } } -- cgit v1.3.1