1

Get sensors values of all units of an unit group on one request

Тема: Get sensors values of all units of an unit group on one request

Hi i want to get the sensors values such as lat, long, engine, speed of units of a unit group with only one request.
i want to know if it is possible and if it is wich service of wialon remote API i must use?

Thank you a lot for your help!

2

Get sensors values of all units of an unit group on one request

Re: Get sensors values of all units of an unit group on one request

There is example of loading all messages and all sensor values for last 24 hours for specified unit:

https://sdk.wialon.com/playground/1PJ5QcuU/2

It expects, that unit will have no more than 999999 messages (else you need also check result of messages/load_interval for actual count of messages and call get_messages/calc_sensors for the rest).

To get values for units from specified group, for first you need to know, what units are belong to that group. You need to do search_item to get your group data.

So, you need to do at least two requests: search_item to get list of units and then batch with load_interval/calc_sensors. But if you put too many requests in one batch, you can trap in the time limit of request processing.

3

Get sensors values of all units of an unit group on one request

Re: Get sensors values of all units of an unit group on one request

OK, thank you very much.
another cuestion, if i need, for example the last message of 500 units, is better to do a for (int i = 0; i < 500; i++) and perform 500 request or do it with a batch?

4

Get sensors values of all units of an unit group on one request

Re: Get sensors values of all units of an unit group on one request

Batches are always preferred. You cannot execute too much requests simultaneously by limits, and also requests, that take long time, can be closed by server (I don't know exact time, it is about 5-10 minutes). So, you need to balance between number of requests and time of their execution.

If you need to just get last messages, there must be no problems with batch with 500 core/search_item.

But if these 500 units are all units that are available to the user, you can use core/search_items with following params:

{"spec":{"itemsType":"avl_unit","propName":"sys_id","propValueMask":"*","sortType":"sys_id"},"force":1,"flags":1025,"from":0,"to":1000}

In propValueMask you can also specify ids separated by comma. Flags = 1025 it is 1 (base) + 0x400 (position & last message).