Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Number to Enum

We have now created tools to make it easier to convert numeric points to enums. This will allow the user to specify a string text value for a numerical value. (Available in v183 or newer)

These tools can be found in Legacy Folio > Tools > Advanced > Number to Enum

Make sure the numeric points don't have units before converting or else an error will be thrown.

Enum Map and Enum Options

The user will have to specify a name for the enum map that contains a list of enum options. For example, if the user wants to create a list of options for a "Fan Status" numeric point. They will name the enum map as "fanStatus" as an example and the enum options would be whatever they want. Once created, this map can then be used for all numerical points that would be considered "Fan Status" points.

Enum Map = "fanStatus"

List of enum options with their numerical value for fanStatus are:

  • "unknown", -1
  • "off", 0
  • "slow", 1
  • "fast", 2

We will use the above example in the below tools.

Create Enum Options

This is where the user will create their enum maps of enum options. The user will go to Legacy Folio > Tools > Advanced > Number to Enum > Create Enum Options.

Once the user selects the tool, they will be prompted with the below:

  • Name - This will be the name of the enum map
  • Number of Options - This will be how many enum options are needed for this enum map

In our example, our name will be "fanStatus" and number of options will be 4.

Once that is configured, the user will be prompted with the below:

  • Options - this will display however many options specified in previous popup. Specify a numerical value and what the string text value should be for that number value

In our example, we have unknown = -1, off = 0, slow = 1, fast = 2.

Thats it, now the user can apply this enum map to points by using the "Apply Enum Options" tool.

Apply Enum Options

This tool allows the user to apply their enum map to points so that they are converted to enums so that they display the correct string text per number value. The user will go to Legacy Folio > Tools > Advanced > Number to Enum > Apply Enum Options.

Once the user selects the tool, they will be prompted with the below: 

  • Points Query - the user will choose a fitler that queries for their points that they want to apply this too
  • Pick The Set of Options - this is where the user picks the enum map they would like to apply to the points
  • Make Writable - by default it is unchecked. This allows the user to specify if the points being applied the enum map are writable or not. If they are, it will add the appropriate tag so that the string is then converted back to a number.

In our example, we are only applying this to one point so we used the id of the point, but it can be tags, navName, or by id. We picked the only option we have which is 'fanStatus' and checked the wrtiable box since our point is writable.

Thats it, once the user applies the change, they will be prompted with the below pop up regarding how many points were changed.

Below is an example of a point that was converted to an enum. As you can see, the tags that get modified/added are kind, enum, curConvert, and writeConvert (if writable).

The points should now be working as an enum. If writable, you can see the actions list gets automatically updated.

Edit Enum Options

If the user needs to modify any of their existing enum maps, they can do so by using the "Edit Enum Options" tool. The user will go to Legacy Folio > Tools > Advanced > Number to Enum > Edit Enum Options.

Once the user selects the tool, they will be prompted with the below: 

  • Name of set of options - the user selects the enum map of options they would like to edit from the list

In our example, we only have 'fanStatus' so we select that. Once selected, the user will get a pop up of the enum options available for that enum map to modify.

Here they can change the numerical or string text value.

Once done, that is it. It is automatically applied to existing points using this particular enum map. Don't need to re-apply since points are already have them.

Delete Enum Options

If the user no longer needs an enum map they have created, they can delete them using this tool. The user will go to Legacy Folio > Tools > Advanced > Number to Enum > Delete Enum Options.

Once the user selects the tool, they will be prompted with the below:

Here the user selects from the drop down an enum map they would like to delete.

Thats it, then it will be removed.


To do this manually, it was covered in the CurConvert Options doc.

Common Errors

Most common errors are below. 

  1. Make sure the numeric point doesn't include units. If so, you'll get an error similar to the below but with the unit it has.
    curErr:
    haystack::UnknownNameErr: codeToName: 0%
    pointExt::EnumDef.codeToName (EnumDefs.fan:137)
    pointExt::EnumNumberToStrConvert.doConvert (PointConvert.fan:709)
    pointExt::EnumConvert.convert (PointConvert.fan:694)
    connExt::ConnPoint.updateCurOk (ConnPoint.fan:150)
    haystackExt::HaystackConn.syncPoint (HaystackConn.fan:219)
    haystackExt::HaystackConn.onPoll (HaystackConn.fan:367)
    fan.sys.List.each (List.java:588)
    haystack::GbGrid.each (GridBuilder.fan:350)
    haystackExt::HaystackConn.onPoll (HaystackConn.fan:357)
    connExt::Conn.doPoll (Conn.fan:897)
    connExt::ConnActor.receive (ConnActor.fan:165)
    concurrent::Actor._dispatch (Actor.java:234)
    concurrent::Actor._work (Actor.java:204)
    concurrent::ThreadPool$Worker.run (ThreadPool.java:262)
    1. There is a way around this if you make the curConvert as "numberToHex() strToNumber() enumNumberToStr(foo)". If writable, writeConvert is something like this but with unit using "enumStrToNumber(foo) as(%)".
  • No labels