Last Updated on : 2022-10-10 03:11:54download
This topic describes the common data types and values of standard instruction sets and status sets. The common data types are described as follows:
Data type | Description | Example |
---|---|---|
Boolean | Represent a binary variable value that is either true or false. | A switch can be set to the on or off state. |
Integer | Apply to data that can be linearly adjusted. | Adjust the temperature, ranging from 20°C to 40°C. |
Enum | A finite set of values. | Working level, including low, medium, and high. |
String | Represent the string data type. | See the subsequent sections. |
JSON | Represent a JSON object. There will be explanations of the corresponding object attributes. | See the subsequent sections. |
Commands and states can be transferred in three types:
Value example
{
"min":11,
"unit":"s",
"scale":0,
"max":86400,
"step":1
}
Description of value constraint
min
: the minimum value. Example: 11
.
max
: the maximum value. Example: 86400
.
unit
: the unit of the value. Example: s
, short for seconds.
scale
: the data will be transferred with an exponential conversion of 10
. Example: 0
, which means the 0th power of 10
, that is, 1
.
step
: the data increment interval (step length). step
and scale
determine the amount of transferred data. Example: step
=5 and scale
=1. It means that the amount of transferred data is step
× 10^1=5 × (10^scale
)=50.
Code | Name | Type | Value constraint |
---|---|---|---|
cur_voltage | Actual voltage | Integer | {“unit”:“V”, “min”:0, “max”:5000, “scale”:2, “step”:5} |
For example, query the device status and get the value {"cur_voltage": 2230}
. The user-readable value is 2230/(10 ^ 2)= 22.3V. That is, the voltage is 22.3 volts.
Value constraint range
The value constraint range in a standard instruction set is only for your reference. In fact, each device has a specific value constraint range.
Value example
{
"maxlen":255
}
Description of value constraint
maxlen
: the maximum length of a value. Example: 255
.
Value example
{
"range":[
"1",
"2",
"3",
"4",
"5"
]
}
Description of value constraint
range
: constraint range of the enumeration values. For example, 1
, 2
, 3
, 4
, and 5
.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback