76

How to get Unit Last update date and time

Re: How to get Unit Last update date and time

Hello!

The requests events/load and events/get are used to get history events (trips, sensors, ignition , fuel thefts/fillings/consumption) which already registered in system
More - https://forum.gurtam.com/viewtopic.php? … 16#p186716

If you need to get current data, when unit is running online, you need to get use the following requests
https://sdk.wialon.com/wiki/en/sidebar/ … date_units - add units to session and specify event's detector
https://sdk.wialon.com/wiki/en/sidebar/ … ck_updates - execute request periodically to get data
See my previous answer - https://forum.gurtam.com/viewtopic.php? … 05#p183805

Diana Cheley
Wialon Hosting Expert
Gurtam
77

How to get Unit Last update date and time

(26/04/2021 15:59:43 отредактировано trushal.shah)

Re: How to get Unit Last update date and time

Hello

Can you help me with how I can execute this command [start engine"]?

http://localhost/wialon/ajax.html?svc=unit/exec_cmd&params={"itemId":11489,"commandName":"custom_msg","linkType":"tcp,vrt","param":"","timeout":1,"flags":0}&sid=04dfaf9bcf913b6fca84e821fb220b11

{
    "error": 5
}

"cml": {
                "1": {
                    "id": 1,
                    "n": "start engine",
                    "c": "custom_msg",
                    "l": "",
                    "p": "Juste un exemple",
                    "a": 1,
                    "f": 0
                },
                "2": {
                    "id": 2,
                    "n": "stop engine",
                    "c": "custom_msg",
                    "l": "",
                    "p": "stop engine",
                    "a": 1,
                    "f": 0
                },
                "3": {
                    "id": 3,
                    "n": "أمر جديد",
                    "c": "custom_msg",
                    "l": "tcp",
                    "p": "",
                    "a": 1,
                    "f": 0
                }
            },

78

How to get Unit Last update date and time

Re: How to get Unit Last update date and time

Hello!

When you execute command you need to pass the same parameters which original command has, like link type, commandName and etc.

In your example,
"n": "start engine" - commandName
"l": "" - link type (empty value means 'Auto')
"p": "Juste un exemple" - specified parameters

So you need to execute request unit/exec_cmd with the following parameters

"params":{"itemId":11489,"commandName":"start engine","linkType":"","param":"Juste un exemple","timeout":1,"flags":0}
Diana Cheley
Wialon Hosting Expert
Gurtam
79

How to get Unit Last update date and time

Re: How to get Unit Last update date and time

Diana пишет:

Hello!

When you execute command you need to pass the same parameters which original command has, like link type, commandName and etc.

In your example,
"n": "start engine" - commandName
"l": "" - link type (empty value means 'Auto')
"p": "Juste un exemple" - specified parameters

So you need to execute request unit/exec_cmd with the following parameters

"params":{"itemId":11489,"commandName":"start engine","linkType":"","param":"Juste un exemple","timeout":1,"flags":0}

Hi thanks for the reply if I set this with APi i am getting "

Unrecognized:JUSTE un example"

and same from penal got this message

Command 'start engine' sent to unit 'Platinum'.

params={"itemId":11489,"commandName":"start engine","linkType":"","param":"TawasolMap","timeout":1,"flags":0}&sid=09fff31a9820105727644773ba146a80

  • How to get Unit Last update date and time
80

How to get Unit Last update date and time

Re: How to get Unit Last update date and time

Hi!

The device send this response to your command as I see on your screenshot, because there is not correct parameter 'Juste un exemple' for command. You need to send command (create command before for unit) with correct parameter for certain command. Please look to device's manual or request to manufacturer  which parameters are correct for this command type.
Maybe here on forum - https://forum.gurtam.com/viewforum.php?id=18  you can find helpful information

Diana Cheley
Wialon Hosting Expert
Gurtam
81

How to get Unit Last update date and time

Re: How to get Unit Last update date and time

Hi,

Thanks for the reply now it's working for us

I just want to know how I can display Map on the report please check below API request

{svc=report/export_result, params={"format":2,"pageOrientation":"portrait","pageSize":"a4","pageWidth":0,"coding":"utf8","delimiter":"semicolon","headings":0,"compress":0,"attachMap":1,"extendBounds":0,"hideMapBasis":0,"outputFileName":"eabdalmnem_30-04-2021"}, sid=d628a7f4e54b4cb31c928154b234cbb8}

I had reviewed with hideMapBasis hide map layer: 0 - no, 1 - yes

"extendBounds":0
"hideMapBasis":1

"extendBounds":1
"hideMapBasis":1

"extendBounds":1
"hideMapBasis":0

extendBounds=0
hideMapBasis=0

Please find both files different only is right of the screenshot with map and left is without map.

  • How to get Unit Last update date and time
82

How to get Unit Last update date and time

Re: How to get Unit Last update date and time

Hello

I need your 2 bits of help

1. Above request how to display Map background on the report

2. How to get sensor engine operation value in the check_updates API

From search_item API we got all sens value check_updates API

"sens": {
                "1": {
                    "id": 1,
                    "n": "حالة المحرك",
                    "t": "engine operation",
                    "d": "",
                    "m": "On/Off",
                    "p": "adc1",
                    "f": 0,
                    "c": "{\"act\":0,\"appear_in_popup\":true,\"ci\":{},\"mu\":0,\"pos\":1,\"show_time\":false,\"timeout\":0,\"uct\":0,\"unbound_code\":\"\",\"validate_driver_unbound\":0,\"consumption\":2}",
                    "vt": 1,
                    "vs": 0,
                    "tbl": []
                },
                "2": {
                    "id": 2,
                    "n": "الكهرب",
                    "t": "voltage",
                    "d": "",
                    "m": "V",
                    "p": "pwr_int",
                    "f": 0,
                    "c": "{\"act\":1,\"appear_in_popup\":true,\"ci\":{},\"cm\":0,\"mu\":\"0\",\"pos\":2,\"show_time\":false,\"timeout\":0,\"uct\":0}",
                    "vt": 1,
                    "vs": 0,
                    "tbl": []
                }


I am looking for same value from update_unit API how i can get, i do get but I got a second sensor not first


svc=events/update_units&params={"mode":"add","units":[{"id":11489,"detect":{"sensors":0}}]}&sid=c0816af7dfa8862ae026cf4a1499f2d8


svc=events/check_updates&params={"detalization":3}&sid=9e0f2c649220ff65229c68a56de69f3e


"11489": [
        {
            "sensors": {
                "2": {
                    "from": {
                        "t": 1615747447,
                        "y": 24.7718658447,
                        "x": 46.633014679
                    },
                    "to": {
                        "t": 1620026997,
                        "y": 24.7718448639,
                        "x": 46.6330413818
                    },
                    "m": 1620026997,
                    "f": 0,
                    "type": 4,
                    "value": 4.141
                }
            }
        }
    ]
}

83

How to get Unit Last update date and time

Re: How to get Unit Last update date and time

Hello!

1. If you need to attach map to the exported PDF file, you need to pass parameter "attachMap":1, "hideMapBasis":0

"hideMapBasis":1 means tracks and markers are shown on the blank background
"extendBounds":1 means option Squeeze in all graphics

For example, parameters for request  report/export_result

{"compress":0,"attachMap":1,"hideGoogleLinks":0,"extendBounds":0,"hideMapBasis":0,"pageOrientation":"landscap","pageSize":"a4","pageWidth":"0","coding":"utf8","delimiter":"semicolon","headings":1,"outputFileName":"Volvo_awesome_!gtest_Eco_driving_03-05-2021_14-38-20","format":2}

2.The sensor engine operation is not included to 'sensors' event detector.  To get data from this sensor type you need to get event type 'ignition'
So instead detector 'sensors' in request events/update_units just add detect 'ignition' - "detect":{"ignition":0} or "detect":{"ignition":1} as you already know the sensor id.

Diana Cheley
Wialon Hosting Expert
Gurtam
84

How to get Unit Last update date and time

(11/05/2021 17:51:15 отредактировано trushal.shah)

Re: How to get Unit Last update date and time

Hello Thanks for the reply it's working fine


to add the unit to get the update we set this API as per your suggestion and its working fine when we have small[20] set of units

but when I have 500 units then we get error

1.{"id":11489,"detect":{"ignition":0,"sensors":0}}
2.{"id":11499,"detect":{"ignition":0,"sensors":0}}
.
.
.
500 .{"id":11989,"detect":{"ignition":0,"sensors":0}}




<head>
    <title>414 Request-URI Too Large</title>
</head>


events/update_units&params={"mode":"add","units":[{"id":11489,"detect":{"ignition":0,"sensors":0}}]}&sid=75252dc521f0c23fd8be8085452bd6ff

85

How to get Unit Last update date and time

Re: How to get Unit Last update date and time

Hello!

First make sure that you perform POST request. There is basic limit to length of URL.
Also I think to monitor at one time all 500 units is quite complicated, even just to get information about all 500 units on one screen  (specially mobile screen). So if in your app the units visualization are divided on several blocks (parts, pages) you can request to add units into session sequentially, if necessary.

Diana Cheley
Wialon Hosting Expert
Gurtam
86

How to get Unit Last update date and time

(22/06/2021 12:44:45 отредактировано trushal.shah)

Re: How to get Unit Last update date and time

Hello,

How I can get the last movement of the vehicle, i am not getting the last movement if any vehicle is running so i can display on the map.

for i.e my last trip was 2 PM after in parking, next i started at 6 PM and my car running so i could not get 6 PM running data till its moves as parking

can you please help me on this....

core/batch&params={"params":[{"svc":"events\/load","params":{"ivalType":1,"itemId":55873,"timeFrom":1623954600,"timeTo":1624040999,"detectors":[{"type":"trips","filter1":0}]}},{"svc":"events\/get","params":{"selector":{"type":"*","timeFrom":1623954600,"timeTo":1624040999,"detalization":11}}},{"svc":"events\/get","params":{"selector":{"type":"*","expr":"trips{s<1}","timeFrom":1623954600,"timeTo":1624040999,"detalization":11}}}],"flags":0}&sid=47a5b1d3697adb0fe149fb7a3c086559

87

How to get Unit Last update date and time

Re: How to get Unit Last update date and time

Hi!

You can use the several ways :

1) Just get the last message from request search item(s) with flag = 1024,     last message and position
Flags - https://sdk.wialon.com/wiki/en/sidebar/ … ormat/unit
Search item(items) - https://sdk.wialon.com/wiki/en/sidebar/ … les/search

