Ejemplo n.º 1
0
        public DataTable GetDeviceInfo()
        {
            DataTable dataTable = new DataTable();

            dataTable.TableName = "EResults";
            dataTable.Columns.Add("ID", typeof(Guid));
            dataTable.Columns.Add("ExtractCount", typeof(int));
            dataTable.Columns.Add("ESState", typeof(string));
            dataTable.Columns.Add("CPUUsage", typeof(int));
            dataTable.Columns.Add("ThreadCount", typeof(int));
            dataTable.Columns.Add("MaxThreadCount", typeof(int));
            int cpuUsage       = ExtractorServer.GetCpuUsage();
            int processorCount = Environment.ProcessorCount;
            int num            = Enumerable.Sum <BcDevices>((IEnumerable <BcDevices>)ExtractorServer.AllDevices, (Func <BcDevices, int>)(dev => dev.ExtractorCount));

            foreach (BcDevices bcDevices in ExtractorServer.AllDevices)
            {
                dataTable.Rows.Add((object)bcDevices.Id, (object)bcDevices.ExtractCount, (object)"Работает", (object)cpuUsage, (object)num, (object)processorCount);
            }
            if (dataTable.Rows.Count == 0)
            {
                dataTable.Rows.Add((object)Guid.Empty, (object)0, (object)"Работает", (object)cpuUsage, (object)num, (object)processorCount);
            }
            return(dataTable);
        }
