Additional User Calculation Information
Following are sections containing a list of valid user calculation operators; examples of valid user calculations with arithmetic, Boolean, and logical operations; and examples of invalid user calculations with explanations as to why they are invalid.
Valid User Calculation Operators
The valid operators are listed in Table 1.
Table 1: Valid User Calculation Operators
+ | Addition |
---|---|
- | Subtraction |
/ | Divide |
* | Multiply |
** | Exponentiation |
.LT. | Less Than |
.LE. | Less Than or Equal To |
.GT. | Greater Than |
.GE. | Greater Than or Equal To |
.EQ. | Equal To |
.NE. | Not Equal To |
.OR. | Logical Or |
.AND. | Logical And |
IF-THEN | If Test, Then Expression |
ELSE | Else Test |
ELSEIF | ElseIf Test |
ENDIF | End of IF-THEN or IF-THEN-ELSE block |
IF-THENn | Embedded Test, Then Expression |
ELSEn | Embedded Else Test |
ELSEIFn | Embedded ElseIf Test |
ENDIFn | Embedded End of IF-THENn or IFTHENn-ELSEn block |
The valid functions are listed in Table 2, where each function has one argument in the form_func (arg).
Table 2: Valid User Calculation Functions
_NOT | Logical Negation |
---|---|
_SQRT | Square Root |
_LOG | Natural Logarithm |
_LOGTEN | Base 10 Logarithm |
_EXP | Exponential Function |
_SIN | Sine |
_SIND | Sine (degrees) |
_COS | Cosine |
_COSD | Cosine (degrees) |
_TAN | Tangent |
_TAND | Tangent (degrees) |
_ASIN | Arc Sine |
_ASIND | Arc Sine (degrees) |
_ACOS | Arc Cosine |
_ACOSD | Arc Cosine (degrees) |
_ATAN | Arc Tangent |
_ATAND | Arc Tangent (degrees) |
_SINH | Hyperbolic Sine |
_COSH | Hyperbolic Cosine |
_TANH | Hyperbolic Tangent |
_ABS | Absolute Value |
_INT | Truncation |
Parentheses can be inserted anywhere in the expression, to specify the order in which expressions are evaluated; however, the number of left parentheses must match the number of right parentheses.
The tests for performing blocks of code depending on logical conditions must be entered in one of the following forms:
IF (expression) THEN
one or more statements
ENDIF
IF (expression) THEN
one or more statements
ELSE
one or more statements
ENDIF
IF (expression) THEN
one or more statements
ELSEIF (expression) THEN
one or more statements
ENDIF
IF (expression) THEN
one or more statements
ELSEIF (expression) THEN
one or more statements
ELSEIF (expression) THEN
one or more statements
.
.
.
ENDIF
IF (expression) THEN
one or more statements
ELSEIF (expression) THEN
one or more statements
ELSEIF (expression) THEN
one or more statements
.
.
.
ELSE
one or more statements
ENDIF
Embedded IF-THEN-ELSE-ENDIF tests can be included as part of a higher-level IF-THEN-ELSE block, but they must be modeled with a special numeric identifier to identify them as lower-level IF-THEN test blocks.
The embedded IF statement must be paired with THENn, ELSEn, ELSEIFn, and ENDIFn statements, where “n” is a numeric value between 0 and 9. There must be no spaces between the THEN, ELSE, ELSEIF, ENDIF strings and the “n” numeric constant.
Following are some examples of valid embedded IF-THEN-ELSE tests:
IF (expression) THEN
IF (expression) THEN1
one or more statements
ELSE1
one or more statements
ENDIF1
one or more statements
ENDIF
IF (expression) THEN
IF (expression) THEN1
one or more statements
ELSE1
one or more statements
ENDIF1
ELSE
IF (expression) THEN1
one or more statements
ELSEIF1 (expression) THEN1
IF (expression) THEN2
one or more statements
ENDIF2
ENDIF1
ENDIF
Examples of Valid User-Defined Calculations
EXAMPLE 1:
WORK AREA:
IF (KVIN .LT. 110.) THEN !If less than 110,
POUT = 0 ! Set point OPEN
ELSE !Else
POUT = 1 ! Set point CLOSED
ENDIF
POINT DEFINITION:
KVIN A N ( 1) > STN TYP DEVICE KV
POUT P Y ( 1) > STN TYP DEVICE STTS
EXAMPLE 2:
WORK AREA:
!
! If input point set CLOSED, then do calc.
!
IF (PNTIN) THEN
ANOUT = (ANIN1 + ANIN2) / ANIN3
ENDIF
POINT DEFINITION:
PNTIN P N ( 5) > STN TYP DEVICE STTS
ANIN1 A N ( 3) > STN TYP DEVICE SUM1
ANIN2 A N ( 4) > STN TYP DEVICE SUM2
ANIN3 A N ( 5) > STN TYP DEVICE CNT
ANOUT A Y ( 7) > STN TYP DEVICE AVG
EXAMPLE 3:
WORK AREA:
A_ = _SQRT(B) + C**3 !A = square root of B ! plus C cubed
POINT DEFINITION:
B A N ( 3) > STN TYP DEVICE ALG1 C A N ( 4) > STN TYP DEVICE ALG2 A A Y ( 5) > STN TYP DEVICE OUT
EXAMPLE 4:
WORK AREA:
IF (A) THEN !If A CLOSED, then
B = ._NOT( C ) ! Set B opposite of C
ELSE !Else
B = .0. ! Set B to OPEN
ENDIF
POINT DEFINITION:
A P N ( 3) > STN TYP DEVICE PNT1
C P N ( 4) > STN TYP DEVICE PNT2
B P Y ( 5) > STN TYP DEVICE PNT3
Examples of Invalid User-Defined Calculations
EXAMPLE 1:
WORK AREA:
A = ( (B C / E) + SQRT(F) ) - 2 * 3 )
POINT DEFINITION:
B A N ( 2) > STN TYP DEVICE ALG1
C A N ( 3) > STN TYP DEVICE ALG2
D A N ( 4) > STN TYP DEVICE ALG3
E A N ( 5) > STN TYP DEVICE ALG4
F A N ( 6) > STN TYP DEVICE ALG5
A A Y ( 1) > STN TYP DEVICE OUT
REASON CALCULATION IS INVALID:
The count of left and right parentheses do
not match. More right parentheses than left
parentheses. The SQRT function is not preceded
an underscore (_).
EXAMPLE 2:
WORK AREA:
IF (A LT B) THEN
C = A
ENDIF
POINT DEFINITION:
A A N ( 1) > STN TYP DEVICE ALG1
B A N ( 2) > STN TYP DEVICE ALG2
C A Y ( 3) > STN TYP DEVICE ALG3
REASON CALCULATION IS INVALID:
LT is not a valid operator, the operator
must have the periods as part of the
operator. It should be:
IF (A .LT. B) THEN
C = A
ENDIF
EXAMPLE 3:
WORK AREA:
A = B * 4.0
POINT DEFINITION:
A A Y ( 1) > STN TYP DEVICE ALG1
REASON CALCULATION IS INVALID:
The variable B is not defined in a point
definition record.
EXAMPLE 4:
WORK AREA:
IF (A .LT. B) THEN
IF (C .NE. B) THEN
C = A
ENDIF
ENDIF
POINT DEFINITION:
A A N ( 1) > STN TYP DEVICE ALG1
B A N ( 2) > STN TYP DEVICE ALG2
C A Y ( 3) > STN TYP DEVICE ALG3
REASON CALCULATION IS INVALID:
Embedded IF statements without the numeric
identifier to identify the embedded IF blocks.
It should be:
IF (A .LT. B) THEN
IF (C .NE. B) THEN2
C = A
ENDIF2
ENDIF