Ejemplo n.º 1
0
        /// <summary>
        /// Start to stop recording after a latency
        /// Callback for timer
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RecordStop_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            applicationRestart.Enabled = false;

            if (isRFIDRequired)
            {
                ObjectDetector.IsOpenRFID = false;
                System.Threading.Thread.Sleep(1000);

                if (rfidThread != null)
                {
                    rfidThread.Abort();
                    rfidThread = null;
                }
            }

            if (objectDetector != null)
            {
                objectDetector = null;
            }

            isRecording      = false;
            isStoppingRecord = false;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Determine recording system status with requirements
        /// </summary>
        private void DetermineSystemStatus()
        {
            // Take number of people in the view for the requirements
            // Start recording
            if (Transformation.GetNumberOfPeople(persons) >= 1)
            {
                if (!isRecording)
                {
                    ActivityRecognition.Record.StartTime = DateTime.Now.ToString("M-d-yyyy_HH-mm-ss");

                    if (objectDetector == null)
                    {
                        objectDetector = new ObjectDetector(ListBox_Object, ListView_Object);
                    }

                    if (isRFIDRequired)
                    {
                        ObjectDetector.IsOpenRFID = true;

                        if (rfidThread == null)
                        {
                            rfidThread = new Thread(new ThreadStart(objectDetector.Run));
                            rfidThread.Start();
                        }
                    }

                    applicationRestart.AutoReset = false;
                    applicationRestart.Elapsed  += ApplicationRestart_Elapsed;
                    applicationRestart.Interval  = APPLICATION_RESTART_INTERVAL;
                    applicationRestart.Enabled   = true;

                    isRecording = true;
                }
            }

            // Stop recording
            if (Transformation.GetNumberOfPeople(persons) < 1)
            {
                if (isRecording)
                {
                    if (!isStoppingRecord)
                    {
                        isStoppingRecord = true;

                        recordStop           = new System.Timers.Timer();
                        recordStop.AutoReset = false;
                        recordStop.Elapsed  += RecordStop_Elapsed;
                        recordStop.Interval  = RECORD_STOP_INTERVAL;
                        recordStop.Enabled   = true;
                    }
                }
            }
            else
            {
                if (isStoppingRecord)
                {
                    isStoppingRecord   = false;
                    recordStop.Enabled = false;
                }
            }
        }