Changeset 479 for trunk/Modules/Meteostation/Meteostation.php
- Timestamp:
- Feb 5, 2013, 9:45:44 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Meteostation/Meteostation.php
r470 r479 11 11 function Show() 12 12 { 13 return('Stav meteostanice'); 13 $Output = 'Stav meteostanice:<br/>'; 14 $Output .= '<img src="'.$this->System->Link('/Modules/Meteostation/cache/1.png').'" alt="stav meteostanice"/>'; 15 return($Output); 14 16 } 15 17 } 16 18 17 class MeteoStation extends AppModule19 class MeteoStation extends Module 18 20 { 19 var $Data; 21 var $Id; 22 var $Name; 23 var $Period; 24 var $URL; 20 25 21 function __construct($System)26 function DownloadData() 22 27 { 23 parent::__construct($System); 24 $this->Name = 'MeteoStation'; 25 $this->Version = '1.0'; 26 $this->Creator = 'Chronos'; 27 $this->License = 'GNU/GPLv3'; 28 $this->Description = 'Gathering and presentation of data from network meteostation.'; 29 $this->Dependencies = array(); 30 } 31 32 function DownloadData($Id, $URL) 33 { 34 $XmlData = simplexml_load_file($URL); 28 $XmlData = simplexml_load_file($this->URL); 35 29 36 $Data = array('MeteoStation' => $ Id,30 $Data = array('MeteoStation' => $this->Id, 37 31 'WindSpeed' => trim($XmlData->windspeed), 38 32 'WindDir' => trim($XmlData->winddir), … … 58 52 } 59 53 60 function DownloadAll()61 {62 $DbResult = $this->Database->select('MeteoStation', '*');63 while($DbRow = $DbResult->fetch_assoc())64 {65 $this->DownloadData($DbRow['Id'], $DbRow['URL']);66 $this->CreateImage('cache/'.$DbRow['Id'].'.png');67 }68 }69 70 54 function CreateImage($FileName) 71 55 { … … 76 60 //$Image->Font->Color = COLOR_RED; 77 61 //$Image->Line(10, 10, 100, 100); 78 $Image->TextOut(10, 10, 'Meteo Koliba Zděchov');62 $Image->TextOut(10, 10, 'Meteo '.$this->Name); 79 63 $Image->TextOut(10, 30, 'Teplote: '.$this->Data['Temperature'].' °C'); 80 64 $Image->SaveToFile($FileName); 81 65 } 66 67 function LoadFromDb() 68 { 69 $DbResult = $this->Database->select('Meteostation', '*', 'Id = '.$this->Id); 70 $DbRow = $DbResult->fetch_assoc(); 71 $this->Name = $DbRow['Name']; 72 $this->URL = $DbRow['URL']; 73 $this->Period = $DbRow['Period']; 74 } 75 } 76 77 class ModuleMeteoStation extends AppModule 78 { 79 var $Data; 80 81 function __construct($System) 82 { 83 parent::__construct($System); 84 $this->Name = 'MeteoStation'; 85 $this->Version = '1.0'; 86 $this->Creator = 'Chronos'; 87 $this->License = 'GNU/GPLv3'; 88 $this->Description = 'Gathering and presentation of data from network meteostation.'; 89 $this->Dependencies = array(); 90 } 91 92 93 function DownloadAll() 94 { 95 $DbResult = $this->Database->select('MeteoStation', '*'); 96 while($DbRow = $DbResult->fetch_assoc()) 97 { 98 $MeteoStation = new MeteoStation(); 99 $MeteoStation->Id = $DbRow['Id']; 100 $MeteoStation->LoadFromDb(); 101 $MeteoStation->DownloadData(); 102 $MeteoStation->CreateImage('cache/'.$DbRow['Id'].'.png'); 103 } 104 } 105 82 106 83 107 function Install()
Note:
See TracChangeset
for help on using the changeset viewer.