Delay
- Last UpdatedJan 18, 2025
- 3 minute read
- PI System
- PI Server 2023
- PI Server
The Delay function allows the output to track the input with a delay of n calculation intervals. This function is useful for real-time calculations, such as those performed in pipeschd.exe. In scenarios where PrevVal might not suit your needs, consider using Delay. It is commonly used in Performance Equations (PE) and PI AF analyses to introduce a controlled delay in real-time calculations. Delay can also be utilized in custom scripts or applications interacting with the PI System, provided the scheduling is appropriately configured.
Before using the Delay function, determine whether the tag is configured for scan class scheduling or event-based scheduling. See Frequently asked questions below.
Syntax
Delay( x, runflag, n )
Arguments
x:
The input signal. Must be an integer or real number.
runflag:
A non-zero value enables the filter to run. Use 0 to disable the filter.
n:
The length of the delay, specified as an integer. This value represents the number of calculation intervals, with the interval determined by the scheduling method (scan class or event-based).
Returns
The Delay function outputs the input signal delayed by n calculation intervals, with the interval determined by the scheduling method:
-
For scan class scheduling: The delay depends on the scan class interval, which is a fixed polling interval (for example, 10 seconds per scan). Commonly used in Performance Equation (PE) calculations.
-
For event-based scheduling: The delay depends on the frequency of the event trigger (for example, tag updates every 15 seconds). Commonly used in PI AF analyses.
For more information on scheduling Performance Equations and PI AF analysis, see Scheduling a PE Calculation and Analysis scheduling.
Exceptions
-
Unsupported Scenarios:
-
The Delay function is not supported in the following tools:
-
The pipetest utility
-
PI DataLink
-
-
-
Invalid Input:
-
If the input point (x) is not a real number or integer, the function returns an error.
-
-
Initialization:
After system startup, the function returns Calc Failed until n intervals have elapsed.
Example
To help clarify usage, here are examples for both scheduling methods:
Example 1: Scan class scheduling
Delay('tag1', 1, 3)
-
'tag1' uses a scan class interval of 10 seconds (check in PI SMT).
-
Total delay: 3 intervals × 10 seconds/interval = 30 seconds.
Example 2: Event-based scheduling
Delay('tag1',1,2)
-
'tag1' representing the input signal.
-
Total delay: 2 intervals × 15 seconds/interval = 30 seconds.
Frequently asked questions
-
How do I find the scan class interval for a tag?
Use PI SMT and navigate to Points > Point Builder. Select the tag and check the Scan Class field under the Data Scan section.
-
How do I determine if a tag uses event-based scheduling?
Open PI System Explorer (PI AF Client), locate the associated element, and check the Analyses tab. If the tag is part of an analysis, review the analysis configuration to identify the trigger and its update frequency.
-
Can I use event-based scheduling if my tag is not in a scan class?
Yes, you can use event-based scheduling. Ensure you know the trigger frequency to calculate the delay accurately.
-
Can the interval be a variable?
No, n must be specified as a constant integer. Using a variable will result in an error.
-
How does the middle argument (runflag) work?
The runflag is a control parameter. Use a non-zero value (for example, 1) to enable the delay filter. Use 0 to disable it.