1

I can n't recover the value of sensor ignition

(02/03/2016 00:15:06 отредактировано arenasx)

Тема: I can n't recover the value of sensor ignition

Hi i have this issue

I can n't recover the value of sensor ignition, I always get the value -348201.3876

This is my code

    for (var i = 0; i< units.length; i++)
    { // construct Select object using found units
        var u = units[i]; // current unit in cycle
            var unit = wialon.core.Session.getInstance().getItem(u.getId());
                var sens = unit.getSensors();
        for(var z in sens) // construct select list
                {
                    var str = sens[z].n
                        var res = str.substring(0,4) 
            if (res == 'Igni')
                        {
                            var result = unit.calculateSensorValue(sens[z].n, unit.getLastMessage());
                                if (result != -348201.3876 && parseFloat(result))
                                {
                                    value = 'on';
                                }
                                else
                                {
                                    value = 'off';
                                }
                                break;
                                }
                            }
        }
     }
2

I can n't recover the value of sensor ignition

Re: I can n't recover the value of sensor ignition

arenasx, You should pass to calculateSensorValue function in first parameter object of sensor (sens[z]) instead of it's name (sens[z].n).

Head of Wialon Local Department
Gurtam