induction_test.html
23.6 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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{ _('感应式料架系统') }}</title>
<link rel="icon" href="/static/favicon.ico">
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
<style>
.row {
margin-bottom: 10px;
}
</style>
</head>
<body style="font-size:18px;">
{% set index=2 %}
{% import 'head.html' as head with context%}
{{ head }}
<div class="container-fluid">
<div class="row">
<hr class="divider"/>
<hr class="divider"/>
<hr class="divider"/>
<div class="col-md-6">
<!--div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">{{ _('串口连接测试') }}</h3>
</div>
<div class="panel-body">
<div class="col-sm-12">
<input type="button" value={{ _('检查串口') }} class="btn btn-warning" style="margin: 2px;" onclick="checkcom()"/>
<input type="button" value={{ _('扫描串口') }} class="btn btn-info" style="margin: 2px;" onclick="scancom()"/>
<input type="button" value={{ _('重置主板') }} class="btn btn-danger" style="margin: 2px;" onclick="resetmain()"/>
<input type="button" value={{ _('打开供电') }} class="btn btn-danger" style="margin: 2px;" onclick="powermain()"/>
<input type="button" value={{ _('扫描库位') }} class="btn btn-info" style="margin: 2px;" onclick="scantest()"/>
<input type="button" value={{ _('停止扫描') }} class="btn btn-danger" style="margin: 2px;" onclick="stopscantest()"/>
</div>
<div style="clear: both;"></div>
</div>
</div-->
<!-- 灯条测试 -->
<div class="panel panel-warning">
<div class="panel-heading">
<h3 class="panel-title">{{ _('灯条测试') }}</h3>
</div>
<div class="panel-body">
<div class="row align-items-start">
<div class="col">
<label for="cha" class="col-sm-2">{{ _('地址') }}</label>
<div class="col-sm-4">
<select id='addrs' class="form-control">
<option>A1</option>
<option>A2</option>
<option>A3</option>
<option>A4</option>
<option>A5</option>
<option>A6</option>
<option>A7</option>
<option>A8</option>
<option>A9</option>
<option>B1</option>
<option>B2</option>
<option>B3</option>
<option>B4</option>
<option>B5</option>
<option>B6</option>
<option>B7</option>
<option>B8</option>
<option>B9</option>
<option>all</option>
</select>
</div>
</div>
<div class="col">
<label for="cha1" class="col-sm-2">{{ _('颜色') }}</label>
<div class="col-sm-4">
<select id='linecolor' class="form-control">
{% for color in colors %}
<option>{{ color }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
<div class="col-sm-6">
<input type="button" value={{ _('开启') }} class="btn btn-warning" onclick="indlineledon()"/>
<input type="button" value={{ _('关闭') }} class="btn btn-info" onclick="indlineledoff()"/>
</div>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">
<h3 class="panel-title">{{ _('库位操作测试') }}</h3>
</div>
<div class="panel-body">
<div class="row align-items-start">
<div class="col">
<label for="stock_cha1" class="col-sm-2">{{ _('库位') }}</label>
<div class="col-sm-4">
<select id="led_address" class="form-control">
{% for optionv in option_list %}
<option>{{ optionv }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="col">
<label for="cha2" class="col-sm-2">{{ _('颜色') }}</label>
<div class="col-sm-4">
<select id='indexcolor' class="form-control">
{% for color in colors %}
<option>{{ color }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
<div class="col-sm-12">
<input type="button" value={{ _('亮灯') }} class="btn btn-warning" onclick="indledopen()"/>
<input type="button" value={{ _('灭灯') }} class="btn btn-info" onclick="indledoff()"/>
<input type="button" value={{ _('重置') }} class="btn btn-info" onclick="indresetled()"/>
<input type="button" value={{ _('标定') }} class="btn btn-info" onclick="single_calibrate()"/>
</div>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">
<h3 class="panel-title">{{ _('状态灯测试') }}</h3>
</div>
<div class="panel-body">
<label for="cha4" class="col-sm-2">{{ _('选择') }}</label>
<div class="col-sm-3">
<select id='workchannel' class="form-control">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
</select>
</div>
<!-- <label for="cha6" class="col-sm-1">{{ _('颜色') }}</label>
<div class="col-sm-3">
<select id='workcolor' class="form-control">
<option>green</option>
<option>yellow</option>
<option>red</option>
</select>
</div> -->
<div class="col-sm-4">
<input type="button" value={{ _('亮灯') }} class="btn btn-warning" onclick="indworkinglight()"/>
<input type="button" value={{ _('灭灯') }} class="btn btn-info" onclick="indworkingoff()"/>
</div><!-- /.col-sm-4 -->
</div>
</div>
<!--div class="panel panel-success">
<div class="panel-heading">
<h3 class="panel-title">{{ _('下载库位二维码') }}</h3>
</div>
<div class="panel-body">
<form action="/downqrcode" method="GET">
<div class="col-sm-3">
<select name="code" class="form-control">
{% for optionv in option_list %}
<option>{{ optionv }}</option>
{% endfor %}
</select>
</div>
<div class="col-sm-3">
<input type="submit" class="btn btn-info" value={{ _('下载二维码') }}>
</div>
<label for="cha11" class="col-sm-4">{{ _('单个二维码尺寸(含白色底框)尺寸为16*16mm,黑码尺寸为10*10mm') }}</label>
</form>
</div>
</div-->
</div>
<div class="col-md-6">
<div id="panel-group">
<!-- 1 -->
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">{{ _('消息') }}</h3>
</div>
<div class="panel-body">
<div class="alert alert-info" role="alert">
<p>
{{ _('运行状态') }}:<span id="shelfstate"></span>
</p>
</div>
<div class="alert alert-info" role="alert">
<p>
{{ _('测试消息') }}:<span id="testinfo"></span>
</p>
</div>
<!-- <div class="alert alert-info" role="alert">
<p>
{{ _('配置文件加载状态') }}:<span>{{ config_state }}</span>
</p>
</div> -->
<div class="alert alert-info" role="alert">
<p>
{{ _('串口状态') }}:<span id="serialstate"></span>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function () {
getstate();
console.log('success');
});
// 获取开机关机状态
function getstate() {
// var form= new FormData(document.getElementById("test_form"));
$.ajax({
url: "/getstate",
type: "post",
// data:form,
dataType: 'json',
processData: false,
contentType: false,
success: function (data) {
console.log(data)
if (data[0].state == 'on') {
$("#shelfstate").html("{{_('运行中')}}");
} else if (data[0].state == 'off') {
$("#shelfstate").html("{{_('已关闭')}}");
} else {
$("#shelfstate").html("{{_('未初始化')}}");
}
// $("#shelfstate").html("<b>已关闭</b>")
// $("#testinfo").html(data[0].msg)
$("#serialstate").html(data[0].serial_state)
},
error: function (e) {
alert("未获取到状态信息");
}
})
}
// 灯条测试
function indlineledon() {
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == "{{_('运行中')}}") {
alert("{{_('料架运行中,请关闭后再进行配置')}}")
} else {
var addrs = document.getElementById("addrs").value;
addrs = addrs.replace('B', 'A1');
addrs = addrs.replace('A', '');
var data = {
"channel_num": addrs,
"channel_color": document.getElementById("linecolor").value
}
console.log(data)
$.ajax({
url: "/indlineledon",
type: "post",
data: JSON.stringify(data),
contentType: "application/json",
dataType: 'json',
success: function (data) {
$("#testinfo").html(data.msg)
// alert (data.msg)
},
error: function (e) {
alert("error");
}
})
}
}
function indlineledoff() {
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == "{{_('运行中')}}") {
alert("{{_('料架运行中,请关闭后再进行配置')}}")
} else {
var addrs = document.getElementById("addrs").value;
addrs = addrs.replace('B', 'A1');
addrs = addrs.replace('A', '');
var data = {
"channel_num": addrs,
"channel_color": 'off'
}
// var form= new FormData(document.getElementById("test_form"));
// var data = {"word":"hello"}
console.log(data)
$.ajax({
url: "/indlineledoff",
type: "post",
data: JSON.stringify(data),
dataType: 'json',
contentType: "application/json",
success: function (data) {
$("#testinfo").html(data.msg)
},
error: function (e) {
alert("error");
}
})
}
}
// 库位灯测试
function indledopen() {
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == "{{_('运行中')}}") {
alert("{{_('料架运行中,请关闭后再进行配置')}}")
} else {
var data = {
"light_led_color": document.getElementById("indexcolor").value,
"light_led": document.getElementById("led_address").value
}
$.ajax({
url: "/indledopen",
type: "post",
data: JSON.stringify(data),
contentType: "application/json",
dataType: 'json',
success: function (data) {
$("#testinfo").html(data.msg)
},
error: function (e) {
alert("error");
}
})
}
}
// 库位灯测试
function indledoff() {
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == "{{_('运行中')}}") {
alert("{{_('料架运行中,请关闭后再进行配置')}}")
} else {
var data = {
"light_led_color": "off",
"light_led": document.getElementById("led_address").value
}
// console.log(data)
$.ajax({
url: "/indledoff",
type: "post",
data: JSON.stringify(data),
contentType: "application/json",
dataType: 'json',
success: function (data) {
$("#testinfo").html(data.msg)
},
error: function (e) {
alert("error");
}
})
}
}
// 状态灯测试
function indworkinglight() {
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == "{{_('运行中')}}") {
alert("{{_('料架运行中,请关闭后再进行配置')}}")
} else {
var data = {
"workchannel": document.getElementById("workchannel").value,
"command": 'worklight'
}
$.ajax({
url: "/indworkinglight",
type: "post",
data: JSON.stringify(data),
contentType: "application/json",
dataType: 'json',
// processData: false,//用于对data参数进行序列化处理 这里必须false
// contentType: false, //必须
success: function (data) {
$("#testinfo").html(data.msg)
},
error: function (e) {
alert("error");
}
})
}
}
// auto_calibrate
function single_calibrate() {
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == "{{_('运行中')}}") {
alert("{{_('料架运行中,请关闭后再进行配置')}}");
return;
}
if (confirm("{{ _('操作前请确保该库位中没有物料') }}")) {
var data = {
"light_led_color": document.getElementById("indexcolor").value,
"light_led": document.getElementById("led_address").value
}
$.ajax({
url: "/single_calibrate",
type: "post",
data: JSON.stringify(data),
contentType: "application/json",
dataType: 'json',
success: function (data) {
// $("#testinfo").html(data.msg)
alert(data.msg);
},
error: function (e) {
alert("error");
}
})
}
}
function indworkingoff() {
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == "{{_('运行中')}}") {
alert("{{_('料架运行中,请关闭后再进行配置')}}")
} else {
var data = {
"workchannel": document.getElementById("workchannel").value,
"command": 'workoff'
}
$.ajax({
url: "/indworkingoff",
type: "post",
data: JSON.stringify(data),
contentType: "application/json",
dataType: 'json',
// processData: false,//用于对data参数进行序列化处理 这里必须false
// contentType: false, //必须
success: function (data) {
$("#testinfo").html(data.msg)
},
error: function (e) {
alert("error");
}
})
}
}
// 库位灯重置
function indresetled() {
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == "{{_('运行中')}}") {
alert("{{_('料架运行中,请关闭后再进行配置')}}")
} else {
$.ajax({
url: "/indresetled",
type: "post",
// data:JSON.stringify(data),
contentType: "application/json",
dataType: 'json',
success: function (data) {
$("#testinfo").html(data.msg)
},
error: function (e) {
alert("error");
}
})
}
}
// 检查串口连接状态
function checkcom() {
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == "{{_('运行中')}}") {
alert("{{_('料架运行中,请关闭后再进行配置')}}")
} else {
$.ajax({
url: "/checkcom",
type: "post",
// data:JSON.stringify(data),
contentType: "application/json",
dataType: 'json',
success: function (data) {
$("#testinfo").html(data.msg)
alert(data.msg)
},
error: function (e) {
alert("error");
}
})
}
}
// 扫描所有串口
function scancom() {
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == "{{_('运行中')}}") {
alert("{{_('料架运行中,请关闭后再进行配置')}}")
} else {
$.ajax({
url: "/scancom",
type: "post",
// data:JSON.stringify(data),
contentType: "application/json",
dataType: 'json',
success: function (data) {
$("#testinfo").html(data.msg)
$("#serialstate").html(data.msg)
alert(data.msg)
},
error: function (e) {
alert("error");
}
})
}
}
// 重置主板
function resetmain() {
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == "{{_('运行中')}}") {
alert("{{_('料架运行中,请关闭后再进行配置')}}")
} else {
var data = {
"command": "reset"
}
$.ajax({
url: "/resetmain",
type: "post",
data: JSON.stringify(data),
contentType: "application/json",
dataType: 'json',
success: function (data) {
$("#testinfo").html(data.msg)
alert(data.msg)
},
error: function (e) {
alert("重置失败");
}
})
}
}
// 重置power
function powermain() {
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == "{{_('运行中')}}") {
alert("{{_('料架运行中,请关闭后再进行配置')}}")
} else {
var data = {
"command": "power"
}
$.ajax({
url: "/powermain",
type: "post",
data: JSON.stringify(data),
contentType: "application/json",
dataType: 'json',
success: function (data) {
$("#testinfo").html(data.msg)
alert(data.msg)
},
error: function (e) {
alert("power重置失败");
}
})
}
}
// 开启扫描自动测试
function scantest() {
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == "{{_('运行中')}}") {
alert("{{_('料架运行中,请关闭后再进行配置')}}")
} else {
$.ajax({
url: "/scantest",
type: "post",
// data:JSON.stringify(data),
contentType: "application/json",
dataType: 'json',
success: function (data) {
$("#testinfo").html(data.msg)
alert(data.msg)
},
error: function (e) {
alert("启动扫描库位失败");
}
})
}
}
// 关闭扫描自动测试
function stopscantest() {
$.ajax({
url: "/stopscantest",
type: "post",
// data:JSON.stringify(data),
contentType: "application/json",
dataType: 'json',
success: function (data) {
$("#testinfo").html(data.msg)
alert(data.msg)
},
error: function (e) {
alert("停止失败");
}
})
}
</script>
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</body>
</html>