Overview
Control Unit Filters are used generally for searching and filtering of devices and components in the RM system.
They can be used:
to appoint extensive searches in the system;
in the scopes of Tasks and Rules to identify the set of devices to be involved in mass executions and automations;
in the GDM Script Service as method arguments for controlling the filtered set of tweaked devices components via RM Scripting;
in the GDM Java API as method arguments for programming of java applications and RM plugins.
A filter is a standard logical expression with logical operators, which operands are conditions describing the searched targets – devices, control units, control unit state variables, etc.
Logical Operators
The priority of logical operators described in the table below, starting from the highest to the lowest is: !, &, |. Parenthesis can be used to determine different priorities:
Operator | Description |
|---|---|
| | Logical "OR". |
& | Logical "AND". |
! | Logical negation. |
Each filter defines different conditions to act as operands in its logical expression. The conditions defined by all the search filters use comparison operators for defining the matching of a searched attribute against the specified value.
Comparison Operators
The Comparison Operators are described in the following table:
Operator | Description |
|---|---|
| Checks if the specified attribute is equal to the given value. |
| Checks if the specified attribute is different to the given value. |
| Checks if the specified attribute starts with the given value. |
| Checks if the specified attribute ends in the given value. |
| Checks if the specified attribute contains the specified value at some place. |
Filter Operands
Attribute Condition
Syntax and semantics. These specify control units by their attribute values. Attribute conditions are matched with the properties provided as metadata for the control units. Script syntax:
[<att_target>] <attribute> <comparison_operator> <search_value>
Example:
stateVar:"myStateVarName" == "someValue")<attribute> ::= TYPE | ID | VERSION | DEVICE_TYPE | DEVICE_ID | <attribute_name> | <attribute_names><attribute_name>::= <string> | <identifier><att_target> ::= (stateVar:) | (capability:) | (nodeProps:)where:
<att_target>– (Optional) Explicitly indicates that what is specified in the <attribute> clause is a name of a control unit state variable, or a device capability, or a device node property. The targets "capability:" and "nodeProps:" are only allowed when the attribute condition is used inside a device condition, i.e. it specifies device-filtering criteria.<attribute>– Specifies the name of the searched attribute.<comparison_operator>– Contains a standard RM script comparison operator (see the "Comparison Operators" section above).<search_value>– Represents the attribute's searched value.
Following is a short description of filtering attribute targets:
Standard attributes – If one of the keywords ID, TYPE, DEVICE_TYPE or DEVICE_ID is present as <attribute>, the condition is considered to be on respectively the control unit ID, control unit type, device type or device ID of the filtered control unit instance.
State variable – The condition is on a state variable of the filtered control unit instance.
Device capability – The condition is on the capabilities of the filtered device.
Node property – The condition is on the node properties of the filtered device.
Custom attribute condition. Except for generic filtering attributes, script filters can accept custom filtering attributes with individually-defined mapping on the underlying resources. Such custom attributes are handled by condition matcher plugins, and attribute conditions containing custom attributes are forwarded for evaluation to those plugins.
Example:
A device provider may provide filtering on log messages related to particular devices of its controlled type, assuming that log messages are not represented as control units and therefore such filtering is not possible with the generic filtering attributes.
See also "Matching Attribute Conditions" section below.
Parent Control Unit Condition
Defines filtering the control units on conditions concerning their parent control units. Its lexical syntax is:
HAVING PARENT (<control_unit_filter>)
where <control_unit_filter> is a control unit filter.
Sub Control Unit Condition
Defines filtering the control units on conditions concerning their sub control units. Its lexical syntax is:
HAVING CHILD (<control_unit_filter>)
where <control_unit_filter> is a control unit filter.
Device Condition
Defines filtering the control units on conditions concerning the devices to which they belong. Its general syntax is:
ON (<device_filter>)
The <device_filter> differs from the standard control unit filter only by the operands that can take part in it. Operands in device filter could be:
Device Attribute Conditions – It is a standard attribute condition (see the "Attribute Condition" section above) that have to specify in its <att_target> clause a device capability or a device node property:
[<device_att_target>] <attribute> <comparison operator> <search value> <device_att_target> ::= (capability:) | (nodeProp:)Containment Conditions – This operand defines filtering the devices that contain certain control units. Its lexical syntax is:
CONTAINING (<control_unit_filter>)where the
<control_unit_filter>is a standard control unit filter.
Matching Attribute Conditions
In straight examples, an attribute condition may look like one of the following cases:
(propName == "propVal") or
(stateVar: propName == "propVal") or
(nodeProp: propName == "propVal") or
(capability: propName == "propVal")
Matching of the attribute condition proceeds in the following way:
If there is an explicitly specified target (i.e.
"stateVar:"or"nodeProp:"or"capability:"),the system matches against the respective explicit target .If no explicit target is present (i.e. the case is
(propName=="propVal")), the system checks ifpropNameis one of the keywords ID, TYPE, DEVICE_TYPE or DEVICE_ID, and matches respectively against the control unit ID, control unit type, device type or device ID.Otherwise (no explicit target and not a standard attribute (id, type, etc.)), the system checks if there is a condition matcher plugin registered to match the
propNameattribute. If yes, forwards the condition to the custom matcher.Otherwise, the system matches the condition as follows:
If the control unit has state variable with name
propName,the system matches against the state variable value of the filtered control unit.Else, if the device of the filtered control unit has a capability with name
propName,the system matches against that capability.Else, if the device of the filtered control unit has a node property with name
propName,the system matches against that property.Else, matching ends with FALSE.
Complete Syntax Definition
<Management_procedure> ::= <Commands> [";"] <EOF><Commands> ::= <Command> [";" <Commands> ]<Command> ::= <BatchCommand> | <ConditionalCommand> | <SingleCommand><BatchCommand> ::= "{" <Commands> [";"] "}"<ConditionalCommand> ::= <Command> <Control_Unit_Filter><SingleCommand> ::= <ControlUnitCommand> | <Call_Command> | <Custom_Scrtipt_Command><ControlUnitCommand> ::= "INVOKE" ["CONTROL" "UNIT"] <CUType> <ActionList><CUType> ::= <string> | <identifier><ActionList> ::= <CUAction> | "{" <CUActions> "}"<CUActions> ::= <CUAction> [";" <CUActions><CUAction> ::= <ActionName> "(" <ActionArgs> ")"<ActionName> ::= <string> | <identifier><ActionArgs> ::= <ActionArg> ["," <ActionArgs>]<ActionArg> ::= <single_value> | <multi_value><single_value> ::= <property_value> ["AS" <single_value_type>]<property_value> ::= <string> | <Identifier> | <number> | <Boolean> | "null" | <dictionary><multi_value> ::= "(" <property_values> ")" ["AS" <multi_value_type>]<property_values> ::= <property_value> ["," <property_values>]<dictionary> ::= "{" [<dict_props >] "}"<dict_props> ::= <dict_prop> [", " <dict_props>]<dict_prop> ::= <property_name> "=" <property_value_list><property_name> ::= <string> | <identifier>// Case sensitive value types<value_type> ::= ("Array" | "Vector") "(" <simple_type> ")"<single_value_type> ::= "byte" | "short" | "int" | "long" | "char" | "boolean" | "float" | "double" | "String" |"Byte" | "Short" | "Integer" | "Long" | "Character" | "Boolean" | "Float" | "Double"<Call_Command> ::= "CALL" <script_name> "(" <call_params> ")"<call_params> ::= <call_param> [","<call_params>]<call_param> ::= <string> | <param><param> ::= "%" <number><Custom_Scrtipt_Command> ::= lexical syntax is custom defined// FILTERS<Control_Unit_Filter> ::= "(" <cu_OR> ")"<cu_OR> ::= <cu_AND> ["|" <cu_OR> ]<cu_AND> ::= <cu_UNARY> ["&" <cu_AND> ]<cu_UNARY> ::= ["!"] <cu_PRIMARY><cu_PRIMARY> ::= <cu_filter_operand> | "(" <cu_OR> ")"<cu_filter_operand> ::= <attribute_condition> | <parent_cu_condition> | <sub_cu_condition> | <device_condition><attribute_condition> ::= [<att_target>] <cu_attribute> <comp_op> <property_value><att_target>::= "stateVar" ":"<comp_op> ::= "==" | "!=" | "startsWith" | "endsWith" | "includes"<cu_attribute> ::= "DEVICE_TYPE" | "DEVICE_ID" | "TYPE" | "ID" | "VERSION" | <identifier> | <string> | <att_names><att_names> ::= (<string> | identifier) [att_names]<parent_cu_condition> ::= "HAVING" "PARENT" "(" < Control_Unit_Filter > ")"<sub_cu_condition> ::= "HAVING" "CHILD" "(" <Control_Unit_Filter> ")"<device_condition> ::= "ON" <Device_Filter><Device_Filter> ::= "(" <device_OR> ")"<device_OR> ::= <cu_AND> ["|" <device_OR> ]<device_AND> ::= <device_UNARY> ["&" <device_AND> ]<device_UNARY> ::= ["!"] <device_PRIMARY><cu_PRIMARY> ::= <device_filter_operand> | "(" <device_OR> ")"<device_filter_operand>::= <device_attribute_condition> | <containmenet_condition><device_attribute_condition>::= [<device_att_target>] <cu_attribute> <comp_op> <property_value><device_att_target>::= ("stateVar" ":") | ("capability" ":") | ("nodeProp" ":")<containmenet_condition>::= "CONTAINING" <Control_Unit_Filter>// SCRIPT TOKENS<String> ::= //any char sequence enclosed in inverted commas. The inverted comma and the backslash take part as escape symbols - \" and \\<Identifier> ::= <Letter> (<Letter>|<Digit>)*<Letter> ::= "a"-"z" | "A"-"Z" | "_" | "-" | "."<Digit> ::= "0"-"9"<Non_Zero_Digit> ::= "1"-"9"<number> ::= <Non_Zero_Digit>(<Digit>)*("."(<Digit>)*)?<boolean> ::= "true" | "false"