captureSettings.esp 7.75 KB
<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>抓拍参数设置</title>
    <link href="../../css/frame.css" rel="stylesheet" />
    <link href="../../scripts/easyui/themes/default/easyui.css" rel="stylesheet" />
    <link href="../../scripts/easyui/themes/icon.css" rel="stylesheet" />
    <link href="../../css/reboot.css" rel="stylesheet" />
    <style type="text/css">
        #childPageIframe {
            width: 100%;
            height: 100%;
            border: 0;
            padding: 0;
            margin: 0;
        }

        #captureModeForm {
            display: inline;
        }
    </style>
</head>

<body>
    <div class="easyui-layout" data-options="fit:true">
        <div data-options="region:'north',border:false" style="height: 40px;padding:8px 0 8px 7px;background-color: #F3F5F6;">
            <span>抓拍模式</span>
            <form id="captureModeForm">
                <select id="captureMode" name="220">
                </select>
                <% inputSecurityToken(); %>
            </form>
        </div>
        <div data-options="region:'center',border:false" style="overflow: hidden;">
            <iframe src="" id="childPageIframe" frameborder="0"></iframe>
        </div>
    </div>

    <script src="../../scripts/easyui/jquery.min.js"></script>
    <script src="../../scripts/easyui/jquery.easyui.min.js"></script>
    <script src="../../scripts/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script src="../../scripts/utilities.js"></script>
    <script type="text/javascript">
        var parameterAdaptor = new ParameterAdaptor();
        var rebootManager = new RebootManager();

        // 仅供开发时测试使用
        var isDebug = false;

        $().ready(function () {
            // 加载所有抓拍模式
            loadAllCaptureModes();
            // 跳转子页面
            $("#captureMode").change(confirmCaptureModeChange);

            if (isDebug) {
                $("#childPageIframe").attr("src", "capture/noMotorVehicleViolation.esp");
            }
        });

        // 加载相机抓拍模式,首先加载所有可用的模式,然后再加载当前的模式,并显示对应的页面
        function loadAllCaptureModes() {
            var url = "/do/trafficController/configVal?t=" + new Date().getTime();
            if (isDebug) {
                url = "../advanced/xml/VasconfigInfo.xml";
            }
            $.get(url, null, function (xmlData) {
                var xmlDoc = null;
                try {
                    var xmlDoc = $.parseXML(xmlData);

                } catch (error) {
                    $.messager.alert("错误", "解释参数XML错误!(XML格式不正确)", "error");
                    if (window.console) {
                        console.error("解析参数XML失败!");
                    }
                    return;
                }
                // 从中解析出抓拍参数
                var captureModePath = "root>功能配置>抓拍参数配置>抓拍模式>AttribRange";
                var modeTextObjs = $(xmlDoc).find(captureModePath);
                if (modeTextObjs.length === 0) {
                    $.messager.alert("错误", "获取相机抓拍模式失败!", "error");
                    if (window.console) {
                        console.error("从xml中未能解析到节点:/root/功能配置/抓拍参数配置/抓拍模式/AttribRange");
                    }
                    return;
                }
                var allModes = modeTextObjs[0].textContent ? modeTextObjs[0].textContent : modeTextObjs[0].text;
                var comboboxData = getComboboxData(allModes);
                // 填充到下拉框
                $("#captureMode").html("");
                var options = [];
                for (var index = 0; index < comboboxData.length; index++) {
                    var element = comboboxData[index];
                    options.push("<option value='" + element.id + "'>" + element.text + "</option>");
                }
                $("#captureMode").html(options.join(""));
                // 调用加载当前相机模式的方法
                loadActiveCaptureMode();
            }, "text");
        }

        function getComboboxData(pRangeString) {
            var enumRegex = /(-?\d+)-(([0-9a-zA-Z\u4e00-\u9faf]+)(&amp;)?)?/g;//枚举类型的正则表达式
            var comboboxData = [];
            var match = enumRegex.exec(pRangeString);
            while (match != null) {
                comboboxData.push({
                    id: match[1],
                    text: match.length >= 4 ? match[3] : ""
                });
                match = enumRegex.exec(pRangeString);
            }
            return comboboxData;
        }

        //加载抓拍模式
        function loadActiveCaptureMode() {
            var refererInfo = "cameraSettings";
            parameterAdaptor.getParameters(refererInfo, function (data) {
                if (data && data.feedback) {
                    $("#captureModeForm").form("load", data.feedback);
                }
                //显示对应的页面
                showChildPage();
            });
        }

        //显示对应的子页面
        function showChildPage() {
            // 获取模式下拉框的值
            var modeValue = $("#captureMode").find("option:selected").val();
            var pageUrl = "";
            switch (modeValue) {
                //路口电警
                case "0":
                    pageUrl = "capture/intersection.esp";
                    break;
                // 路段电警,视频卡口
                case "1":
                case "2":
                    pageUrl = "capture/videoBayonet.esp";
                    break;
                // 移动公交
                case "3":
                    pageUrl = "capture/busSetting.esp";
                    break;
                // 非机动车违法
                case "4":
                    pageUrl = "capture/noMotorVehicleViolation.esp";
                    break;
                default:
            }
            if (pageUrl) {
                $("#childPageIframe").attr("src", pageUrl);
            }
        }

        //向用户确认抓拍模式变更,保存参数并重启相机
        function confirmCaptureModeChange() {
            var captureMode = $("#captureMode").find("option:selected").val();
            // debug模式 直接显示对应的页面
            if (isDebug) {
                showChildPage();
                return;
            }
            //隐藏ROIOcx
            hideRoiOcx();

            $.messager.confirm("提示", "变更抓拍模式需要重启相机,确认变更吗?", function (isConfirm) {
                if (isConfirm) {
                    //确认变更,保存参数
                    var formObj = $("#captureModeForm");
                    parameterAdaptor.saveParameters(formObj, function (data) {
                        if (data.error) {
                            $("#childPageIframe").hide();
                            rebootManager.sendRebootCmd();
                        } else {
                            $.messager.alert("提示", "切换抓拍模式失败!", "error");
                        }
                    }, "GET");
                }
                //显示RoiOcx
                showRoiOcx();
            });
        }

        function hideRoiOcx() {
            var ocx = childPageIframe.document.getElementById("roiOcxObject");
            if (ocx) {
                ocx.style.display = "none";
            }
        }

        function showRoiOcx() {
            var ocx = childPageIframe.document.getElementById("roiOcxObject");
            if (ocx) {
                ocx.style.display = "block";
            }
        }

    </script>
</body>

</html>