Тема: How get to value of milage or odometer of each unit?
I am getting the values the sensors and other things but I need to get milage value. Put of example of code that get for wialon playground
function getSelectedUnitInfo(){ // print information about selected Unit
var val = $("#units").val(); // get selected unit id
if(!val) return; // exit if no unit selected
var unit = wialon.core.Session.getInstance().getItem(val); // get unit by id
if(!unit){ msg("Unit not found");return; } // exit if unit not found
// construct message with unit information
var text = "<div>'"+unit.getName()+"' selected. "; // get unit name
var icon = unit.getIconUrl(32); // get unit Icon url
if(icon) text = "<img class='icon' src='"+ icon +"' alt='icon'/>"+ text; // add icon to message
var pos = unit.getPosition(); // get unit position
if(pos){ // check if position data exists
var time = wialon.util.DateTime.formatTime(pos.t);
text += "<b>Last message</b> "+ time +"<br/>"+ // add last message time
"<b>Position</b> "+ pos.x+", "+pos.y +"<br/>"+ // add info about unit position
"<b>Speed</b> "+ pos.s+"<br/>"+ // add info about unit speed
"<b>Odometer</b> "; //THIS VALUE OF MILAGE OR ODOMETER
// try to find unit location using coordinates
wialon.util.Gis.getLocations([{lon:pos.x, lat:pos.y}], function(code, address){
if (code) { msg(wialon.core.Errors.getErrorText(code)); return; } // exit if error code
msg(text + "<br/><b>Location of unit</b>: "+ address+"</div>"); // print message to log
});
} else // position data not exists, print message
msg(text + "<br/><b>Location of unit</b>: Unknown</div>");
}