2) To get current event (trip or stop) via requests events/update_units & events/check_updates  (not events/load,  it's used only to get history data) - https://sdk.wialon.com/wiki/en/sidebar/ … ck_updates
https://sdk.wialon.com/wiki/en/sidebar/ … date_units
Here more useful information (webinar) how to work with these requests (methods event) - https://www.youtube.com/watch?v=nUtNS5Al5wo

Diana Cheley
Wialon Hosting Expert
Gurtam
88

How to get Unit Last update date and time

(24/06/2021 17:28:13 отредактировано trushal.shah)

Re: How to get Unit Last update date and time

Thanks for update

The query is above API will get the vehicle's last location.

e.t my last trip ends at 2 PM and I have started at 3 Pm new trip and continue

I can get till 2 PM all location of the vehicle but Runnin trips[All movement need to display at Map] i am not sure how i can get 
with

can we made any cane in load / get trip data API

like till last message movement data on map

Please find attach the request

  • How to get Unit Last update date and time
89

How to get Unit Last update date and time

Re: How to get Unit Last update date and time

Hi!

yes, you can get current trip via events requests - events/check_updates
where in JSON response in 'to' you will get the last coordinates

"to": {
            "t":<uint>,    /* time (UNIX-time) */
            "y":<double>,    /* latitude */
            "x":<double>    /* longitude */
        }

For example

1. Add unit to session - https://sdk.wialon.com/wiki/en/sidebar/ … date_units
events/update_units

params
{"mode":"add","units":[{"id":21728414,"detect":{"trips":0,"sensors":0}}]}

2. Execute request check_updates
events/check_updates

params {"detalization":3}

In response we get current trip  which starts at 1624876649   Jun 28 2021 13:37:29 GMT+03
"state": 1 means that the trip is going  ( /* state: 0 - parking, 1 - trip, 2 - stop */ )
the last message and location in parameter 'to'

"trips": {
                "from": {
                    "t": 1624876649,
                    "y": 53.4268836975,
                    "x": 27.9888801575
                },
                "to": {
                    "t": 1624877580,
                    "y": 53.4268836975,
                    "x": 27.9888801575
                },
                "m": 1624877580,
                "f": 2,
                "state": 1,
                "max_speed": 23,
                "curr_speed": 23,
                "avg_speed": 0,
                "distance": 0,
                "odometer": 2147483648,
                "course": 90,
                "altitude": 90,
                "pos_flags": 0
            }

3 Again execute events/check_updates and get the new data:
updated last position and time in parameter 'to'
the "state": 1 , so the trip is still going


 "trips": {
                "from": {
                    "t": 1624876649,
                    "y": 53.4268836975,
                    "x": 27.9888801575
                },
                "to": {
                    "t": 1624877925,
                    "y": 51.4268836975,
                    "x": 27.9888801575
                },
                "m": 1624877925,
                "f": 2,
                "state": 1,
                "max_speed": 120,
                "curr_speed": 120,
                "avg_speed": 628,
                "distance": 222553,
                "odometer": 2147483648,
                "course": 90,
                "altitude": 90,
                "pos_flags": 0
            }
        }
