Ignore:
Timestamp:
Dec 9, 2012, 10:44:56 PM (12 years ago)
Author:
chronos
Message:
  • Přidáno: Stahování dat z meteo stanice GIOM 3000.
Location:
trunk/Modules/Meteostation
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Meteostation/Meteostation.php

    r463 r467  
    1111class MeteoStation extends AppModule
    1212{
     13 
    1314  function __construct($Database, $System)
    1415  {
     
    2021    $this->Description = 'Gathering and presentation of data from network meteostation.';
    2122    $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    }
    2259  }
    2360 
Note: See TracChangeset for help on using the changeset viewer.