valueIsMax
Short summary
This assertion method checks if the current value is less than or equal to the maximum value
Attention:
Any comparsion to NaN is FALSE that means if currentValue OR maximumValue
is NaN then is the assertion false.
For details check IEEE 754_ and the truth table below.
Attention: Every number is smaller than infinity except infinity, it's equal. Every number is greater than -infinity except -infinity, it's equal. For details check IEEE 754 and the truth table below.
truth table for special values
+----------------------+----------------------+---------------+
| currentValue | maximumValue | assertion |
+======================+======================+===============+
| NaN | Any value | FASLE |
+----------------------+----------------------+---------------+
| Any value | NaN | FALSE |
+----------------------+----------------------+---------------+
| NOT NaN | infinity | TRUE |
+----------------------+----------------------+---------------+
| -infinity | NOT NaN | TRUE |
+----------------------+----------------------+---------------+
| infinity | NOT infinity | FALSE |
+----------------------+----------------------+---------------+
| NOT -infinity | -infinity | FALSE |
+----------------------+----------------------+---------------+
Parameters
| Name | Type | Comment | Kind |
|---|---|---|---|
| currentValue | LREAL | current value to check | input |
| maximumValue | LREAL | upper limit for the current value | input |
| message | AssertMessage | message if the assertion is false | input |
Code
Declaration
METHOD valueIsMax
VAR_INPUT
(* current value to check *)
currentValue :LREAL;
(* upper limit for the current value *)
maximumValue :LREAL;
(* message if the assertion is false *)
message :AssertMessage;
END_VAR
Implementation
IF (
THIS^.isValueNaN(currentValue)
OR_ELSE THIS^.isValueNaN(maximumValue)
OR_ELSE (
THIS^.isValueNegativeInfinite(maximumValue)
AND_THEN (NOT THIS^.isValueNegativeInfinite(currentValue))
) OR_ELSE (
THIS^.isValuePositiveInfinite(currentValue)
AND_THEN (NOT THIS^.isValuePositiveInfinite(maximumValue))
)
) THEN
THIS^.assertionWasWrong(message, THIS^.getDebugInfo('valueIsMax'));
ELSIF (
THIS^.isValuePositiveInfinite(maximumValue)
OR_ELSE THIS^.isValueNegativeInfinite(currentValue)
) THEN
RETURN;
ELSIF (currentValue > maximumValue) THEN
THIS^.assertionWasWrong(message, THIS^.getDebugInfo('valueIsMax'));
END_IF