1

API entities: unit, resource, geofence, etc.

Тема: API entities: unit, resource, geofence, etc.

Hi,

Probably a new baby question, but anyway could You please briefly describe what such entity as "resource" is, and how it is related to units, geofences or whatever? My current task is to show names of geofences where an unit currently is (last message), but I can't figure out why do I need to think about a resource.

Generally, it will very nice if you compose some sort of "API Entities" article, where you describe ALL the entities which covered by API(s), what they really mean, and how they related to each other.

Thanks in advance!

Sergei Shirokov / GoGPS Service
Senior Software Engineer
www.gogps.eu
Skype: sergei.shirokov
2

API entities: unit, resource, geofence, etc.

Re: API entities: unit, resource, geofence, etc.

Check this sample https://github.com/ashmigelski/units-inside, it seems to be very close to your task

And some more useful info:

1) http://docs.wialon.com/en/hosting/cms/accounts/accounts

Resource is a system macro object which includes different micro objects as its contents, which are POIs, geofences, jobs, notifications, drivers, trailers, and report templates. Availability of a resource gives user opportunity to create such objects

2) http://sdk.wialon.com/wiki/en/sidebar/r … e/resource

This chapter describes commands which can be applied to such resource subitems as POIs, geofences, drivers, trailers, notifications, and jobs

Maybe our documentation not ideal, but we're always ready to help - feel free to ask

3

API entities: unit, resource, geofence, etc.

(25/09/2014 00:14:00 отредактировано sergej.shirokov)

Re: API entities: unit, resource, geofence, etc.

The sample "https://github.com/ashmigelski/units-inside" helped a lot. Now I've got geofences, and even have managed to determine which units inside which zones. Actually I don't like my own code because now have to do explicit remote call 'wialon.util.Helper.getZonesInPoint' per each unit, but ok, it works.

Traditional question: is it possible to be notified when something happens with a zone(s), so that minimize number of getZonesInPoint calls?

Sergei Shirokov / GoGPS Service
Senior Software Engineer
www.gogps.eu
Skype: sergei.shirokov
4

API entities: unit, resource, geofence, etc.

Re: API entities: unit, resource, geofence, etc.

sergej.shirokov пишет:

Actually I don't like my own code because now have to do explicit remote call 'wialon.util.Helper.getZonesInPoint' per each unit, but ok, it works.

You can try some ways of optimization, e.g listen units 'positionChange' event and send 'wialon.util.Helper.getZonesInPoint' only when unit far away from previous calculated point. More over you can push such units in array and send batch request once in minute or any other time you need. And even more, you can get all geofences info and solve 'point inside polygon' task on JS without sending requests at all

sergej.shirokov пишет:

Traditional question: is it possible to be notified when something happens with a zone(s), so that minimize number of getZonesInPoint calls?

Actually, from developers side  'zone', 'customFields', 'adminFields' and all other sub-elements of item the same class of objects - Items propitem. And same logic should be used for all of them. My post from previous topic works with propItem 'CustomFields', here is same example for more common situation

// load library to work with <propItem> (including events)
wialon.core.Session.getInstance().loadLibrary("item<propItem>");
// add "update<propItem>" listener
item.addListener("update<propItem>", function (e) {
  console.log("<propItem> updated", e);
});