avl_evts
To get information about the events that have occurred since the last execution of this request, use the avl_evts method.
Endpoint
https://<host>/avl_evts?sid=<text>
Parameters
The request must contain the following parameter:
| Parameter | Description |
|---|---|
| sid | Session ID. |
Response
If the request is completed successfully, the response is returned in the following format:
{
"tm": <uint>, /* Server time. */
"events": [ /* Events. */
{
"i": <long>, /* Item ID. */
"t": "<text>", /* Event type: m for a message, u for an update, d for a deletion. */
"d": { /* Event description. Depends on the event type. Omitted for deletion events (t: "d"). */
...
}
}
],
"sensors": [
{
"i": <uint>, /* Unit ID. */
"d": { /* Sensor data object. */
"<sensor_id>": {
"value": <double|text>, /* Sensor value (numeric or text). */
"format": {
"value": <text> /* Formatted sensor value. */
}
}
}
}
],
"units_update": { /* Event updates from the detectors. Returned only in the 0x200 mode. */
"<item_id>": [ /* Item ID. */
{
"<detector_name>": { /* Detector data. Depends on the detector and the detail flags. */
...
}
}
]
}
}
sensors field
The sensors field contains calculated sensor values for the units that have received new data messages since the last avl_evts request. This field provides real-time sensor value updates, so you don’t need separate sensor calculation requests.
- If no units have new sensor values, the
sensorsfield returns an empty array. - Each object in the array represents one unit, identified by
i(unit ID). - The
dobject contains sensor data, where keys are sensor IDs.
Sensor value formats
The format of the sensor value in the response depends on the sensor type.
The following sensors return text values:
- custom sensors with the Text parameters option enabled;
- sensors of the Driver assignment, Trailer assignment, Passenger sensor types.
All other sensors return numeric values.
| Parameter | Numeric sensor | Text sensor |
|---|---|---|
value |
Numeric value converted to the measurement system of the session (for example, 16.749812). Returns -348201.3876 if no data has been received. |
Text value (for example, "Active"). Returns the string "---" if no data has been received. |
format.value |
Formatted value with units (for example, "0 km" or "62.15 °F"). Returns "---" if no data has been received. If a custom label is defined in Intervals and colors unit setting and matches the current value, the field is "<custom label> (<formatted value>)". |
Same as value (for example, "Active"). If a custom label matches the current value, the field contains "<custom label> (<text value>)". |
units_update field
The units_update field contains event updates from the items added to the session with events/update_items or events/update_units. Items can be units or resources. The field is returned only if the evt_flags parameter of these methods includes the value 0x200.
To receive driver assignment updates, use events/update_items to add the resource to the session and set the resource_drivers detector.
The data is the same as the one returned by events/check_updates. It is grouped by item ID, and for each item it contains an array of detector objects. For the structure of the detector objects, see events/check_updates.
Each response contains only the updates registered since the previous avl_evts request. If there are no new updates, the field isn’t returned.
In this mode, don’t call
events/check_updates. It returns an empty object.
The level of detail is set by the detail flags (bits 0x1 to 0x100) of the evt_flags parameter. You can’t set it in the avl_evts request.
The language and the measurement system of the returned values are taken from the locale settings of the session. To change them, use render/set_locale. Unlike events/check_updates, the avl_evts method doesn’t support the lang and measure parameters.
For a response example, see events/update_items.
Session migration
If the session is being moved to another server at the time of the request, the method returns a response with "migrate": 1 and an empty events array. This isn’t an error. Keep sending requests with the same session ID. The method returns event data again once the migration is completed.
Error codes
If the request isn’t completed, an error code is returned.
| Error code | Description |
|---|---|
| 1 | Invalid, missing, or expired session ID. |
| 1003 | The limit of requests is exceeded. The response can include the reason field with additional information. See Limitations. |
| 1016 | Internal error (empty response). |