MOTOR Control:
";
$xx=@explode('?',$uri);
$params=@$xx[1];
// echo"param: $params
";
$yy=@explode('&',$params);
$zz1=@explode('=',$yy[0]);$page=@$zz1[1];
$zz2=@explode('=',$yy[1]);$date=@$zz2[1];
//echo"page: $page
";
//echo"date: $date
";
echo"
";
if ($page=="realtime" or $page==""){
display_real_time($date);
}
if ($page=="simulation"){
display_simulation();
}
echo"
";
}
function display_real_time($date){
global $host;
echo"
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
";
echo"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 simulation. Or, just check this page again after few hours to notice the change.
";
show_chart_info();
show_graph($date);
show_dates();
}
function display_simulation(){
global $host;
echo"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.
";
echo"Go back to real-time view
";
show_chart_info_2();
}
//-------------------------display_simulation() supporting function--------------------------------------
function show_chart_info_2(){
global $simulation_path;
$path=$simulation_path."/dashboard_simulation.php";
//echo"$path
";
echo"";
echo"
";
}
//--------------------------------------------------------------------------------------
//=================display_real_time() supporting function==========================================
function show_chart_info(){
global $realtime_path;
$path=$realtime_path."/dashboard.php";
//echo"$path
";
echo"";
echo"
";
}
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
";
//echo"";
echo"";
}
function show_dates(){
/*
$currentTime = time();
$seconds_in_day=24*60*60;
echo"";
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="$dt1";
//echo"link: $link
";
echo"$link | ";
}
echo"
";
*/
echo"";
$dt1="2020-06-18";
$dt2="2020-06-20";
$dt3="2020-06-26";
global $host;
$link1="18 Jun 20";
$link2="20 Jun 20";
$link3="26 Jun 20";
echo"$link1 | ";
echo"$link2 | ";
echo"$link3 | ";
echo"
";
}
//=========================================================================================
?>