示例#1
0
        /**
         * This method is triggered when an image is caught.
         */
        private void camera_PictureCaptured(GTM.GHIElectronics.Camera sender, GT.Picture picture)
        {
            if (throw_allarm || picture == null || !setupComplete)
            {
                return;
            }

            Int32  HeurSum = 0;
            Bitmap bitmapB = picture.MakeBitmap();

            Debug.Print("Image captured! ");
            try
            {
                if (contImage < 2)
                {
                    if (contImage == 0)
                    {
                        setupCameraTakePicture();
                    }
                    contImage++;
                    return;
                }

                if (bitmapA == null)    //per gestire la prima volta
                {
                    WindowsManager.showWindowInsertPin();
                    bitmapA         = bitmapB;
                    RGlobal         = heuristicSum(bitmapA);
                    PreviousAverage = RGlobal / 9;
                    sendPicture(picture.PictureData, true);
                    return;
                }

                Debug.Print(DateTime.Now.ToString());
                HeurSum = heuristicSum(bitmapB);
                Debug.Print(DateTime.Now.ToString());

                Debug.Print(PreviousAverage.ToString());
                Int32 average = (HeurSum / 9);
                Debug.Print(average.ToString());

                if (System.Math.Abs(PreviousAverage - average) > 45)    //SOGLIA LIMITE 40/50
                {
                    Debug.Print("Suspicious picture!");
                    sendPicture(picture.PictureData, false);
                }

                RGlobal         = HeurSum;
                PreviousAverage = average;

                //  displayT35.SimpleGraphics.DisplayImage(picture, 0, 0); //TODO eliminare alla fine
            }
            catch (SocketException e)
            {
                timer_getimage.Stop();
                timer_keepAlive.Stop();
                WindowsManager.showWindowErrorServer();
            }
        }
示例#2
0
 /**
  * This method is triggered when the network goes up.
  */
 private void OnNetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
 {
     Debug.Print("Network up!");
     NetworkUp = true;
     multicolorLED.TurnGreen();
     ListNetworkInterfaces();
     ethernetJ11D.NetworkDown += OnNetworkDown;
     WindowsManager.showWindowInsertPin();
 }
示例#3
0
        /**
         * This method is run when the mainboard is powered up or reset.
         */
        void ProgramStarted()
        {
            Debug.Print("Program Started");     // to show messages in "Output" window during debugging
            multicolorLED.TurnRed();

            Thread.Sleep(300);
            InitSensors();

            SetupEthernet();

            camera.PictureCaptured += camera_PictureCaptured;
            camera.BitmapStreamed  += camera_BitmapStreamed;

            camera.CameraDisconnected += camera_CameraDisconnected;
            camera.CameraConnected    += camera_CameraConnected;
            WindowsManager.showWindowInsertPin();
        }
示例#4
0
        /**
         * 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;
            }
        }