1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <meta charset="utf-8" />
5
    <title>Wialon Playground - Create driver</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
<div id="base">
12
    <div>
13
        Resource: <select id="resource" name="resource"><option value="">-- select resource --</option></select>
HTML
17
 
1
.btn {
2
  cursor:pointer;
3
}
4
div {
5
    margin-bottom:20px;
6
}
7
#log_cont {
8
    background-color: #EEEEEE;
9
    height: 150px;
10
    overflow-y: scroll;
11
    font-size:75%;
12
}
13
#log_cont table {
14
    width:100%;
15
}
16
17
CSS
94
 
1
var createDriver = {
2
    init: function () {
3
        var sess = wialon.core.Session.getInstance();
4
5
        sess.loadLibrary( "resourceDrivers" );
6
        
7
        // flags to specify what kind of data should be returned
8
        var flags =  wialon.util.Number.or(wialon.item.Item.dataFlag.base, wialon.item.Resource.dataFlag.drivers); // 64 bit OR
9
10
        // Subscribe on resource data
11
        sess.updateDataFlags( // load items to current session
12
            [{type: "type", data: "avl_resource", flags: flags, mode: 0}], // Items specification
13
            function (code){ // updateDataFlags callback 
14
                if (code) {
15
                    createDriver.log("Error: "+wialon.core.Errors.getErrorText(code));
16
                    return; // exit if error code 
17
                }
JS
Result
Source code of example Close ✕
1
 
1
/*source*/