Click or drag to resize
OSIsoft, LLC

AFCalculationPercentTrue Method

This method evaluates the passed boolean expression over the passed time range. The passed time range is first divided into a number of calculation intervals. The method then computes the percentage of time the passed expression evaluates to true over each of the periods.

Namespace:  OSIsoft.AF.Data
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version:
public static AFValues PercentTrue(
	Object target,
	string expression,
	AFTimeRange timeRange,
	AFTimeSpan calculationInterval,
	AFTimeSpan minimumSampleInterval,
	AFTimestampCalculation timeType,
	out AFValues percentGood


Type: SystemObject
The target can either be a PIServer, an AFDatabase, or any derived objects of AFBaseElement. References to attributes or points within the expression are based on the target.
Type: SystemString
A string containing the boolean expression to be evaluated. The syntax for the expression generally follows the Performance Equation syntax as described in the PI Data Archive documentation, with the exception that expressions which target elements use attribute names in place of tag names in the equation.
Type: OSIsoft.AF.TimeAFTimeRange
The bounding time for the evaluation period.
Type: OSIsoft.AF.TimeAFTimeSpan
The length of the calculation interval. A value will be returned for each interval within the specified time range.
Type: OSIsoft.AF.TimeAFTimeSpan
Specifies the minimum sample time within each interval to evaluate the expression at. A smaller sample time will provide a more accurate answer at the cost of longer execution time and heavier PI Data Archive load.
Type: OSIsoft.AF.DataAFTimestampCalculation
A flag indicating what how to calculate a timestamp for each interval.
Type: OSIsoft.AF.AssetAFValues
Out parameter indicating the percent good of each calculation interval value.

Return Value

Type: AFValues
Returns an AFValues collection with each value containing the percentage of time the expression was true over each calculation interval.

The caller can also control how often the expression is evaluated during the computation of the Percent True results with the MinSampleInterval argument. The server will limit the MinSampleInterval to between 1/100 and 1/10000 of the calculation period. This flexibility allows the user to manage the trade-off between accuracy and execution time. Higher accuracy typically imposes a heavier load on the server. In the extreme cases, this may impact other applications from accessing the server.

Calculations are limited to Attributes or PI Points which originate from a single PI Data Archive. Attributes which resolve to a static value (no data reference configured), are also acceptable.

Version Information


Supported in: 2.10.5, 2.10, 2.9.5, 2.9, 2.8.5, 2.8, 2.7.5, 2.7, 2.6, 2.5
See Also
Enabling Operational Intelligence