| ofs | hex dump | ascii |
|---|
| 0000 | 00 00 01 00 06 00 10 10 00 00 00 00 20 00 68 04 00 00 66 00 00 00 20 20 00 00 00 00 20 00 a8 10 | ..............h...f............. |
| 0020 | 00 00 ce 04 00 00 30 30 00 00 00 00 20 00 a8 25 00 00 76 15 00 00 40 40 00 00 00 00 20 00 28 42 | ......00.......%..v...@@......(B |
| 0040 | 00 00 1e 3b 00 00 80 80 00 00 00 00 20 00 28 08 01 00 46 7d 00 00 00 00 00 00 00 00 20 00 28 20 | ...;..........(...F}..........(. |
| 0060 | 04 00 6e 85 01 00 28 00 00 00 10 00 00 00 20 00 00 00 01 00 20 00 00 00 00 00 40 04 00 00 00 00 | ..n...(...................@..... |
| 0080 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff ff ff 01 ff ff ff 01 ff ff ff 01 ff ff ff 01 ff ff | ................................ |
| 00a0 | ff 01 ff ff ff 01 29 2b 2d 19 8c 8d 8e 47 b8 b8 b9 73 c9 c9 ca 9d b7 b7 b8 c5 ba bb bc e9 c1 c2 | ......)+-....G...s.............. |
| 00c0 | c3 f3 9b 9c 9d 45 ff ff ff 01 ff ff ff 01 ff ff ff 01 ff ff ff 01 99 9a 9b 47 bf c0 c0 8b ab ab | .....E...................G...... |
| 00e0 | ac bb b4 b5 b6 e9 d4 d4 d5 ff df df df ff da db db ff cc cc cd ff f7 f7 f7 ff fd fd fd ff f4 f4 | ................................ |
| 0100 | f5 ff 8b 8c 8d 99 ff ff ff 01 ff ff ff 01 ff ff ff 01 28 2a 2e 03 b8 b8 b9 c3 e0 e1 e1 ff e8 e8 | ..................(*............ |
| 0120 | e8 ff f2 f2 f2 ff fe fe fe ff fe fe fe ff e3 e4 e4 ff f9 f9 f9 ff fe fe fe ff fe fe fe ff fe fe | ................................ |
| 0140 | fe ff bb bc bc fd 6a 6b 6d 33 ff ff ff 01 ff ff ff 01 8e 8f 90 49 fd fd fd ff fe fe fe ff df df | ......jkm3...........I.......... |
| 0160 | df ff fd fd fd ff fe fe fe ff fe fe fe ff df df e0 ff fd fd fd ff fe fe fe ff fe fe fe ff fe fe | ................................ |
| 0180 | fe ff d9 d9 da ff 88 88 89 77 ff ff ff 01 ff ff ff 01 be be bf 7b fe fe fe ff fe fe fe ff df df | .........w...........{.......... |
| 01a0 | df ff fe fe fe ff fe fe fe ff fe fe fe ff df df e0 ff fd fd fd ff fe fe fe ff fe fe fe ff fe fe | ................................ |
| 01c0 | fe ff df df df ff 8c 8d 8e 85 ff ff ff 01 ff ff ff 01 ca ca cb 97 fe fe fe ff fe fe fe ff df df | ................................ |
| 01e0 | e0 ff fe fe fe ff fe fe fe ff fe fe fe ff df df e0 ff fe fe fe ff fe fe fe ff fe fe fe ff fe fe | ................................ |
| 0200 | fe ff df e0 e0 ff 94 95 96 91 ff ff ff 01 ff ff ff 01 d0 d1 d1 ad fe fe fe ff fe fe fe ff df df | ................................ |
| 0220 | e0 ff fe fe fe ff fd fd fd ff fd fd fd ff da da db ff e3 e4 e4 ff df df e0 ff e7 e8 e8 ff fe fe | ................................ |
| 0240 | fe ff df df e0 ff 9a 9a 9b 9b ff ff ff 01 ff ff ff 01 d4 d5 d5 bb e3 e3 e4 ff d9 d9 da ff bb bc | ................................ |
| 0260 | bc ff c0 c1 c2 ff c0 c1 c2 ff c0 c1 c1 ff c7 c7 c8 ff db db db ff df df e0 ff d4 d4 d4 ff df df | ................................ |
| 0280 | e0 ff c3 c3 c4 ff 9c 9d 9e a3 ff ff ff 01 ff ff ff 01 bc bc bd bf dd dd dd ff e5 e5 e5 ff f8 f8 | ................................ |
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.Commands;
using Tango.Integration.Operation;
using Tango.PMR.Power;
using Tango.PPC.Common;
using Tango.PPC.UI.AppBarItems;
using Tango.PPC.UI.Views;
namespace Tango.PPC.UI.ViewModels
{
public class PowerOffViewVM : PPCViewModel
{
private PowerDownHandler _handler;
private PowerOffAppBarItem _appBarItem;
private int _abortTries;
private StartPowerDownResponse _status;
public StartPowerDownResponse Status
{
get { return _status; }
set { _status = value; RaisePropertyChangedAuto(); }
}
public RelayCommand AbortCommand { get; set; }
public PowerOffViewVM()
{
_appBarItem = new PowerOffAppBarItem();
_appBarItem.Pressed += (x, e) =>
{
NavigationManager.NavigateTo<InternalModule>(nameof(PowerOffView));
};
AbortCommand = new RelayCommand(AbortPowerOff);
}
public override void OnApplicationStarted()
{
}
public override void OnApplicationReady()
{
base.OnApplicationReady();
MachineProvider.MachineOperator.PowerDownStarted += MachineOperator_PowerDownStarted;
}
private void MachineOperator_PowerDownStarted(object sender, PowerDownStartedEventArgs e)
{
_abortTries = 0;
_handler = e.Handler;
_handler.StatusChanged += OnStatusChanged;
_handler.Failed += OnFailed;
_handler.Completed += OnCompleted;
InvokeUI(async () =>
{
await NavigationManager.NavigateTo<InternalModule>(nameof(PowerOffView));
NotificationProvider.PushAppBarItem(_appBarItem);
});
}
private void OnStatusChanged(object sender, PowerDownStatusChangedEventArgs e)
{
Status = e.Status;
_appBarItem.Status = Status;
}
private void OnCompleted(object sender, EventArgs e)
{
InvokeUI(async () =>
{
if (IsVisible)
{
await NavigationManager.NavigateBack();
}
NotificationProvider.PopAppBarItem(_appBarItem);
});
}
private void OnFailed(object sender, Exception ex)
{
InvokeUI(async () =>
{
await NotificationProvider.ShowError($"An error occurred while powering off the machine.\n{ex.FlattenMessage()}");
if (IsVisible)
{
await NavigationManager.NavigateBack();
}
NotificationProvider.PopAppBarItem(_appBarItem);
});
}
private async void AbortPowerOff()
{
try
{
NotificationProvider.SetGlobalBusyMessage("Aborting machine power off...");
await _handler.Abort();
await NavigationManager.NavigateBack();
NotificationProvider.PopAppBarItem(_appBarItem);
}
catch (Exception ex)
{
_abortTries++;
LogManager.Log(ex, "Power down abort error.");
NotificationProvider.ReleaseGlobalBusyMessage();
await NotificationProvider.ShowError($"An error occurred while trying to abort the power off sequence.\n{ex.FlattenMessage()}");
if (_abortTries > 2)
{
if (IsVisible)
{
await NavigationManager.NavigateBack();
}
NotificationProvider.PopAppBarItem(_appBarItem);
}
}
finally
{
NotificationProvider.ReleaseGlobalBusyMessage();
}
}
}
}