A data type defines the structure, encoding, scaling, and units for a datapoint or property. In the case of properties, the data type also defines the usage of the property.
A data type may specify that additional data type information is encoded within a datapoint or property based on the type. For example, the iot_analog type is typically used for datapoints that represent an analog value such as a temperature, pressure, or humidity value. The iot_analog type is a structure that includes a floating point value field and also includes units field that specifies the units of the value field.
The following table lists the IoT data types that are typically used for IzoT applications:
|iot_alarm||Alarm report for a block or device|
Additional data types are defined for applications requiring other data types. A listing of standard data types is available at the following locations:
- Standard datapoint types: www.lonmark.org/technical_resources/resource_files/snvt.pdf
- Standard property types: www.lonmark.org/technical_resources/resource_files/scpt.pdf
You can also create your own data types, but using the standard data types provides interoperability with devices from other manufacturers.
A data type may be a scalar type or an aggregate type.
The following table summarizes the scalar types:
|Bitfield||A signed or unsigned bitfield, 1 to 8 bits wide. Only available for fields within a structure or union.|
|Double Float||An ANSI/IEEE 754 standard 64-bit double‑precision floating point value with 1 sign bit, 11 exponent bits, and 52 mantissa bits, for a total of 64 bits. The maximum range is approximately -1E308 to +1E308 units.|
|Enumerated||A signed 8-bit enumerated value.|
|Float||An ANSI/IEEE 754 standard 32-bit floating point value with 1 sign bit, 8 exponent bits, and 23 mantissa bits, for a total of 32 bits. The maximum range is approximately -1E38 to +1E38 units.|
|Reference||A reference to a network variable type. Uses the type definition of the referenced network variable type. If you are creating a structure or union, an individual field can reference a network variable type. If the referenced network variable type changes in some way, the referencing type or field will automatically change as well.|
|Signed Character||An 8-bit signed character value.|
|Signed Long||A 16-bit signed integer value. Maximum unscaled range of -32,768 – 32,767.|
|Signed Quad||A 32-bit signed integer value.|
|Signed Short||An 8-bit signed integer value. Maximum unscaled range of -128 – 127.|
|Unsigned Character||An 8-bit unsigned character.|
|Unsigned Long||A 16-bit unsigned integer value. Maximum unscaled range of 0 – 65,535.|
|Unsigned Quad||A 32-bit unsigned value.|
|Unsigned Short||An 8-bit unsigned integer value. Maximum unscaled range of 0 – 255.|
The following table summarizes the aggregate data types:
|Structure||A structure containing multiple fields. Each field may be any of the scalar data types described in the previous table.|
|Union||A union containing multiple fields. Each field may be a structure or any of the scalar data types described in the previous table.|
Scalar data types and fields specify scaling factors that can be used to modify the range of the type. The scaling factors are defined by three values called A, B, and C. These values are used to calculate a scaled value as follows:
ScaledValue = A * 10B * (UnscaledValue + C)
For example, the lev_percent type is defined to represent a one‑byte percentage value. The scaling factors are defined as A=5, B=-2, and C=0, resulting in the following scaling formula:
ScaledValue = 5 * 10-3 * (UnscaledValue + 0)
Using this formula, an unscaled value of 200 results in a scaled value of 100. A value of 1 results in 0.5, providing an 0.5 percent resolution.
Scalar data types and fields define a units string that describes the data contained within the network variable or field. This string may be specified in multiple languages to allow localization of displayed values. For example, the English-language unit string for the lev_percent network variable type is “% of full scale.”
For data types that do not include an embedded unit of measure field, units of measures are typically specified in Systeme Internationale (SI) units. For example, temperature is typically represented in Celcius. A standard mechanism is provided to scale measurement values. This allows measurement values to be displayed in alternative systems. For example, temperature can be displayed in Fahrenheit using an appropriate format.
Scalar data types and fields define minimum and maximum values for the network variable type. These values restrict the values that may be assigned to the network variable or field. Scalar data types may also define an invalid value. An invalid value indicates that the value of the network variable is unknown. For example, a temperature sensor network variable output that reports an invalid value indicates that the current temperature is not available. Scalar data types based on a floating point type use the floating point NaN value to represent the invalid value.