Zeig mal deinen PHP-Code bitte.
Hallo,
hat ein bißchen gedauert!
Hier der Code.
Gruss
P.s. Sorry, aber ich konnte kein Anhang hochladen!
<?php
# -----------------------------------------------------
# Datei: update.php
# -----------------------------------------------------
# Beschreibung:
# Holt AVR-Werte und schreibt sie in eine Datenbank oder woanders hin
# -----------------------------------------------------
echo'<meta http-equiv="refresh" content="15; URL=http://meineHomepage/thermometer.php\">';
// Funktion zum Auslesen der Daten aus einer Webpage
function getAVRNetIOValue($id) {
$value = NULL;
error_reporting(0);
$avr_net_io = fopen("http://meineHomepage/daten.htm", "r") or die("Die Werte des AVR-Webservers konnten nicht ermittelt werden!<BR>Entweder ist der AVR-webserver offline oder loop´t im Nirvana!");
if ($avr_net_io!=false) {
while ( ($data = fgetcsv($avr_net_io, 1000, "=")) !== FALSE ) {
$num = count($data);
$row++;
if ($data[0] == $id) {
$value = $data[1];
}
}
fclose($avr_net_io);
}
return $value;
}
// Analoge Werte
$aussen = getAVRNetIOValue("Aussen");
$aussen = 1*$aussen;
$kueche = getAVRNetIOValue("Kueche");
$kueche = 1*$kueche;
$heizung = getAVRNetIOValue("Heizung");
$heizung = 1*$heizung;
$schlaffzimmer = getAVRNetIOValue("Schlaffzimmer");
$schlaffzimmer = 1*$schlaffzimmer;
$felix = getAVRNetIOValue("Felix");
$felix = 1*$felix;
$bad = getAVRNetIOValue("Bad");
$bad = 1*$bad;
$flur = getAVRNetIOValue("flur");
$flur = 1*$flur;
$keller = getAVRNetIOValue("Bastel Keller");
$keller = 1*$keller;
$wohnzimmer = getAVRNetIOValue("Wohnzimmer");
$wohnzimmer = 1*$wohnzimmer;
$Opel_Spannung = getAVRNetIOValue("Opel_Spannung");
$Opel_Spannung = 1*$Opel_Spannung;
$Opel_Spannung1 = getAVRNetIOValue("Opel_Spannung1");
$Opel_Spannung1 = 1*$Opel_Spannung1;
$Opel_Spannung_Ges = getAVRNetIOValue("Opel_Spannung_Gesamt");
$Opel_Temp = getAVRNetIOValue("Opel_Temp");
$Opel_Temp = 1*$Opel_Temp;
if ($Opel_Temp > 100)
{
$flag = 1;
$Opel_Temp = (256 - $Opel_Temp);
}
$stde= getAVRNetIOValue("Stunde");
$stde = 1*$stde;
$mine = getAVRNetIOValue("Minute");
$mine = 1*$mine;
$tage = getAVRNetIOValue("Tag");
$tage = 1*$tage;
$monate = getAVRNetIOValue("Monat");
$monate = 1*$monate;
$jahre = getAVRNetIOValue("Jahr");
$jahre = 1*$jahre;
$heiz_on = getAVRNetIOValue("Heiz_Status");
$heiz_on = 1*$heiz_on;
$abgas_temp = getAVRNetIOValue("Abgas_temp");
$abgas_temp = 1*$abgas_temp;
$brauch_wasser = getAVRNetIOValue("BRwasser_temp");
$brauch_wasser = 1*$brauch_wasser;
//*** noch integrieren
//$brauch_wasser = 33;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++
//$value = $bdata[2];
$root = "c:/xampp/htdocs/";
$svg_template = simplexml_load_file("$root/template.svg");
//*keller
$result = $svg_template->xpath("//*[@id='temp_level_keller']");
if(count($result) == 1) $temp_level_keller = $result[0];
//else exit("Unable to find a node with temp_level_keller ID");
$result = $svg_template->xpath("//*[@id='temp_value_keller']");
if(count($result) == 1) $temp_value_keller = $result[0];
//**aussen
$result = $svg_template->xpath("//*[@id='temp_level_aussen']");
if(count($result) == 1) $temp_level_aussen = $result[0];
$result = $svg_template->xpath("//*[@id='temp_value_aussen']");
if(count($result) == 1) $temp_value_aussen = $result[0];
//**Heizung
$result = $svg_template->xpath("//*[@id='temp_level_heiz']");
if(count($result) == 1) $temp_level_heiz = $result[0];
$result = $svg_template->xpath("//*[@id='temp_value_heiz']");
if(count($result) == 1) $temp_value_heiz = $result[0];
$result = $svg_template->xpath("//*[@id='heiz_an']");
if(count($result) == 1) $heiz_an = $result[0];
$result = $svg_template->xpath("//*[@id='brwasser_temp']");
if(count($result) == 1) $brwasser_temp = $result[0];
$result = $svg_template->xpath("//*[@id='ab_temp']");
if(count($result) == 1) $ab_temp = $result[0];
//**Opel
$result = $svg_template->xpath("//*[@id='opel_volt_1']");
if(count($result) == 1) $opel_volt_1 = $result[0];
$result = $svg_template->xpath("//*[@id='opel_volt_2']");
if(count($result) == 1) $opel_volt_2 = $result[0];
$result = $svg_template->xpath("//*[@id='opel_temp']");
if(count($result) == 1) $opel_temp = $result[0];
$result = $svg_template->xpath("//*[@id='minus']");
if(count($result) == 1) $minus = $result[0];
$result = $svg_template->xpath("//*[@id='hh_ausgabe']");
if(count($result) == 1) $hh_ausgabe = $result[0];
$result = $svg_template->xpath("//*[@id='mm_ausgabe']");
if(count($result) == 1) $mm_ausgabe = $result[0];
$result = $svg_template->xpath("//*[@id='tag']");
if(count($result) == 1) $tag = $result[0];
$result = $svg_template->xpath("//*[@id='monat']");
if(count($result) == 1) $monat = $result[0];
$result = $svg_template->xpath("//*[@id='jahr']");
if(count($result) == 1) $jahr = $result[0];
//**wohn
$result = $svg_template->xpath("//*[@id='temp_level_wohn']");
if(count($result) == 1) $temp_level_wohn = $result[0];
$result = $svg_template->xpath("//*[@id='temp_value_wohn']");
if(count($result) == 1) $temp_value_wohn = $result[0];
//**küche
$result = $svg_template->xpath("//*[@id='temp_level_kueche']");
if(count($result) == 1) $temp_level_kueche = $result[0];
$result = $svg_template->xpath("//*[@id='temp_value_kueche']");
if(count($result) == 1) $temp_value_kueche = $result[0];
//**schlafzimmer
$result = $svg_template->xpath("//*[@id='temp_level_schlaf']");
if(count($result) == 1) $temp_level_schlaf = $result[0];
$result = $svg_template->xpath("//*[@id='temp_value_schlaf']");
if(count($result) == 1) $temp_value_schlaf = $result[0];
//**Badezimmer
$result = $svg_template->xpath("//*[@id='temp_level_bad']");
if(count($result) == 1) $temp_level_bad = $result[0];
$result = $svg_template->xpath("//*[@id='temp_value_bad']");
if(count($result) == 1) $temp_value_bad = $result[0];
//**flur
$result = $svg_template->xpath("//*[@id='temp_level_flur']");
if(count($result) == 1) $temp_level_flur = $result[0];
$result = $svg_template->xpath("//*[@id='temp_value_flur']");
if(count($result) == 1) $temp_value_flur = $result[0];
//**Felix Zimmer
$result = $svg_template->xpath("//*[@id='temp_level_felix']");
if(count($result) == 1) $temp_level_felix = $result[0];
$result = $svg_template->xpath("//*[@id='temp_value_felix']");
if(count($result) == 1) $temp_value_felix = $result[0];
//****Funktionsaufrufe
wert_setzen($temp_level_keller, $keller, 5, 1);
wert_setzen($temp_value_keller, $keller, 5, 1);
wert_setzen($temp_level_wohn, $wohnzimmer, 5, 1);
wert_setzen($temp_value_wohn, $wohnzimmer, 5, 1);
wert_setzen($temp_level_kueche, $kueche, 5, 1);
wert_setzen($temp_value_kueche, $kueche, 5, 1);
wert_setzen($temp_level_schlaf, $schlaffzimmer, 5, 1);
wert_setzen($temp_value_schlaf, $schlaffzimmer, 5, 1);
wert_setzen($temp_level_bad, $bad, 5, 1);
wert_setzen($temp_value_bad, $bad, 5, 1);
wert_setzen($temp_level_flur, $flur, 5, 1);
wert_setzen($temp_value_flur, $flur, 5, 1);
wert_setzen($temp_level_felix, $felix, 5, 1);
wert_setzen($temp_value_felix, $felix, 5, 1);
wert_setzen($temp_value_aussen, $aussen, 5, 1);
wert_setzen($temp_level_aussen, $aussen, 5, 1);
wert_setzen($temp_value_heiz, $heizung, 2.6,1);
wert_setzen($temp_level_heiz, $heizung, 2.6,1);
wert_setzen($opel_temp, $Opel_Temp, 0,1);
wert_setzen($opel_volt_1, $Opel_Spannung, 0, 1);
wert_setzen($opel_volt_2, $Opel_Spannung1, 0, 1);
wert_setzen($brwasser_temp, $brauch_wasser, 5, 1);
wert_setzen($ab_temp, $abgas_temp, 5, 1);
wert_setzen($hh_ausgabe, $stde, 5, 0);
wert_setzen($mm_ausgabe, $mine, 5, 0);
wert_setzen($tag, $tage, 5, 0);
wert_setzen($monat, $monate, 5, 0);
wert_setzen($jahr, $jahre, 5, 0);
///***Abfragen
if ($flag == 1)
{
$minus['style'] = "font-size:32px;fill:#0000ff";
}
if ($heiz_on == 0)
{
$heiz_an['height'] = 30;
}
else
{
$heiz_an['height'] = 0;
}
//****funktion
function wert_setzen($wert_wo, $wert, $faktor, $farb_flag)
{
$wert_wo['height'] = $wert*$faktor ;
$wert_wo[0] = $wert;
if($farb_flag == 1)
{
if($wert < 15) {
$wert_wo['style']="fill:#0000ff;stroke:none";
$wert_wo['style'] = "font-size:32px;fill:#0000ff";
} elseif($wert < 25 && farb_flag == 1) {
$wert_wo['style']="fill:#00ff00;stroke:none";
$wert_wo['style'] = "font-size:32px;fill:#00ff00";
} else {
$wert_wo['style']="fill:#ff0000;stroke:none";
$wert_wo['style'] = "font-size:32px;fill:#ff0000";
}
}
}
header("Content-type: image/svg+xml");
echo $svg_template->asXML();
?>