Numeric entry with unit conversion (bidirectional) question

Regarding "bind a custom property to engUnit on the tag" above, the goal would be to allow conversion from any unit to another of the operator's choosing. The conversion would be a two-step process, but straightforward. Ex: "R" --> "degF" --> "degC" (where 'degF' is selected as your 'standard' for temperature conversion). Consider building a table (as a tag and/or session prop?) which contains everything needed for any unit conversion to another. Something resembling:

Units Type Factor Offset
psig Pressure 1 0
psia Pressure 1 -14.6959
inHg Pressure 0.491154 0
inH2O Pressure 0.0360912 0
kPa Pressure 0.14503774 -14.6959
°F Temperature 1 0
°R Temperature 1 -459.67
°C Temperature 1.8 32
gpm Rate 1 0
m³/s Rate 15,850.30 0
ft³/min Rate 7.48052 0
  • Optionally, add an additional column for an adjustment to formatString on the tag.
  • The slope (Factor) & intercept (Offset) columns would contain values to convert to a standard unit of your choosing.
  • Disclaimer, don't trust any numbers in the table above, or my math below. :nerd_face:
  • An operator could select their desired units (from a config screen), whereby session props would contain the desired scaling (via lookup() function) to convert from their selected unit to a standard unit. Inside of your view, custom properties would contain the same logic - scaling to get from units on the tag to standard units. Combine the session props w/ view props to provide the resultant scaling, all in one expression binding (extra parenthesis added):
ClientValue = (((TagValue * TagFactor) + TagOffset) - ClientOffset) / ClientFactor

(I suppose you could also come up with resultant scaling values as additional custom props).