Software Customisation
Reference Manual
PML 1 Expressions
: Units in Expressions
Units in Expressions
When a user enters a literal value then the units are not necessarily known. The units for PML variables may not be known if not input initially. Where units are known, then all internal values are set to database units (mm for distances). The value is then converted to the target (local) units on assignment to a variable or on output.
To cope with ’unknown’ units each value remembers its original units internally. An attempt is then made to allow for ’unknown’ units across operators.
The internal settings for units are as follows:
Setting
Comments
NONE
No units. e.g. attribute OBS.
UNKN
Unknown units. e.g. 10.
MM
Dist/bore attribute if units are MM, or literal e.g. 10 mm.
INCH
Dist/bore attribute if units are INCH/FINCH, or literal e.g. 10’.
SQIN
Multiply two INCH values together, or literal e.g. 10 sq in.
CUIN
Multiply SQIN by INCH, or literal e.g. 10 cu in.
On comparison, addition or subtraction of two values the following assumptions are made. If one of the units is unknown and the other is anything other than UNKN, then the unknown value is assumed to have the same units as the known units. A suitable conversion is then done if the known units is INCH or SQIN or CUIN.
For example:
(XLEN GT 10).
If we are working in distance units of inches, it is known that XLEN is a distance value. Internally the value is held in mm, but the units are held as INCH. The units for ’10’ are held as unknown. On doing the comparison, the ’10’ is assumed to be inches and thus multiplied by 25.4 to make sure that the comparison works as expected.
Special action is also taken to preserve the correct units across multiplication, division, POWER and SQRT, in particular the maintenance of SQIN and CUIN. In these situations, units of %UNKN are treated as none. For example
, (10 * XLEN)
is assumed to result in INCH rather than SQIN. An exception is made when a reciprocal would result from division. For example: for
(10 / XLEN)
we assume that the 10 is in inches rather than none.
1974 to current year.
AVEVA Solutions Limited and its subsidiaries. All rights reserved.