Filter

[ Interface ]

export interface Filter extends Array<Comparison | LogicOperator | Filter> { }

Defines a set of conditions that an object must fulfill.

A filter is an array that can contain Comparisons, LogicOperators and other filters. There must always be a logic operator between two comparisons, two filters or a comparison and a filter. In this way, a logical expression is formed, with nested filters performing the function of parentheses.

Sample - JavaScript

var filter = [
    {
        path: 'domain',
        comparator: '==',
        value: 'TcHmiEventLogger'
    },
    {
        logic: 'AND'
    },
    {
        path: 'severity',
        comparator: '>=',
        value: TcHmi.Server.Events.Severity.Warning
    },
    {
        logic: 'OR',
    },
    {
        path: 'type',
        comparator: '==',
        value: TcHmi.Server.Events.Type.Alarm
    },
    {
        logic: 'AND'
    },
    [
        {
            path: 'timeConfirmed',
            comparator: '==',
            value: new Date(0)
        },
        {
            logic: 'OR'
        },
        {
            path: 'timeConfirmed',
            comparator: '==',
            value: new Date(0)
        }
    ]
]

In this example, events are filtered. All events of the EventLogger with a severity of warning or higher and all alarms that were not acknowledged or not deleted fit through this filter. The filter corresponds to this logical expression:

event.domain == 'TcHmiEventLogger'
&& event.severity >= 2
|| event.type == 1
&& (
    event.timeConfirmed.getTime() == 0
    || event.timeCleared.getTime() == 0
)
Filter 1:

Available from version 1.10