diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2019-08-11 16:53:56 +0300 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2019-08-11 16:53:56 +0300 |
| commit | 111684728db118e40f05efc01287ea91ea295502 (patch) | |
| tree | 10f619288f346b713a31e3231253cd5b68bae481 /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels | |
| parent | d045a47ad7363e62b763013fa6afcdb1762a7ce3 (diff) | |
| parent | 7a914abc9e34c12acec0234ab748e17a21833af7 (diff) | |
| download | Tango-111684728db118e40f05efc01287ea91ea295502.tar.gz Tango-111684728db118e40f05efc01287ea91ea295502.zip | |
merge conflict
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/EmergencyViewVM.cs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/EmergencyViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/EmergencyViewVM.cs new file mode 100644 index 000000000..87b3c012b --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/EmergencyViewVM.cs @@ -0,0 +1,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."); + } + }); + } + } +} |
