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/ViewModels | |
| 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/ViewModels')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs | 76 |
1 files changed, 74 insertions, 2 deletions
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<Rml> rmls = new List<Rml>(); + + 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<ThreadLoadingViewVM>(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 } } |
