Command disabled: backlink

Reports

There are some peculiarities in working with reports. All commands from the chapter Reports except report/update_report can be performed only if the session contains some results of report execution. A session can contain only one report at the same time. That's why before executing a new report, you need to clear results of the previous one by the command report/cleanup_result.

Report execution

For executing report the request exec_report is used:

<your_wialon_pro_address>/ajax.html?svc=report/exec_report&
	params={
		"reportResourceId":163266,
		"reportTemplateId":10,
		"reportObjectId":34868,
		"reportObjectSecId":0,
		"interval":{
			"from":1356984000,
			"to":1358711999,
			"flags":0
		},
		"tzOffset":134228528,
		"lang":"en"
	}&ssid=<your_sid>

Response:

{
    "reportResult": {
        "msgsRendered": 1,
        "stats": [
            ["Move time", "7:09:23"],
            ["Trips count", "120"],
            ["Stops count", "0"],
            ["Parking time", "19 days 16:34:20"],
            ["Parkings count", "121"]
        ],
        "tables": [{
            "nm": "unit_trips",
            "text": "Trips without stops",
            "f": 4497,
            "r": 16,
            "c": 16,
            "h": ["№", "Date", "Beginning", "Initial location", "End", "Final location", "Driver", "Duration", "Engine hours", "Mileage", "Mileage (adjusted)", "Avg speed", "Max speed", "Trips count", "Initial fuel level", "Final fuel level"],
            "t": ["", "", "2013-01-01 17:36:58", "", "2013-01-20 18:26:50", "", "", "7:09:23", "0:00:00", "0.00 km", "0.00 km", "0 km\/h", "118 km\/h", "120", "0 lt", "0 lt"]
        }, {
            "nm": "unit_stays",
            "text": "Parkings",
            "f": 272,
            "r": 74,
            "c": 5,
            "h": ["Beginning", "End", "Duration", "Location", "Count"],
            "t": ["2013-01-01 00:07:56", "2013-01-20 23:51:39", "19 days 13:50:40", "", "74"]
        }],
        "attachments": [{
            "n": "Speed and mileage chart",
            "t": "chart"
        }]
    },
    "reportLayer": {
        "name": "report unit_msgs",
        "bounds": [53.8326976, 27.2796096, 53.9644416, 27.6123168],
        "units": [{
            "id": 34868,
            "msgs": {
                "count": 6585,
                "first": {
                    "time": 1356984476,
                    "lat": 53.9077377319,
                    "lon": 27.5011463165
                },
                "last": {
                    "time": 1358711499,
                    "lat": 53.839679718,
                    "lon": 27.5609111786
                }
            },
            "mileage": 770003.067396,
            "max_speed": 118
        }]
    },
    "layerCount": 2
}

Conclusions that can be drawn out of the response:

  • report contains a table with statistics (“stats” section);
  • report contains 2 tables;
  • report contains a chart (see “attachments” section);
  • report contains a layer with messages (because “msgsRendered” is 1);
  • 6585 messages were used to build this layer.

Get tables data

To get data from tables you should use request report/get_result_rows. It is suitable for most reports. However, it returns only rows of the top level. If you have a multilevel report, you need to make an additional request to get the rows of lower levels – report/get_result_subrows.

Let's get the first row of the table which has index 0 in “tables” array.

<your_wialon_pro_address>/ajax.html?svc=report/get_result_rows&
	params={
		"tableIndex":0,
		"indexFrom":0,
		"indexTo":0
	}&ssid=<your_sid>

Response:

[{
    "n": 0,
    "i1": 108,
    "i2": 214,
    "t1": 1357047418,
    "t2": 1357056357,
    "d": 3,
    "c": ["1", "2013-01-01", {
        "t": "17:36:58",
        "y": 53.9097984,
        "x": 27.4998528
    }, {
        "t": "Beruta st., Minsk",
        "y": 53.9097984,
        "x": 27.4998528
    }, {
        "t": "20:05:57",
        "y": 53.8847872,
        "x": 27.5675072
    }, {
        "t": "Mayakovskogo st., Minsk",
        "y": 53.8847872,
        "x": 27.5675072
    }, "", "0:11:15", "0:00:00", "0.00 km", "0.00 km", "0 km\/h", {
        "t": "72 km\/h",
        "y": 53.9070656,
        "x": 27.5216608
    }, "3", "0 lt", "0 lt"]
}]

