calc_sensors

To get sensor values, use the unit/calc_sensors command.

Copied!
svc=unit/calc_sensors&params={"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:

  1. The system retrieves all messages within the specified bounds.
  2. The system divides the entire interval into the number of subintervals specified in the width parameter.
  3. Within each subinterval, the system identifies the first recorded sensor value (left), the last recorded value (right), the minimum value (bottom), and the maximum value (top). These values are then combined into the final server response.

Response

If the request with no specified width is completed successfully, a response of the following format is returned:

Copied!
[	/* 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:

Copied!
[
    [
        {
            "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:

  • Invalid input data.
  • Failed to fetch the unit messages.
  • Failed to fetch the unit sensors.
7Failed to fetch the specified unit because the user doesn't have the required access right (ADF_ACL_AVL_UNIT_VIEW_SENSORS).
Download PDF file
Download Word document

See also