mobile CCTV,mobile surveillance,police body worn cameras

标题: 获取GSP格式不对,时间对不上 [打印本页]

author: tank    time: 2021-3-19 14:34
标题: 获取GSP格式不对,时间对不上
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>gps</title>
</head>
<body>
    <input type="button" value="登录" />
    <input type="button" value="获取GPS" />
    <input type="button" value="停止获取GPS" />
    <div id="msg"></div>
</body>
</html>
<script type="text/javascript" src="http://120.25.247.85:8081/js/jsw.js"></script>
<script type="text/javascript">
    window.onload = function () {
        jSW.swInit({
            url: "http://120.25.247.85:8081", // bv_nginx.exe服务器地址
            calltype: jSW.CallProtoType.AUTO, // AUTO: IE优先使用OCX, 如果希望IE仍然使用HTTP通信, 请使用jSW.CallProtoType.HTTP
        });
    }
    window.onbeforeunload = function () {
        jSW.swDeInit();
    }

    var session = null;
    function testLogin() {
    document.getElementById('msg').innerHTML = '';
        if (session) { delete session; }
        session = new jSW.SWSession({
            server: '47.100.89.71', // 如果是jSW.CallProtoType.OCX方式,这里需要填写具体的IP
            port: 9701,
            onopen: function (sess) {
                    sess.swLogin({
                        user: 'admin',
                        password: '123456'
                    });
                }
        });

        // 注册事件的回调函数
        session.swAddCallBack('login', sessionCallback);
        session.swAddCallBack('logout', sessionCallback);
    }

    function testLogout() {
        if (session) {
            session.swLogout();
        }
    }

    function sessionCallback(sender, event, json) {
        var info = '';
        if ('login' == event) {
            info += '登录';
        } else if ('logout' == event) {
            info += '退出';
        }

        if (json.code == jSW.RcCode.RC_CODE_S_OK) {
            info += '成功';
        } else {
            info += '失败, error code: ' + json.code;
        }

        document.getElementById('msg').innerHTML = info + '<br/><textarea rows="18" cols="100" readonly="readonly"> ' + JSON.stringify(json, null, 4) + '</textarea>';
    }

    function testGPS(isGetGps) {

        if (null == session) {
            alert('无效的连接');
            return;
        }

        var gps = session.swGetPuChanel('PU_20127761', 65536);
        if (null == gps) {
            alert('没有该设备通道');
            return ;
        }

        if (isGetGps) {
            gps.swOpen({
                repeat: 10,
                interval: 2000,
                callback: OnGetGPS,
            });
        } else {
            gps.swClose();
        }
    }

    function OnGetGPS(options, response) {
        if (response.emms.code == jSW.RcCode.RC_CODE_S_OK) {
            var data = response.gps;
                        console.log(data);
            document.getElementById('msg').innerHTML = 'orientationstate:' + data.orientationstate
            + '<br/>long:' + data.long
            + '<br/>lat:' + data.lat
            + '<br/>height:' + data.height
            + '<br/>speed:' + data.speed
            + '<br/>time:' + data.sttime.year + '-' + data.sttime.month + '-' + data.sttime.day + ' ' + data.sttime.hour + ':' + data.sttime.minute + ':' + data.sttime.second
            + '<br/>starcount:' + data.starcount;
        }
    }
</script>







author: hardfire    time: 2021-3-19 17:28
首先注意设备要放在户外才能真正搜到卫星。

author: IBeli    time: 2021-3-19 17:45
你好,时间是utc时间,utc时间和北京时间相差8小时




欢迎光临 mobile CCTV,mobile surveillance,police body worn cameras (http://bbs.besovideo.com:8067/) Powered by Discuz! X3.2