aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs146
1 files changed, 52 insertions, 94 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 b53a54682..05fb610c8 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs
@@ -21,6 +21,7 @@ using Tango.PPC.Common.WatchDog;
using Tango.PPC.UI.Dialogs;
using Tango.SharedUI;
using System.Data.Entity;
+using Tango.PPC.UI.AppBarItems;
namespace Tango.PPC.UI.ViewModels
{
@@ -33,6 +34,8 @@ namespace Tango.PPC.UI.ViewModels
private DispatcherTimer _date_timer;
private bool _isPowerUpDialogShown;
private bool _isThreadLoadingShown;
+ private PowerUpAppBarItem _powerUpAppBar;
+ private bool _started;
private DateTime _currentDateTime;
/// <summary>
@@ -64,11 +67,53 @@ namespace Tango.PPC.UI.ViewModels
{
base.OnApplicationReady();
MachineProvider.MachineOperator.CartridgeValidationRequestReceived += MachineOperator_CartridgeValidationRequestReceived;
- MachineProvider.MachineOperator.PowerUpStarted += MachineOperator_PowerUpStarted;
+ MachineProvider.MachineOperator.FirmwareStarted += MachineOperator_FirmwareStarted;
MachineProvider.MachineOperator.ThreadLoadingStatusChanged += MachineOperator_ThreadLoadingStatusChanged;
MachineProvider.MachineOperator.ThreadLoadingConfirmationRequired += MachineOperator_ThreadLoadingConfirmationRequired;
+
+ MachineProvider.MachineOperator.PowerUpStarted += MachineOperator_PowerUpStarted;
+ MachineProvider.MachineOperator.PowerUpProgress += MachineOperator_PowerUpProgress;
+ MachineProvider.MachineOperator.PowerUpEnded += MachineOperator_PowerUpEnded;
+ }
+
+ #region Power Up
+
+ private void MachineOperator_PowerUpEnded(object sender, EventArgs e)
+ {
+ _started = false;
+ _powerUpAppBar?.Close();
+ _powerUpAppBar = null;
+ }
+
+ private void MachineOperator_PowerUpProgress(object sender, PMR.Power.StartPowerUpResponse status)
+ {
+ if (_powerUpAppBar != null)
+ {
+ _powerUpAppBar.Status = status;
+ }
+ }
+
+ private void MachineOperator_PowerUpStarted(object sender, PMR.Power.StartPowerUpResponse e)
+ {
+ _started = true;
+
+ InvokeUI(() =>
+ {
+ if (_powerUpAppBar != null)
+ {
+ _powerUpAppBar.Close();
+ }
+
+ if (_started)
+ {
+ _powerUpAppBar = NotificationProvider.PushAppBarItem<PowerUpAppBarItem>();
+ _powerUpAppBar.Priority = AppBarPriority.Low;
+ }
+ });
}
+ #endregion
+
#region Event Handlers
/// <summary>
@@ -101,7 +146,7 @@ namespace Tango.PPC.UI.ViewModels
});
}
- private async void MachineOperator_PowerUpStarted(object sender, EventArgs e)
+ private async void MachineOperator_FirmwareStarted(object sender, EventArgs e)
{
if (_isPowerUpDialogShown)
{
@@ -191,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
}