calc_last
To get the last known sensor values, counters, and position for units, use the unit/calc_last method.
To get the data, you need the View object and its basic properties access right to every unit specified in the request.
Endpoint
svc=unit/calc_last¶ms={
"itemIds": [<long>]
}
Parameters
The request must contain the following parameter:
| Parameter | Description |
|---|---|
itemIds |
Array of IDs of the units for which you want to get the last known values. The array mustn’t be empty. |
The response contains a block only for those IDs that belong to units. IDs of other item types are skipped.
Example
Below is an example of the unit/calc_last request.
svc=unit/calc_last¶ms={
"itemIds": [16091323, 16454260]
}
Response
If the request is completed successfully, the response is returned in the following format:
[
{
"i": <long>, /* Unit ID */
"mileage": { /* Mileage counter */
"value": <double>,
"format": {
"value": <text> /* Formatted value with units of measurement (for example, "24498.82 km") */
}
},
"engine_hours": { /* Engine hours counter */
"value": <double>,
"format": {
"value": <text> /* Formatted value with units of measurement (for example, "0.00 h") */
}
},
"pos": { /* Last known position */
"y": <double>, /* Latitude */
"x": <double>, /* Longitude */
"c": <int>, /* Course */
"z": { /* Altitude */
"value": <double>,
"format": {
"value": <text> /* Formatted value with units of measurement (for example, "139.00 m") */
}
},
"s": { /* Speed */
"value": <double>,
"format": {
"value": <text> /* Formatted value with units of measurement (for example, "75.00 km/h") */
}
},
"sc": <int> /* Number of satellites */
},
"sensors": { /* Values of all sensors of the unit */
"<sensor_id>": {
"value": <double|text>, /* Sensor value */
"format": {
"value": <text> /* Formatted sensor value with units of measurement */
}
}
}
}
]
The response has the following features:
- The
sensorssection contains all sensors of the unit. For sensors that return text values,valuecontains text instead of a number. - If a sensor value falls into a custom value interval with a text description (the
ciparameter of the unit/update_sensor method), theformatsection contains this description followed by the value in parentheses. - If a value can’t be calculated,
---is returned instead of it. - If the unit has no messages with a position, all the
posfields are set to zero. - Values are converted to the measurement system of the current session, which you can set with the render/set_locale method.
If the request fails, an error code is returned.
Error codes
| Error code | Description |
|---|---|
| 4 | Invalid input parameters. |
| 7 | No View object and its basic properties access right to units. |