Changeset 467
- Timestamp:
- Dec 9, 2012, 10:44:56 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/AppModule.php
r463 r467 19 19 var $Manager; 20 20 21 function __construct($Database, $System) 22 { 23 $this->System = &$System; 24 $this->Database = &$Database; 25 } 26 21 27 function Install() 22 28 { -
trunk/Modules/Meteostation/Meteostation.php
r463 r467 11 11 class MeteoStation extends AppModule 12 12 { 13 13 14 function __construct($Database, $System) 14 15 { … … 20 21 $this->Description = 'Gathering and presentation of data from network meteostation.'; 21 22 $this->Dependencies = array(); 23 } 24 25 function DownloadData($Id, $URL) 26 { 27 $XmlData = simplexml_load_file($URL); 28 29 $Data = array('MeteoStation' => $Id, 30 'WindSpeed' => trim($XmlData->windspeed), 31 'WindDir' => trim($XmlData->winddir), 32 'WindGust' => trim($XmlData->windgust), 33 'Pressure' => trim($XmlData->pressure), 34 'SysTemp' => trim($XmlData->systemp), 35 'Temperature' => trim($XmlData->temperature), 36 'BarAltitude' => trim($XmlData->baraltitude), 37 'WindChill' => trim($XmlData->windchill), 38 'RelHumidity' => trim($XmlData->relhumidity), 39 'AbsHumidity' => trim($XmlData->abshumidity), 40 'DewPoint' => trim($XmlData->dewpoint) 41 ); 42 $this->Database->insert('MeteoStationMeasure', array( 43 'Time' => TimeToMysqlDateTime(time()), 'MeteoStation' => $Data['MeteoStation'], 44 'WindSpeed' => $Data['WindSpeed'], 'WindDir' => $Data['WindDir'], 45 'WindGust' => $Data['WindGust'], 'Pressure' => $Data['Pressure'], 46 'SysTemp' => $Data['SysTemp'], 'Temperature' => $Data['Temperature'], 47 'BarAltitude' => $Data['BarAltitude'], 'WindChill' => $Data['WindChill'], 48 'RelHumidity' => $Data['RelHumidity'], 'AbsHumidity' => $Data['AbsHumidity'], 49 'DewPoint' => $Data['DewPoint'])); 50 } 51 52 function DownloadAll() 53 { 54 $DbResult = $this->Database->select('MeteoStation', '*'); 55 while($DbRow = $DbResult->fetch_assoc()) 56 { 57 $this->DownloadData($DbRow['Id'], $DbRow['URL']); 58 } 22 59 } 23 60
Note:
See TracChangeset
for help on using the changeset viewer.