Skip to content
Permalink
Browse files

meteo update

  • Loading branch information...
techfreak
techfreak committed May 19, 2016
1 parent 5716e8d commit 01b81ead1393c824996828a14a8d362dcf0929c2
@@ -31,7 +31,6 @@
<!-- bootstrap-toogle -->
<link href="html/bootstrap-toggle/bootstrap-toggle.min.css" rel="stylesheet">
<script type="text/javascript" src="html/bootstrap-toggle/bootstrap-toggle.min.js"></script>

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
@@ -8,6 +8,8 @@
$hum = isset($_POST['hum']) ? $_POST['hum'] : '';
$status = isset($_POST['status']) ? $_POST['status'] : '';
$onoff = isset($_POST['onoff']) ? $_POST['onoff'] : '';
$status_norm = isset($_POST['status_norm']) ? $_POST['status_norm'] : '';
$onoff_norm = isset($_POST['onoff_norm']) ? $_POST['onoff_norm'] : '';
if ($save == "save") {
@@ -24,6 +26,14 @@
header("location: " . $_SERVER['REQUEST_URI']);
exit();
}
if ($onoff_norm == "onoff_norm") {
$db->exec("UPDATE meteo SET normalized='$status_norm' WHERE id='1'") or die("exec 1");
$db = null;
header("location: " . $_SERVER['REQUEST_URI']);
exit();
}
?>
<div class="panel panel-default">
@@ -125,11 +135,15 @@
</fieldset>
</form>
<form action="" method="post">
<label>Meteo status</label>
<label style="width:150px">Meteo status</label>
<input data-toggle="toggle" data-size="mini" onchange="this.form.submit()" type="checkbox" name="status" value="on" <?php echo $m['onoff'] == 'on' ? 'checked="checked"' : ''; ?> /></td>
<input type="hidden" name="onoff" value="onoff" />
</form>

<form action="" method="post">
<label style="width:150px">Normalized pressure</label>
<input data-toggle="toggle" data-size="mini" onchange="this.form.submit()" type="checkbox" name="status_norm" value="on" <?php echo $m['normalized'] == 'on' ? 'checked="checked"' : ''; ?> /></td>
<input type="hidden" name="onoff_norm" value="onoff_norm" />
</form>
<?php }
?>
</div>
@@ -301,4 +301,5 @@ sqlite3 -cmd ".timeout 2000" $dir/dbf/nettemp.db "CREATE TABLE rs485 (id INTEGER
sqlite3 -cmd ".timeout 2000" $dir/dbf/nettemp.db "ALTER TABLE sensors ADD jg TEXT"
sqlite3 -cmd ".timeout 2000" $dir/dbf/nettemp.db "ALTER TABLE sensors ADD current TEXT"

sqlite3 -cmd ".timeout 2000" $dir/dbf/nettemp.db "ALTER TABLE meteo ADD normalized TEXT"

