Px widget scenarios

When engineering Px widget properties, especially for “BoundLabel” types with a binding to a component, there is an important property using BFormat type:

 BoundLabel:Text (ObjectToString): Determines the content of the displayed text.

By default, when you drag a component onto a Px page (for example a BooleanWritable point), the “Make Widget” wizard associates a BoundLabel’s Text with (and makes a binding to) the ord of that component, with the default text value of: %.%

A simple edit is to add “static” text in front of this default Text value, as shown done in Figure 4.

Figure 4. Example adding static text in Text property of a BoundLabel


Example adding static text in Text property of a BoundLabel


See the following related subtopics:

Default BoundLabel Text results

For any point (or any component with an “Out” property), default text from the binding is identical to the “out” value displayed in that component’s property sheet. This includes any facets, plus additional information as follows:

  • If bound to a writable point, there are 3 pieces of data in the text, namely:

    <value> <status> @priorityLevel>

     for example:

    On {ok} @16” (a BooleanWritable) or “20% {ok} @12” (a NumericWritable)

  • If bound to a read-only point, the default Text provides 2 pieces of data in the text, that is:

    <value> <status>

     for example:

    Clean {ok}” (a BooleanPoint) or “72.3 ˚F {ok}” (a NumericPoint)

  • If bound to a “non-point” component (that is there is no “Out” property), you must bind to a particular slot of that component, in order to display text other than its component “type”.

    For example, if you drag a DegreeDays component onto a Px page, the default text displayed is “Degree Days”. However, if you change the binding’s ord to “<objectName>/clgDegDays”, the text displays its calculated cooling degree-days value (and status), for example: “5.0 {ok}

Editing BoundLabel Text for points

If desired, you can edit the Text property in any BoundLabel widget to include additional static text, and/or modify (or limit) the real-time data in the text. Table 2 provides a few example Formatting variables and results for writable points.

Table 2. Edit options for writable points and Text in BoundLabel

Text (BFormat) value Description Example text if out is “On {ok} @ 16” Example with static text, resulting display
%out.value% Value only (with facets). On AHU is %out.value%.
AHU is On.
%out.status% Status including priority level, if writable point. {ok} @ 16 Status of AHU is %out.status%.
Status of AHU is {ok} @ 16.
%activeLevel% Number only (1-16, def) for priority level, writable points only. 16 AHU is %out.value% at level %activeLevel%.
AHU is On at level 16.
%status.flagsToString% String value(s) for status flags set, without braces. If non: “ok”. ok AHU status is %status.flagsToString%.
AHU status is ok.

Advanced BoundLabel Text editing

The “Object to String” scripting is quite flexible when working with BoundLabel widgets, where you are limited only by your understanding of Baja (see online Bajadoc in NiagaraAX Help). For the non-developer, these few simple rules may help:

  1. The BoundLabel widget must actually be bound to an object (using ord)—in other words, you cannot simply drag a BoundLabel from the kitPx palette onto the Px page, edit the Text property, and get results. However, the Text value may be totally unrelated to the bound object, if needed.

    For example, you can bind to any object and enter a “system type” call, for example: %time().toDateString% to produce text like “01-Nov-08”.

  2. Relative to the bound object, you can use the “parent” technique to “walk up” the component tree for text for a slot (or name), for example “%parent.parent.name%” for the name of the parent two levels up.

    An example use of parent technique could be a BoundLabel bound to a DiscreteTotalizerExt under a BooleanPoint, where you wish to display the (parent) point’s name and the number of times it has changed state, since its last reset. This could be done using this Text entry:

    %parent.displayName% had %changeOfStateCount% COS since last reset.

    Where the displayed text might look like: “ChWPump2 had 14 COS since last reset.”

  3. In addition (contrary to what was stated in previous revisions of this document), relative to the bound object, you can also “walk down” the tree in a parallel path, using the slot name (versus name or displayName).

    An example of this “walk down” method (via slot name) is in the previous history extension (historyName) example, along with the “parent” technique. See History extension scenario.