Legacy Support > ThingWorx XMPP Edge MicroServer (EMS) Software > Edge Thing Configuration at the Device > Edge Enhanced Thing > Configuring Property Push from the Edge
  
Configuring Property Push from the Edge
While you can set up edge data properties to be read on demand, you can also define data push rules so that you do not have to poll for data from the edge.
Configuration
An example of the properties section of the template file is shown here. We discuss specific property settings below.
-- ------------------------------------------------------------------------------------------------
-- Properties are defined using Lua tables. The table format is as follows:
-- baseType: The ThingWorx base type for the property. Required.
-- dataChangeType: ALWYAS, VALUE, ON, OFF or NEVER. Provides a default value for the
-- Data Change Type field of the property definition on the server, if the
-- property is initially created using ThingWorx's Manage Bindings function.
-- dataChangeThreshold: Provides a default value for the Data Change Threshold field of the
-- property definition on the server, if the property is initially
-- created using ThingWorx's Manage Bindings function.
-- pushType: ALWAYS, VALUE, or NEVER. Each property in the properties table can be
-- monitored, and on change its value can be pushed to the server. A
-- pushType of ALWAYS or VALUE should be used if the property is to
-- be pushed. Defaults to NEVER.
-- pushThreshold: For properties with a baseType of NUMBER and a pushType of VALUE, this
-- attribute indicated how much a property must change by in order for it
-- to be pushed to the server.
-- handler: The name of the handler to use for property reads/writes. The current set of
-- handler options are 'script', 'inmemory', 'http', 'https', or 'generator. The
-- default handler is 'inmemory'. The 'script', 'http', and 'https' handlers will
-- use the key field to determine the endpoint to execute their reads/writes on.
-- key: A key that the handler can use to look up or set the property's value. In the case
-- of a script, this is a URL path. For http or https handlers, this field should contain
-- a URL, not including the protocol. Not required for handers that are inmemory or nil.
-- value: The default value for the property. This will be updated as the property's value
-- changes during execution. Defaults to 0.
-- time: The last time, in milliseconds since the epoch, that the property was updated.
-- When Things are created from this template, this value will be automatically set to
-- the current time, unless a default is provided in the property definition.
-- quality: The quality of the property's value. A default should be provided if a default
-- value is defined. Otherwise it will default to GOOD for properties with no
-- handler, and UNKNOWN for properties with a handler.
-- scanRate: How frequently this property should be inspected for a change event.
-- Specified in milliseconds. The global default is 5000.
-- cacheTime: Used to initialize a property's cache time value at the server. This value
-- defaults to -1 for property's with a dataChangeType of NEVER, and 0 for
-- property's with a dataChangeType of ALWAYS or VALUE. If a different value
-- is specified it will be used by the server as the initial value and is only
-- applied when using the server's browse functionality to bind the property.
--
-- Note: Custom handlers can specify other property attributes. When a handler is utilized to
-- read or write a property, the entire property table is passed to the handler.
--
properties.InMemory_Number = { baseType="NUMBER", pushType="NEVER", value=1, dataChangeThreshold=5 }
properties.InMemory_String = { baseType="STRING", pushType="NEVER", value="Default value 1" }
properties.InMemory_Boolean = { baseType="BOOLEAN", pushType="NEVER", value=true, cacheTime=5000 }
properties.InMemory_Datetime = { baseType="DATETIME", pushType="NEVER", value=os.time() * 1000, cacheTime=5000 }
properties.InMemory_Location = { baseType="LOCATION", pushType="NEVER", value = { latitude=40.03, longitude=-75.62, elevation=103 }, pushType="NEVER" }
properties.Pushed_InMemory_Number = { baseType="NUMBER", pushType="VALUE", value=2, pushThreshold=5 }
properties.Pushed_InMemory_String = { baseType="STRING", pushType="VALUE", value="Default value 2"}
properties.Pushed_InMemory_Boolean = { baseType="BOOLEAN", pushType="VALUE", value=false }
properties.Pushed_InMemory_Datetime = { baseType="DATETIME", pushType="VALUE", value=os.time() * 1000 }
properties.Pushed_InMemory_Location = { baseType="LOCATION", pushType="VALUE", value={ latitude=40.03, longitude=-75.62, elevation=103 }}
properties.Incrementing_Number = { baseType="NUMBER", value=0, handler="generator", functionType="ramp", minValue=10, maxValue=1000 }
properties.Incrementing_DateTime = { baseType="DATETIME", handler="generator", functionType="ramp", minValue="1999-4-1 4:00:00", maxValue="2002-1-17 8:00:00", step="86400" }
properties.Pushed_Incrementing_Number = { baseType="NUMBER", pushType="VALUE", handler="generator", functionType="ramp", minValue=1, maxValue=1000 }
properties.Pushed_Incrementing_DateTime = { baseType="DATETIME", pushType="VALUE", handler="generator", functionType="ramp", minValue="1999-4-1 4:00:00", maxValue="2002-1-17 8:00:00", step="86400" }
properties.Pushed_Incrementing_Location = { baseType="LOCATION", pushType="VALUE", handler="generator", functionType="ramp", minValue="0", maxValue="1000" }
properties.Random_String = { baseType="STRING", pushType="NEVER", handler="generator", functionType="random" }
properties.Random_Number = { baseType="NUMBER", pushType="NEVER", handler="generator", functionType="random", minValue=0, maxValue=100, qualityPercent=90, errorQualityStatus="BAD" }
properties.Random_DateTime = { baseType="DATETIME", pushType="NEVER", handler="generator", functionType="random", minValue="2012-11-10 7:00:00", maxValue="2012-11-10 8:00:00" }
properties.Random_Location = { baseType="LOCATION", pushType="NEVER", handler="generator", functionType="random" }
properties.Pushed_Random_String = { baseType="STRING", pushType="ALWAYS", handler="generator", functionType="random" }
properties.Pushed_Random_Number = { baseType="NUMBER", pushThreshold=50, handler="generator", functionType="random", minValue=0, maxValue=100, qualityPercent=90, errorQualityStatus="BAD" }
properties.Pushed_Random_DateTime = { baseType="DATETIME", pushType="ALWAYS", handler="generator", functionType="random", minValue="2012-11-10 7:00:00", maxValue="2012-11-10 8:00:00" }
properties.Pushed_Random_Location = { baseType="LOCATION", pushType="ALWAYS", handler="generator", functionType="random" }
properties.Pushed_Sin_Number = { baseType="NUMBER", pushType="ALWAYS", scanRate=p_data.scanRate or 1000, handler="generator", functionType="sin", minValue=0, maxValue=359 }
properties.Pushed_Cos_Number = { baseType="NUMBER", pushType="ALWAYS", scanRate=p_data.scanRate or 5000, handler="generator", functionType="cos", minValue=0, maxValue=359 }
properties.Pushed_Square_Number = { baseType="NUMBER", pushType="ALWAYS", scanRate=p_data.scanRate or 10000, handler="generator", functionType="square", minValue=0, maxValue=100 }
-- ---------------------------------------------------------------------------------------------------------------------------------------
A property is defined by a line like the following:
properties.InMemory_Number = { baseType="NUMBER", pushType="NEVER", value=1, dataChangeThreshold=5 scanRate=30000 }
where you define the name (inMemory_Number), the data, or base type (NUMBER), the push type and the threshold for determining a data change push. The dataChangeThreshold attribute is only applicable if the property base type is NUMBER and the pushType = Value. If you do not define the scanRate, the scanRate in the configuration file will be used. Defining it within the individual property allows you to override the edge thing setting.
A push type of NEVER will not push the data, as expected. Therefore, whenever a property value with pushType=NEVER is queried on the server, the server will ask the edge software for the value.
ALWAYS pushes the data every time the property is read at the edge. For data that is read from the device or source, the scanRate will determine how often the properties are read for the Edge Thing, and therefore how often the data is pushed to the ThingWorx server. If the value is not set, it will default to the Thing setting in the main configuration file. If it is not set there either, it will default to 60 seconds. It is worth noting that the edge software will push all properties with a push type of ALWAYS with the same scan rate in one call, and not make individual calls per property.
If the property is of type NUMBER, a push type of VALUE will push the data to the ThingWorx server only on a change greater than the DdataChangeThreshold setting.
When you bind these properties at the server, the server will respect the settings. However, if changes to push and cache settings are made at the server, those will override the settings in the local configuration files.