@@ -0,0 +1,121 @@
<?php
class Meteo
{
private $temperatura='';
private $wilgotnosc='';
private $cisnienie='';
private $szerokosc='';
private $wysokosc='';
private $idtmp='';
private $idpre='';
private $idhum='';
private $sila_grawitacji=''; //si³a grawitacji
private $temp_znormalizowana=''; //temperatura znormalizowana K
private $tz=''; //temperatura znormalizowana C
private $cz=''; //ciœnienie znormalizowane
private $tpr=''; //temperatura punktu rosy
private $cisnienie_pary_nasyconej=''; //ciœnienie pary nasyconej
private $cisnienie_pary=''; //ciœnienie pary wodnej
private $wb=''; //wilgotnoœæ bezwzglêdna
protected $sql = array(
'getOnOff' => "SELECT onoff FROM meteo WHERE id= :id",
'getDataById' => 'SELECT * FROM meteo WHERE id = :id'
);
function __construct()
{
$this->get_data();
$this->meteo();
}
function get_data()
{
$root=$_SERVER["DOCUMENT_ROOT"];
$db = new PDO("sqlite:$root/dbf/nettemp.db") or die("cannot open the database");
$met1 = $db->prepare("SELECT * FROM meteo WHERE id='1'");
$met1->execute();
$resultmet1 = $met1->fetchAll();
foreach ($resultmet1 as $me) {
$this->szerokosc=$me['latitude'];
$this->wysokosc=$me['height'];
$this->idtmp=$me['temp'];
$this->idpre=$me['pressure'];
$this->idhum=$me['humid'];
}
$sth = $db->prepare("select tmp from sensors where id='$this->idtmp'");
$sth->execute();
$result = $sth->fetchAll();
foreach ($result as $a) {
$this->temperatura=$a['tmp'];
}
$sth = $db->prepare("select tmp from sensors where id='$this->idpre'");
$sth->execute();
$result = $sth->fetchAll();
foreach ($result as $a) {
$this->cisnienie=$a['tmp'];
}
$sth = $db->prepare("select tmp from sensors where id='$this->idhum'");
$sth->execute();
$result = $sth->fetchAll();
foreach ($result as $a) {
$this->wilgotnosc=$a['tmp'];
}
}
function meteo(){
//$meteo_status = new _View('status_meteo.phtml');
//$this->model_sensors = new model_Sensors;
//$display = $this->getOnOff(array('id' => 1))[0]->onoff;
//if ($display == "on") {
$this->sila_grawitacji=9.780313*(pow(1+0.005324*SIN($this->szerokosc),2)-0.0000058*pow(SIN(2*$this->szerokosc),2)-0.000003085*$this->wysokosc);
$this->temp_znormalizowana=((2*($this->temperatura+273.15))+((0.6*$this->wysokosc)/100))/2;
$this->tz=$this->temp_znormalizowana-273.15;
$this->cz=($this->cisnienie*(EXP(($this->sila_grawitacji*$this->wysokosc)/(287.05*$this->temp_znormalizowana)))*10)/10;
$this->tpr=243.12*(((LOG10($this->wilgotnosc)-2)/0.4343)+(17.5*$this->temperatura)/(243.12+$this->temperatura))/(17.62-(((LOG10($this->wilgotnosc)-2)/0.4343)+(17.5*$this->temperatura)/(243.12+$this->temperatura)));
$this->cisnienie_pary_nasyconej=6.112*EXP((17.67*$this->temperatura)/($this->temperatura+243.5));
$this->cisnienie_pary=$this->wilgotnosc/(1/$this->cisnienie_pary_nasyconej)/100;
$this->wb=2165*(($this->cisnienie_pary/10)/(273.15+$this->temperatura));
return true;
}
function getSilaGrawitacji()
{
return $this->sila_grawitacji;
}
function getTemperaturaZnormalizowana()
{
return $this->tz;
}
function getCisnienieZnormalizowane()
{
return $this->cz;
}
function getTpr()
{
return$this->tpr;
}
function getCisnienieParyNasyconej()
{
return $this->cisnienie_pary_nasyconej;
}
function getCisnieniePary()
{
return $this->cisnienie_pary;
}
function getWb()
{
return $this->wb;
}
}
0 status/justgage_refresh.php 100644 → 100755
No changes.
@@ -14,38 +14,24 @@
if ( $onoff == "on") {
$met1 = $db->prepare("SELECT * FROM meteo WHERE id='1'");
$met1->execute();
$resultmet1 = $met1->fetchAll();
foreach ($resultmet1 as $me) {
$szerokosc=$me['latitude'];
$wysokosc=$me['height'];
$idtmp=$me['temp'];
$idpre=$me['pressure'];
$idhum=$me['humid'];
}
$sth = $db->prepare("select tmp from sensors where id='$idtmp'");
$sth->execute();
$result = $sth->fetchAll();
foreach ($result as $a) {
$temperatura=$a['tmp'];
}
$sth = $db->prepare("select tmp from sensors where id='$idpre'");
$sth->execute();
$result = $sth->fetchAll();
foreach ($result as $a) {
$cisnienie=$a['tmp'];
}
$sth = $db->prepare("select tmp from sensors where id='$idhum'");
$sth->execute();
$result = $sth->fetchAll();
foreach ($result as $a) {
$wilgotnosc=$a['tmp'];
}
//require("Meteo.class.php"); ->requested class loaded in sensors_status.php !!!
$meteo=new Meteo();
$sila_grawitacji=$meteo->getSilaGrawitacji();//9.780313*(pow(1+0.005324*SIN($szerokosc),2)-0.0000058*pow(SIN(2*$szerokosc),2)-0.000003085*$wysokosc);
$temp_znormalizowana=$meteo->getTemperaturaZnormalizowana();//((2*($temperatura+273.15))+((0.6*$wysokosc)/100))/2;
$tz=$meteo->getTemperaturaZnormalizowana()-273.15;//$temp_znormalizowana-273.15;
$cz=$meteo->getCisnienieZnormalizowane();//($cisnienie*(EXP(($sila_grawitacji*$wysokosc)/(287.05*$temp_znormalizowana)))*10)/10;
$tpr=$meteo->getTpr();//243.12*(((LOG10($wilgotnosc)-2)/0.4343)+(17.5*$temperatura)/(243.12+$temperatura))/(17.62-(((LOG10($wilgotnosc)-2)/0.4343)+(17.5*$temperatura)/(243.12+$temperatura)));
$cisnienie_pary_nasyconej=$meteo->getCisnienieParyNasyconej();//6.112*EXP((17.67*$temperatura)/($temperatura+243.5));
$cisnienie_pary=$meteo->getCisnieniePary();//$wilgotnosc/(1/$cisnienie_pary_nasyconej)/100;
$wb=$meteo->getWb();//2165*(($cisnienie_pary/10)/(273.15+$temperatura));
?>
<script>
function normalized(){
document.getElementById("normalized").innerHTML = <?php echo number_format($cz, 2, '.', '')."hPa npm"; ?>
};
</script>
<?php
if ( $onoff == "on" ) {
?>
<div class="grid-item ms">
<div class="panel panel-default">
@@ -55,7 +41,7 @@
<tr>
<td>Sila grawitacji [m/s^2]"</td>
<td><?php
$sila_grawitacji=9.780313*(pow(1+0.005324*SIN($szerokosc),2)-0.0000058*pow(SIN(2*$szerokosc),2)-0.000003085*$wysokosc);
//$sila_grawitacji=9.780313*(pow(1+0.005324*SIN($szerokosc),2)-0.0000058*pow(SIN(2*$szerokosc),2)-0.000003085*$wysokosc);
echo number_format($sila_grawitacji, 2, '.', '');
?>
</td>
@@ -65,7 +51,7 @@
<td>Temperatura znormalizowana [K]
<td>
<?php
$temp_znormalizowana=((2*($temperatura+273.15))+((0.6*$wysokosc)/100))/2;
//$temp_znormalizowana=((2*($temperatura+273.15))+((0.6*$wysokosc)/100))/2;
echo number_format($temp_znormalizowana, 2, '.', '');
?>
</td>
@@ -75,7 +61,7 @@
<td>Temperatura znormalizowana [C]
<td>
<?php
$tz=$temp_znormalizowana-273.15;
//$tz=$temp_znormalizowana-273.15;
echo number_format($tz, 2, '.', '');
?>
</td>
@@ -85,7 +71,7 @@
<td>Cisnienie znormalizowane [hPa]
<td>
<?php
$cz=($cisnienie*(EXP(($sila_grawitacji*$wysokosc)/(287.05*$temp_znormalizowana)))*10)/10;
//$cz=($cisnienie*(EXP(($sila_grawitacji*$wysokosc)/(287.05*$temp_znormalizowana)))*10)/10;
echo number_format($cz, 2, '.', '');
?>
</td>
@@ -96,7 +82,7 @@
<td>Temperatura punktu rosy [°C]
<td>
<?php
$tpr=243.12*(((LOG10($wilgotnosc)-2)/0.4343)+(17.5*$temperatura)/(243.12+$temperatura))/(17.62-(((LOG10($wilgotnosc)-2)/0.4343)+(17.5*$temperatura)/(243.12+$temperatura)));
//$tpr=243.12*(((LOG10($wilgotnosc)-2)/0.4343)+(17.5*$temperatura)/(243.12+$temperatura))/(17.62-(((LOG10($wilgotnosc)-2)/0.4343)+(17.5*$temperatura)/(243.12+$temperatura)));
echo number_format($tpr, 2, '.', '');
?>
</td>
@@ -107,7 +93,7 @@
<td>Cisnienie pary wodnej nasyconej [hPa]
<td>
<?php
$cisnienie_pary_nasyconej=6.112*EXP((17.67*$temperatura)/($temperatura+243.5));
//$cisnienie_pary_nasyconej=6.112*EXP((17.67*$temperatura)/($temperatura+243.5));
echo number_format($cisnienie_pary_nasyconej, 2, '.', '');
?>
</td>
@@ -117,7 +103,7 @@
<td>Cisnienie pary wodnej [hPa]
<td>
<?php
$cisnienie_pary=$wilgotnosc/(1/$cisnienie_pary_nasyconej)/100;
//$cisnienie_pary=$wilgotnosc/(1/$cisnienie_pary_nasyconej)/100;
echo number_format($cisnienie_pary, 2, '.', '');
?>
</td>
@@ -126,7 +112,7 @@
<td>Wilgotnosc bezwzgledna [g/m^3]
<td>
<?php
$wb=2165*(($cisnienie_pary/10)/(273.15+$temperatura));
//$wb=2165*(($cisnienie_pary/10)/(273.15+$temperatura));
echo number_format($wb, 2, '.', '');
?>
</td>
@@ -138,5 +124,6 @@
</div>
</div>
<?php
}
}
?>
@@ -1,4 +1,4 @@
<div class="grid-item ss" >
<div class="grid-item ss">
<div class="panel panel-default">
<div class="panel-heading">Sensors</div>
<?php
@@ -10,6 +10,12 @@
foreach ($row as $a) {
$temp_scale=$a['temp_scale'];
}
$rows_meteo = $db->query("SELECT normalized,pressure FROM meteo WHERE id='1'");
$row_meteo = $rows_meteo->fetchAll();
foreach ($row_meteo as $a) {
$normalized=$a['normalized'];
$pressure=$a['pressure'];
}
$rows = $db->query("SELECT * FROM sensors");
$row = $rows->fetchAll();
@@ -116,6 +122,29 @@
<?php echo $updo; ?>
</td>
</tr>
<?php if ($normalized == "on" && $pressure == $a['id']): ?>
<tr>
<td></td>
<td><span
<?php if(($a['tmp'] == 'error') || ($label=='danger')) {
echo 'class="label label-danger"';
}
else {
echo 'class="label label-success"';
}
?>
>
<?php require('Meteo.class.php');
$m=new Meteo();
echo number_format($m->getCisnienieZnormalizowane(),2,'.','').' hPa npm';
?>
</span>
</td>
<td>
<?php echo $updo; ?>
</td>
</tr>
<?php endif; ?>
<?php
unset($mm);
unset($max);

0 comments on commit 01b81ea

Please sign in to comment.
You can’t perform that action at this time.