forked from TejasSathawane/Smart_Water_Tank_rpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
185 lines (132 loc) · 5.43 KB
/
index.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
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>MOTOR Control</title>
</head>
<body>
MOTOR Control:
<form method="get" action="index.php">
<input type="submit" value="ON" name="on">
<input type="submit" value="OFF" name="off">
</form>
<?php
$setmode17 = shell_exec("/usr/local/bin/gpio -g mode 17 out");
if(isset($_GET['on'])){
$gpio_on = shell_exec("/usr/local/bin/gpio -g write 17 1");
echo "MOTOR is on";
}
else if(isset($_GET['off'])){
$gpio_off = shell_exec("/usr/local/bin/gpio -g write 17 0");
echo "MOTOR is off";
}
?>
<?php
error_reporting(-1);//report all errors during execution
global $host;
//$host="https://helloworld.co.in";
$host="http://localhost";
global $realtime_path,$simulation_path;
$realtime_path = "$host/web_host/watertank";
$simulation_path = "$host/web_host/watertank_simulation";
display_data();
function display_data(){
$uri= $_SERVER['REQUEST_URI'];
// echo"uri: $uri<br>";
$xx=@explode('?',$uri);
$params=@$xx[1];
// echo"param: $params<br>";
$yy=@explode('&',$params);
$zz1=@explode('=',$yy[0]);$page=@$zz1[1];
$zz2=@explode('=',$yy[1]);$date=@$zz2[1];
//echo"page: $page<br>";
//echo"date: $date<br>";
echo"<hr>";
if ($page=="realtime" or $page==""){
display_real_time($date);
}
if ($page=="simulation"){
display_simulation();
}
echo"<hr>";
}
function display_real_time($date){
global $host;
echo"
<p>The dashboard shown below displays real time water level of my house's overhead tank. Tank level is updated every minute on arrival of sensor data.
The graph (shown below the tank animation) displays the water level readings for a selected date.
Y-axis indicates the volume of water left in the tank and X-axis denotes hours in a day</p>
";
echo"<p>Since the real-time data changes marginally in a minute, you may find no change in the tank level.
To appreciate the tank animation, check out this <a href='$host/web_host?page=simulation&date=0'>simulation</a>. Or, just check this page again after few hours to notice the change.</p>";
show_chart_info();
show_graph($date);
show_dates();
}
function display_simulation(){
global $host;
echo"<p>In this simulation, the remote sensor data has been replaced with a value that changes at much faster rate. This value is Server's time's 'Second' value.
This value is fed to the tank animation. Since 'Second' value changes from 0 to 60, the water level in this animation also varies between 0-60.</p>";
echo"<p>Go back to <a href='$host/web_host'>real-time</a> view</p>";
show_chart_info_2();
}
//-------------------------display_simulation() supporting function--------------------------------------
function show_chart_info_2(){
global $simulation_path;
$path=$simulation_path."/dashboard_simulation.php";
//echo"$path<br>";
echo"<iframe height='500px' width='100%' src='$path' name='iframe_a'></iframe>";
echo"<br>";
}
//--------------------------------------------------------------------------------------
//=================display_real_time() supporting function==========================================
function show_chart_info(){
global $realtime_path;
$path=$realtime_path."/dashboard.php";
//echo"$path<br>";
echo"<iframe height='500px' width='100%' src='$path' name='iframe_a'></iframe>";
echo"<br>";
}
function show_graph($date){
if($date==""){
//$date=date('Y-m-d', time());
$date="2020-06-26";
}
global $realtime_path;
$path=$realtime_path.'/phplot/graph.php?date='.$date;
//echo"path = $path<br>";
//echo"<iframe height='300px' width='100%' src='$realtime_path/phplot/graph.php?date=$date' name='iframe_b' style='border:1px solid green;'></iframe>";
echo"<iframe height='320px' width='100%' src='$path' name='iframe_b' style='border:1px solid lightgray;'></iframe>";
}
function show_dates(){
/*
$currentTime = time();
$seconds_in_day=24*60*60;
echo"<table><tr>";
for($i=0;$i<7;$i++){
$t=$currentTime - $i * $seconds_in_day;
$dt=date('Y-m-d', $t);
$dt1=date('d M y', $t);
global $host;
$link="<a href='$host/water-tank?page=realtime&date=$dt'>$dt1</a>";
//echo"link: $link<br>";
echo"<td style='border:1px solid grey;padding:5px'>$link</td>";
}
echo"</tr></table>";
*/
echo"<table><tr>";
$dt1="2020-06-18";
$dt2="2020-06-20";
$dt3="2020-06-26";
global $host;
$link1="<a href='$host/web_host/index.php?page=realtime&date=$dt1'>18 Jun 20</a>";
$link2="<a href='$host/web_host/index.php?page=realtime&date=$dt2'>20 Jun 20</a>";
$link3="<a href='$host/web_host/index.php?page=realtime&date=$dt3'>26 Jun 20</a>";
echo"<td style='border:1px solid grey;padding:5px'>$link1</td>";
echo"<td style='border:1px solid grey;padding:5px'>$link2</td>";
echo"<td style='border:1px solid grey;padding:5px'>$link3</td>";
echo"</tr></table>";
}
//=========================================================================================
?>
</body>
</html>