NumberToState()

Format

NumberToState(DigitalStateValues [,Datasource] [,DigitalStateSet])

Returns

Returns the name of the digital state that corresponds to the provided digital state value.

Inputs

DigitalStateValues: The values of the digital states which should be converted to their respective names. If you have a tag that returns a collection of digital state values, you can supply the tag name here, using tag syntax (i.e. {tagname})
Behaviour: Required
Dimensions: Collection, SingleValue, MultiCollection
Valid data types: Integer

Datasource: Optional. Name of the datasource to which the digital state set belongs. If this parameter is supplied then the DigitalStateSet parameter must also be specified. Use null if the digital state set is not assigned to a datasource. 
Behaviour: Optional
Dimensions: SingleValue
Valid data types: Null, String

Note: The 2nd and 3rd parameters are used to correctly identify the digital state set for the function. They are usually needed because:
- A manually created digital state set might not be imported by an adaptor; in such cases it might not have a datasource.
- It’s possible that multiple datasources/adaptors import different digital state sets with the same name. E.g. “On Off” is quite common.

DigitalStateSet: Optional. Name of the digital state set which should be used for converting digital state values to names.
Behaviour: Optional
Dimensions: SingleValue
Valid data types: String

How to format data types

Examples

Expression: NumberToState(1, null, 'OnOffStates')
Result: Returns 'ON' if the assigned name of digital state 1 is 'ON' in the digital state set called 'OnOffStates'.

Expression: NumberToState({Tag1})
Result: Returns the name of every digital state value that {Tag1} returned during the fetch, using the digital state set which is assigned to {Tag1}. Note: This will only work if Tag1 has a digital state set assigned,

Expression: NumberToState({Tag1}, '', 'OnOffStates')
Result: Returns the name of every digital state value that {Tag1} returned during the fetch using the 'OnOffStates' digital state set. Note: Because the 2nd and 3rd parameter are specified, the function ignores whatever is assigned to the tag and will instead use the digital state set provided.

Tip: If you have access to the sample data, try running the following examples using the calculation tester

Expression: NumberToState(0, "Oil and Gas Data", "On Off")
Result: Off 

Expression: NumberToState(0, null, "Status")
Result: Online 

Release History

  • NumberToState() 4.6.5
    • Changed DigitalStateValues parameter to support MultiCollection values.
  • NumberToState() 4.5.1
    • Initial version

Comments are closed