Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

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 >

1. The user will have to select on the Folio application which is under the Advanced Apps

Image Added

2. Once Folio has launched, the user can select on the Tools button Image Added located on the right

  • In the tool list, navigate towards the following: Advanced > Number to Enum

Image Added

Note

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

...

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:

...

We will use the above example in the below tools.

Create Enum Options

This is The Create Enum Option tool 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

1. Once the user selects the tool, they will be prompted with the below:Image Removed

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

Image Added

Info
  • 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.

2. Once that is configured, the user will be prompted with the below:Image Removed

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

Image Added

Info
  • Options - this will display however many options specified in the 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.

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

Apply Enum Options

This The Apply Enum Option 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  

1. Once the user selects the tool, they will be prompted with the below: Image Removed

  • 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 writable box since our point is writable

Image Added

Info
  • Points Query - the user will choose a

...

  • filter 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.

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

Image RemovedImage Added

Example

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).

Image RemovedImage Added

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

Image RemovedImage Added

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  tool

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

Image RemovedImage Added

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

2. 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.Image Removed

  • Here they can change the numerical or string text value

Image Added

3. 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

1. Once the user selects the Delete Enum Option tool, they will be prompted with the below:

Image RemovedImage Added

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

...

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(%)".