-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathconfig.html
executable file
·740 lines (702 loc) · 21.7 KB
/
config.html
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML><HEAD>
<METAHTTP-EQUIV="Pragma"CONTENT="no-cache">
<METAHTTP-EQUIV="Cache-Control"CONTENT="no-cache">
<METAHTTP-EQUIV="Expires"CONTENT="0">
<meta charset="utf-8">
<TITLE>适配器配置</TITLE>
<style>
#table{
border-radius:20px;
border:0px;
background:#CCCCCC;
}
#table td{
color:black;
font-family:"仿宋";
color:#666666;border:0px;
}
#h1{
color:#CCCCCC;
font-family:"仿宋";
}
input{
font-family:"仿宋";
height:30px;
color:#0;
border : 0;
background:#F0FFFF;
}
.button{
margin-right:10px;
background:#666666;
width:80px;
border-radius:5px;
color:#FAF0E6;
}
.button:active{
background:green;
}
.file-box{
position:relative;
width:340px;
}
.txt{
height:30px;
border:1px solid #CCCCCC;
width:180px;
}
.btn{
background-color:#666666;
border:1px solid #CDCDCD;
height:30px;
width:70px;
}
.file{
position:absolute;
top:0;
right:80px;
height:30px;
filter:alpha(opacity:0);
opacity: 0;
width:260px
}
#box{
width:400px;
height:200px;
border:1px solid black;
border-radius:5px;
position:relative;
background-color: darkgray;top:-150px;/*改变此数值,改变显示位置*/
left:800px;/*改变此数值,改变显示位置*/
display:none;
}
#proBox{
width:300px;
height:15px;
border:1px solid black;
border-radius:10px;
position:absolute;
top:20px;
left:40px;
}
#proBox .progress{
width:0px;height:15px;
border-radius:10px;
position:absolute;
background:green;/*可以加载背景图片:格式:background:url(背景图片地址) x-repeat left center*/
top:-16px;
left:0px;
}
#proBox span{
position:absolute;
top:-0px;
left:305px;
font-size:14px "微软雅黑";
}
#text{
width:250px;
text-align: center;
min-height:20px;
line-height:20px;
position:absolute;
top:35px;
left:80px;
font-size:14px "仿宋";
}
</style>
</HEAD>
<BODY style="background:#666666" onload="GetConfig()">
<iframe name="server" style="display:none;" src=' '></iframe>
<form action="/cgi-bin/config.cgi" method="POST" target="server" ENCTYPE="multipart/form-data">
<input style="border-radius:5px;background: red;width:150px;height:60px;font-size:24px ;font-weight:bold;color:white" id="connectstatus" input type="submit" disabled="true" value="服务停止" >
<table id="table" cellpadding="5" width="60%" border="1px" align="center" border-radius="5px"><tr bgcolor="#E0F0F"></tr><br>
<tr><td align="center" width="20%" style="color: black;font-weight:bold;">硬件版本号:</td><td id = "HardVersion"></td></tr>
<tr><td align="center" width="20%" style="color: black;font-weight:bold;">软件版本号:</td><td id = "SoftVersion"></td></tr>
<tr><td align="center" width="20%" style="color: black;font-weight:bold;">MAC:</td><td id = "MAC"></td></tr>
<tr>
<td align="center" width="20%" style="color: black;font-weight:bold;">适配器ID:</td><td id = "AdapterID" style="font-weight:bold"></td>
</tr>
<tr><td align="center" width="20%" style="color: black;font-weight:bold;">IMEI:</td><td id = "IMEI"></td></tr>
<tr><td align="center" width="20%" style="color: black;font-weight:bold;">服务器IP:</td><td ><input name="ip" size="30" id = "Ip"></td></tr>
<tr><td align="center" width="20%" style="color: black;font-weight:bold;">端口号:</td><td><input name="port" size="30" id = "Port"></td></tr>
<tr><td align="center" width="20%" style="color: black;font-weight:bold;">通讯接口选择:</td><td>
<input type="checkbox" id=Porttypea232 name="portcheck" value="1" onclick="Display232(this)">RS232
<input type="checkbox" id=Porttypeb485 name="portcheck" value="2" onclick="Display485(this)">RS485</td></tr>
<tr><td align="center" width="20%" style="color: black;font-weight:bold;">波特率(RS232):</td><td>
<select name ="bau232" id="selbau232"></select></td></tr>
<tr><td align="center" width="20%" style="color: black;font-weight:bold;">波特率(RS485):</td><td>
<select name ="bau485" id="selbau485"></select></td></tr>
<tr><td align="center" width="20%" style="color: black;font-weight:bold;">通讯文件上载:</td><td align="left" width="20%"><div class="file-box">
<input type='text' name='textfield' id='textfield' class='txt' />
<input type='button' class='btn' value='浏览' />
<input type="file" name="sofile" class="file" id="fileField" size="28" onchange="document.getElementById('textfield').value=this.value" /> </div>
<tr><td align="center" width="20%" style="color: black;font-weight:bold;">通讯协议(RS232):</td><td>
<select name ="net232" id="setnet232" ></select></td></tr>
<tr><td align="center" width="20%" style="color: black;font-weight:bold;">通讯协议(RS485):</td><td>
</select><select name ="net485" id="setnet485"></select></td></tr>
<tr>
<td align="center" width="20%" style="color: black;font-weight:bold;">控制器类型:</td>
<td><select name="controllertype" id="controllertypeid">
<option value="1">火灾报警控制器</option>
<option value="10">可燃气体报警控制器</option>
<option value="11">电气火灾监控设备</option>
<option value="22">气体灭火控制器</option>
<option value="31">消防设备电源监控器</option>
<option value="34">防火门监控器</option>
</select></td>
</tr>
<tr><td align="center" width="20%" style="color: black;font-weight:bold;">控制器ID:</td><td><input name="controllerid" size="30" id = "controlleridid"></td></tr>
<tr><td align="center" width="20%" style="color: black;font-weight:bold;">升级文件上载:</td><td align="left" width="20%"><div class="file-box">
<input type='text' name='textfield1' id='textfield1' class='txt' />
<input type='button' class='btn' value='浏览' /> <input type="file" name="updatefile" class="file" id="fileField1" size="28" onchange="document.getElementById('textfield1').value=this.value" /> </div>
<tr><td align="center" width="20%" style="color: black;font-weight:bold;">MD5文件上载:</td><td align="left" width="20%"><div class="file-box"> <input type='text' name='textfield2' id='textfield2' class='txt' /> <input type='button' class='btn' value='浏览' />
<input type="file" name="MD5file" class="file" id="fileField2" size="28" onchange="document.getElementById('textfield2').value=this.value" /> </div>
<tr><td></td><td align="left">
<input class ="button" id="enter" input type="submit" name="Setting" onclick="ShowLoadNews()" value="确认">
</table>
</form>
<div id="box">
<div id = "proBox">
<p class = "progress"></p>
<span class="scale">0%</span>
</div>
<p id = "text"></p>
</div>
<td><input style="margin-right:10px; text-decoration:underline border-radius:5px;background: greenyellow;width:100px;height:30px;font-size:18px ; font-weight:bold;color:black" input type="button" onClick="location='./watersys.html'" value="水系统配置" >
</BODY>
<script type="text/javascript">
var IsSelect232Port=0; //判断是否选择232或者485选择框
var IsSelect485Port=0;
var Display232 = function(dom)
{
var div = dom.nextElementSibling;
if (dom.checked)
{
IsSelect232Port=1;
//document.getElementById("setnet232").style.display = "block";
//document.getElementById("selbau232").style.display = "block";
}
else
{
IsSelect232Port=0;
//document.getElementById("setnet232").style.display = "none";
//document.getElementById("selbau232").style.display = "none";
}
}
var Display485 = function(dom)
{
var div = dom.nextElementSibling;
if (dom.checked)
{
IsSelect485Port=1;
//document.getElementById("setnet485").style.display = "block";
//document.getElementById("selbau485").style.display = "block";
}
else
{
IsSelect485Port=0;
//document.getElementById("setnet485").style.display = "none";
//document.getElementById("selbau485").style.display = "none";
}
}
/***************************************************************************/
/**这部分是获取云平台通信是否正常*****/
/***************************************************************************/
/***************************************************************************/
function StatusProcess(returnValue)
{
var str0 = returnValue.split(/\n\/*/g);
if ( !Array.prototype.forEach ) //判定浏览器是否支持foreach函数,解决IE无法支持的问题
{
Array.prototype.forEach = function forEach( callback, thisArg )
{
var T, k;
if ( this == null )
{
throw new TypeError( "this is null or not defined" );
}
var O = Object(this);
var len = O.length >>> 0;
if ( typeof callback !== "function" )
{
throw new TypeError( callback + " is not a function" );
}
if ( arguments.length > 1 )
{
T = thisArg;
}
k = 0;
while( k < len )
{
var kValue;
if ( k in O )
{
kValue = O[ k ];
callback.call( T, kValue, k, O );
}
k++;
}
};
}
str0.forEach(function (eachData)
{
//以=切割字符串
var str1 = eachData.split("=");
console.log(str1[0]);
SysState=str1[0];
switch(str1[1])
{
case "Run":
document.getElementById("connectstatus").value="服务启动";
document.getElementById("connectstatus").style.background="green";
break;
case "Stop":
document.getElementById("connectstatus").value="服务停止";
document.getElementById("connectstatus").style.background="red";
break;
}
})
}
function StatusCallback()
{
if (xhr.readyState == 4)
{
if (xhr.status == 200)
{
var returnValue = xhr.responseText;
if(returnValue != null && returnValue.length > 0)
{
console.log(returnValue);
StatusProcess(returnValue);
}
else
{
console.log("结果为空!");
}
}
else
{
console.log("页面出现异常!");
}
}
}
function SendGetStatus()
{
//test.cgi后面跟个cur_time参数是为了防止Ajax页面缓存
xhr.open("GET", "cgi-bin/config.cgi?getstatus");
xhr.send(null);
setTimeout("SendGetStatus()", 5000);
}
function GetConnect()
{
var xhr;
xhr = createXHR();
if(xhr)
{
xhr.onreadystatechange=StatusCallback;
SendGetStatus();
}
else
{
//XMLHttpRequest对象创建失败
alert("浏览器不支持,请更换浏览器!");
}
}
/***************************************************************************/
/**这部分是获取配置文件信息显示*****/
/***************************************************************************/
/***************************************************************************/
/*
*创建异步访问对象
*/
function createXHR()
{
try
{
// Firefox, Opera 8.0+, Safari
xhr=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xhr=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xhr=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("您的浏览器不支持AJAX!");
return false;
}
}
}
return xhr;
}
/*
*异步访问提交处理
*/
function GetConfig()
{
var xhr;
//document.getElementById("setnet232").style.display = "none";
//document.getElementById("selbau232").style.display = "none";
//document.getElementById("setnet485").style.display = "none";
//document.getElementById("selbau485").style.display = "none";
xhr = createXHR();
if(xhr)
{
xhr.onreadystatechange=callbackFunction;
//test.cgi后面跟个cur_time参数是为了防止Ajax页面缓存
xhr.open("GET", "cgi-bin/config.cgi?getconf"+ new Date().getTime());
xhr.send(null);
}
else
{
//XMLHttpRequest对象创建失败
alert("浏览器不支持,请更换浏览器!");
}
}
function baudratepress(bauset , flag)
{
if(0==flag)
{
var selObj = document.getElementById("selbau232");
}
else
{
var selObj = document.getElementById("selbau485");
}
//var baulib=new Array("2400","4800","9600","14400","19200","38400","57600","115200","230400","460800","921600");
var baulib=new Array(2400,4800,9600,14400,19200,38400,57600,115200,230400,460800,921600);
var Option = document.createElement("OPTION");
Option.value = bauset;
Option.text = bauset;
selObj.options.add(Option);
for(var i=0 ; i<baulib.length ; i++)
{
if(bauset!=baulib[i])
{
var Option = document.createElement("OPTION");
Option.value=baulib[i];
Option.text=baulib[i];
selObj.options.add(Option);
}
}
}
var Systype;
//数据处理函数
function dataProcess(returnValue){
//以/\n切割字符串
var str0 = returnValue.split('/');
if ( !Array.prototype.forEach ) //判定浏览器是否支持foreach函数,解决IE无法支持的问题
{
Array.prototype.forEach = function forEach( callback, thisArg )
{
var T, k;
if ( this == null )
{
throw new TypeError( "this is null or not defined" );
}
var O = Object(this);
var len = O.length >>> 0;
if ( typeof callback !== "function" )
{
throw new TypeError( callback + " is not a function" );
}
if ( arguments.length > 1 )
{
T = thisArg;
}
k = 0;
while( k < len )
{
var kValue;
if ( k in O )
{
kValue = O[ k ];
callback.call( T, kValue, k, O );
}
k++;
}
};
}
str0.forEach(function (eachData){
//以=切割字符串
var str1 = eachData.split("=");
//console.log(str1[0]);
switch(str1[0]){
case "HardVersion":
document.getElementById("HardVersion").innerHTML = str1[1];
break;
case "SoftVersion":
document.getElementById("SoftVersion").innerHTML = str1[1];
break;
case "MAC":
document.getElementById("MAC").innerHTML = str1[1];
break;
case "CPUID":
var strmachine = "01_TX3251_";
strmachine += str1[1];
document.getElementById("AdapterID").innerHTML = strmachine;
break;
case "controllertype":
var value=Number(str1[1]);
var opts = document.getElementById("controllertypeid");
for(var i=0;i<opts.options.length;i++)
{
if(value==opts.options[i].value)
{
opts.options[i].selected = 'selected';
break;
}
}
break;
case "IMEI":
document.getElementById("IMEI").innerHTML = str1[1];
break;
case "Ip":
document.getElementById("Ip").value = str1[1];
break;
case "Port":
document.getElementById("Port").value = str1[1];
break;
case "controllerid":
document.getElementById("controlleridid").value = str1[1];
break;
case "Portselect":
var value=Number(str1[1]);
if(1==value)
{
IsSelect232Port=1;
//document.getElementById("setnet232").style.display = "block";
//document.getElementById("selbau232").style.display = "block";
document.getElementById("Porttypea232").checked=true;
document.getElementById("Porttypeb485").checked=false;
}
else if(2==value)
{
IsSelect485Port=1;
//document.getElementById("setnet485").style.display = "block";
//document.getElementById("selbau485").style.display = "block";
document.getElementById("Porttypea232").checked=false;
document.getElementById("Porttypeb485").checked=true;
}
else
{
IsSelect232Port=1;
IsSelect485Port=1;
//document.getElementById("setnet232").style.display = "block";
//document.getElementById("selbau232").style.display = "block";
document.getElementById("Porttypea232").checked=true;
//document.getElementById("setnet485").style.display = "block";
//document.getElementById("selbau485").style.display = "block";
document.getElementById("Porttypeb485").checked=true;
}
break;
case "bau232":
baudratepress(str1[1] , 0);//传进来232波特率的值
break;
case "bau485":
baudratepress(str1[1] , 1);//传进来的485波特率得值
break;
case "Lib232":
var selObj = document.getElementById("setnet232");
var Option = document.createElement("OPTION");
Option.value=str1[1];
Option.text=str1[1];
selObj.options.add(Option);
break;
case "Lib485":
var selObj = document.getElementById("setnet485");
var Option = document.createElement("OPTION");
Option.value=str1[1];
Option.text=str1[1];
selObj.options.add(Option);
break;
case "setnet232":
var selObj = document.getElementById("setnet232");
var Option = document.createElement("OPTION");
Option.value=str1[1];
Option.text=str1[1];
selObj.options.add(Option);
break;
case "setnet485":
var selObj = document.getElementById("setnet485");
var Option = document.createElement("OPTION");
Option.value=str1[1];
Option.text=str1[1];
selObj.options.add(Option);
break;
case "readend":
xhr.abort();
GetConnect();
break;
}
})
}
/*
*异步回调函数处理
*/
function callbackFunction()
{
if (xhr.readyState == 4)
{
if (xhr.status == 200)
{
var returnValue = xhr.responseText;
if(returnValue != null && returnValue.length > 0)
{
console.log(returnValue);
dataProcess(returnValue);
}
else
{
console.log("结果为空!");
}
}
else
{
console.log("页面出现异常!");
}
}
}
/********************************************************************************************************************************************************************/
/********************************************************************************************************************************************************************/
/**这部分读取升级进度*****/
/********************************************************************************************************************************************************************/
/********************************************************************************************************************************************************************/
//进度条
var SysState=0xff;
var num = 0;
var timer;
function progress(timeValue){
var flag=0;
//加载进度条
document.getElementById("box").style.display = "block";
document.getElementById("text").innerHTML = "系统正在升级,请保持电源连接稳定\n 正在下载.....";
//清理定时器
clearInterval(timer);
//开启进度条定时器
timer = setInterval(function (){
if(num<30)
{
document.getElementsByClassName("progress")[0].style.width = num*3 + "px";
document.getElementsByTagName("span")[0].innerHTML = num + "%";
num++;
}
else
{
switch(SysState)
{
case "0":
flag=1;
document.getElementById("text").innerHTML = "请保持电源连接稳定\n";
document.getElementsByClassName("progress")[0].style.width = 100*3 + "px";
document.getElementsByTagName("span")[0].innerHTML = 100 + "%";
setTimeout(function (){
if (hasfile!=2)
alert("系统配置成功");
else
alert("系统更新成功");
},1000);
break;
case "1":
flag=1;
document.getElementById("text").innerHTML = "请保持电源连接稳定\n 系统更新失败:MD5校验失败";
document.getElementsByClassName("progress")[0].style.width = 20*3 + "px";
document.getElementsByTagName("span")[0].innerHTML = 20 + "%";
alert("系统更新失败:MD5校验失败");
break;
case "2":
flag=1;
document.getElementById("text").innerHTML = "请保持电源连接稳定\n 系统更新失败:解压状态失败";
document.getElementsByClassName("progress")[0].style.width = 40*3 + "px";
document.getElementsByTagName("span")[0].innerHTML = 40 + "%";
alert("系统更新失败:解压状态失败");
break;
case "3":
flag=1;
document.getElementById("text").innerHTML = "请保持电源连接稳定\n 系统更新失败:安装失败";
document.getElementsByClassName("progress")[0].style.width = 60*3 + "px";
document.getElementsByTagName("span")[0].innerHTML = 60 + "%";
alert("系统更新失败:安装失败");
break;
case "4":
flag=1;
document.getElementById("text").innerHTML = "请保持电源连接稳定\n 系统更新失败:删除升级文件失败";
document.getElementsByClassName("progress")[0].style.width = 80*3 + "px";
document.getElementsByTagName("span")[0].innerHTML = 80 + "%";
alert("系统更新失败:删除升级文件失败");
break;
default:
if(hasfile!=2)
{
//document.getElementById("text").innerHTML = "请保持电源连接稳定\n";
//document.getElementsByClassName("progress")[0].style.width = 100*3 + "px";
//document.getElementsByTagName("span")[0].innerHTML = 100 + "%";
SysState="0";
}
else
{
SysState=0xff;
}
flag=0;
break;
}
//关闭定时器
if(flag==1)
{
setTimeout(function (){
document.getElementById("box").style.display = "none";
document.getElementById("enter").style.display = "block";
window.location.reload();
},1000);
clearInterval(timer);
}
return;
}
},timeValue)
//显示传输内容
}
/*
*异步访问提交处理
*/
var hasfile=0;
function ShowLoadNews()
{
if(0==IsSelect232Port&&0==IsSelect485Port)
{
alert("非法参数:未选择通讯端口");
return;
}
xhr.abort();
var ff = document.getElementsByTagName("input");
for(var i=0;i< ff.length; i++)
{
if(ff[i].type == "file")
{
if(ff[i].value!=""&&ff[i].name!="sofile")
{
hasfile++;//have some file to upload
}
}
}
if(hasfile!=2)
{
progress(100);
return;
}
else
{
progress(100);
}
}
</script>
</HTML>