I have found these parts of the code in Smart Client Overlay Graph on Event:
Code 1:
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);
}
}
Code 2:
/// <summary>
/// Draw the overlay on one specific imagevieweraddon
/// </summary>
/// <param name="addOn"></param>
private void DrawGraphOverlay(ImageViewerAddOn addOn)
{
OverlayObject oo;
if (!_dicAddOnOverlayObjects.TryGetValue(addOn, out oo))
{
return;
}
ClientControl.Instance.CallOnUiThread(() =>
{
List<Shape> shapes = VideoOS.Platform.Util.AnalyticsOverlayBuilder.BuildShapeOverlay(
addOn.PaintSize.Width,
addOn.PaintSize.Height,
(BaseEvent)oo.EventObject
);
UpdateShapeOverlay(addOn, shapes);
});
}
Code 3:
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[] { };
}
}
It seems like Code 1 checks wether one of the AnalyticsEvent objects should be analysed and, if it is in the proper Time frame, add it to a dictionary to present it in the Visor
(_dicAddOnOverlayObjectsPlayback.Add(imageViewerAddOn, overlayObjectList)
On Code 2, a new shape is added to a list of the VideoOS.Platform, if there is any value in the list contained by the object addOn.
But also, it defines the Width and the Height of the object as can be seen in Line 15:
_List<Shape> shapes = VideoOS.Platform.Util.AnalyticsOverlayBuilder.BuildShapeOverlay(_
addOn.PaintSize.Width,
addOn.PaintSize.Height,
(BaseEvent)oo.EventObject
);
It is the only place I have seen that data involving a shape of a box or a frame might be implied
And, inside Code 3, it seems that it recovers the list of Analytic Events but no parameters of them are represented there, only if they are between a Time frame.
I will keep on reading the code trying to understand it, but I still cannot find where the data received from the Analytics Event is handled in Smart Client Overlay Graph on Event to draw the frame on the video, and I feel confused.
Would you mind pointing me in the right direction, please?
Thank you
Edit: Typo