AnyNumber (STRUCT)¶
TYPE AnyNumber : STRUCT
AnyNumber represents a numeric value either as value or POINTER TO value with variable base type.
Supported base types:
SINT (8bit -128 .. 127)
USINT (8bit 0 .. 255)
INT (16bit -32768 .. 32767)
UINT (16bit 0 .. 65535)
DINT (32bit -2147483648 .. 2147483647)
UDINT (32bit 0 .. 4294967295)
REAL (32bit float)
DOUBLE (64bit float)
The base type is initialized to AnyNumberTypes.TYPE_NONE, which will be detected as invalid base type on read operations, so ensure to set the base type properly.
Using the POINTER TO value representation requires the POINTER TO value <> 0 (set u.p.p* according to baseType). The POINTER TO value is initialized to 0, which will be detected as invalid on read / write operations, so ensure to set the POINTER TO value properly.
There are functions to support certain operations using AnyNumber:
compare base type - see |AnyNumberBaseTypeEquals|
check for consistency - see AnyNumberCheck
compare - see AnyNumberCompare
assigment - see AnyNumberAssign
arithmetic - see AnyNumberArithmetic
Initialization of AnyNumber is a bit eloquent, but no matter of this simple:
Example:
/// AnyNumber base type REAL with value representation
any1_REAL_value : DNP3.AnyNumber := (
baseType:=DNP3.AnyNumberTypes.TYPE_REAL, /// init the base type
u:=(val:=(valREAL:=42)) /// init the value
);
/// AnyNumber base type REAL with POINTER TO value representation
/// The value to point to …
any2_value : REAL;
/// Now the AnyNumber pointing to any2_value
any2_REAL_POINTER_TO_value : DNP3.AnyNumber := (
baseType:=DNP3.AnyNumberTypes.TYPE_REAL, /// init the base type
isPtr:=TRUE, /// select POINTER TO value representation
u:=(p:=(pREAL:=ADR(any2_value))) /// init the POINTER TO
);
- InOut:
Name
Type
Initial
Comment
baseType
AnyNumberTypes.TYPE_NONE
Base type
isPtr
BOOL
FALSE
isPtr = TRUE => represents a POINTER TO value
u
Data holding either the value or POINTER TO value according to baseType. For value representation access u.val.val* For POINTER TO value representation access u.p.p* according to baseType.