The Filter Tab of a Capture Type Function Block allows you to set
up filters that control which messages are captured when the block runs. There are two different ways to
define filters for a capture block: either with custom message filters or using script-based filtering.
This tab contains only two elements as shown in Figure 1.
To create custom message filters for the data capture, click the Filters... button. This
will cause the Setup Filter dialog box to appear (the same one used to
define custom filters in Messages View). Within the dialog box you can
include and exclude messages from the capture. Note that if no message filters are selected, all messages
are collected by default.
This feature and script filtering (below) are mutually exclusive: only one may be used.
This is an advanced option for power users that provides complete control over exactly which messages are stored in the capture buffer, and under what circumstances. Instead of defining a filter using the standard Setup Filter dialog box, you use a Script Type Function Block in conjunction with a capture block to precisely determine which messages are saved.
To use script filtering, follow these steps:
Define the parameters for the Set Value command that captures data as follows:
Make sure the capture block is set to start automatically or include a command to start it via a Function Block Action command in the script, before any Set Value commands are executed.
For both of these examples we will use a fairly simple capture block with the following major settings:
The first example, shown in Figure 2, is a simple one showing how you can arbitrarily set conditions under which data
is captured. It is designed to run a simulation containing Engine and Vehicle Speed messages. The
function block script loops continuously since it has no Stop command. Each time, the loop waits for a new message,
then checks the value of the Engine Speed signal; if it is over 1,000, it executes the
Set Value statement in step 4 to save the message to the capture block. Once the capture block has
received a total of 2,000 messages, it will automatically stop and save its data to the disk.
Of course this is a very simple condition: we are just checking for a single signal value. You have complete flexibility
to make the script as complex as required.
The second example (Figure 3) shows how you can use script filtering to do sampling of incoming data. We have defined two application signals; Number of Samples and Sample Rate, both of which are pretty self-explanatory. The function block script runs in a loop controlled by the value of Number of Samples. It saves one message to the capture block, then waits for a number of milliseconds dictated by Sample Rate before looping. When the loop is done, the capture block data is saved and both blocks are stopped using script commands.