Diana Cheley
Wialon Hosting Expert
Gurtam
90

How to get Unit Last update date and time

Re: How to get Unit Last update date and time

Thanks for the update

yes, this I do use to display running car on the map and its movement

but here I need to display his all past and current running movement on the Map

e.g I started my vehicle at 6 AM and I moves to continue for 5 hours, till 11 AM

and in between if I want to see his trip all position on the Map from 6 to 8 and still vehicle is moving,

91

How to get Unit Last update date and time

Re: How to get Unit Last update date and time

trushal.shah пишет:

Thanks for the update

yes, this I do use to display running car on the map and its movement

but here I need to display his all past and current running movement on the Map

e.g I started my vehicle at 6 AM and I moves to continue for 5 hours, till 11 AM

and in between if I want to see his trip all position on the Map from 6 to 8 and still vehicle is moving,

Hello!

In this case to get all messages from event you can pass digitalization  flags 16 plus 8 , for example total  "detalization":25

The response

"msgs":[{"tm":1454479860,"x":38.4273986816,"y":65.6319351196,"z":30,"c":18,"m":0,"s":10}...], // all messages
"track":"qvqoKejpiFkG??mIaAlI?{Sg^zSyS?"}} // track in Google notation https://developers.google.com/maps/docu … ineutility

Diana Cheley
Wialon Hosting Expert
Gurtam