-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemperatures.html
190 lines (154 loc) · 4.82 KB
/
temperatures.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
<html>
<head>
<title>Temperatures</title>
<script src="jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="jquery-ui-1.8.18.custom/js/jquery-ui-1.8.18.custom.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="jquery-ui-1.8.18.custom/css/ui-lightness/jquery-ui-1.8.18.custom.css" />
<style>
body{
font-family: 'sans serif' ,serif, 'Serif';
/* font-family: DroidSerifRegular, serif;*/
}
.ts_cells{
width:20px;
height:30px;
background:black;
/*border radius*/
border-radius: 3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
}
.t369_cells{
width:25px;
height:40px;
background:black;
/*border radius*/
border-radius: 3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
}
table{
margin:0px;
padding:0px;
border: 0px solid black;
border-spacing: 0px;
border-collapse: collapse;
}
</style>
</head>
<body>
<div style="padding:5px;">Temperatures map:</div>
<div id="temperatures_map"></div>
<script>
var master_ip = "161";
var n = 9;
init_temperatures_table();
function init_temperatures_table(){
var table_contents ="<table>\n<tr>\n";
var str = "";
//sensors
for(var i=(+master_ip);i<(+master_ip+n-1);i++) {
//reset str
str = "<td>\n\t<table>\n";
for (var j=1;j<4;j++) {
str += "<tr><td><div id='c"+i+"t_"+j+"' class='ts_cells'></div></td></tr>\n";
}
table_contents += str+"</table>\n</td>";
}
table_contents += "</tr>\n<tr><td colspan=8 align='center'><table>";
//369s
for(var i=+master_ip;i<(+master_ip+4);i++) {
str = "<tr>\n";
str += "\t<td><div id='c"+i+"t_0' class='t369_cells'></div></td>\n";
str += "\t<td><div id='c"+(i+4)+"t_0' class='t369_cells'></div></td>\n";
str += "<tr>\n";
table_contents += str;
}
table_contents += "</table>\n</td></tr><tr><td align='center' colspan='8'>\n";
table_contents += "<table>";
table_contents += "<tr>";
table_contents += "\t<td><div id='c"+(+master_ip+n-1)+"t_1' class='ts_cells'></div></td>\n";
table_contents += "\t<td><div id='c"+(+master_ip+n-1)+"t_0' class='t369_cells'></div></td>\n";
table_contents += "\t<td><div id='c"+(+master_ip+n-1)+"t_2' class='ts_cells'></div></td>\n";
table_contents += "</tr>";
table_contents += "</table>\n</td></tr></table>";
$("#temperatures_map").html(table_contents);
//finalize init
read_temperatures();
}
function read_temperatures(){
for(var i=(+master_ip);i<(+master_ip+n);i++) {
$("#c"+i+"t_0").css("background","black");
$("#c"+i+"t_1").css("background","black");
$("#c"+i+"t_2").css("background","black");
$("#c"+i+"t_3").css("background","black");
get_temperature(i,"TEMPERATURE01");
get_temperature(i,"TEMPERATURE23");
}
}
function get_temperature(ip,par){
var url = "eyesis4pi_control.php?get_parameter&master_ip="+ip+"&n=1&pname="+par;
$.ajax({
url: url,
success: function(data){
var tmp_line = +$(data).find('get_parameter').text();
t0_hex = (+$(data).find('get_parameter').text())&0xffff;
t1_hex = (+$(data).find('get_parameter').text())>>16;
var t0 = convertTemperature(t0_hex);
var t1 = convertTemperature(t1_hex);
var t0_color = TtoColor(t0,40,80);
var t1_color = TtoColor(t1,40,80);
if (par=="TEMPERATURE01") {
$("#c"+ip+"t_0").css("background",t0_color);
$("#c"+ip+"t_1").css("background",t1_color);
$("#c"+ip+"t_0").attr("title","camera "+ip+" - 10369: "+t0+"C");
if (ip==(+master_ip+9-1)) $("#c"+ip+"t_1").attr("title","camera "+ip+" - upper: "+t1+"C");
else $("#c"+ip+"t_1").attr("title","camera "+ip+" - top: "+t1+"C");
}
if (par=="TEMPERATURE23") {
$("#c"+ip+"t_2").css("background",t0_color);
$("#c"+ip+"t_3").css("background",t1_color);
if (ip==(+master_ip+9-1)) $("#c"+ip+"t_2").attr("title","camera "+ip+" - lower: "+t0+"C");
else $("#c"+ip+"t_2").attr("title","camera "+ip+" - middle: "+t0+"C");
$("#c"+ip+"t_3").attr("title","camera "+ip+" - bottom: "+t1+"C");
}
}
});
}
function convertTemperature(hex){
var t=0;
if (hex==-1){
}else{
t = (hex&0xfff)/16;
if ((hex&0xf000)!=0) t = -t;
}
return t;
}
function TtoColor(int,min,max){
var r=0,g=0,b=0;
var ratio = 0;
var full_scale = max-min;
if (int==0) return "rgba(220,220,220,1)";
if (int<(full_scale/2+min)) {
ratio = (full_scale/2+min-int)/(full_scale/2);
g = 255*(1-ratio);
b = 255*ratio;
}else{
ratio = (max-int)/(full_scale/2);
r = 255*(1-ratio);
g = 255*ratio;
}
r = Math.round(r);
g = Math.round(g);
b = Math.round(b);
if (r<0) r=0;
if (r>255) r=255;
if (g<0) g=0;
if (g>255) g=255;
if (b<0) b=0;
if (b>255) b=255;
return "rgba("+r+","+g+","+b+",1)";
}
</script>
</body>
</html>