aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.DAL.Local/Properties/AssemblyInfo.cs
blob: db56a1e950a2bf67cda5141a8e91fcc2cfba5f5c (plain)
1
2
3
4
5
6
7
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("Tango - Local Data Access Layer")]
[assembly: AssemblyVersion("2.0.16.1737")]
[assembly: ComVisible(false)]
String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
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.");
                }
            });
        }
    }
}