コード例 #1
0
ファイル: Program.cs プロジェクト: Sarcares/PL_FEZ3
        /**
         * This method is triggered when the network goes down.
         * It triggers the alarm.
         */
        private void OnNetworkDown(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {
            Debug.Print("Network down!");
            NetworkUp = false;
            multicolorLED.TurnRed();
            if (proxy != null)
            {
                proxy.closeChannel();
                proxy.Dispose();
                proxy.Dispose();
                proxy = null;
            }

            if (streaming)
            {
                streaming = false;
                camera.StopStreaming();
                button.ButtonPressed -= button_ButtonPressed;
                if (timer_joystick.IsRunning)
                {
                    timer_joystick.Stop();
                }
            }

            if (setupComplete)
            {
                timer_keepAlive.Stop();
                if (!throw_allarm)
                {
                    ThrowAllarm();
                }
                WindowsManager.showWindowInsertPin();
            }
            else
            {
                camera.StopStreaming();
                Thread.Sleep(250);
                WindowsManager.showWindowNetworkDown();
                return;
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Sarcares/PL_FEZ3
        /**
         * This method is triggered when the button is pressed.
         */
        private void button_ButtonPressed(GTM.GHIElectronics.Button sender, GTM.GHIElectronics.Button.ButtonState state)
        {
            Debug.Print("Button pressed!");
            button.ButtonPressed -= button_ButtonPressed;
            streaming             = false;
            camera.StopStreaming();
            camera.StopStreaming();
            timer_joystick.Stop();
            WindowsManager.showWindowLoadingStatic();
            Thread.Sleep(200);

            if (NetworkUp)
            {
                initServer();
            }
            else
            {
                Debug.Print("Network_Down!!!");
                WindowsManager.showWindowNetworkDown();
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Sarcares/PL_FEZ3
        public int checkLogin(String pin)
        {
            // HashAlgorithm hashSHA256 = new HashAlgorithm(HashAlgorithmType.MD5);
            Byte[] dataToHmac = System.Text.Encoding.UTF8.GetBytes(pin);

            if ((setupComplete && !NetworkUp && VolatilePin.Length == 8) || (setupComplete && NetworkUp && VolatilePin.Length == 8))
            {
                if (VolatilePin.Equals(pin))
                {
                    deactivateSystem();
                    return(2);
                }
            }

            if (setupComplete && NetworkUp)
            {
                try
                {
                    var data = proxy.isValid(new isValid()
                    {
                        mac = myMac,
                        pin = dataToHmac
                    });

                    if (data.isValidResult)
                    {
                        deactivateSystem();
                        return(2);
                    }
                    return(-1);
                }
                catch (Exception e)
                {
                    WindowsManager.showWindowServiceDown();
                    return(1);
                }
            }

            if (!NetworkUp)
            {
                WindowsManager.showWindowNetworkDown();
                return(2);
            }


            bindProxyService();

            try
            {
                var data2 = proxy.isValid(new isValid()
                {
                    mac = myMac,
                    pin = dataToHmac
                });
                if (data2.isValidResult)
                {
                    VolatilePin = pin;
                    return(0);
                }
                else
                {
                    return(-1);
                }
            }
            catch (Exception e)
            {
                WindowsManager.showWindowServiceDown();
                return(1);
            }
        }