LprEvents filtering

Hi.
I’m developing a client plugin using MilestoneSystems.VideoOS.Platform v.23.3.2.

I receive 2 custom LprEvents from a camera.

This is the first XML:

<?xml version="1.0" encoding="utf-8"?>

<AnalyticsEvent xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:milestone-systems">

<EventHeader>

   <ID>00000000-0000-0000-0000-000000000000</ID>

   <Timestamp>${VIRTUAL.ISO8601_TIMESTAMP}</Timestamp>

   <Type>LprEvent</Type>

   <Message>My-Custom-Event-1</Message>

   <CustomTag>TagFromXML</CustomTag>

   <Source>

      <Name>${DEVICE.IP_ETHERNET}</Name>

   </Source>

</EventHeader>

<Description>Transit analytics event data</Description>

<Location>-</Location>

<Vendor>

<Name>My Company Srl</Name>

</Vendor>

</AnalyticsEvent>

And this is the second one:

<?xml version="1.0" encoding="utf-8"?>

<AnalyticsEvent xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:milestone-systems">

<EventHeader>

   <ID>00000000-0000-0000-0000-000000000000</ID>

   <Timestamp>${VIRTUAL.ISO8601_TIMESTAMP}</Timestamp>

   <Type>LprEvent</Type>

   <Message>My-Custom-Event-2</Message>

   <CustomTag>TagFromXML</CustomTag>

   <Source>

      <Name>${DEVICE.IP_ETHERNET}</Name>

   </Source>

</EventHeader>

<Description>Transit analytics event content</Description>

<Location>-</Location>

<Vendor>

<Name>My Company Srl</Name>

</Vendor>

</AnalyticsEvent>

This is the code I’m trying to use to query the events:

List<Condition> conditionList = new List<Condition>();
OrderBy orderBy = new OrderBy();

Condition descCond = new Condition();
descCond.Operator = Operator.Equals;
descCond.Target = Target.Description;
descCond.Value = "Transit analytics event data";
conditionList.Add(descCond);

Condition typeCond = new Condition();
typeCond.Operator = Operator.Equals;
typeCond.Target = Target.Type;
typeCond.Value = "LprEvent";
conditionList.Add(typeCond);

Condition timeCond = new Condition();
timeCond.Operator = Operator.GreaterThan;
timeCond.Target = Target.Timestamp;
timeCond.Value = dateTimePickerStart.Value.ToUniversalTime();
conditionList.Add(timeCond);

Condition timeCondUpper = new Condition();
timeCondUpper.Operator = Operator.LessThan;
timeCondUpper.Target = Target.Timestamp;
timeCondUpper.Value = dateTimePickerEnd.Value.ToUniversalTime();
conditionList.Add(timeCondUpper);

CameraEntry camera = cameras[i];
Condition source = new Condition();
source.Operator = Operator.Contains;
source.Target = Target.SourceName;
source.Value = camera.Name;
conditionList.Add(source);

/* Order filter */
orderBy.Order = Order.Descending;
orderBy.Target = Target.Timestamp;

EventFilter eventFilter = new EventFilter();
eventFilter.Conditions = conditionList.ToArray();
eventFilter.Orders = new OrderBy[] { orderBy };

eventFilters.Add(eventFilter);

I want to retrieve only the events with description = “Transit analytics event data” but the query always returns to me all events, also events with description = “Transit analytics event content".

I also tried to filter by message and not by description with the same result…

I’d like not to filter in post-query code to avoid the overhaed of reading also unwanted events (other events should be managed in a different part of code and not always).

Could you please give some hints on how to manage this situation in the correct way?

Thank you and best regards,

Enrico

Does the filter work if you test with having only one condition, only the one on Target.Description?
Does the filter work for the other conditions and only fails for the one with Target.Description?
My question is to clarify if the use of multiple conditions makes it fail, or it fails regardless.

I will run a series of test to see if I can reproduce the issue.

Hi and thank you for feedback.

I tried a version with only the filter on description:

Condition descCond = new Condition();
descCond.Operator = Operator.Equals;
descCond.Target = Target.Description;
descCond.Value = "Transit analytics event data";
conditionList.Add(descCond);

but the result is the same: I receive both event types.

Time condition works.

SourceName condition works.

I inserted this code after retrieving the requested events:

BaseEvent baseEvent = alarmClient.GetEvent(line.Id);

AnalyticsEvent aEvent = baseEvent as AnalyticsEvent;
if (aEvent != null)
{
    if (!aEvent.Description.Contains("Transit analytics event data"))
    {
        // "Transit analytics event content"
        Trace.TraceError("Event type not managed");
    }

and I see the trace (and I shouldn’t).

Thanks

I have reproduced your observations.

We normally recommend using the newest MIP SDK version (latest NuGet package). In this case, I tested with that version and was able to reproduce the issue, so upgrading will unfortunately not resolve the behavior.

I have reported this as a bug to Milestone Development and will update this thread when I receive feedback from the development team.

Thank you for answer, I’ll look forward updates.

In the meanwhile I’d like to ask about another topic, but always related to events filtering

I need to fast query information transmitted inside the custom data of the event, avoiding post query filtering.

I know that CustomData field is not included in possible query conditions.

Which fields of the event are valid condition targets to be used for a string containing these data? For example: license plate, brand, color, etc. of the vehicle.

I’d like to retrieve from query only matching events instead of getting them all and then filter…

Thak you again.

Enrico

The full list of possible Targets should be here. Target -VideoOS.Platform.Proxy.Alarm Namespace Reference

Milestone Development has analyzed this behavior and confirmed that Description is not a supported target for filtering in the current implementation of GetEventLines.

Unfortunately, the documentation has historically indicated that Description could be used as a filter target, which is incorrect. Due to the way the event data is stored and structured in the database, there is no straightforward way to implement support for filtering on this field.

As a result, Milestone Development will not be providing a fix for this limitation.

We realize this may not be the outcome you were hoping for. We hope you have been able to find an alternative approach using one of the supported filter targets. If you need assistance identifying possible alternatives, please feel free to ask and we will be happy to help.