Get events from session

When you loaded events into session with events/load and want to get selections please use events/get:

By time:

svc=events/get&params={"selector":{
					"type":<text>,
					"expr":<text>,
					"timeFrom":<uint>,
					"timeTo":<uint>,
					"detalization":<uint>
				    },
				    ...
		      }

By index:

svc=events/get&params={"selector":[
				    {
					"type":<text>,
					"expr":<text>,
					"indexFrom":<uint>,
					"indexTo":<uint>,
					"detalization":<uint>,
					"filter1":<uint>
				    },
				    ...
		      ]}

Parameters

Param Description
type sensor group: lls, trips, ignition, sensors, counters * (all groups)
expr intervals expression, it used instead of "type" param to get custom events intervals
timeFrom interval start, UNIX-time
timeTo interval end, UNIX-time
detalization output flags (see below)
indexFrom index of the first event requested
indexTo index of the last event requested
filter1 sensor ID

Output flags

Flag Descrition
0x1 Basic JSON: event start - event end
0x2 Specified detector data
0x4 User parameters (those which user stated for this event)
0x10 Full JSON. Every detector treats it its own way
0x20 Formatted value
0x40 grouping the intersections of intervals with tf и tt
0x80 add summary

Custom events intervals

To get custom events intervals use expression in "expr":<text> param instead type param.

Expression format in "expr" param

OperatorDescriptionExample
& AND trips&ignition
| OR trips|ignition
~ NOT trips&~ignition
[] choise of sensor id sensors[3], default first
() brackets trips&~ignition&(~sensors[3]|sensors[5])
- hyphenated custom interval 1451953325-1451953525&trips&ignition
{} selection intervals by the value of detalization trips{s<20}&ignition

Response

Reponse depends on type specified.

0x1 flag

Returns basic JSON (equal to all sensor groups)

"<type_name>": {
	"<sensor_id>": {
		"from": {
			"t":<uint>,	/* time (UNIX-time) */
			"y":<double>,	/* latitude */
			"x":<double>	/* longitude */
		},
		"to": {
			"t":<uint>,	/* time (UNIX-time) */
			"y":<double>,	/* latitude */
			"x":<double>	/* longitude */
		},
		"m":<uint>,		/* last message received time */
		"f":<uint> 		/* service flag */
	}
}

0x2 flag

Returns specified detector data

"ignition": {
	"<sensor_id>": 
			{
			    "state":<uint>,	/* state: 0 - off, 1 - on */
			    "type": 1,		/* sensor type: switcher sensor */
			    "hours":<uint>,	/* engine hours for all history, sec */
			    "switches":<uint>,	/* number of swithes for all hoistory */
			    "value":<bool>	/* current value */
			}
	...
}

Here are listed all sensor types for sensors:

"sensors": {
	"<sensor_id1>": 
			{
			    "state":<uint>,	/* state: 0 - off, 1 - on */
			    "type": 1,		/* sensor type: switcher sensor */
			    "hours":<uint>,	/* engine hours for all history, sec */
			    "switches":<uint>,	/* number of swithes for all hoistory */
			    "value":<bool>	/* current value */
			},
	"<sensor_id2>": 
			{
			    "type": 2,			/* sensor type: instant sensor */
			    "counter":<uint>,		/* message sequence conuter in event */
			    "summary":<uint>,		/* value summary in event */
			    "total_counter":<uint>,	/* number of messages in history */
			    "total_summary"<uint>,	/* value summary in history */
			    "value":<double> 		/* last value; if -348201.3876 -- value unknown */
			},
	"<sensor_id3>": 
			{
			    "type": 3,			/* sensor type: differential sensor */
			    "counter":<uint>,		/* value sum in event */
			    "total_counter":<uint>,	/* value sum in history */
			    "value":<double> 		/* last value; if -348201.3876 -- value unknown */
			},
	"<sensor_id4>": 
			{
			    "type": 4,			/* sensor type: analog sensor */
			    "value":<double> 		/* last value; if -348201.3876 -- value unknown */
			}
}
"lls": {
	"<sensor_id>":
			{
			    "value":<double>, 		/* last message value with calculated level */
			    "level":<double>, 		/* average median value  (FLS filtration value is used) */
			    "filled":<double> 		/* fuel filled */
			}
}
"trips": {
		"state":<bool>,		/* state: 0 - parking, 1 - trip, 2 - stop */
		"max_speed":<uint>,	/* max speed in trip */
		"curr_speed":<uint>,	/* current speed */
		"avg_speed":<uint>,	/* average speed according to distance */
		"distance":<uint>,	/* GPS mileage in trip */
		"odometer":<uint>,	/* distance for all trips */
		"course":<uint>,	/* course */
		"altitude":<uint>	/* altitude */
}
"counters": {
	"engine_hours": <uint>,   /* engine hours counter */
	"mileage": <uint>,        /* mileage counter */
	"bytes": <uint>           /* GPRS traffic counter */ 
}

0x4 flag

Returns user parameters Response depends on user definitions for current event.

"<type_name>": {
	"<sensor_id>": {
		"p":{	/* user-defined object content */
			"test":2,
			"foo":"bar",
			"trips":1
		}
	}
}

0x10 flag

Returns full JSON For sensors with both type=2 and type=3 (except FLS):

"sensors": {
	"<sensor_id>": 
			{
			    "msgs": [
					{
					    "tm":<uint>,	/* message time, UNIX-time */
					    "v":<double>	/* value */
					},
					...
				    ]
			},
	...
}

For FLS:

"lls": {
	"<sensor_id>": {
		"msgs": [
			    {
				"tm":<uint>,	/* message time, UNIX-time */
				"v":<double>,	/* value */
				"l":<double>	/* average median value  (FLS filtration value is used) */
			    },
			    ...
			]
		}
	},
	...
}

0x20 flag

Returns formatted values

"ignition": {
	"sensor_id": {
		"format": {
			    "value":<text>	/* formatted value  (usually "On"/"Off") */
		}
	}
}
"sensors": {
	"sensor_id": {
		"format": {
			    "value":<text>	/* formatted value, depends on sensor type and format */
		}
	}
}
"trips": {
	"format": {
		"distance":<text>,		/* distance according to prev message */
		"avg_speed":<text>		/* average speed according to "distance"  */
	}
}
"lls": {
	"sensor_id": {
		"format": {
			    "value":<text>,	/* formatted value, depends on sensor type and format */
			    "filled":<text>	/* fuel filled */
		}
	}
}
"counters": {
	"format": {
	"engine_hours":<uint>,   /* formatted value of engine hours counter */
	"mileage":<text>,        /* formatted value of mileage counter */
	"bytes":<uint>           /* formatted value of GPRS traffic counter */ 
	}
}

0x40 flag

"selector": [
    {
    "tf": <uint>, /* intersections interval, time from (unix time) */
    "tt": <uint>, /* intersections interval, time to (unix time) */
	"d": {
	    "<type_name>":{
		"<sensor_id>":[
		    { },
		]
	    },
	}
    }, 
]

0x80 flag

"selector":{
    "<type_name>":{
	"<sensor_id>":[
	{ },
	]
    },
},
"summary":{
    "<type_name>":{
	"<sensor_id>":{
	    "<summary_param_value>:<uint>",    /* summary, different for different detectors */
  	    "format": {
		"value":<text>	/* formatted value, depends on sensor type and format */
	    }
 
	}
}
Follow us on Facebook Gurtam Wialon Twitter Gurtam Wialon info@gurtam.com   |   Copyright © 2002-2021 Gurtam