예제 #1
0
 private static void OnDataRecived(object sender, DetectingEventArgs e)
 {
     e.PrintConsole();
     lock (locker)
     {
         SaveToDatabase(e);
     }
 }
예제 #2
0
 public static void PrintConsole(this DetectingEventArgs e)
 {
     Console.WriteLine();
     Console.WriteLine("Source " + e.DataSource +
                       " Motions " + e.AverageMotions +
                       " Count " + e.TotalCount +
                       " Time " + e.TimeStart.Hour + ":" + e.TimeStart.Minute + ":" + e.TimeStart.Second
                       );
 }
        private void SendData()
        {
            DetectingEventArgs data = new DetectingEventArgs
            {
                AverageMotions = (int)average_motions,
                AveragePixels  = average_pixels,
                TimeStart      = _cycleStart,
                TimeFinish     = DateTime.Now,
                TotalCount     = total_count,
                DataSource     = _connectionString
            };

            DataRecived?.Invoke(this, data); //если есть подписчик, то передаем ему данные
        }
예제 #4
0
        public static void SaveToDatabase(DetectingEventArgs e)
        {
            using (JournalDbCobtext db = new JournalDbCobtext())
            {
                db.Logs.Add(new Log()
                {
                    AverageMotions = e.AverageMotions,
                    TimeStart      = e.TimeStart,
                    TimeFinish     = e.TimeFinish,
                    TotalCount     = e.TotalCount,
                    Camera         = db.Cameras.Where(x => x.Source == e.DataSource).SingleOrDefault()
                });

                db.SaveChanges();
            }
        }
예제 #5
0
        private void OnFrameProcessed(object sender, DetectingEventArgs e)
        {
            try
            {
                Label   source_label = (Label)ActiveForm.Controls.Find("l_source", true).Where(x => x.Text == e.DataSource).Single();
                Control contr        = source_label.Parent.Controls["l_out"];
                _action = new MethodInvoker(() => contr.Text = e.TotalCount.ToString());


                if (contr.InvokeRequired)
                {
                    contr.Invoke(_action);
                }
                else
                {
                    _action();
                }
            }
            catch { }
        }
 private void OnControllerDataRecived(object sender, DetectingEventArgs e)
 {
     DataRecived?.Invoke(this, e);
 }
 private void Detector_FrameProcessed(object sender, DetectingEventArgs e)
 {
     //e.DataSource, e.TotalCount
     FrameProcessed?.Invoke(this, e);
 }