Exemplo n.º 1
0
        private EventLine[] GetAnalyticsEventList(DateTime periodStart, DateTime periodEnd)
        {
            AlarmClientManager _alarmClientManager = new AlarmClientManager();

            int eventCount = (int)(_startCache + _endCache) / 500;

            try
            {
                IAlarmClient alarmClient = _alarmClientManager.GetAlarmClient(EnvironmentManager.Instance.MasterSite.ServerId);
                EventLine[]  events      = alarmClient.GetEventLines(0, eventCount, new VideoOS.Platform.Proxy.Alarm.EventFilter()
                {
                    Conditions = new Condition[] { new Condition()
                                                   {
                                                       Operator = Operator.NotEquals, Target = Target.Type, Value = "System Event"
                                                   },
                                                   new Condition()
                                                   {
                                                       Operator = Operator.LessThan, Target = Target.Timestamp, Value = periodEnd
                                                   },
                                                   new Condition()
                                                   {
                                                       Operator = Operator.GreaterThan, Target = Target.Timestamp, Value = periodStart
                                                   } }
                });
                return(events);
            }
            catch (Exception ex)
            {
                // this will happen if for instance the Event Server cannot be contacted. Showing error each time is quite intrusive, so let's just log.
                EnvironmentManager.Instance.Log(true, nameof(OverlayGraphOnEventBackgroundPlugin), "Exception thrown: " + ex.Message);
                return(new EventLine[] { });
            }
        }
Exemplo n.º 2
0
        private void CreatePlaybackDictionary(ImageViewerAddOn imageViewerAddOn, DateTime videoTime)
        {
            CachedOverlayObjects coo;

            if (!_dicAddOnOverlayObjectsPlayback.TryGetValue(imageViewerAddOn, out coo) || coo.StartTime > videoTime || coo.EndTime < videoTime)
            {
                DateTime startDatetime = videoTime.AddMilliseconds(-_startCache);
                DateTime endDatetime   = videoTime.AddMilliseconds(_endCache);
                if (endDatetime > DateTime.Now)
                {
                    endDatetime = DateTime.Now;
                }

                EventLine[] analyticsEventLines = GetAnalyticsEventList(startDatetime, endDatetime);
                if (analyticsEventLines.Length == 0)
                {
                    return;
                }

                CachedOverlayObjects overlayObjectList = new CachedOverlayObjects();
                overlayObjectList.OverlayObjectList = new List <OverlayObject>();
                overlayObjectList.StartTime         = startDatetime;
                overlayObjectList.EndTime           = endDatetime;

                AlarmClientManager _alarmClientManager = new AlarmClientManager();
                IAlarmClient       alarmClient         = _alarmClientManager.GetAlarmClient(EnvironmentManager.Instance.MasterSite.ServerId);

                foreach (EventLine ev in analyticsEventLines)
                {
                    BaseEvent baseevent = alarmClient.GetEvent(ev.Id);
                    overlayObjectList.OverlayObjectList.Add(new OverlayObject(baseevent, ev.Timestamp));
                }
                if (_dicAddOnOverlayObjectsPlayback.ContainsKey(imageViewerAddOn))
                {
                    _dicAddOnOverlayObjectsPlayback.Remove(imageViewerAddOn);
                }
                _dicAddOnOverlayObjectsPlayback.Add(imageViewerAddOn, overlayObjectList);
            }
        }
Exemplo n.º 3
0
        private void loadClientLPR()
        {
            try
            {
                IAlarmClient alarmClient = _alarmClientManager.GetAlarmClient(EnvironmentManager.Instance.MasterSite.ServerId);

                EventLine[] events = alarmClient.GetEventLines(0, 10,
                                                               new VideoOS.Platform.Proxy.Alarm.EventFilter()
                {
                    Conditions = new Condition[] { new Condition()
                                                   {
                                                       Operator = Operator.Equals, Target = Target.Type, Value = "LPR Event"
                                                   } }
                });


                foreach (EventLine line in events)
                {
                    BaseEvent       baseevent = alarmClient.GetEvent(line.Id);
                    DataGridViewRow row       = new DataGridViewRow();
                    row.Tag = baseevent;
                    AnalyticsEvent aEvent = baseevent as AnalyticsEvent;
                    if (aEvent != null)
                    {
                        string oValue      = "";
                        string oConfidence = "";
                        if (aEvent.ObjectList != null && aEvent.ObjectList.Count > 0)
                        {
                            oValue      = aEvent.ObjectList[0].Value ?? "";
                            oConfidence = aEvent.ObjectList[0].Confidence.ToString("F5");
                        }
                        row.CreateCells(dataGridViewAlarm, aEvent.EventHeader.Type, oValue, oConfidence, aEvent.EventHeader.CustomTag, aEvent.EventHeader.Timestamp.ToLocalTime(), aEvent.EventHeader.Source.Name);
                        dataGridViewAlarm.Rows.Add(row);
                    }
                }
            }
            catch (Exception ex)
            {
                EnvironmentManager.Instance.ExceptionDialog("loading LPR Analytics", ex);
            }
        }