Ejemplo n.º 2
0
 public static void WorkerThread(object extractor)
 {
     ExtractorServer.KeyExtractor keyExtractor = (ExtractorServer.KeyExtractor)extractor;
     while (!keyExtractor.StopFlag)
     {
         while (keyExtractor.BreakFlag)
         {
             keyExtractor.Breaked = true;
             if (!keyExtractor.StopFlag)
             {
                 Thread.Sleep(30);
             }
             else
             {
                 break;
             }
         }
         keyExtractor.Breaked = false;
         BcDevices bcDevices = keyExtractor.Device;
         try
         {
             Engine.Initialize(0U);
             using (Engine engine = new Engine())
             {
                 while (!keyExtractor.BreakFlag && !keyExtractor.StopFlag)
                 {
                     FaceFrame orDefault = LimitedConcurrentQueueExtensions.GetOrDefault <FaceFrame>(ExtractorServer._faceframes);
                     if (orDefault == null)
                     {
                         Thread.Sleep(10);
                     }
                     else
                     {
                         byte[] template = ExtractorServer.ExtractTemplate(orDefault, (IEngine)engine);
                         bcDevices.AddKeyFrame(new KeyFrame()
                         {
                             Frame = orDefault,
                             Key   = template
                         });
                         ++bcDevices.ExtractCount;
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             ExtractorServer.Logger.Error((object)string.Concat(new object[4]
             {
                 (object)"Extractor Thread Error ",
                 (object)ex.Message,
                 (object)" Extractor Index ",
                 (object)ExtractorServer.Extractors.IndexOf(keyExtractor)
             }));
         }
     }
     keyExtractor.Stopped = true;
 }
Ejemplo n.º 3
0
 public static void RefreshDevicesLoop()
 {
     while (!ExtractorServer.StopFlag)
     {
         if (ExtractorServer.IsLoaded)
         {
             try
             {
                 ExtractorServer.RefreshDevices();
             }
             catch (Exception ex)
             {
                 ExtractorServer.Logger.Error((object)"refresh device error ", ex);
             }
         }
         Thread.Sleep(10000);
     }
 }
Ejemplo n.º 4
0
 private static void SyncCurrentAndActualDevices(List <BcDevices> actualDevices)
 {
     foreach (BcDevices bcDevices in actualDevices)
     {
         BcDevices d1 = bcDevices;
         BcDevices d2 = Enumerable.FirstOrDefault <BcDevices>((IEnumerable <BcDevices>)ExtractorServer.AllDevices, (Func <BcDevices, bool>)(bcDevice => bcDevice.Id == d1.Id));
         if (d2 != null)
         {
             if (ExtractorServer.HasDifferProperties(d1, d2))
             {
                 ExtractorServer.BreakExtractor(d2.Id);
                 d2.SetData(d1.GetData());
                 ExtractorServer.UnBreakExtractor(d2.Id);
             }
         }
         else
         {
             d1.CurrentThread = new Thread(new ParameterizedThreadStart(ExtractorServer.VideoThread))
             {
                 IsBackground = true
             };
             d1.CurrentThread.Start((object)d1);
             ExtractorServer.AllDevices.Add(d1);
         }
         ExtractorServer.ReloadExtractors();
     }
     foreach (BcDevices bcDevices in Enumerable.ToArray <BcDevices>(Enumerable.Where <BcDevices>((IEnumerable <BcDevices>)ExtractorServer.AllDevices, (Func <BcDevices, bool>)(d => Enumerable.All <BcDevices>((IEnumerable <BcDevices>)actualDevices, (Func <BcDevices, bool>)(d2 => d2.Id != d.Id))))))
     {
         BcDevices bcDevicese = bcDevices;
         ExtractorServer.AllDevices.Remove(bcDevicese);
         foreach (ExtractorServer.KeyExtractor keyExtractor in Enumerable.ToArray <ExtractorServer.KeyExtractor>(Enumerable.Where <ExtractorServer.KeyExtractor>((IEnumerable <ExtractorServer.KeyExtractor>)ExtractorServer.Extractors, (Func <ExtractorServer.KeyExtractor, bool>)(d => d.Device.Id == bcDevicese.Id))))
         {
             keyExtractor.StopFlag = true;
             keyExtractor.WaitForStop();
             ExtractorServer.DestroyIfNeeded(keyExtractor.Device.CurrentThread);
         }
     }
 }
Ejemplo n.º 5
0
 public void SetDevice(Guid id, Hashtable row, bool delete)
 {
     try
     {
         BcDevices deviceById = ExtractorServer.GetDeviceById(id);
         BcDevices bcDevices1 = BcDevicesStorageExtensions.LoadById(id);
         if (bcDevices1.Esid != ExtractorServer.MainServer.Id)
         {
             delete = true;
         }
         if (!delete)
         {
             if (deviceById.Id != Guid.Empty)
             {
                 int extractorCount = deviceById.ExtractorCount;
                 ExtractorServer.BreakExtractor(deviceById.Id);
                 deviceById.SetData(row);
                 if (extractorCount != deviceById.ExtractorCount)
                 {
                     ExtractorServer.ReloadExtractors();
                 }
                 ExtractorServer.UnBreakExtractor(deviceById.Id);
             }
             else
             {
                 try
                 {
                     if (bcDevices1.Esid != ExtractorServer.MainServer.Id)
                     {
                         BcDevices bcDevices2 = BcDevicesStorageExtensions.LoadById(id);
                         bcDevices2.CurrentThread = new Thread(new ParameterizedThreadStart(ExtractorServer.VideoThread))
                         {
                             IsBackground = true
                         };
                         bcDevices2.CurrentThread.Start((object)bcDevices2);
                         ExtractorServer.AllDevices.Add(bcDevices2);
                         ExtractorServer.ReloadExtractors();
                     }
                 }
                 catch (Exception ex)
                 {
                     ExtractorServer.Logger.Error((object)"Set device error", ex);
                 }
             }
         }
         else
         {
             for (int index = 0; index < ExtractorServer.Extractors.Count; ++index)
             {
                 if (ExtractorServer.Extractors.Count > 0 && index >= 0 && index < ExtractorServer.Extractors.Count)
                 {
                     ExtractorServer.KeyExtractor keyExtractor = ExtractorServer.Extractors[index];
                     if (keyExtractor.Device.Id == id)
                     {
                         keyExtractor.StopFlag = true;
                         keyExtractor.WaitForStop();
                         ExtractorServer.Extractors.RemoveAt(index);
                         break;
                     }
                 }
             }
             for (int index = 0; index < ExtractorServer.AllDevices.Count; ++index)
             {
                 if (ExtractorServer.AllDevices[index].Id == id)
                 {
                     ExtractorServer.AllDevices.RemoveAt(index);
                     break;
                 }
             }
         }
     }
     catch
     {
     }
 }
Ejemplo n.º 6
0
 private static void RefreshDevices()
 {
     ExtractorServer.SyncCurrentAndActualDevices(BcDevicesStorageExtensions.LoadByEsid(ExtractorServer.MainServer.Id));
 }