SRGDataWatcher

SRGDataWatcher is another Objective Chart component that can be created and added to the component list. The data watcher’s primary function is to scan the data; not to draw it.

In standard charts, one or more data watchers can be added to the component list immediately before the display component on which it acts. Being positioned before the display allows the data watcher to modify style settings for out-of-range data items to highlight them.

SRGDataWatcher is derived from SRGGridLines. This hierarchy is shown in a figure in Chapter 18 Compound Component System The data watcher can optionally draw its limit lines on its associated display.

Data may be watched for the conditions outlined in SRGDataWatcher:

SRGDataWatcher

Condition

Description

CX_SCAN_ABOVELIMIT

All data must be below the limit.

CX_SCAN_BELOWLIMIT

All data must be above the limit.

CX_SCAN_AVERAGEABOVELIMIT

The average of the data in the scope must be below the limit.

CX_SCAN_AVERAGEBELOWLIMIT

The average of the data in the scope must be above the limit.

CX_SCAN_INBRACKET

All data must remain in the range defined by the upper and lower limits.

CX_SCAN_OUTOFBRACKET

All data must remain outside of the range defined by the upper and lower limits.

CX_SCAN_AVERAGEINBRACKET

The average of the data in the scope must remain within the range defined by the upper and lower limits.

CX_SCAN_AVERAGEOUTOFBRACKET

The average of the data in the scope must remain outside of the range defined by the upper and lower limits.

CX_SCAN_CUSTOM

A custom routine is called which decides the validity of the data according to parameters defined in the user application.

The function SetScanType() selects the desired limit condition. SetHighLimit() and SetLowLimit() set the limit values.

Note: For the conditions that require only one limit, use SetHighLimit().

During the processing of its Draw() function, the SRGDataWatcher scans the data to be plotted.

For half of the limit conditions, each data value is compared to the limit condition. For each data value, either MarkExcursion() or UnMarkExcusion() is called depending on whether the out-of-range condition is met. MarkExcursion() sets the highlight flag to CX_HIGHLIGHT_MEDIUM in the data item’s style member and calls FlagExcursion(). FlagExcursion() does nothing, but it can be overridden to perform some sensible application-specific task, such as incrementing a counter or changing other style flags. UnMarkExcursion() just resets the highlight flag to CX_HIGHLIGHT_NONE.

The other limit conditions compare the average of the data values to the limits. For these conditions, MarkExcursion() and UnMarkExcursion() are not called, and data items are not highlighted.

For all limit conditions, ScanData() calls either DataInRange() or DataExcursion() once, depending on whether any data values were out of range. Both of these functions do nothing, but they can be overridden to perform some sensible task such as displaying a message, sounding a warning, or taking corrective action.

The following sections provide details about using a data watcher in a chart.