case()
lets you examine a value and then based on that value return a different value. Similar to how a select case
operation works in many programing languages.
https://docs.inductiveautomation.com/display/DOC81/case
binEnc()
is short for Binary Encode, it takes a number of binary values and returns the decimal value.
In this case there are 4 possible values (0,1,2,3). I chose to use 3 or (1,1) as the default case, but you could also use any of the other values. The important part is knowing what integer values are possible when binEnc()
is supplied two bits.
https://docs.inductiveautomation.com/display/DOC81/binEnc
mean()
will return the mean() (a.k.a Average) of the supplied values.
https://docs.inductiveautomation.com/display/DOC81/mean
You could probably simplify this a bit more by factoring out the division.
numberFormat(
case(
binEnc(
{[default]Main/P9P10Flow/P9 Pump Status},
{[default]Main/P9P10Flow/P10 Pump Status}
),
0,0,
1,{[default]Pop up window info/P10/Frequency},
2,{[default]Pop up window info/P9/Frequency},
mean(
{[default]Pop up window info/P9/Frequency},
{[default]Pop up window info/P10/Frequency})
)/100, "00' Hz'"
)
This will indeed Return 00 Hz if both pumps are false. If you remove the 0,0,
line it would technically return the Mean, which would also be 00 Hz, but I chose to list it explicitly for clarity, and in case you wanted to provide some other number in that case.