Ignore:
Timestamp:
Feb 11, 2015, 10:59:24 PM (10 years ago)
Author:
chronos
Message:
  • Modified: Collect values from 6 readouts and use only median value.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/temp/meteo/load_meteo.php

    r548 r733  
    4949    $this->Data = $Data;
    5050  }
    51  
     51
    5252  function SaveDataToDb()
    5353  {
     
    106106}
    107107
     108function median($Array)
     109{
     110  return($Array[count($Array) / 2]);
     111}
     112
    108113$Meteo = new MeteoStation();
    109114$Meteo->URL = 'http://meteo-koliba.zdechov.net/status.xml';
     
    112117$URL = 'http://stat.zdechov.net/meteo/add.php';
    113118$I = 0;
     119$Collect = array();
    114120while(1)
    115121{
    116122  $Meteo->DownloadData();
    117123  $Meteo->CreateImage('koliba.png');
     124  foreach($Meteo->Data as $Index => $Item)
     125  {
     126    $Collect[$Index][] = $Item;
     127  }
    118128  if(($I % 6) == 0)
    119129  {
    120     file_get_contents($URL.'?MeasureId=28&Value='.$Meteo->Data['Temperature']);
    121     file_get_contents($URL.'?MeasureId=29&Value='.$Meteo->Data['AbsHumidity']);
    122     file_get_contents($URL.'?MeasureId=30&Value='.$Meteo->Data['BarAltitude']);
    123     file_get_contents($URL.'?MeasureId=31&Value='.$Meteo->Data['DewPoint']);
    124     file_get_contents($URL.'?MeasureId=32&Value='.$Meteo->Data['Pressure']);
    125     file_get_contents($URL.'?MeasureId=33&Value='.$Meteo->Data['RelHumidity']);
    126     file_get_contents($URL.'?MeasureId=34&Value='.$Meteo->Data['SysTemp']);
    127     file_get_contents($URL.'?MeasureId=35&Value='.$Meteo->Data['WindChill']);
    128     file_get_contents($URL.'?MeasureId=36&Value='.$Meteo->Data['WindDir']);
    129     file_get_contents($URL.'?MeasureId=37&Value='.$Meteo->Data['WindGust']);
    130     file_get_contents($URL.'?MeasureId=38&Value='.$Meteo->Data['WindSpeed']);
     130    foreach($Collect as $Index => $Item)
     131    {
     132      sort($Collect[$Index]);   
     133    }
     134    file_get_contents($URL.'?MeasureId=28&Value='.median($Collect['Temperature']));
     135    file_get_contents($URL.'?MeasureId=29&Value='.median($Collect['AbsHumidity']));
     136    file_get_contents($URL.'?MeasureId=30&Value='.median($Collect['BarAltitude']));
     137    file_get_contents($URL.'?MeasureId=31&Value='.median($Collect['DewPoint']));
     138    file_get_contents($URL.'?MeasureId=32&Value='.median($Collect['Pressure']));
     139    file_get_contents($URL.'?MeasureId=33&Value='.median($Collect['RelHumidity']));
     140    file_get_contents($URL.'?MeasureId=34&Value='.median($Collect['SysTemp']));
     141    file_get_contents($URL.'?MeasureId=35&Value='.median($Collect['WindChill']));
     142    file_get_contents($URL.'?MeasureId=36&Value='.median($Collect['WindDir']));
     143    file_get_contents($URL.'?MeasureId=37&Value='.median($Collect['WindGust']));
     144    file_get_contents($URL.'?MeasureId=38&Value='.median($Collect['WindSpeed']));
     145    $Collect = array();
    131146  }
    132147  sleep(10);
Note: See TracChangeset for help on using the changeset viewer.