beautypg.com

Using a conditional format, Using a scaling factor and unit string – Echelon NodeBuilder Resource Editor User Manual

Page 69

background image

long, bitfield, or enum.

You can use a backslash (‘\’) character as an escape character to include other format

characters as text. For example, the following characters can be included in a format

string:

\%

The % character.

\\

The \ character.

\"

The " character.

\|

The | character.

Using a Conditional Format

You can use a conditional format to specify one of two different formats, where one

format is selected when a value is formatted based on a conditional value. The syntax for

a conditional format is similar to the ANSI C “?:” conditional expression. The syntax is
as follows:

? : false>

The condition is limited to expressions with the equal to ('==') and is not equal to ('!=')

comparison operators.

The field that appears in the conditional statement must appear in a text format list

before it appears in the conditional statement. Formats are processed in left-to-right

order.

Following is an example of a format definition with conditional format specifiers

extracted from the SNVT_earth_pos#SI format definition (much of the format definition
has been deleted for simplification):


UNVT_DM_Command: text( ("%m ", cmd),

((cmd == 1) ? ("%d", cmdData.databaseId) :

((cmd == 2) ? (" ") :

((cmd == 3) ? ("%d", cmdData. deviceIndex) :

) ) ) );

Using a Scaling Factor and Unit String

You can use a scaling factor within a format string to specify a multiplier and adder, and

an optional unit string suffix, that are used to scale the value to be formatted. You can

scale any simple data type, and you can also scale any field in a structure or union that is
a simple data type. The scaling factors are applied as a multiplication and an addition

when data is converted for output, and they are applied in the reverse order, as a
subtraction and a division when data is input.
You can also specify a scope and language string index that specifies a language string to

use as the unit description. This string overrides the unit description string found in the
type file.
Alternate formats with scaling factors can be used for converting units to the United

States (US) or other measurement systems.

The syntax for a scaling factor is as follows:

*+[(:Index>)]

NodeBuilder Resource Editor User's Guide

61