blob: 87b3c012b1d0a8ceb3ebd90a4ac497da5ab90b8c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Integration.Emergency;
using Tango.PPC.Common;
using Tango.PPC.Common.Navigation;
namespace Tango.PPC.UI.ViewModels
{
public class EmergencyViewVM : PPCViewModel
{
private bool _isActive;
public override void OnApplicationStarted()
{
}
public override void OnApplicationReady()
{
base.OnApplicationReady();
MachineProvider.MachineOperator.EmergencyNotificationProvider.StatusChanged += EmergencyNotificationProvider_StatusChanged;
}
private void EmergencyNotificationProvider_StatusChanged(object sender, EmergencyStatusChangedEventArgs e)
{
InvokeUI(async () =>
{
if (e.Status == EmergencyStatus.On && !_isActive)
{
LogManager.Log("Emergency switch activated...");
_isActive = true;
await NavigationManager.NavigateTo(NavigationView.EmergencyView);
}
else if (_isActive)
{
LogManager.Log("Emergency switch deactivated...");
_isActive = false;
await NavigationManager.NavigateTo(NavigationView.LayoutView);
}
if (e.Status == EmergencyStatus.Error && e.ErrorException != null)
{
LogManager.Log(e.ErrorException, "Error occurred while detecting emergency switch.");
}
});
}
}
}
|