IFLONGER/IFSHORTER
- Last UpdatedMar 03, 2025
- 2 minute read
The IFLONGER() and IFSHORTER() functions return a stream of values based on the results of a logical expression over the specified time interval.
Syntax
|
Format |
Stream = IFLONGER( StreamLogicalExpression, Interval [, TrueStream [, FalseStream ] ] ) |
|
Arguments |
StreamLogicalExpression - A logical expression to be evaluated Interval - The time interval over which the expression's state is compared TrueStream - A stream of values from which to select when the expression evaluates to TRUE for the length of the specified interval or longer FalseStream - A stream of values from which to select when the expression does not evaluate to TRUE for at least the length of the specified interval |
|
Description |
The expression represented by StreamLogicalExpression is evaluated, and if it remains TRUE for a period of time equal to or greater than the specified Interval, the corresponding value from TrueStream is selected, otherwise the corresponding value from FalseStream is selected. If no FalseStream is provided, a "bad quality" value is selected instead when a FalseStream value would have been selected. If neither TrueStream nor FalseStream are provided, a stream of Boolean values representing the state of the StreamLogicalExpression during each Interval is returned. |
|
Format |
Stream = IFSHORTER( StreamLogicalExpression, Interval [, TrueStream [, FalseStream ] ] ) |
|
Arguments |
StreamLogicalExpression - A logical expression to be evaluated Interval - The time interval over which the expression's state is compared TrueStream - A stream of values from which to select when the expression evaluates to TRUE for less time than the length of the specified interval FalseStream - A stream of values from which to select when the expression evaluates to TRUE for the length of the specified interval or longer |
|
Description |
The expression represented by StreamLogicalExpression is evaluated, and if it remains TRUE for less time than the specified Interval, the corresponding value from TrueStream is selected, otherwise the corresponding value from FalseStream is selected. If no FalseStream is provided, a "bad quality" value is selected instead when a FalseStream value would have been selected. If neither TrueStream nor FalseStream are provided, a stream of Boolean values representing the state of the StreamLogicalExpression during each Interval is returned. |
Example 1
The following expression evaluates whether or not the stream Pump1.Flowrate remains greater than 75 for a period longer than or equal to 1 minute. If it does, it returns a value of TRUE. If it doesn't, it returns a value of FALSE.
IFLONGER(Pump1.FlowRate > 75.0, 1 minute)
Example 2
The following expression evaluates whether or not the stream SysTimeSec remains greater than or equal to 20 for a period longer than or equal to half a minute. If it does, it returns the value 5. If it doesn't, it returns a "bad quality" value.
IFLONGER(SysTimeSec >= 20, 0.5 minute, 5)
Example 3
The following expression evaluates whether or not the stream Pump1.Flowrate remains shorter than 75 for a period shorter than 1 minute. If it does, it returns the value from Pump1.Flowrate. If it doesn't, it returns a value of 75.
IFSHORTER(Pump1.FlowRate > 75.0, 1 minute, Pump1.FlowRate, 75.0)