Datapoint Presets

Datapoint Presets

Datapoint Presets are available with SmartServer 2.8 and higher.

Datapoint presets are discussed in Connections and Datapoint Objects property table.

This pages contains the following sections:

Using Presets and Localization Together

You can use both presets and localization properties at the same time.  When presets and localization are set for a datapoint, the presets map is configured based on the local value.  So when you get an update, the value needs to be localized first before mapping to a preset string.  Same with the other direction, when users input a preset string, the map value needs to be transformed using the reverse transformation rule to get the IAP value. 

The Presets Object

The presets object describes the presets.

  • Presets are optional. If the source/destinations do not have presets, the presets object is set to an empty object or null.

  • The presets object contains the presets transformations for the source and destinations.

  • The presets object is submitted with the connection object’s create or update actions and stored in the connection configuration objects.

  • The presets object is not stored in the connection object’s status.

  • The presets are optional.

  • Presets can be used with localization or can be used by itself.  If a localization rule is used, the presets are configured using the local values.

  • There is one presets map definition for the connection source. Multiple sources within the same connection use the same presets.  

  • Each destination can have different presets.

  • If the source/destinations do not have presets, the presets object is set to an empty object or null.

  • The presets transformation is applied at the data source and destination.

  • Data sent from segment S1 to segment S2 is first transformed using the presets definitions of segment S1. It reaches segment S2 in its preset form, and the destination segment S2 is responsible to apply the preset transformation (reverse transformation).

The following table describes the presets object properties:

Field Name 

Type     

Description

Field Name 

Type     

Description

source

Object. 
The presets transformation object for the source segment.

The source presets are global for all the datapoints sources. The source object is empty if there are no source presets.

{                                                         
  "$": {
     "transform": "$.value == 100 &&
       $.state == 1 ? \"ON\" :
       $.value == 50 && $.state == 1 ?
       \"MID\" : $.value == 0 &&
       $.state == 0 ? \"OFF\" : \"INV\""
   }
}

destinations

List.
Items are the presets transformation object used in destination segment.

The name in the presets map for the datapoint source and destination must be exactly matched. If the destination onlyPreset option is set to true, the data will only be sent to the destination if the presets name maps to the destination presets. If the onlyPreset is set to false, the IAP/local value will be sent to the destination segment. 

The source object is empty if there are no destination presets.

[                                                           
   {
   "$": {
     "value": {
       "enumeration": {
         "source": "$",
         "map": {
           "ON": 90,
         "MID": 40,
           "OFF": 15
         }
       }
     },
     "state": {
       "enumeration": {
         "source": "$",
         "map": {
           "ON": 1,
           "MID": 1,
           "OFF": 0
         }
       }
     }
   },
   "onlyPreset": true
}
]

In the following example, the data will not be sent to the destination segment.

presets: {                                                                                                                   
   source: {
     "$": {
         enumeration: {
           source: "$",
           map: {
               “1”: “OCCUPIED”,
               “0”: “UNOACCUPIED”,
           } //map
         } // enum
     }
   },
   destinations: [
   {
     "$": {
        enumeration: {
           source: "$",
           map: {
               "ON": 100,
               “OFF”: 0
           } //map
        } // enum
      },

     onlyPreset: true // only propagate the value
// if preset value is present  

}
   ]   // destination
} // presets

repeatPresets

Boolean

The property repeatPresets is set to true if all the destinations use the same presets rule. If the repeatPresets is set to false and there are multiple destinations with presets, only the first destination uses presets. The rest of the destinations will not use presets.