forked from iinnovations/cupidweblib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.html
executable file
·488 lines (461 loc) · 21.3 KB
/
settings.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
<?php require_once('/var/www/auth/user.php'); ?>
<?php $user->require_login(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><!-- InstanceBegin template="/Templates/main.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- Get me some jquery-->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CuPID Settings</title>
<link rel="stylesheet" href="/mobile/css/CuPID.css" />
<script src="/js/jquery-1.11.0.min.js"></script>
<script src="/js/jquery-migrate-1.2.1.min.js"></script>
<script language="javascript" type="text/javascript" src="js/jqplot/jquery.jqplot.min.js"></script>
<link rel="stylesheet" type="text/css" href="js/jqplot/jquery.jqplot.css" />
<script type="text/javascript" src="js/jqplot/plugins/jqplot.canvasTextRenderer.min.js"></script>
<script type="text/javascript" src="js/jqplot/plugins/jqplot.canvasAxisLabelRenderer.min.js"></script>
<script src="/js/iijslib.js" type="text/javascript"></script>
<script src="/js/cupidjslib.js" type="text/javascript"></script>
<script type="text/javascript">
<!--Record auth level-->
var sessiondata = {}
sessiondata.username = "<?php if (!empty($_SESSION['user']['name'])) { echo $_SESSION['user']['name'];} ?>";
sessiondata.sessionid = "<?php if (!empty($_SESSION['user']['sessionid'])) {echo $_SESSION['user']['sessionid'];} ?>";
sessiondata.appip = "<?php if (!empty($_SESSION['user']['appip'])) {echo $_SESSION['user']['appip'];} ?>";
sessiondata.realip = "<?php if (!empty($_SESSION['user']['realip'])) {echo $_SESSION['user']['realip'];} ?>";
sessiondata.hpass = "<?php if (!empty($_SESSION['user']['realip'])) {echo $_SESSION['user']['hpass'];} ?>";
sessiondata.authlevel = "<?php if (!empty($_SESSION['user']['authlevel'])) {echo $_SESSION['user']['authlevel'];} ?>";
// <!--Log access-->
logUserAuths(sessiondata)
</script>
<!-- InstanceBeginEditable name="doctitle" -->
<title>CuPID Settings</title>
<!-- InstanceEndEditable -->
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<style media="all" type="text/css">
@import "css/all.css";
</style>
<!-- InstanceBeginEditable name="head" -->
</script>
<style type="text/css">
input[type="text"]{width:65px;}
</style>
<!-- Here we define some dynamic table functions -->
<SCRIPT language="javascript">
var editmode="off"
var updateinterval=15000
// These are variables that are shared between the various settings
var actauthlevel=2
var stdmessage='You do not have sufficient authorization for this action'
//function xxSetStatusData(){
// queryarray=[]
// //alert(booleansToIntegerString($('.picontrolenabled').prop('checked')))
// queryarray.push('update systemstatus set picontrolenabled=\'' + booleansToIntegerString(document.getElementsByClassName("picontrolenabled").item(0).checked) + '\'')
// queryarray.push('update systemstatus set picontrolfreq=\'' + document.getElementsByClassName("picontrolfreq").item(0).value + '\'')
// queryarray.push('update systemstatus set inputsreadenabled=\'' + booleansToIntegerString(document.getElementsByClassName("inputsreadenabled").item(0).checked) + '\'')
// queryarray.push('update systemstatus set inputsreadfreq=\'' + document.getElementsByClassName("inputsreadfreq").item(0).value+ '\'')
// queryarray.push('update systemstatus set enableoutputs=\'' + booleansToIntegerString(document.getElementsByClassName("enableoutputs").item(0).checked) + '\'')
// //alert(query)
// wsgiExecuteQueryArray (controldatabase,queryarray)
//}
function SetChannelsData(){
queryarray=[]
for (i=0;i<document.getElementById('channelstable').rows.length-1;i++) {
index = String(i + 1)
queryarray.push('update channels set name=\'' + $('.channelsname' + index).val() + '\' where channelindex=' + $('.channelschannelindex' + index).html())
queryarray.push('update channels set controlinput=\'' + $('.channelscontrolinput' + index).val() + '\' where channelindex=' + $('.channelschannelindex' + index).html())
queryarray.push('update channels set enabled=\'' + booleansToIntegerString($('.channelsenabled' + index + 'checkbox').prop('checked')) + '\' where channelindex=' + $('.channelschannelindex' + index).html())
queryarray.push('update channels set outputsenabled=\'' + booleansToIntegerString($('.channelsoutputsenabled' + index + 'checkbox').prop('checked')) + '\' where channelindex=' + $('.channelschannelindex' + index).html())
queryarray.push('update channels set controlalgorithm=\'' + $('.channelscontrolalgorithm' + index + 'select').val() + '\' where channelindex=' + $('.channelschannelindex' + index).html())
queryarray.push('update channels set positiveoutput=\'' + $('.channelspositiveoutput' + index + 'select').val() + '\' where channelindex=' + $('.channelschannelindex' + index).html())
queryarray.push('update channels set negativeoutput=\'' + $('.channelsnegativeoutput' + index + 'select').val() + '\' where channelindex=' + $('.channelschannelindex' + index).html())
console.log(queryarray)
}
wsgiExecuteQueryArray (controldatabase,queryarray)
}
//function xxSetOutputsData(){
// queryarray=[]
// for (i=0;i<document.getElementById('outputstable').rows.length-1;i++) {
// queryarray.push('update outputs set name=\'' + $(".outputname")[i].value + '\' where outputindex=' + $(".outputindex")[i].innerHTML)
// queryarray.push('update outputs set minontime=\'' + $(".minontime")[i].value + '\' where outputindex=' + $(".outputindex")[i].innerHTML)
// queryarray.push('update outputs set minofftime=\'' + $(".minofftime")[i].value + '\' where outputindex=' + $(".outputindex")[i].innerHTML)
//
// queryarray.push('update outputs set enabled=\'' + booleansToIntegerString($(".outputenabled")[i].checked) + '\' where outputindex=' + $(".outputindex")[i].innerHTML)
//
// queryarray.push('update outputs set mode=\'' + $(".mode")[i].firstChild.value + '\' where outputindex=' + $(".outputindex")[i].innerHTML)
// //alert(queryarray)
// }
// wsgiExecuteQueryArray (controldatabase,queryarray)
//}
//function xxSetAlgorithmsData(){
// queryarray=[]
// for (i=0;i<document.getElementById('algorithmstable').rows.length-1;i++) {
// queryarray.push('update controlalgorithms set name=\'' + document.getElementsByClassName("algorithmname").item(i).value + '\'')
// queryarray.push('update controlalgorithms set type=\'' + document.getElementsByClassName("type").item(i).firstChild.value + '\'')
// queryarray.push('update controlalgorithms set proportional=\'' + document.getElementsByClassName("proportional").item(i).value + '\'')
// queryarray.push('update controlalgorithms set integral=\'' + document.getElementsByClassName("integral").item(i).value + '\'')
// queryarray.push('update controlalgorithms set derivative=\'' + document.getElementsByClassName("derivative").item(i).value + '\'')
// queryarray.push('update controlalgorithms set deadbandhigh=\'' + document.getElementsByClassName("deadbandhigh").item(i).value + '\'')
// queryarray.push('update controlalgorithms set deadbandlow=\'' + document.getElementsByClassName("deadbandlow").item(i).value + '\'')
// queryarray.push('update controlalgorithms set dutypercent=\'' + document.getElementsByClassName("dutypercent").item(i).value + '\'')
// queryarray.push('update controlalgorithms set dutyperiod=\'' + document.getElementsByClassName("dutyperiod").item(i).value + '\'')
//
// //alert(queryarray)
// }
// wsgiExecuteQueryArray (controldatabase,queryarray)
//}
//
//function xxRemoveChannel(){
// // get the channel we want to delete
// queryarray=['']
// $('.channelchecked').each(function(index,element){
// if (element.checked==true) {
// chindex = $('.channelindex').eq(index).html()
// //queryarray.push('delete from channels where \'index\'='+chindex)
// queryarray.push('delete from channels where \"channelindex\"='+chindex)
// }
// })
// alert(queryarray)
// //query="delete from channels where name=\'" + nametodelete + "\'")
// wsgiExecuteQueryArray (controldatabase,queryarray)
//}
$(document).ready(function() {
// button responses
// Refresh data
$('#statusrefreshbutton').click(function(){
//alert('I am going to update now');
UpdateSystemStatusData()
});
$('#channelsrefreshbutton').click(function(){
//alert('I am going to update now');
UpdateChannelsTable({editable:true})
});
$('#outputsrefreshbutton').click(function(){
//alert('I am going to update now');
UpdateOutputsTable()
});
$('#inputsrefreshbutton').click(function(){
//alert('I am going to update now');
UpdateInputsTable()
});
$('#algorithmsrefreshbutton').click(function(){
//alert('I am going to update now');
UpdateControlAlgorithmsTable({tablerowstart:2, editable:true});
});
// Set new data
$('#statussetdatabutton').click(function(){
checkauth(sessiondata.authlevel, actauthlevel, function(){
//alert('I am going to update now');
SetStatusData()
setTimeout(function(){GetAndRenderStatusTable()},1000)
}, stdmessage);
});
$('#channelssetdatabutton').click(function(){
checkauth(sessiondata.authlevel, actauthlevel, function(){
//alert('I am going to update now');
SetChannelsData()
setTimeout(function(){UpdateChannelsTable({editable:true})},1000)
}, stdmessage);
});
$('#outputssetdatabutton').click(function(){
checkauth(sessiondata.authlevel, actauthlevel, function(){
//alert('I am going to update now');
SetOutputsData()
setTimeout(function(){GetAndRenderOutputsTable()},1000)
}, stdmessage);
});
$('#algorithmssetdatabutton').click(function(){
checkauth(sessiondata.authlevel, actauthlevel, function(){
//alert('I am going to update now');
SetalgorithmsData()
setTimeout(function(){GetAndRenderAlgorithmsTable()},1000)
}, stdmessage);
});
$('#addchannelbutton').click(function(){
checkauth(sessiondata.authlevel, actauthlevel, function(){
//alert('I am going to update now');
addChannel()
setTimeout(function(){GetAndRenderChannelsTable()},1000)
}, stdmessage);
});
$('#removechannelbutton').click(function(){
checkauth(sessiondata.authlevel, actauthlevel, function(){
//alert('I am going to update now');
RemoveChannel()
setTimeout(function(){GetAndRenderChannelsTable()},1000)
}, stdmessage);
});
UpdateSystemStatusData();
UpdateChannelsTable({editable:true});
UpdateControlAlgorithmsTable({tablerowstart:2, editable:true});
// Run these periodically. Delay slightly
setTimeout(function(){
UpdateOutputsTable();
UpdateInputsTable();
UpdateControlRecipeData();
setTimeout(function(){UpdateChannelsTable({editable:true})},1000);
// UpdateChannelsData();
// UpdateControlAlgorithmsData();
// UpdateControlAlgorithmsData()
// UpdateInputsData()
// UpdateOutputsData()
// UpdateControlRecipeData()
// UpdateControlAlgorithmTypesData()
},2000)
});
</script>
<!-- InstanceEndEditable -->
</head>
<body>
<div id="main">
<!-- InstanceBeginEditable name="NavBar" -->
<div id="header"> <a href="http://www.interfaceinnovations.org" class="logo"><img src="/images/cmstemplate/logo.png"alt="" /></a>
<ul id="top-navigation">
<li><span><span><a href="index.html">Home</a></span></span></li>
<li><span><span><a href="controlpanel.html">Panel</a></span></span></li>
<li><span><span><a href="smallpanel.html">SmPanel</a></span></span></li>
<li><span><span><a href="inputs.html">Inputs</a></span></span></li>
<li><span><span><a href="datalogs.html">Datalogs</a></span></span></li>
<li class="active"><span><span>Settings</span></span></li>
<li><span><span><a href="admin.html">Admin</a></span></span></li>
<li><span><span><a href="help.html">Help</a></span></span></li>
</ul>
<div id="login"><?php
if($user->logged_in()):
?>
<p>You are logged in as <?php echo $_SESSION['user']['name']; ?>. <a href="auth/logout">Log out</a></p>
<?php
endif;
if(!$user->logged_in()):
?>
<p>You are not logged in. <a href="auth/login">Log in</a>
<?php
endif;
?>
</div><!-- login -->
</div>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="MainBody" -->
<div id="middle">
<div id="full-column">
<div class="top-bar">
<h1>Settings</h1>
<div class="breadcrumbs">All your device settings are belong to us.</div>
</div> <!-- End top bar -->
<br />
<div class="fullcontent">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>
<h2>System Settings</h2>
</td>
<td align="right">
<button id="statusrefreshbutton"><b>Reload Status Data</b></button>
<button id="statussetdatabutton">Set New Status Data</button>
</td>
</tr>
</table>
</div> <!-- fullcontent -->
<div class="table fulltable" ><img src="images/cmstemplate/bg-th-left.gif" width="8" height="7" alt="" class="left" /> <img src="images/cmstemplate/bg-th-right.gif" width="7" height="7" alt="" class="right" />
<table class="listing fulllisting" cellpadding="0" cellspacing="0" id="systemstatustable">
<tr>
<th class="first" colspan="4">Pi Control</th>
<th colspan="4">Inputs Read</th>
<th> </th>
<th class="last"> </th>
</tr>
<tr>
<th>Enabled</th>
<th>Status</th>
<th>Poll Freq</th>
<th>Last Poll</th>
<th>Enabled</th>
<th>Status</th>
<th>Freq (s)</th>
<th>Last Poll</th>
<th>Outputs Enabled</th>
<th>System Message</th>
</tr>
<tr>
<td><input id="systemstatuspicontrolenabledcheckbox" class="regular-checkbox systemstatuspicontrolenabledcheckbox" type="checkbox"/><label for="systemstatuspicontrolenabledcheckbox"></label></td>
<td><input class="regular-checkbox systemstatuspicontrolstatuscheckbox" type="checkbox"/><label for="systempicontrolstatuscheckbox"></label></td>
<td class="systemstatuspicontrolfreq" id="systemstatuspicontrolfreq" >value</td>
<td class="systemstatuslastpicontrolpoll">value</td>
<td><input id="systemstatusupdateioenabledcheckbox" class="regular-checkbox systemstatusupdateioenabledcheckbox" type="checkbox"/><label for="systemstatusupdateioenabledcheckbox"></label></td>
<td><input class="regular-checkbox systemstatusupdateiostatuscheckbox" type="checkbox"/><label for="systemstatusupdateiostatuscheckbox"></label></td>
<td class="systemstatusupdateiofreq" id="fffreq" >value</td>
<td class="systemstatuslastinputspoll">value</td>
<td><input id="systemstatusoutputsenabledcheckbox" class="regular-checkbox systemstatusoutputsenabledcheckbox" type="checkbox"/><label for="systemstatusoutputsenabled"></label></td>
<td class="systemstatussystemmessage">value</td>
</tr>
</table>
</div> <!-- full table -->
<div class="fullcontent">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>
<h2>Channels</h2>
</td>
<td>
<button id="addchannelbutton" >Add Channel</button>
<button id="removechannelbutton" >Remove Channel</button>
</td>
<td align="right">
<button id="channelsrefreshbutton" >Reload Channels Data</button>
<button id="channelssetdatabutton" >Set New Channels Data</button>
</td>
</tr>
</table>
</div>
<div class="table fulltable"> <img src="images/cmstemplate/bg-th-left.gif" width="8" height="7" alt="" class="left" /> <img src="images/cmstemplate/bg-th-right.gif" width="7" height="7" alt="" class="right" />
<table class="listing fulllisting" cellpadding="0" cellspacing="0" id="channelstable">
<tr>
<th class="first"> </th>
<th>Name</th>
<th>Control Input</th>
<th>Enabled</th>
<th>Output Enabled</th>
<th>Control Algorithm</th>
<th>Control Recipe</th>
<th>Control Value</th>
<th>Setpoint Value</th>
<th>Pos. Output</th>
<th class="last">Neg. Output.</th>
</tr>
<tr>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
</tr>
</table>
</div> <!-- full table -->
<div class="fullcontent">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>
<h2>Inputs</h2>
</td>
<td align="right">
<button id="inputsrefreshbutton">Reload Inputs Data</button>
<button id="inputssetdatabutton">Set New Inputs Data</button>
</td>
</tr>
</table>
</div>
<div class="table fulltable"> <img src="images/cmstemplate/bg-th-left.gif" width="8" height="7" alt="" class="left" /> <img src="images/cmstemplate/bg-th-right.gif" width="7" height="7" alt="" class="right" />
<table class="listing fulllisting" cellpadding="0" cellspacing="0" id="inputstable">
<tr>
<th class="first">Name</th>
<th>ID</th>
<th>Interface</th>
<th>Type</th>
<th>Address</th>
<th>Value</th>
<th class="last">Polltime</th>
</tr>
<tr>
<td>value </td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
</tr>
</table>
</div> <!-- full table -->
<div class="fullcontent">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>
<h2>Outputs</h2>
</td>
<td align="right">
<button id="outputsrefreshbutton">Reload Outputs Data</button>
<button id="outputssetdatabutton">Set New Outputs Data</button>
</td>
</tr>
</table>
</div>
<div class="table fulltable"> <img src="images/cmstemplate/bg-th-left.gif" width="8" height="7" alt="" class="left" /> <img src="images/cmstemplate/bg-th-right.gif" width="7" height="7" alt="" class="right" />
<table class="listing fulllisting" cellpadding="0" cellspacing="0" id="outputstable">
<tr>
<th class="first">Name</th>
<th>ID</th>
<th>Interface</th>
<th>Type</th>
<th>Address</th>
<th>Value</th>
<th class="last">Polltime</th>
</tr>
<tr>
<td>value </td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
</tr>
</table>
</div> <!-- full table -->
<div class="fullcontent">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>
<h2>Control algorithms</h2>
</td>
<td align="right">
<button id="algorithmsrefreshbutton" >Reload algorithms Data</button>
<button id="algorithmssetdatabutton" >Set New algorithms Data</button>
</td>
</tr>
</table>
</div>
<div class="table fulltable"> <img src="images/cmstemplate/bg-th-left.gif" width="8" height="7" alt="" class="left" /> <img src="images/cmstemplate/bg-th-right.gif" width="7" height="7" alt="" class="right" />
<table class="listing fulllisting" cellpadding="0" cellspacing="0" id="controlalgorithmstable">
<tr>
<th class="first" colspan="5"> </th>
<th colspan="2">Deadband</th>
<th>Duty %</th>
<th class="last">Duty</th>
</tr>
<tr>
<th>Name</th>
<th>Type</th>
<th width="20px">P</th>
<th width="20px">I</th>
<th width="20px">D</th>
<th>High</th>
<th>Low</th>
<th>Duty Percent</th>
<th>Duty Period</th>
</tr>
<tr>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
<td>value</td>
</tr>
</table>
</div> <!-- full table -->
</div>
</div>
<!-- InstanceEndEditable -->
<div id="footer"></div>
</div>
</body>
<!-- InstanceEnd --></html>