calc_sensors
To get sensor values, use the unit/calc_sensors command.
svc=unit/calc_sensors¶ms={"source":<text>,
"indexFrom":<uint>,
"indexTo":<uint>,
"unitId":<long>,
"sensorId":<long>,
"width":<uint>}
Parameters
Parameter | Description |
---|---|
source | Source of messages (layer name). If this parameter is empty, the message loader is used by default. |
indexFrom | Index of the first message. |
indexTo | Index of the last message. |
unitId | Unit ID. |
sensorId | Sensor ID. If set to 0, the values of all sensors are returned. |
width | Number of items to return. Optional. This parameter is used when you need a fixed number of aggregated (i.e., preprocessed) sensor values. This is particularly useful for generating and zooming in on charts with preprocessed data. The process works as follows:
|
If the source parameter is specified, the unitId parameter must be specified too. If source is not specified, you can set unitId to any value. In this case, unitId is not used and messages are obtained directly from the message loader.
Response
If the request with no specified width is completed successfully, a response of the following format is returned:
[ /* array of message data */
{ /* values of sensors from one message */
<text>:<double|text>, /* sensor ID: sensor value */
...
}
]
If width is specified, a response of the following format is returned:
[
[
{
"name": <sensor_name>, /* Sensor name */
"data": [
{
"left": [<unix_time1>, <value1>], /* First recorded sensor value in the subinterval and its time */
"right": [<unix_time2>, <value2>], /* Last recorded sensor value in the subinterval and its time */
"bottom": [<unix_time3>, <value3>], /* Minimum sensor value in the subinterval and its time */
"top": [<unix_time4>, <value4>] /* Maximum sensor value in the subinterval and its time */
},
...
]
},
...
]
]
If the request hasn’t been completed, an error code is returned.
Error codes
Error code | Description |
---|---|
4 | One of the following errors:
|
7 | Failed to fetch the specified unit because the user doesn't have the required access right (ADF_ACL_AVL_UNIT_VIEW_SENSORS). |