You can operate messages with the help of a special object – the message loader. First, you load messages into the message loader using command messages/load_interval. Then you can work with them. However, if you need to load other messages, you must clear the loader first, using the command messages/unload.
Let's load three first messages for some interval with the help of the request messages/load_interval:
<your_wialon_pro_address>/ajax.html?svc=messages/load_interval& params={ "itemId":48, "type":1, "ival1":1361912400, "ival2":1361998799, "flags":0, "flagsMask":0, "loadLocations":false, "loadCount":3 }&ssid=<your_sid>
Response:
{ "count": 20, "messages": [{ "t": 1361964965, "f": 512, "tp": "ucr", "cn": "query_pos", "cp": "", "ug": "8793338c1389cc6c1bb7c64e3fdc565f", "ln": "", "lt": "gsm", "et": 1361964966, "p": {} "p": {} }, { "t": 1361964969, "f": 256, "tp": "us", "st": "PC,0001,27\/02\/13,11:36:07,5350.5499,N,02728.1261,E,29.0km,0.0,A,010043", "mp": "+375290000000", "p": {} }, { "t": 1361964981, "f": 512, "tp": "ucr", "cn": "query_pos", "cp": "", "ug": "8793338c1389cc6c1bb7c64e3fdc565f", "ln": "", "lt": "gsm", "et": 1361964982, "p": {} }] }
There 20 messages for the specified period, however, only 3 first are in the message loader.
After loading messages, you can choose any number of them for further processing. For example, let's choose the first two messages from the loader. For this, use the request messages/get_messages:
<your_wialon_pro_address>/ajax.html?svc=messages/get_messages& params={ "indexFrom":0, "indexTo":1, "loadLocations":false }&ssid=<your_sid>
Response:
[{ "t": 1361964965, "f": 512, "tp": "ucr", "cn": "query_pos", "cp": "", "ug": "8793338c1389cc6c1bb7c64e3fdc565f", "ln": "", "lt": "gsm", "et": 1361964966, "p": {} }, { "t": 1361964969, "f": 256, "tp": "us", "st": "PC,0001,27\/02\/13,11:36:07,5350.5499,N,02728.1261,E,29.0km,0.0,A,010043", "mp": "+375290000000", "p": {} }]
Now we will try to delete the first message using the request messages/delete_message:
<your_wialon_pro_address>/ajax.html?svc=messages/delete_message& params={ "index":0 }&ssid=<your_sid>
Response:
0
If you want to load messages for other interval or unit, clear the message loader first:
<your_wialon_pro_address>/ajax.html?svc=messages/unload¶ms={}&ssid=<your_sid>
Response:
{}
If you try to query messages from empty loader, the following error code will be returned:
<your_wialon_pro_address>/ajax.html?svc=messages/get_messages& params={ "indexFrom":0, "indexTo":1, "loadLocations":false }&ssid=<your_sid>
Response:
{ "error": 1001 }
If loaded messages contain geographic coordinates, a track can be built on their basis. To do this, you should load messages into a special graphic layer. Track layer can be used in the same way as the message loader. The only difference between them is graphics.
Before creating track layer we should create image renderer:
<your_wialon_pro_address>/ajax.html?svc=renderer/create_image_renderer& params={ "tzOffset":134228528, "lang":"ru" }&ssid=<your_sid>
Response:
{ "name": "avl-74d5ab0-0x206a7d0-0x7ff83cd97700", "layers": [], "bounds": [0, 0, 0, 0] }
Let's create a track layer. We can do it using the request renderer/create_messages_layer:
<your_wialon_pro_address>/ajax.html?svc=renderer/create_messages_layer& params={ "lname":"messages", "rname":"avl-74d5ab0-0x206a7d0-0x7ff83cd97700", "itemId":48, "timeFrom":1360875600, "timeTo":1361998799, "tripDetector":1, "trackColor":cc713cff, "trackWidth":5, "arrows":1, "points":0, "pointColor":0, "annotations":0, "roadLock":false }&ssid=<your_sid>
Response:
{ "name": "messages", "bounds": [53.8327466667, 27.4098016667, 53.97141, 27.696855], "units": [{ "id": 9, "msgs": { "count": 71, "first": { "time": 1361275577, "lat": 53.8424987793, "lon": 27.4687690735 }, "last": { "time": 1361965107, "lat": 53.8801002502, "lon": 27.4176311493 } }, "mileage": 130117.245939, "max_speed": 80 }] }
You can get the tiles of a track layer using the request avl_render.
|