mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-12 16:46:35 +00:00
DBlog added
git-svn-id: https://svn.fhem.de/fhem/trunk@579 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
8ee65abb77
commit
692764fcb4
@ -570,4 +570,7 @@
|
||||
- bugfix: dummy/structure was listed twice in list and xmllist
|
||||
- feature: 11_FHT.pm added new readings for warnings on battery, lowtemp,
|
||||
window and windowsensor (M.Fischer)
|
||||
- feature: on-for-timer added for X10 modules (Boris)
|
||||
- feature: on-for-timer added for X10 modules (Boris)
|
||||
- bugfix: pgm3: Better check of availability of google-weather (MartinH)
|
||||
- feature: pgm3: DBLog added for everything except UserDefs
|
||||
(Gerhard Pfeffer / MartinH)
|
||||
|
@ -198,3 +198,9 @@ It is not necessary to tell fhem that there are other logs.
|
||||
2010-01-08
|
||||
-- Feature, Bugs look at HISTORY
|
||||
Changed: every php-File!
|
||||
2010-03-12
|
||||
-- Bugfix: Better check of availability of Google-Weather
|
||||
Changed: weather.php
|
||||
-- Feature: DBLog for everything except UserDefs
|
||||
Changed: index.php, config.php, fht.php, hsm100.php,
|
||||
fhtpulldown.php, ks300.php
|
||||
|
@ -105,3 +105,6 @@
|
||||
-- Misc: Output of html better formated
|
||||
-- Feature. Skinable -- change the colors
|
||||
|
||||
- Martin 2010-03-12
|
||||
-- Bugfix: better check of availability of google-weather
|
||||
-- Feature: DBLog added for everything except UserDefs
|
||||
|
@ -7,14 +7,21 @@
|
||||
|
||||
|
||||
###### required settings
|
||||
$fhem="fhem"; #only php5 is supported! On which machine is fhem runnning??
|
||||
#$fhem="localhost"; #only php5 is supported! On which machine is fhem runnning??
|
||||
$fhem="localhost"; #only php5 is supported! On which machine is fhem runnning??
|
||||
# it needs not to be on the same machine as fhem
|
||||
# if it is not localhost then the fhem.cfg must
|
||||
# run global: "attr global port <nr> global"
|
||||
$fhemport="7072"; # port of fhem.pl
|
||||
$logpath="/mnt/fhz/"; # where are your logs? Use a writabel nfs-share if pgm3 and fhem are not on the same machine
|
||||
$AbsolutPath="/srv/www/htdocs/"; # where ist your pgm3?
|
||||
$logpath="/var/tmp/"; # where are your logs? Use a writabel nfs-share if pgm3 and fhem are not on the same machine
|
||||
$AbsolutPath="/var/www/"; # where ist your pgm3?
|
||||
|
||||
###### DBlog instead of Filelogs -- only for experienced Users!
|
||||
## Look at contrib/dblog and http://fhemwiki.de for further information
|
||||
$DBUse="0"; # Wanna use DB-Logging instead of File-Logging? Use 1 for ye s and 0 for no.
|
||||
$DBNode="localhost"; # On which machine is your db running?
|
||||
$DBName="fhem"; # Whats the name of your DB for fhem?
|
||||
$DBUser="USER"; # Enter the username to connect to the DB.
|
||||
$DBPass="PASSWD"; # Enter the password which is needed to connect to the DB
|
||||
|
||||
|
||||
##################################################################################
|
||||
@ -102,13 +109,13 @@
|
||||
$desR='255'; $desG='255'; $desB='255'; # Color of desired-temp-line Red/Green/Blue (Default: 255/255/255)
|
||||
$show_actuator=1; # show the actuator-value as a graphic (0/1)
|
||||
$actR='255'; $actG='247'; $actB='200'; # Color of Actuator-line Red/Green/Blue (Default: 255/247/200)
|
||||
$FHTyrange='15:31'; # Temperature in gnuplot. Default 15 to 31 (Celsius)
|
||||
$FHTyrange='14:31'; # Temperature in gnuplot. Default 14 to 31 (Celsius)
|
||||
$FHTy2range='0:70'; # Actuator in gnuplot. Default 0 to 70 (Percent)
|
||||
$maxcount='510'; # Maximum count of pixel (from right to left) (Default:460)
|
||||
$XcorrectDate=380; # Text of e.g. Date from the right side (Default:380)
|
||||
$XcorrectMainText=32; # Text of main text from the right side (Default: 32)
|
||||
$logrotateFHTlines=5400; # automatic Logrotate; $logrotate must be 'yes'.
|
||||
# Default:4800
|
||||
$logrotateFHTlines=8200; # automatic Logrotate; $logrotate must be 'yes'.
|
||||
# Default:8200
|
||||
# read docs/logrotate if you want adjust it manually!
|
||||
# otherwise the system will slow down
|
||||
# pgm3 (user www-data) needs the rights to write the logs
|
||||
@ -124,8 +131,8 @@
|
||||
$maxcountHMS='575'; # Maximum count of pixel (from right to left) (Default:575)
|
||||
$XcorrectMainTextHMS=25; # Text of main text from the right side (Default:)
|
||||
$showdewpoint='yes'; # Dewpoint (german: taupunkt)
|
||||
$logrotateHMSlines=1200; # automatic Logrotate; $logrotate must be 'yes'.
|
||||
# Default:1200
|
||||
$logrotateHMSlines=1500; # automatic Logrotate; $logrotate must be 'yes'.
|
||||
# Default:1500
|
||||
# read docs/logrotate if you want adjust it manually!
|
||||
# otherwise the system will slow down
|
||||
# pgm3 (user www-data) needs the rights to write the logs
|
||||
@ -170,7 +177,7 @@
|
||||
|
||||
|
||||
# Do you want user defined graphics? 1/0 Default: 0
|
||||
$UserDefs=1;
|
||||
$UserDefs=0;
|
||||
|
||||
#####################
|
||||
## Userdef: 0
|
||||
@ -220,20 +227,20 @@ $UserDefs=1;
|
||||
########################
|
||||
# example:
|
||||
#define solarpumpe.log FileLog /var/tmp/solarpumpe.log solarpumpe:.*(on|off).*
|
||||
#$sortnumber=0;
|
||||
#$userdef[$sortnumber]['name']='PiriO';
|
||||
#$userdef[$sortnumber]['name']='SolarPumpe';
|
||||
#$userdef[$sortnumber]['valuefield']=3;
|
||||
#$userdef[$sortnumber]['gnuplottype']='fs20';
|
||||
#$userdef[$sortnumber]['logpath']='/mnt/fhz/solarpumpe.log';
|
||||
#$userdef[$sortnumber]['room']='cellar';
|
||||
#$userdef[$sortnumber]['semlong']='Solarpumpe';
|
||||
#$userdef[$sortnumber]['semshort']='';
|
||||
#$userdef[$sortnumber]['imagemax']=725;
|
||||
#$userdef[$sortnumber]['imagemay']=52;
|
||||
#$userdef[$sortnumber]['maxcount']=575;
|
||||
#$userdef[$sortnumber]['XcorrectMainText']=25;
|
||||
#$userdef[$sortnumber]['logrotatelines']=50;
|
||||
$sortnumber=0;
|
||||
$userdef[$sortnumber]['name']='PiriO';
|
||||
$userdef[$sortnumber]['name']='SolarPumpe';
|
||||
$userdef[$sortnumber]['valuefield']=3;
|
||||
$userdef[$sortnumber]['gnuplottype']='fs20';
|
||||
$userdef[$sortnumber]['logpath']='/mnt/fhz/solarpumpe.log';
|
||||
$userdef[$sortnumber]['room']='cellar';
|
||||
$userdef[$sortnumber]['semlong']='Solarpumpe';
|
||||
$userdef[$sortnumber]['semshort']='';
|
||||
$userdef[$sortnumber]['imagemax']=725;
|
||||
$userdef[$sortnumber]['imagemay']=52;
|
||||
$userdef[$sortnumber]['maxcount']=575;
|
||||
$userdef[$sortnumber]['XcorrectMainText']=25;
|
||||
$userdef[$sortnumber]['logrotatelines']=50;
|
||||
|
||||
|
||||
##########################
|
||||
@ -253,6 +260,26 @@ $UserDefs=1;
|
||||
#$userdef[$sortnumber]['XcorrectMainText']=25;
|
||||
#$userdef[$sortnumber]['logrotatelines']=30;
|
||||
|
||||
##########################
|
||||
# example:
|
||||
#define rolu1.log FileLog /var/tmp/rolu1.log rolu1:.*(on|off|dimup|dimdown).*
|
||||
$sortnumber=1;
|
||||
$userdef[$sortnumber]['name']='allight';
|
||||
$userdef[$sortnumber]['valuefield']=3;
|
||||
$userdef[$sortnumber]['gnuplottype']='fs20';
|
||||
$userdef[$sortnumber]['logpath']='/mnt/fhz/allight.log';
|
||||
$userdef[$sortnumber]['room']='alarm';
|
||||
$userdef[$sortnumber]['semlong']='Alarm light';
|
||||
$userdef[$sortnumber]['semshort']='';
|
||||
$userdef[$sortnumber]['imagemax']=725;
|
||||
$userdef[$sortnumber]['imagemay']=52;
|
||||
$userdef[$sortnumber]['maxcount']=575;
|
||||
$userdef[$sortnumber]['XcorrectMainText']=25;
|
||||
$userdef[$sortnumber]['logrotatelines']=30;
|
||||
##########################
|
||||
|
||||
|
||||
#$sortnumber=2;
|
||||
#$userdef[$sortnumber]['name']='tARV';
|
||||
#$userdef[$sortnumber]['valuefield']=3;
|
||||
#$userdef[$sortnumber]['gnuplottype']='temperature';
|
||||
@ -321,14 +348,15 @@ $UserDefs=1;
|
||||
$showAT='no'; #show the AT_JOBS at startup. Default: yes Values: yes/no
|
||||
$showNOTI='no'; #show the NOTIFICATIONS at startup. Default: no Values: yes/no
|
||||
$showHIST='yes'; #show the HISTORY (if taillog=1) at startup. Default: yes Values: yes/no
|
||||
$showPICS='yes'; #if shwowebcam=1 then initial the Pics will be shown. Default: yes
|
||||
$showPICS='no'; #if shwowebcam=1 then initial the Pics will be shown. Default: yes
|
||||
$showWeath='yes'; # Show weather on startup? $enableweather must 1
|
||||
|
||||
$RSStitel='FHEM :-)';
|
||||
|
||||
$urlreload=90; # Automatic reloading page [sec]. Default fast: 60 slow:90
|
||||
$titel="PHP-Webmachine for fhem :-)"; #feel free to create an own title
|
||||
$timeformat="Y-m-d H:i:s";
|
||||
#$timeformat="Y-m-d H:i:s"; #English
|
||||
$timeformat="d.m.Y H:i:s"; # German
|
||||
$winsize=800; # width of the pgm3
|
||||
|
||||
|
||||
@ -354,20 +382,20 @@ $UserDefs=1;
|
||||
$bg1_R='110';$bg1_G='148';$bg1_B='181';
|
||||
##########################
|
||||
##ORANGE
|
||||
# $bodybg="bgcolor='#FFDAB9'";
|
||||
# $bg1="bgcolor='#FF8C00'";
|
||||
# $bg2="bgcolor='#FFA500'";
|
||||
# $bg4="bgcolor='#6394BD'";
|
||||
# $bg5="bgcolor='#FFFFFF'";
|
||||
# $fontcolor1="color='#000000'";
|
||||
# $fontcolor3="color='#000000'";
|
||||
#$bodybg="bgcolor='#FFDAB9'";
|
||||
#$bg1="bgcolor='#FF8C00'";
|
||||
#$bg2="bgcolor='#FFA500'";
|
||||
#$bg4="bgcolor='#6394BD'";
|
||||
#$bg5="bgcolor='#FFFFFF'";
|
||||
#$fontcolor1="color='#000000'";
|
||||
#$fontcolor3="color='#000000'";
|
||||
# The Button needs decimal Code Instead Hex.
|
||||
# Use the column left from the HEX on
|
||||
# http://www.farb-tabelle.de/de/farbtabelle.htm
|
||||
# You must delete the old graphics after the change. "rm <pgm3>/tmp/*"
|
||||
# $buttonBg_R='255';$buttonBg_G='165';$buttonBg_B='0';
|
||||
#$buttonBg_R='255';$buttonBg_G='165';$buttonBg_B='0';
|
||||
#Dec-Code from $bg1:
|
||||
# $bg1_R='255';$bg1_G='140';$bg1_B='0';
|
||||
#$bg1_R='255';$bg1_G='140';$bg1_B='0';
|
||||
|
||||
|
||||
|
||||
@ -391,4 +419,13 @@ $UserDefs=1;
|
||||
############################### end of settings
|
||||
putenv('GDFONTPATH=' . realpath('.'));
|
||||
|
||||
|
||||
|
||||
### If DB-query is used, this is the only point of connect. ###
|
||||
if ($DBUse=="1") {
|
||||
@mysql_connect($DBNode, $DBUser, $DBPass) or die("Can't connect");
|
||||
@mysql_select_db($DBName) or die("No database found");
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
|
||||
################# Creates graphics vor pgm3
|
||||
|
||||
|
||||
@ -9,6 +7,7 @@
|
||||
|
||||
include "../config.php";
|
||||
include "functions.php";
|
||||
#include "dblog.php";
|
||||
|
||||
setlocale (LC_ALL, 'de_DE.utf8');
|
||||
|
||||
@ -17,21 +16,25 @@ setlocale (LC_ALL, 'de_DE.utf8');
|
||||
$battery=$_GET['battery'];
|
||||
$room=$_GET['room'];
|
||||
|
||||
$file="$logpath/$drawfht.log";
|
||||
|
||||
if (! file_exists($file)) show_error($file,$drawfht,$imgmaxxfht,$imgmaxyfht);
|
||||
|
||||
|
||||
if ($DBUse=="1") {
|
||||
$sqlquery=mysql_query("select timestamp from history where device='".$drawfht."' and type='FHT' order by timestamp desc limit 1");
|
||||
$query=mysql_fetch_object($sqlquery);
|
||||
$date=str_replace(" ","_",$query->timestamp);
|
||||
}
|
||||
else {
|
||||
$file="$logpath/$drawfht.log";
|
||||
if (! file_exists($file)) show_error($file,$drawfht,$imgmaxxfht,$imgmaxyfht);
|
||||
|
||||
## do we really need a new graphic??
|
||||
$execorder=$tailpath.' -1 '.$file;
|
||||
exec($execorder,$tail1);
|
||||
$parts = explode(" ", $tail1[0]);
|
||||
$date=$parts[0];
|
||||
$execorder=$tailpath.' -1 '.$file;
|
||||
exec($execorder,$tail1);
|
||||
$parts = explode(" ", $tail1[0]);
|
||||
$date=$parts[0];
|
||||
}
|
||||
|
||||
#if the expected graphic already exist then do not redraw the picture
|
||||
|
||||
$savefile=$AbsolutPath."/tmp/FHT.".$drawfht.".log.".$parts[0].".png";
|
||||
$savefile=$AbsolutPath."/tmp/FHT.".$drawfht.".log.".$date.".png";
|
||||
if (file_exists($savefile)) {
|
||||
|
||||
$im2 = @ImageCreateFromPNG($savefile);
|
||||
@ -52,44 +55,60 @@ setlocale (LC_ALL, 'de_DE.utf8');
|
||||
$_SESSION["arraydata"] = array();
|
||||
|
||||
|
||||
$array = file($file);
|
||||
if ($DBUse=="1") $sqlarray=mysql_query("select timestamp,reading,value from (select timestamp,reading,value from history where device='".$drawfht."' order by timestamp desc limit ".$logrotateFHTlines.") as subtable order by timestamp asc") or die (mysql_error());
|
||||
else $array = file($file);
|
||||
$oldmin=0; //only the data from every 10min
|
||||
$oldhour=0; //only the data from every 10min
|
||||
$actuator="00%";
|
||||
$actuator_date="unknown";
|
||||
$counter=count($array);
|
||||
|
||||
if ($DBUse=="1") $counter=mysql_num_rows($sqlarray);
|
||||
else $counter=count($array);
|
||||
|
||||
$arraydesired=array();
|
||||
$arrayactuator=array();
|
||||
|
||||
|
||||
#Logrotate
|
||||
if ((($logrotateFHTlines+200) < $counter) and ($logrotate == 'yes')) LogRotate($array,$file,$logrotateFHTlines);
|
||||
if ((($logrotateFHTlines+200) < $counter) and ($logrotate == 'yes') and ($DBUse!="1")) LogRotate($array,$file,$logrotateFHTlines);
|
||||
|
||||
for ($x = 0; $x < $counter; $x++)
|
||||
{
|
||||
$parts = explode(" ", $array[$x]);
|
||||
$date=$parts[0];
|
||||
$type=$parts[2];
|
||||
$temp=$parts[3];
|
||||
if ($type=="desired-temp:")
|
||||
for ($x = 0; $x < $counter; $x++)
|
||||
{
|
||||
if ($DBUse=="1") {
|
||||
mysql_data_seek($sqlarray,$x);
|
||||
$parts=mysql_fetch_assoc($sqlarray);
|
||||
# $date=$parts['timestamp'];
|
||||
$date=str_replace(" ","_",$parts['timestamp']);
|
||||
$type=$parts['reading'];
|
||||
$temp=$parts['value'];
|
||||
$array[$x]=$date." ".$type." ".$temp;
|
||||
if ($type=="actuator") $temp=$temp."%";
|
||||
# print "Output: ".$date." ".$type." ".$temp."<br />";
|
||||
}
|
||||
else {
|
||||
$parts = explode(" ", $array[$x]);
|
||||
$date=$parts[0];
|
||||
$type=$parts[2];
|
||||
$temp=$parts[3];
|
||||
}
|
||||
|
||||
if (substr($type,0,12)=="desired-temp")
|
||||
{$desired_temp=$temp;$desired_date=$date;}
|
||||
if ($type=="actuator:")
|
||||
if (substr($type,0,8)=="actuator")
|
||||
{
|
||||
if (trim($temp) != 'lime-protection')
|
||||
{$actuator=rtrim($temp);$actuator_date=$date;}
|
||||
}
|
||||
if ((($array[$x][14] != $oldmin) or ($array[$x][12] != $oldhour)) and ($type=="measured-temp:"))
|
||||
# print ":::".$array[$x][14]."---".$oldmin."<br />";
|
||||
# print "...".$array[$x][12]."---".$oldhour."<br />";
|
||||
if ((($array[$x][14] != $oldmin) or ($array[$x][12] != $oldhour)) and (substr($type,0,13)=="measured-temp"))
|
||||
{
|
||||
$oldmin=$array[$x][14];
|
||||
$oldhour=$array[$x][12];
|
||||
array_push( $_SESSION["arraydata"],array($date,$type,$temp));
|
||||
array_push( $arraydesired,$desired_temp);
|
||||
array_push( $arrayactuator,$actuator);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$resultreverse = array_reverse($_SESSION["arraydata"]);
|
||||
@ -187,7 +206,7 @@ setlocale (LC_ALL, 'de_DE.utf8');
|
||||
$txtcolor=$bg3p;
|
||||
$fontsize=7;
|
||||
$text="min= $mintemp max= $maxtemp";
|
||||
ImageTTFText ($im, $fontsize, 0, 67-$XcorrectMainText, 49, $txtcolor, $fontttf, $text);
|
||||
ImageTTFText ($im, $fontsize, 0, 90-$XcorrectMainText, 49, $txtcolor, $fontttf, $text);
|
||||
|
||||
$text=$txtroom.$room;
|
||||
ImageTTFText ($im, $fontsize, 0, 3, 49, $txtcolor, $fontttf, $text);
|
||||
@ -214,7 +233,8 @@ setlocale (LC_ALL, 'de_DE.utf8');
|
||||
$fontsize=7;
|
||||
$text=$battery;
|
||||
if ($battery == 'none') {$text='Bat: ok';}
|
||||
else {$text='Bat: low'; $txtcolor=$red;}
|
||||
elseif ($battery =='empty') {$text='Bat: low'; $txtcolor=$red;}
|
||||
else {$text='';};
|
||||
ImageTTFText ($im, $fontsize, 0, 165, 10, $txtcolor, $fontttf, $text);
|
||||
$fontsize=7;
|
||||
|
||||
|
@ -2,6 +2,11 @@
|
||||
|
||||
##Functions for pgm3
|
||||
|
||||
### If DB-query is used, this is the only point of connect. ###
|
||||
#if ($DBUse=="1") {
|
||||
# @mysql_connect($DBNode, $DBUser, $DBPass) or die("Can't connect");
|
||||
# @mysql_select_db($DBName) or die("No database found");
|
||||
#}
|
||||
|
||||
function LogRotate($array,$file,$logrotatelines)
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
################
|
||||
|
||||
|
||||
function drawgnuplot($gnudraw,$gnutyp,$gnuplot,$pictype,$logpath,$FHTyrange,$FHTy2range)
|
||||
function drawgnuplot($gnudraw,$gnutyp,$gnuplot,$pictype,$logpath,$FHTyrange,$FHTy2range,$DBUse)
|
||||
{
|
||||
|
||||
if ($gnutyp=="userdef")
|
||||
@ -33,6 +33,19 @@ function drawgnuplot($gnudraw,$gnutyp,$gnuplot,$pictype,$logpath,$FHTyrange,$FHT
|
||||
$IN="$gnudraw ($gnutyp)";
|
||||
|
||||
}
|
||||
|
||||
|
||||
### DBUse for
|
||||
if ($DBUse == '1' and ( $gnutyp=='FHT' or $gnutyp=='HMS100T' or $gnutyp=='HMS100TF' or $gnutyp=='CUL_WS' or $gnutyp=='KS300_t1' or $gnutyp=='KS300_t2' or $gnutyp=='WS300_t1' or $gnutyp=='WS300_t2'))
|
||||
{
|
||||
include "config.php";
|
||||
$logfile="tmp/".$gnudraw.".log";
|
||||
$f1=fopen($logfile,"w+");
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
$gnudraw1=$gnudraw.'1';
|
||||
$OUT1="set output 'tmp/$gnudraw.$pictype'";
|
||||
$OUT2="set output 'tmp/$gnudraw1.$pictype'";
|
||||
@ -47,17 +60,26 @@ $gplothdr="
|
||||
set title '$IN'
|
||||
set grid
|
||||
";
|
||||
|
||||
|
||||
$datumtomorrow= mktime (0,0,0,date("m") ,date("d")+1,date("Y"));
|
||||
$xrange1= date ("Y-m-d",$datumtomorrow);
|
||||
$datumyesterday= mktime (0,0,0,date("m") ,date("d")-1,date("Y"));
|
||||
$datumweek= mktime (0,0,0,date("m") ,date("d")-6,date("Y"));
|
||||
$xrange2= date ("Y-m-d",$datumyesterday);
|
||||
$xrange="set xrange ['$xrange2':'$xrange1']
|
||||
";
|
||||
$xrange3= date ("Y-m-d",$datumweek);
|
||||
$xrange="set xrange ['$xrange2':'$xrange1'] ";
|
||||
$xrangeweek="set xrange ['$xrange3':'$xrange1'] ";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
switch ($gnutyp):
|
||||
Case FS20: ############################################
|
||||
$gplotmain=<<<EOD
|
||||
|
||||
set size 1,0.5
|
||||
set noytics
|
||||
set noy2tics
|
||||
@ -65,10 +87,24 @@ set yrange [-0.2:1.2]
|
||||
set ylabel "On/Off"
|
||||
plot "< awk '{print $1, $3==\"on\"? 1 : $3==\"dimup\"? 1 : $3==\"dimdown\"? 0 : $3==\"off\"? 0 : 0.5;}' $logfile" using 1:2 title '' with steps
|
||||
EOD;
|
||||
#plot "< awk '{print $1, $3==\"on\"? 1 : $3==\"dimup\"? 0.8 : $3==\"dimdown\"? 0.2 : $3==\"off\"? 0 : 0.5;}' $logfile" using 1:2 title '' with steps
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Case WS300_t1: ############################################
|
||||
if ($DBUse==1)
|
||||
{
|
||||
$sqlarray=mysql_query("select timestamp,reading,value from history where device='".$gnudraw."' and reading='data' order by timestamp desc limit ".$logrotateKS300lines."") or die (mysql_error());
|
||||
while ($row = mysql_fetch_object($sqlarray)) {
|
||||
$date=str_replace(" ","_",$row->timestamp);
|
||||
fputs($f1,"$date $gnudraw $row->value\n");
|
||||
}
|
||||
fclose($f1);
|
||||
}
|
||||
$gplotmain="
|
||||
set ylabel 'Temperature (Celsius)'
|
||||
set y2label 'Humidity (%)'
|
||||
@ -77,7 +113,21 @@ break;
|
||||
";
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Case WS300_t2: ############################################
|
||||
if ($DBUse==1)
|
||||
{
|
||||
$sqlarray=mysql_query("select timestamp,reading,value from history where device='".$gnudraw."' and reading='data' order by timestamp desc limit ".$logrotateKS300lines."") or die (mysql_error());
|
||||
while ($row = mysql_fetch_object($sqlarray)) {
|
||||
$date=str_replace(" ","_",$row->timestamp);
|
||||
fputs($f1,"$date $gnudraw $row->value\n");
|
||||
}
|
||||
fclose($f1);
|
||||
}
|
||||
$gplotmain=<<<EOD
|
||||
set ylabel "Air Pressure (hPa)"
|
||||
set y2label "Willi"
|
||||
@ -86,7 +136,21 @@ plot "< grep -v avg $logfile" using 1:8 axes x1y1 title 'Air Pressure' with line
|
||||
EOD;
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Case KS300_t1: ############################################
|
||||
if ($DBUse==1)
|
||||
{
|
||||
$sqlarray=mysql_query("select timestamp,reading,value from history where device='".$gnudraw."' and reading='data' order by timestamp desc limit ".$logrotateKS300lines."") or die (mysql_error());
|
||||
while ($row = mysql_fetch_object($sqlarray)) {
|
||||
$date=str_replace(" ","_",$row->timestamp);
|
||||
fputs($f1,"$date $gnudraw $row->value\n");
|
||||
}
|
||||
fclose($f1);
|
||||
}
|
||||
$gplotmain="
|
||||
set ylabel 'Temperature (Celsius)'
|
||||
set y2label 'Humidity (%)'
|
||||
@ -95,16 +159,44 @@ EOD;
|
||||
";
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Case KS300_t2: ############################################
|
||||
$gplotmain=<<<EOD
|
||||
set ylabel "Wind (Km/h)"
|
||||
set y2label "Rain (l/m2)"
|
||||
plot "< grep -v avg $logfile" using 1:8 axes x1y1 title 'Wind' with lines, \
|
||||
"< grep -v avg $logfile" using 1:10 axes x1y2 title 'Rain' with lines
|
||||
EOD;
|
||||
if ($DBUse==1)
|
||||
{
|
||||
$sqlarray=mysql_query("select timestamp,reading,value from history where device='".$gnudraw."' and reading='data' order by timestamp desc limit ".$logrotateKS300lines."") or die (mysql_error());
|
||||
while ($row = mysql_fetch_object($sqlarray)) {
|
||||
$date=str_replace(" ","_",$row->timestamp);
|
||||
fputs($f1,"$date $gnudraw $row->value\n");
|
||||
}
|
||||
fclose($f1);
|
||||
}
|
||||
$gplotmain="
|
||||
set ylabel 'Wind (Km/h)'
|
||||
set y2label 'Rain (l/m2)'
|
||||
plot '$logfile' using 1:8 axes x1y1 title 'Wind' with lines, \
|
||||
'$logfile' using 1:10 axes x1y2 title 'Rain' with lines
|
||||
";
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Case FHT: ############################################
|
||||
if ($DBUse==1)
|
||||
{
|
||||
$sqlarray=mysql_query("select timestamp,reading,value from history where device='".$gnudraw."' order by timestamp desc limit ".$logrotateFHTlines."") or die (mysql_error());
|
||||
while ($row = mysql_fetch_object($sqlarray)) {
|
||||
$date=str_replace(" ","_",$row->timestamp);
|
||||
fputs($f1,"$date $gnudraw $row->reading $row->value\n");
|
||||
}
|
||||
fclose($f1);
|
||||
}
|
||||
|
||||
|
||||
$gplotmain="
|
||||
set ylabel 'Temperature (Celsius)'
|
||||
set yrange [$FHTyrange]
|
||||
@ -136,6 +228,15 @@ EOD;
|
||||
break;
|
||||
|
||||
Case HMS100T: ############################################
|
||||
if ($DBUse==1)
|
||||
{
|
||||
$sqlarray=mysql_query("select timestamp,reading,value from history where device='".$gnudraw."' and reading='data' and type='HMS' order by timestamp desc limit ".$logrotateHMSlines."") or die (mysql_error());
|
||||
while ($row = mysql_fetch_object($sqlarray)) {
|
||||
$date=str_replace(" ","_",$row->timestamp);
|
||||
fputs($f1,"$date $gnudraw $row->value\n");
|
||||
}
|
||||
fclose($f1);
|
||||
}
|
||||
$gplotmain="
|
||||
set ylabel 'Temperature (Celsius)'
|
||||
plot '$logfile' using 1:4 axes x1y1 title 'Temperature' with lines lw 2
|
||||
@ -166,6 +267,16 @@ EOD;
|
||||
|
||||
Case HMS100TF: ############################################
|
||||
Case CUL_WS: ############################################
|
||||
if ($DBUse==1)
|
||||
{
|
||||
$sqlarray=mysql_query("select timestamp,reading,value from history where device='".$gnudraw."' and reading='data' and (type='HMS' or type='CUL_WS') order by timestamp desc limit ".$logrotateHMSlines."") or die (mysql_error());
|
||||
while ($row = mysql_fetch_object($sqlarray)) {
|
||||
$date=str_replace(" ","_",$row->timestamp);
|
||||
fputs($f1,"$date $gnudraw $row->value\n");
|
||||
}
|
||||
fclose($f1);
|
||||
}
|
||||
|
||||
$gplotmain="
|
||||
set ylabel 'Temperature (Celsius)'
|
||||
set y2label 'Humidity (%)'
|
||||
@ -176,10 +287,13 @@ EOD;
|
||||
default:
|
||||
endswitch;
|
||||
|
||||
$message=$OUT1.$gplothdr.$gplotmain;
|
||||
$f1=fopen("tmp/gnu1","w+");
|
||||
fputs($f1,$message);
|
||||
fclose($f1);
|
||||
|
||||
|
||||
|
||||
$message=$OUT1.$gplothdr.$xrangeweek.$gplotmain;
|
||||
$f3=fopen("tmp/gnu1","w+");
|
||||
fputs($f3,$message);
|
||||
fclose($f3);
|
||||
exec("$gnuplot tmp/gnu1",$output);
|
||||
|
||||
$message=$OUT2.$gplothdr.$xrange.$gplotmain;
|
||||
|
@ -17,11 +17,21 @@ $type=$_GET['type'];
|
||||
$battery=$_GET['battery'];
|
||||
$supported_HMS= array('HMS100T','HMS100TF','HMS100WD','HMS100MG','HMS100TFK','HMS100W','RM100-2','HMS100CO','CUL_WS');
|
||||
|
||||
|
||||
#Supported Device. Use UserDefs if you have other devices
|
||||
if (! in_array($type,$supported_HMS)) show_error_type($imgmaxxhms,$imgmaxyhms,$type);
|
||||
|
||||
|
||||
|
||||
if ($DBUse=="1") {
|
||||
$sqlquery=mysql_query("select timestamp from history where device='".$drawhms."' and reading='data' order by timestamp desc limit 1");
|
||||
$query=mysql_fetch_object($sqlquery);
|
||||
$date=str_replace(" ","_",$query->timestamp);
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
$file="$logpath/$drawhms.log";
|
||||
if (! in_array($type,$supported_HMS)) show_error_type($imgmaxxhms,$imgmaxyhms,$type);
|
||||
if (! file_exists($file)) show_error($file,$drawhms,$imgmaxxhms,$imgmaxyhms,$type);
|
||||
|
||||
## do we really need a new graphic??
|
||||
@ -29,20 +39,21 @@ $supported_HMS= array('HMS100T','HMS100TF','HMS100WD','HMS100MG','HMS100TFK','HM
|
||||
exec($execorder,$tail1);
|
||||
$parts = explode(" ", $tail1[0]);
|
||||
$date=$parts[0];
|
||||
|
||||
} #DBUse
|
||||
|
||||
|
||||
$savefile=$AbsolutPath."/tmp/HMS.".$drawhms.".log.".$parts[0].".png";
|
||||
$savefile=$AbsolutPath."/tmp/HMS.".$drawhms.".log.".$date.".png";
|
||||
|
||||
if (file_exists($savefile)) {
|
||||
|
||||
#echo "exists: $savefile"; exit;
|
||||
$im2 = @ImageCreateFromPNG($savefile);
|
||||
header("Content-type: image/png");
|
||||
imagePng($im2);
|
||||
exit; # ;-)))
|
||||
exit; # ;-))) we do not need a new graphic
|
||||
}
|
||||
else #delete old pngs
|
||||
{
|
||||
#echo "not exist: $savefile"; exit;
|
||||
$delfile=$AbsolutPath."/tmp/HMS.".$drawhms.".log.*.png";
|
||||
foreach (glob($delfile) as $filename) {
|
||||
unlink($filename);
|
||||
@ -70,7 +81,21 @@ $supported_HMS= array('HMS100T','HMS100TF','HMS100WD','HMS100MG','HMS100TFK','HM
|
||||
ImageFill($im, 0, 0, $bg2p);
|
||||
ImageRectangle($im, 0, 0, $imgmaxxhms-1, $imgmaxyhms-1, $white);
|
||||
|
||||
$array = file($file);
|
||||
|
||||
if ($DBUse=="1")
|
||||
{
|
||||
$array=array();
|
||||
$sqlarray=mysql_query("select timestamp,event from history where device='".$drawhms."' and reading='data' order by timestamp desc limit ".$logrotateHMSlines."") or die (mysql_error());
|
||||
while ( $row=mysql_fetch_object($sqlarray))
|
||||
{
|
||||
$date=str_replace(" ","_",$row->timestamp);
|
||||
array_push($array,$date.' '.$drawhms.' '.$row->event);
|
||||
}
|
||||
$array=array_reverse($array);
|
||||
}
|
||||
else $array = file($file);
|
||||
|
||||
|
||||
$oldmin=0; //only the data from every 10min
|
||||
$oldhour=0; //only the data from every 10min
|
||||
$mintemp=100;
|
||||
@ -79,7 +104,7 @@ $supported_HMS= array('HMS100T','HMS100TF','HMS100WD','HMS100MG','HMS100TFK','HM
|
||||
#if ($maxcountHMS < $counter) {$counter=$maxcountHMS;};
|
||||
|
||||
#Logrotate
|
||||
if ((($logrotateHMSlines+100) < $counter) and ($logrotate == 'yes')) LogRotate($array,$file,$logrotateHMSlines);
|
||||
if ((($logrotateHMSlines+100) < $counter) and ($logrotate == 'yes') and ($DBUse!="1")) LogRotate($array,$file,$logrotateHMSlines);
|
||||
|
||||
#print_r($array[1]);
|
||||
#print_r($array[1][12]); exit;
|
||||
@ -243,7 +268,7 @@ if ( $type == "HMS100TF" and $showdewpoint=='yes' )
|
||||
$fontsize=7;
|
||||
$text='Bat: '.$battery;
|
||||
if ($type=="CUL_WS") $text="";
|
||||
if ($battery != 'ok') {$txtcolor=$red; $text='Bat: low';};
|
||||
if ($battery == 'empty') {$txtcolor=$red; $text='Bat: low';};
|
||||
ImageTTFText ($im, $fontsize, 0, 105, 10, $txtcolor, $fontttf, $text);
|
||||
$fontsize=7;
|
||||
$txtcolor=$bg3p;
|
||||
|
@ -14,6 +14,15 @@ $room=$_GET['room'];
|
||||
$avgday=$_GET['avgday'];
|
||||
$avgmonth=$_GET['avgmonth'];
|
||||
|
||||
|
||||
if ($DBUse=="1") {
|
||||
$sqlquery=mysql_query("select timestamp from history where device='".$drawks."' order by timestamp desc limit 1");
|
||||
$query=mysql_fetch_object($sqlquery);
|
||||
$date=str_replace(" ","_",$query->timestamp);
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
$file="$logpath/$drawks.log";
|
||||
if (! file_exists($file)) show_error($file,$drawks,$imgmaxxks,$imgmaxyks);
|
||||
|
||||
@ -21,9 +30,12 @@ $avgmonth=$_GET['avgmonth'];
|
||||
$execorder=$tailpath.' -1 '.$file;
|
||||
exec($execorder,$tail1);
|
||||
$parts = explode(" ", $tail1[0]);
|
||||
$date=$parts[0];
|
||||
} #dbuse
|
||||
|
||||
|
||||
$savefile=$AbsolutPath."/tmp/KS.".$drawks.".log.".$parts[0].".png";
|
||||
#if the expected graphic already exist then do not redraw the picture
|
||||
$savefile=$AbsolutPath."/tmp/KS.".$drawks.".log.".$date.".png";
|
||||
if (file_exists($savefile)) {
|
||||
|
||||
$im2 = @ImageCreateFromPNG($savefile);
|
||||
@ -66,7 +78,24 @@ $avgmonth=$_GET['avgmonth'];
|
||||
ImageFill($im, 0, 0, $bg2p);
|
||||
ImageRectangle($im, 0, 0, $imgmaxxks-1, $imgmaxyks-1, $white);
|
||||
|
||||
$array = file($file);
|
||||
if ($DBUse=="1")
|
||||
{
|
||||
$array=array();
|
||||
$sqlarray=mysql_query("select timestamp,event from history where device='".$drawks."' and reading='data' order by timestamp desc limit ".$logrotateKS300lines."") or die (mysql_error());
|
||||
while ( $row=mysql_fetch_object($sqlarray))
|
||||
{
|
||||
$date=str_replace(" ","_",$row->timestamp);
|
||||
array_push($array,$date.' '.$drawks.' '.$row->event);
|
||||
}
|
||||
$array=array_reverse($array);
|
||||
#print_r($array); #debug
|
||||
#exit;
|
||||
}
|
||||
|
||||
else $array = file($file);
|
||||
|
||||
|
||||
|
||||
$oldmin=0; //only the data from every 10min
|
||||
$oldhour=0; //only the data from every 10min
|
||||
$mintemp=100;
|
||||
@ -74,7 +103,7 @@ $avgmonth=$_GET['avgmonth'];
|
||||
$counter=count($array);
|
||||
|
||||
#Logrotate
|
||||
if ((($logrotateKS300lines+200) < $counter) and ($logrotate == 'yes')) LogRotate($array,$file,$logrotateKS300lines);
|
||||
if ((($logrotateKS300lines+200) < $counter) and ($logrotate == 'yes') and ($DBUse!="1")) LogRotate($array,$file,$logrotateKS300lines);
|
||||
|
||||
# go
|
||||
for ($x = 0; $x < $counter; $x++)
|
||||
|
@ -41,8 +41,10 @@ include "include/gnuplot.php";
|
||||
include "include/functions.php";
|
||||
|
||||
|
||||
$pgm3version='100108';
|
||||
$pgm3version='100312';
|
||||
|
||||
|
||||
|
||||
$Action = $_POST['Action'];
|
||||
$order = $_POST['order'];
|
||||
$showfht = $_POST['showfht'];
|
||||
@ -388,11 +390,12 @@ xml_parser_free($xml_parser);
|
||||
|
||||
|
||||
|
||||
#################################################### HMS
|
||||
#################################################### HMS and CUL_WS
|
||||
|
||||
|
||||
|
||||
elseif (substr($stack[0][children][$i][name],0,4)=='HMS_')
|
||||
elseif ((substr($stack[0][children][$i][name],0,4)=='HMS_') || (substr($stack[0][children][$i][name],0,7)=='CUL_WS_'))
|
||||
|
||||
{
|
||||
for($j=0; $j < count($stack[0][children][$i][children]); $j++)
|
||||
{
|
||||
@ -404,7 +407,7 @@ xml_parser_free($xml_parser);
|
||||
}
|
||||
}
|
||||
}
|
||||
} # HMS
|
||||
} # HMS and CUL_WS
|
||||
|
||||
#################################################### LogpathFileLOG
|
||||
|
||||
@ -753,7 +756,7 @@ ht><font $fontcolor1><b>
|
||||
echo "</td></tr>\r";
|
||||
if (isset($showfs20) and $showgnuplot == 1)
|
||||
{
|
||||
drawgnuplot($showfs20,"FS20",$gnuplot,$pictype,$logpath, $FHTyrange,$FHTy2range);
|
||||
drawgnuplot($showfs20,"FS20",$gnuplot,$pictype,$logpath, $FHTyrange,$FHTy2range,$DBUse);
|
||||
$FS20dev1=$showfs20.'1';
|
||||
echo "\r<tr><td colspan=5 align=center><img src='tmp/$showfs20.$pictype'><br>
|
||||
<img src='tmp/$FS20dev1.$pictype'>
|
||||
@ -819,7 +822,7 @@ ht><font $fontcolor1><b>
|
||||
|
||||
if ($showfht==$FHTdev and $showgnuplot == 1)
|
||||
{
|
||||
drawgnuplot($FHTdev,"FHT",$gnuplot,$pictype,$logpath, $FHTyrange,$FHTy2range);
|
||||
drawgnuplot($FHTdev,"FHT",$gnuplot,$pictype,$logpath, $FHTyrange,$FHTy2range,$DBUse);
|
||||
$FHTdev1=$FHTdev.'1';
|
||||
echo "\r<tr><td colspan=5 align=center><img src='tmp/$FHTdev.$pictype'><br>
|
||||
<img src='tmp/$FHTdev1.$pictype'>
|
||||
@ -893,7 +896,7 @@ ht><font $fontcolor1><b>
|
||||
echo "<img src='include/hms100.php?drawhms=$HMSdev&room=$room&type=$type&battery=$battery' width='$imgmaxxhms' height='$imgmaxyhms'></td> </tr>";
|
||||
|
||||
if ($showhmsgnu == $HMSdev and $showgnuplot == 1)
|
||||
{ drawgnuplot($HMSdev,$type,$gnuplot,$pictype,$logpath,0,0);
|
||||
{ drawgnuplot($HMSdev,$type,$gnuplot,$pictype,$logpath,0,0,$DBUse);
|
||||
$HMSdev1=$HMSdev.'1';
|
||||
echo "\r<tr><td colspan=5 align=center><img src='tmp/$HMSdev.$pictype'><br>
|
||||
<img src='tmp/$HMSdev1.$pictype'>
|
||||
@ -967,11 +970,11 @@ ht><font $fontcolor1><b>
|
||||
{
|
||||
if ($kstyp=="1")
|
||||
{
|
||||
drawgnuplot($KSdev,$drawtype."_t1",$gnuplot,$pictype,$logpath,0,0);
|
||||
drawgnuplot($KSdev,$drawtype."_t1",$gnuplot,$pictype,$logpath,0,0,$DBUse);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawgnuplot($KSdev,$drawtype."_t2",$gnuplot,$pictype,$logpath,0,0);
|
||||
drawgnuplot($KSdev,$drawtype."_t2",$gnuplot,$pictype,$logpath,0,0,$DBUse);
|
||||
}
|
||||
$KSdev1=$KSdev.'1';
|
||||
echo "\r<tr><td colspan=5 align=center><img src='tmp/$KSdev.$pictype'><br>
|
||||
@ -1106,7 +1109,7 @@ ht><font $fontcolor1><b>
|
||||
echo "\r<img src='include/userdefs.php?userdefnr=$i' width='$imgmaxxuserdef' height='$imgmaxyuserdef'></td> </tr>";
|
||||
|
||||
if ($showuserdefgnu == $UserDef and $showgnuplot == 1)
|
||||
{ drawgnuplot($UserDef,$type,$gnuplot,$pictype,$logpath,$userdef[$i],$i);
|
||||
{ drawgnuplot($UserDef,$type,$gnuplot,$pictype,$logpath,$userdef[$i],$i,$DBUse);
|
||||
$UserDef1=$UserDef.'1';
|
||||
echo "\r<tr><td colspan=5 align=center><img src='tmp/$UserDef.$pictype'><br>
|
||||
<img src='tmp/$UserDef1.$pictype'>
|
||||
|
Loading…
x
Reference in New Issue
Block a user