captureSettings.esp
7.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<!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]+)(&)?)?/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>