Using filters with actions

Using simple filters

The following are examples of uses for the simple filter:

Use the “with a delay of” option to delay the execution of an action for a specified amount of time after a device is added or removed from a folder.

Using the “Trigger on Active” filter

Choose the “Trigger on Active” filter to set an action to only execute a command when a condition becomes Active. For example, if you are monitoring the Paper Tray Missing event and someone removes a tray from a monitored printer, the printer generates a Paper Tray Missing event with a state of Active. The Active state satisfies the condition of the filter and the specified action is executed. When the paper tray is replaced, the printer generates another Paper Tray Missing event with a state of Clear. The Clear state does not satisfy the condition of the filter and the action is not executed.

Using the “Trigger on Either Active or Clear” filter

Choose the “Trigger on Either Active or Clear” filter to set an action to execute each time a condition becomes Active or Clear. For example, use the filter to keep a log of all printer paper jams to determine the average time it takes to clear a jam. When a paper jam occurs, the printer generates an event with a state of Active. This satisfies the condition of the filter and executes the action. When the paper jam is cleared, the printer generates another event with a state of Clear. This event also satisfies the condition of the filter and executes the action. There are now two lines on the log file, one with the time at which the paper jam occurred and another with the time it was cleared.

Using custom filters

Use a custom filter to define how an action executes. Upload a script file or write a new one. MarkVision Messenger provides a very simple scripting language to define filters. The following is a complete list of the statements and conditions available for use in a custom filter:

Statements:

Conditions:

Scripting example - “Trigger on Active” filter

The following is an example of the script representation of the built-in “Trigger on Active filter”:

IfThen (EventDataIs("state", "ACTIVE"))
Distribute

The effect of the EventDataIs condition is to ask the event for the value of the event: state keyword. This keyword can be inserted into command lines and e-mail messages. The IfThen statement executes the next statement if the condition EventDataIs ("state", "ACTIVE") is true. An EventDataIs condition is true if the value of the keyword (state) matches the given value (ACTIVE). The next statement, Distribute, causes the command to execute.

Scripting example - “Trigger on Active” filter with a 30 second delay

The following is an example of script used when the “Trigger on Active filter” action is delayed by 30 seconds:

{
WaitUntil (TimeIsAfter(30))
IfThen(EventDataIs("state", "ACTIVE"))
Distribute
}

The braces ({}) are used to group statements into a list. They were not needed in the previous example because the IfThen and following statements were treated as a single statement.

The WaitUntil statement causes the script to pause execution until the condition is true. The TimeIsAfter condition checks for true only after the specified number of seconds has passed. If the event is still active after 30 seconds, the Distribute statement executes the command.

Scripting example - “Trigger on Either Active or Clear” filter

The following is a script representation of the built-in “Trigger on Either Active or Clear” filter for these circumstances: the Paper Tray Missing event is selected for Tray 3, there is a 20-minute delay before the command is executes, and the command repeats every 20 minutes if the condition remains Active.

While (And(EventDataIs("state", "ACTIVE"), EventDataIs("location", "Tray 3")))
{
WaitUntil(TimeIsAfter(1200))
IfThen(EventDataIs("state", "ACTIVE"))
Distribute
}

In this example, And was used to build a compound condition. The While loop is only entered or repeated if the event is active for Tray 3. The code within the loop is the same as the code for the “Trigger on Active” filter, except the TimeIsAfter condition is set to wait 1200 seconds (20 minutes).