Number 3 in the parameter d tells us that the current row contains 3 subrows. To get them, make the request:

<your_wialon_pro_address>/ajax.html?svc=report/get_result_subrows&
	params={
		"tableIndex":0,
		"rowIndex":0
	}&ssid=<your_sid>

Response:

[{
    "i1": 108,
    "i2": 118,
    "t1": 1357047418,
    "t2": 1357047581,
    "c": ["1.1", "", {
        "t": "17:36:58",
        "y": 53.9097984,
        "x": 27.4998528
    }, {
        "t": "Beruta st., Minsk",
        "y": 53.9097984,
        "x": 27.4998528
    }, {
        "t": "17:39:41",
        "y": 53.9152448,
        "x": 27.4865568
    }, {
        "t": "Matusevicha st., Minsk",
        "y": 53.9152448,
        "x": 27.4865568
    }, "", "0:02:43", "0:00:00", "0.00 km", "0.00 km", "0 km\/h", {
        "t": "34 km\/h",
        "y": 53.910112,
        "x": 27.495648
    }, "1", "0 lt", "0 lt"]
}, {
    "i1": 151,
    "i2": 169,
    "t1": 1357053985,
    "t2": 1357054222,
    "c": ["1.2", "", {
        "t": "19:26:25",
        "y": 53.9205888,
        "x": 27.492064
    }, {
        "t": "Danily Serdicha st., 68, Minsk",
        "y": 53.9205888,
        "x": 27.492064
    }, {
        "t": "19:30:22",
        "y": 53.9094592,
        "x": 27.4950912
    }, {
        "t": "Pritytskogo st., Ratomka",
        "y": 53.9094592,
        "x": 27.4950912
    }, "", "0:03:57", "0:00:00", "0.00 km", "0.00 km", "0 km\/h", {
        "t": "41 km\/h",
        "y": 53.9177472,
        "x": 27.4873152
    }, "1", "0 lt", "0 lt"]
}, {
    "i1": 200,
    "i2": 214,
    "t1": 1357056082,
    "t2": 1357056357,
    "c": ["1.3", "", {
        "t": "20:01:22",
        "y": 53.8974912,
        "x": 27.5369984
    }, {
        "t": "Klary Tsetkin st., Minsk",
        "y": 53.8974912,
        "x": 27.5369984
    }, {
        "t": "20:05:57",
        "y": 53.8847872,
        "x": 27.5675072
    }, {
        "t": "Mayakovskogo st., Minsk",
        "y": 53.8847872,
        "x": 27.5675072
    }, "", "0:04:35", "0:00:00", "0.00 km", "0.00 km", "0 km\/h", {
        "t": "62 km\/h",
        "y": 53.8868928,
        "x": 27.5656
    }, "1", "0 lt", "0 lt"]
}]

Getting graphic data

During execution of the report a layer with trips and parkings was generated for the report. We can get the image of this layer (combined with map) using the request get_result_map:

<your_wialon_pro_address>/ajax.html?svc=report/get_result_map&
	params={
		"width":600,
		"height":600
	}&ssid=<your_sid>

Response:

Also there is “Speed and mileage chart” in the report. You can get its image using the request get_result_chart. To place a chart name above the chart, set the flag 0×01, and to place a legend under the chart, set the flag 0x200.

<your_wialon_pro_address>/ajax.html?svc=report/get_result_chart&
	params={
		"attachmentIndex":0,
		"action":0,
		"width":600,
		"height":300,
		"autoScaleY":0,
		"pixelFrom":0,
		"pixelTo":300,
		"flags":513
	}&ssid=<your_sid>

Response:

Follow us on Facebook Gurtam Wialon Twitter Gurtam Wialon info@gurtam.com   |   Copyright © 2002-2024 Gurtam