1

Wialon Hosting

Topic: Wialon Hosting

Can anyone please help me about getting satellite-strength of a unit.
Thanks in advance

2

Wialon Hosting

Re: Wialon Hosting

Position has sc field with satellites count. It should be less than 255 (255 means, that specific count is unknown).

Also, message parameters (p field) from some devices can contain hdop/vdop/*dop.

3

Wialon Hosting

Re: Wialon Hosting

Thank you so much dear.

4

Wialon Hosting

Re: Wialon Hosting

Hi, please help me once again,

actually , I need drivers data, idling , trailer RFID and PTO parameters and Media files and so on.

for driver data:  i added "resourceDrivers" library and also "0x00000100" as flag,

but , i am getting null value.
also i did same for retailers as well, but getting null, actually all values i am getting is null

5

Wialon Hosting

Re: Wialon Hosting

farah.aidid wrote:

for driver data:  i added "resourceDrivers" library and also "0x00000100" as flag,

but , i am getting null value.

Looks strange. session.loadLibrary was called before updateDataFlags/searchItem?

6

Wialon Hosting

(edited by farah.aidid 14/11/2019 13:20:26)

Re: Wialon Hosting

yes, i am calling first loadLibrary(), then updateDataFlags()

7

Wialon Hosting

Re: Wialon Hosting

var sess = wialon.core.Session.getInstance()
sess.loadLibrary("resourceDrivers")
let flags = wialon.item.Item.dataFlag.base | 0x00000100
sess.updateDataFlags(
        [
          { type: "type", data: "avl_resource", flags: flags, mode: 0 }
        ],
        function(code) {
            if (code) {
               alert(wialon.core.Errors.getErrorText(code))
               return;
             }
             var resources = sess.getItems("avl_resource")
             console.log(resources)             
        }
)




this is my code

8

Wialon Hosting

Re: Wialon Hosting

farah.aidid wrote:

var sess = wialon.core.Session.getInstance()
sess.loadLibrary("resourceDrivers")
let flags = wialon.item.Item.dataFlag.base | 0x00000100
sess.updateDataFlags(
        [
          { type: "type", data: "avl_resource", flags: flags, mode: 0 }
        ],
        function(code) {
            if (code) {
               alert(wialon.core.Errors.getErrorText(code))
               return;
             }
             var resources = sess.getItems("avl_resource")
             console.log(resources)             
        }
)

this is my code

Sorry for long reply. Executed same code, it works correctly.

Check for the:

sess.getFeatures().svcs.drivers

(it should be 1, else you have no access to the drivers service)

And:

resource.getUserAccess() & wialon.item.Resource.accessFlag.viewDrivers

(it should be non-zero, else you has no access to view drivers)

9

Wialon Hosting

Re: Wialon Hosting

thank you so much

10

Wialon Hosting

Re: Wialon Hosting

Please help me:

How can I get Moving State of a unit?

I am using Javascript API.

Thank you again.

11

Wialon Hosting

Re: Wialon Hosting

farah.aidid wrote:

How can I get Moving State of a unit?

Currently there is no method to get moving state, such as displayed in the monitoring.

We have code similar to:

function getUnitMovingState(unit) {
  let info = {
    isMoving: false, // by real-time sensor or speed
    isIgnitionOn: null, // Boolean | null

    isLbs: false,
    isStale: true, // expired `unitMovingTimeout`

    isPositionPresent: false,
    isIgnitionPresent: false,
    isRealTimeSensorPresent: false
  };

  let pos = getLastKnownPosition(unit);

  if (!pos) {
    return info;
  }

  info.isPositionPresent = true;

  //// LBS
  info.isLbs = !!(
    pos.s <= 0 &&
    typeof pos.f === "number" &&
    wialon.util.Number.and(pos.f, wialon.item.Unit.dataMessageFlag.lbsFlag)
  );

  let serverTime = session.getServerTime();

  //// Stale position
  let unitMovingTimeout = parseInt(
    currentUser.getCustomProperty("mu_move_durr", "3600"),
    10
  );
  if (!isFinite(unitMovingTimeout)) unitMovingTimeout = 3600;

  info.isStale = unitMovingTimeout < serverTime - pos.t;

  //// Sensors
  let sensors = unit.getSensors();

  let realTimeSensor, ignitionSensor;

  for (let prop in sensors)
    if (sensors[prop].t === "real-time motion sensor") {
      realTimeSensor = sensors[prop];
      break;
    }
  for (let prop in sensors)
    if (sensors[prop].t === "engine operation") {
      ignitionSensor = sensors[prop];
      break;
    }

  //// Ignition
  let ignitionSensorValue = null;

  if (ignitionSensor) {
    ignitionSensorValue = calculateLastSensorValue(unit, ignitionSensor);

    if (typeof ignitionSensorValue === "number") {
      info.isIgnitionPresent = true;
    }
  }

  info.isIgnitionOn = !!ignitionSensorValue;

  //// Moving state
  let realTimeSensorValue = null;

  if (realTimeSensor) {
    realTimeSensorValue = calculateLastSensorValue(unit, realTimeSensor);

    if (typeof realTimeSensorValue === "number") {
      info.isRealTimeSensorPresent = true;
    }
  }

  if (typeof realTimeSensorValue === "number") {
    info.isMoving = realTimeSensorValue !== 0;
  } else {
    info.isMoving = pos.s > 0;
  }

  return info;
}

(there is few missing functions like getLastKnownPosition, calculateLastSensorValue, they can be replaced by unit.getPosition, unit.calculateSensorValue, but calculateLastSensorValue should return null instead of -348201.3876 in the case of invalid value)

Then we are visualizing this state.

12

Wialon Hosting

Re: Wialon Hosting

thank you again

13

Wialon Hosting

Re: Wialon Hosting

Hi, I want to get Unit Group Name, I requested with
https://hst-api.wialon.com/wialon/ajax.html

data-params:
{
                svc: 'report/exec_report',
                params: {
                  "spec":{
                    "itemsType":"avl_unit_group",
                    "propName":"",
                    "propValueMask":"",
                    "sortType":"",
                    "propType":"",
                    "or_logic":false
                  },
                "force":1,
                "flags":1,
                "from":0,
                "to":0
                },
                sid: session
              }



also with this

{
                svc: 'core/search_items',
                params: {
                  "spec":{
                    "itemsType":"avl_unit_group",
                    "propName":"",
                    "propValueMask":"",
                    "sortType":"",
                    "propType":"",
                    "or_logic":false
                  },
                "force":1,
                "flags":1,
                "from":0,
                "to":0
                },
                sid: session
              }


But, I got this exception:

TypeError: Cannot read property 'setName' of undefined
    at wialon.item.Item.remoteUpdateName() (wialon.js:11195)
    at e (jquery.min.js:4)
    at Ab (jquery.min.js:4)
    at Ab (jquery.min.js:4)
    at Ab (jquery.min.js:4)
    at Function.r.param (jquery.min.js:4)
    at Function.ajax (jquery.min.js:4)
    at eval (Dashboard.vue?98fa:1094)
    at Array.forEach (<anonymous>)



I am confused about this, can you please help me?

14

Wialon Hosting

Re: Wialon Hosting

Are you called remoteUpdateName method directly?

It is internal method and should be called only from SDK itself.

Correct method for name change is updateName.

15

Wialon Hosting

Re: Wialon Hosting

did not call any method, just put an AJAX request on this URL with this data,

response comes with this error

16

Wialon Hosting

Re: Wialon Hosting

I see such error for the first time and code says, that remoteUpdateName cannot be called with undefined item.

How are you perform request to core/search_items?

Like this:

sess.searchItems(
  {
    itemsType: "avl_unit_group",
    propName: "",
    propValueMask: "",
    sortType: "",
    propType: "",
    or_logic: false
  },
  1, // flags
  1, // force
  0, // from
  0, // to
  function(error, result) {
    console.log(error, result);
  }
);

or via other methods?

17

Wialon Hosting

Re: Wialon Hosting

oops, i made mistake with requesting jquery AJAX request.

thank you so much

18

Wialon Hosting

Re: Wialon Hosting

hi, i can get last active time of a unit,
i need to get the time of when unit engine is on but not moving (Idle)

can you please help me about this?

19

Wialon Hosting

Re: Wialon Hosting

farah.aidid wrote:

hi, i can get last active time of a unit,
i need to get the time of when unit engine is on but not moving (Idle)

This is a bit complicated.

To get historical data, there is three ways:

  • Fetch messages and calculate whatever you want
  • Execute report, that will provide required info
  • Use events, which has time intervals of sensor values/trips

Events is a most efficient way (because you don't know, how much messages you need to fetch to find message, when engine was on, for some units you can easily fetch megabytes and find nothing; reports internally processing all messages for specified period and can be slow; events are precalculated and in most of the cases will be much faster).

You need to execute events/load with sensors type and some time interval, then events/get.

Something like:

let time = sdk.s.getServerTime();

remote.remoteCall('events/load', {
    itemId: 42,
    ivalType: 1,
    timeFrom: 0, // better to limit it for few days
    timeTo: time,
    detectors: [{
        type: 'sensors',
        filter1: 13,
    }],
}, function() { ... });

// ... in a callback:

remote.remoteCall('events/get', {
    selector: {
        type: 'sensors',
        timeFrom: time - 24 * 60 * 60,
        timeTo: time,
        detalization: 3,
    },
});

(where 13 (filter1) — is an engine sensor id)

Then you can try to find latest interval, where engine was on.

With such interval, you can try to fetch trips from events to find stops inside it (events also has expr, that allow to intersect intervals, but I cannot help with them).

20

Wialon Hosting

Re: Wialon Hosting

Hi, I have reports of a unit group, and each row also has some child rows,


I am requesting like this to get reports
res.execReport(template, uid, 0, interval,function(code,data){}),

but, i get only first row, cannot get any child rows,

can you please help me about this?

thank you.

21

Wialon Hosting

Re: Wialon Hosting

See for report/get_result_subrows and report/select_result_rows

22

Wialon Hosting

Re: Wialon Hosting

unit.getCommands()

this returns null sometimes and sometimes list of commands.

i am confused about this.
can you please help

23

Wialon Hosting

Re: Wialon Hosting

I am getting user-access as value : 19327369763
and wialon.item.Unit.accessFlag.executeCommands value is:   16777216
so, when checking whether can-execute the command or not, returns false.