induction_control.html
7.8 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{ _('感应式料架系统') }}</title>
<!-- <link rel="icon" href="/static/favicon.ico"> -->
<!-- <link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}"> -->
<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>
</head>
<body style="font-size:18px;">
{% set index=1 %}
{% import 'head.html' as head with context%}
{{ head }}
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<h2>{{ _('料架系统') }}</h2>
<hr class="divider">
<!-- 料架启动关闭 -->
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">{{ _('开关') }}</h3>
</div>
<div class="panel-body">
<input type="button" value={{ _('启动') }} class="btn btn-info" onclick="startpost()"/>
<input type="button" value={{ _('停止') }} class="btn btn-warning" onclick="stoppost()"/>
</div>
</div>
<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">{{ config_state }}</span>
</p>
</div> -->
<div class="alert alert-info" role="alert">
<p>
{{ _('服务器地址') }}:<span id="ipconfig"></span>
</p>
</div>
<div class="alert alert-info" role="alert">
<p>
{{ _('料架序列号') }}:<span id="ccid"></span>
</p>
</div>
<!-- <div class="alert alert-info" role="alert">
<p>
{{ _('服务器连接状态') }}:<span id="poststate"></span>
</p>
</div> -->
<div class="alert alert-info" role="alert">
<p>
{{ _('串口状态') }}:<span id="serialstate"></span>
</p>
</div>
<div class="alert alert-info" role="alert">
<p>
{{ _('服务器连接状态') }}:<span id="serverstate"></span>
</p>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<h2>{{ _('运行日志&状态信息') }}</h2>
<hr class="divider">
<!-- 日志下载 -->
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">{{ _('日志下载') }}</h3>
</div>
<div class="panel-body">
<a type="button" class="btn btn-warning" href="{{ url_for('download') }}">{{ _('下载日志') }}</a>
</div>
</div>
<!-- 日志显示 -->
<!-- <div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">{{ _('日志') }}</h3>
</div>
<div class="panel-body">
<div id="logmsg" style="overflow:auto;height: 400px;background:#000; color:green"></div>
</div>
</div> -->
</div>
</div>
</div>
<script>
$(document).ready(function () {
getstate();
getauto();
console.log('success');
});
function startpost(){
$.ajax({
url:"/startpost",
type:"post",
// data:form,
dataType: 'json',
processData:false,
contentType:false,
success:function(data){
if (data[0].state == 'on') {$("#shelfstate").html("{{_('运行中')}}");}
else if (data[0].state == 'off') {$("#shelfstate").html("{{_('已关闭')}}");}
else {$("#shelfstate").html("{{_('未初始化')}}");}
// console.log(data)
alert (data[0].msg)
},
error:function(e){
alert("{{_('启动失败')}}");
}
})
}
function stoppost(){
// var form= new FormData(document.getElementById("test_form"));
var shelfstate = document.getElementById("shelfstate").value
console.log(shelfstate)
$.ajax({
url:"/stoppost",
type:"post",
// data:form,
dataType: 'json',
processData:false,
contentType:false,
success:function(data){
if (data[0].state == 'on') {$("#shelfstate").html("{{_('运行中')}}");}
else if (data[0].state == 'off') {$("#shelfstate").html("{{_('已关闭')}}");}
else {$("#shelfstate").html("{{_('未初始化')}}");}
console.log(data)
alert (data[0].msg)
},
error:function(e){
alert("{{_('停止失败')}}");
}
})
}
// 获取开机关机状态
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("{{_('未初始化')}}");}
// $("#gpioconfig").html(data[0].gpio)
$("#ipconfig").html(data[0].ipconfig['ip'])
$("#ccid").html(data[0].ipconfig['cid'])
$("#serialstate").html(data[0].serial_state)
},
error:function(e){
alert("{{_('未获取到状态信息')}}");
}
})
}
// 获取开机关机状态
function taillog(){
// var form= new FormData(document.getElementById("test_form"));
$.ajax({
url:"/taillog",
type:"post",
// data:form,
dataType: 'json',
processData:false,
contentType:false,
success:function(data){
$("#logmsg").html(data.msg)
// $("#poststate").html(data.poststate)
},
error:function(e){
}
})
}
// 获取服务器连接状态状态
function getauto(){
// var form= new FormData(document.getElementById("test_form"));
$.ajax({
url:"/getauto",
type:"post",
// data:form,
dataType: 'json',
processData:false,
contentType:false,
success:function(data){
$("#serverstate").html(data.msg)
console.log(data)
},
error:function(e){
//alert("{{_('未获取到状态信息')}}");
}
})
}
setInterval(function(){
// taillog();
getauto();
}, 3000);
</script>
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</body>
</html>