1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <meta charset="utf-8" />
5
    <title>Wialon Playground - Edit sensors</title>
6
    <script type="text/javascript" src="//code.jquery.com/jquery-latest.min.js"></script>
7
    <script type="text/javascript" src="//hst-api.wialon.com/wsdk/script/wialon.js"></script>
8
</head>
9
<body>
10
11
Select unit: <select id="units"></select> available sensors <select id="sensors"></select>
12
    <table>
13
    <tr>
HTML
2
 
1
#log, td{ border: 1px solid #c6c6c6; padding:5px;}
2
table select, table input { width:100%; }
CSS
145
 
1
var cur_sens; // global variable
2
3
// Print message to log
4
function msg(text) { $("#log").prepend(text + "<br/>"); }
5
6
function init() { // Execute after login succeed
7
    var sess = wialon.core.Session.getInstance(); // get instance of current Session
8
    // flags to specify what kind of data should be returned
9
    var flags = wialon.item.Item.dataFlag.base |
10
             wialon.item.Unit.dataFlag.sensors | 
11
             wialon.item.Unit.dataFlag.lastMessage;
12
    sess.loadLibrary("unitSensors"); // load Sensor Library
13
    
14
    sess.updateDataFlags( // load items to current session
15
        [{type: "type", data: "avl_unit", flags: flags, mode: 0}], // Items specification
16
        function (code) { // updateDataFlags callback
17
            if (code) { msg(wialon.core.Errors.getErrorText(code)); return; } // exit if error code 
JS
Result
Source code of example Close ✕
1
 
1
/*source*/