forked from iinnovations/cupidweblib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrolpanel.html
executable file
·416 lines (382 loc) · 20.6 KB
/
controlpanel.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
<?php require_once('auth/user.php'); ?>
<!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-->
<script src="/js/jquery-1.11.0.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="/mobile/js/jqplot/plugins/jqplot.canvasTextRenderer.min.js"></script>
<script type="text/javascript" src="/mobile/js/jqplot/plugins/jqplot.canvasAxisLabelRenderer.min.js"></script>
<script type="text/javascript" src="/mobile/js/jqplot/plugins/jqplot.dateAxisRenderer.js"></script>
<script type="text/javascript" src="/mobile/js/jqplot/plugins/jqplot.cursor.min.js"></script>
<script src="/js/iijslib.js" type="text/javascript"></script>
<script src="/js/cupidjslib.js" type="text/javascript"></script>
<!--Record auth level-->
<script type="text/javascript">
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 Control Panel</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" -->
<?php $user->require_login(); ?>
<script type="text/javascript">
// Define our usr for access control of features:
// define some globals
var activeindex=1;
var jqmpage=false;
var updatetimeout=100
var loginterval=10000
var updateinterval=10000
var actauthlevel=2
var stdmessage='You do not have sufficient authorization for this action'
//------------------------------------------------------------------------//
// The execution of our basic functions to get data for the tables/charts
//------------------------------------------------------------------------//
// Load all possible values into selectors
//// Control Mode
function UpdateControlModes() {
UpdateSelect("controlmode", ["auto","manual"])
}
// Extend jQuery with some easing (copied from jQuery UI)
$.extend($.easing, {
easeOutElastic: function (x, t, b, c, d) {
var s=1.70158;var p=0;var a=c;
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
if (a < Math.abs(c)) { a=c; var s=p/4; }
else var s = p/(2*Math.PI) * Math.asin (c/a);
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
}
});
//-------------------------------------------------------//
// All of the button functions
//-------------------------------------------------------//
$(function(){
$('#channelssetpointvalueincdown').click(function(){
checkauth(sessiondata.authlevel, actauthlevel, function(){
alert(sessiondata.hpass);
console.log(sessiondata.hpass);
var selectedchannelname=document.getElementById("channelselect").value;
$.ajax({
url: "/wsgiactions",
type: "post",
datatype:"json",
data: {'action':'spchange','subaction':'incdown','database':controldatabase,'channelname':selectedchannelname},
success: function(){
setTimeout(function(){UpdateChannelsData({'indexselector':'channelselect'})},updatetimeout);
}
});
}, stdmessage);
});
$('#channelssetpointvalueincup').click(function(){
checkauth(sessiondata.authlevel, actauthlevel, function(){
var selectedchannelname=document.getElementById("channelselect").value;
$.ajax({
url: "/wsgiactions",
type: "post",
datatype:"json",
data: {'action':'spchange','subaction':'incup','database':controldatabase,'channelname':selectedchannelname},
success: function(){
setTimeout(function(){UpdateChannelsData({'indexselector':'channelselect'})},updatetimeout);
}
});
}, stdmessage);
});
$('#channelsactionincdown').click(function(){
checkauth(sessiondata.authlevel, actauthlevel, function(){
var selectedchannelname=document.getElementById("channelselect").value;
$.ajax({
url: "/wsgiactions",
type: "post",
datatype:"json",
data: {'action':'actiondown','database':controldatabase,'channelname':selectedchannelname},
success: function(){
setTimeout(function(){UpdateChannelsData({'indexselector':'channelselect'})},updatetimeout);
}
});
}, stdmessage);
});
$('#channelsactionincup').click(function(){
checkauth(sessiondata.authlevel, actauthlevel, function(){
var selectedchannelname=document.getElementById("channelselect").value;
$.ajax({
url: "/wsgiactions",
type: "post",
datatype:"json",
data: {'action':'actionup','database':controldatabase,'channelname':selectedchannelname},
success: function(){
setTimeout(UpdateChannelsData({'indexselector':'channelselect'}),updatetimeout);
}
});
}, stdmessage);
});
$('#channelscontrolmodetoggle').click(function(){
checkauth(sessiondata.authlevel, actauthlevel, function(){
var selectedchannelname=document.getElementById("channelselect").value;
$.ajax({
url: "/wsgiactions",
type: "post",
datatype:"json",
data: {'action':'togglemode','database':controldatabase,'channelname':selectedchannelname},
success: function(){
setTimeout(UpdateChannelsData({'indexselector':'channelselect'}),updatetimeout);
}
});
}, stdmessage);
});
$('#channelscontrolrecipeselectset').click(function(){
checkauth(sessiondata.authlevel, actauthlevel, function(){
var selectedchannelname=document.getElementById("channelselect").value;
var newrecipe=document.getElementById("controlrecipeselect").value;
$.ajax({
url: "/wsgiactions",
type: "post",
datatype:"json",
data: {'action':'setrecipe','database':controldatabase,'channelname':selectedchannelname,'recipe':newrecipe},
success: function(){
setTimeout(UpdateChannelsData({'indexselector':'channelselect'}),updatetimeout);
}
});
}, stdmessage);
});
})
$(document).ready(function(){
togglestolamps()
//button stuff
// run once to respond, but not interval running.
$('#channelselect').change(function(){
UpdateChannelsData();
GetAndRenderLogData({'channelnameid':'channelselect','renderplotids':['chart1'], serieslabels :['f','f','f'], seriesnames: ['controlvalue','setpointvalue','action'], 'renderplotoptions': [largeChannelOptionsObj]})
})
UpdateControlRecipeData({'timeout':updateinterval})
UpdateControlAlgorithmsData({timeout:updateinterval})
UpdateOutputsData({timeout:updateinterval})
UpdateInputsData({timeout:updateinterval})
UpdateSystemStatusData({'timeout':updateinterval})
// Just get one channel's worth of data. These are 1-indexed
// which matches up with rowID on table, and a selector with a 'none' first entry
// UpdateChannelsData({'timeout':updateinterval,'indexselector':'channelselect'})
GetAndRenderTableData({database:controldatabase, tablename:'channels','timeout':updateinterval, 'indexselector':'channelselect', selectorclass:'channelselect',setactions:false})
UpdateTimestamps({'timeout':updateinterval,'renderids':['lastpanelupdate']})
// Give the class with the channel name time to render.
setTimeout(function(){
GetAndRenderLogData({'channelnameid':'channelselect',serieslabels :['f','f','f'],'renderplotids':['chart1'],'timeout':updateinterval,'seriesnames':['controlvalue','setpointvalue','action'], 'renderplotoptions':[largeChannelOptionsObj]})
},1000)
});
</script>
<!-- InstanceEndEditable -->
</head>
<body>
<div id="main">
<!-- InstanceBeginEditable name="NavBar" -->
<div id="header" style="padding-left:0px"> <a href="http://www.interfaceinnovations.org/cupidcontrols.html" 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 class="active"><span><span>Panel</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><span><span><a href="settings.html">Settings</a></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;
?>
</p></div><!-- login -->
</div><!-- header -->
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="MainBody" -->
<div id="middle">
<div id="full-column">
<div class="top-bar">
<h1>Control Panel</h1>
<div class="breadcrumbs">Simple monitor and control station</div>
</div> <!-- End top bar -->
<table width="100%" >
<tr>
<td valign="top" align="left" width="50%">
<div><h2>Channel Data</h2></div>
<div class="table halftable">
<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 halflisting" cellpadding="0" cellspacing="0">
<tr>
<th class="first firstnoborder bighead">Channel</th>
<th class="noborder" colspan="2"><select class="channelselect" id="channelselect" name="channelselect" style="width:175px; font-size: 14px">
<option value="None" selected="selected">None</option></select></th>
<th colspan="2" width="10" class="last lastnoborder"> </th>
</tr>
<tr>
<td width="90" >Control Value</td>
<td width="75"><span class="channelscontrolvalue" id="channelscontrolvalue">value</span></td>
<td width="10">F</td>
<td width="120" style="text-align:left" colspan="2" height="30px"> </td>
</tr>
<tr>
<td>Setpoint Value</td>
<td><span class="channelssetpointvalue" id="channelssetpointvalue">value</span></td>
<td>F</td>
<td colspan="2" >
<button id="channelssetpointvalueincup" type="button" style="width:40px; font-size:16px;font-weight:bolder">+</button>
<button id="channelssetpointvalueincdown" type="button" style="width:40px; font-size:16px;font-weight:bolder">-</button></td>
</tr>
<tr>
<td>Action</td>
<td><span class="channelsaction" id="channelsaction">value</span></td>
<td>%</td>
<td colspan="2" >
<button id="channelactionsincup" style="width:40px; font-size:16px;font-weight:bolder" data-iconpos="none">+</button>
<button id="channelsactionincdown" style="width:40px; font-size:16px;font-weight:bolder">-</button></td>
</tr>
<tr>
<td>Control Mode</td>
<td colspan="2"><span class="channelsmode" id="channelscontrolmode">value</span></td>
<td colspan="2" ><button id="channelscontrolmodetoggle" style="width:85px" >Toggle</button></td>
</tr>
<tr>
<td>Control Algorithm</td>
<td colspan="2" style="text-align:left;"><select id="channelscontrolalgorithmselect" class="channelscontrolalgorithmselect controlalgorithmselect" style="width:125px"><option value="None">None</option></select></td>
<td colspan="2" > </td>
</tr>
<tr>
<td>Control Recipe</td>
<td colspan="2" style="text-align:left; "><select id="channelscontrolrecipeselect" class="channelscontrolrecipeselect controlrecipeselect" style="width:125px"><option value="None">None</option></select></td>
<td colspan="2" > </td>
</tr>
<tr>
<td width="90" >Recipe Stage</td>
<td width="75" colspan="2"><span class="channelsrecipestage" ic=class="channelsrecipestage">value</span></td>
<td> </td>
</tr>
<tr>
<td>Enabled</td>
<td colspan="2" ><input type="checkbox" class="regular-checkbox channelsenabledcheckbox" id="channelsenabledcheckbox"/><label for="channelsenabledcheckbox"></label></td>
<td colspan="2"> </td>
</tr>
<tr>
<td>Outputs Enabled</td>
<td colspan="2" ><input id="channelsoutputsenabledcheckbox" class="regular-checkbox channelsoutputsenabledcheckbox" type="checkbox"/><label for="channelsoutputsenabledcheckbox"></label></td>
<td colspan="2" > </td>
</tr>
<tr>
<td>Positive Output</td>
<td colspan="2" style="text-align:left"><select class="outputselect channelspositiveoutputselect" id="channelspositiveoutputselect" style="width:125px"><option value="None">None</option><option value="a value">A value</option></select></td>
<td colspan="2" > </td>
</tr>
<tr>
<td>Negative Output</td>
<td colspan="2" style="text-align:left"><select class="outputselect channelsnegativeoutputselect" id="channelsnegativeoutputselect" style="width:125px"><option value="None">None</option></select></td>
<td colspan="2"> </td>
</tr>
<tr>
<td>Control Input</td>
<td colspan="2" style="text-align:left"><select class="channelscontrolinputselect inputselect" id="channelscontrolinputselect" style="width:125px"><option value="None">None</option></select></td>
<td colspan="2" > </td>
</tr>
<tr>
<td>Status Message</td>
<td style="text-align:left" colspan="4"><span id="channelsstatusmessage" class="channelsstatusmessage">Value</span></td>
</tr>
<tr>
<td width="125" >Last Panel Update</td>
<td colspan="2" width="150" ><span id="lastpanelupdate" class="lastpanelupdate">value</span></td>
<td width="125" style="text-align:left" colspan="2"> </td>
</tr>
</table>
</div> <!-- half table -->
</td>
<td valign="top" align="left" width="50%">
<div><h2>System Status</h2></div>
<div class="table halftable">
<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 halflisting" cellpadding="0" cellspacing="0">
<tr>
<th class="first firstnoborder" width="10"> </th>
<th class="noborder bighead" colspan="2">Pi Control</th>
<th class= "last lastnoborder" width="10"> </th>
</tr>
<tr>
<td width="100" colspan="2">Pi Control Enabled</td>
<td width="125" colspan="2" ><input type="checkbox" class="regular-checkbox systemstatuspicontrolenabledcheckbox" id="systemstatuspicontrolenabledcheckbox"/><label for="systemstatuspicontrolenabledcheckbox"></label></td>
</tr>
<tr>
<td width="75" colspan="2">Control Status</td>
<td width="125" colspan="2" ><input type="checkbox" class="regular-checkbox systemstatuspicontrolstatuscheckbox" id="systemstatuspicontrolstatuscheckbox"/><label for="systemstatuspicontrolstatuscheckbox"></label></td>
</tr>
<tr>
<td width="75" colspan="2">Outputs Enabled</td>
<td width="125" colspan="2" ><input type="checkbox" class="regular-checkbox systemstatusenableoutputscheckbox" id="systemstatusenableoutputscheckbox"/><label for="systemstatusenableoutputscheckbox"></label></td>
</tr>
<tr>
<td width="75" colspan="2">Last Poll</td>
<td width="125" colspan="2" class="systemstatuslastpicontrolpoll" id="systemstatuslastpicontrolpoll"></td>
</tr>
<tr>
<td width="75" colspan="2">Poll Frequency (s)</td>
<td width="125" colspan="2" class="systemstatuspicontrolfreq" id="systemstatuspicontrolfreq"></td>
</tr>
</table>
</div>
<div class="table halftable">
<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 halflisting" cellpadding="0" cellspacing="0">
<tr>
<th class="first firstnoborder" width="10"> </th>
<th class="noborder bighead" colspan="2">Inputs Read</th>
<th class= "last lastnoborder" width="10"> </th>
</tr>
<tr>
<td width="75" colspan="2">Enabled</td>
<td width="125" colspan="2" ><input type="checkbox" class="regular-checkbox systemstatusupdateioenabledcheckbox" id="systemstatusupdateioenabledcheckbox"/><label for="systemstatusupdateioenabledcheckbox"></label></td>
</tr>
<tr>
<td width="75" colspan="2">Status</td>
<td width="125" colspan="2"><input type="checkbox" class="regular-checkbox systemstatusupdateiostatuscheckbox" id="systemstatusupdateiostatuscheckbox"/><label for="systemstatusupdateiostatuscheckbox"></label></td>
</tr>
<tr>
<td width="75" colspan="2">Last Poll</td>
<td width="125" colspan="2" class="systemstatuslastinputspoll" id="systemstatuslastinputspoll">Value</td>
</tr>
<tr>
<td width="75" colspan="2">Poll Frequency (s)</td>
<td width="125" colspan="2" class="systemstatusupdateiofreq" id="systemstatusupdateiofreq">Value</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<br />
<table>
<tr><td>
<div class="rounded-borders" style="width: 885px; height: 500px; padding:15px"><div id="chart1" style="height:100%; width:100%">Loading...</div></div>
</td></tr>
</table>
</div><!-- center colun -->
</div><!-- moddle -->
<!-- InstanceEndEditable -->
<div id="footer"></div>
</div>
</body>
<!-- InstanceEnd --></html>