Item events management

To get events from items, you need to add them to the session. To stop watching item state, remove it from the session. To add/remove items to/from a session, use the command core/update_data_flags:

svc=core/update_data_flags&params={"spec":[
					{
						"type":<text>,
						"data":<long|text|[long]>,
						"flags":<long>,	
						"mode":<uint>,
						"max_items":<uint>
					}
				   ]}

:!: You can find an example of this request in the sample Item events management.

Parameters

Name Description
spec array of item configurations
type method of transmitting items to the session (see the list below)
data data (depends on the value of the “type” parameter)
flags flags that define what part of item data will be added to the session (data for-
mats of all item types and their flags are described in the chapter Data format)
mode flags application mode (see the list below)
max_items param is available when type='type', defines max quantity of subscribed items

Methods of item transmission:

  • id – by ID (if such a method is selected, you indicate item ID in the data parameter);
  • type – by type (if such a method is selected, you indicate item type in the data parameter - see Search items by property);
  • col – by list of IDs (if such a method is selected, you write an array of item IDs in the data parameter).

Flags application mode:

  • 0 – redefine item flags;
  • 1 – add specified flags to those already present in the session;
  • 2 – remove specified flags from the session (if you remove the base flag, the item will be removed from the session).

Flags are set to watch changes of specific item properties. The number of observed flags depend on your needs. If you want to get all events from an item, you should set up all flags. You can get events using the request avl_evts.

Response

[		/* array of items */
	{
		"i":<long>,	/* ID  */
		"d":{		/* other fields */
			...
		},
		"f":<long>	/* applied data flags */
	},
	...
]

The format of “d” depends on item type. All formats are described in the chapter Data format.

If you call this command with flags application mode set to “2”, the field “d” will be null.

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