ServerId = $ServerId; $this->MeasureId = $MeasureId; $this->PeriodList = array( array('Name' => 'Hodina', 'Period' => 60 * 60), array('Name' => 'Den', 'Period' => 60 * 60 * 24), array('Name' => 'Týden', 'Period' => 60 * 60 * 24 * 7), array('Name' => 'Měsíc', 'Period' => 60 * 60 * 24 * 30), array('Name' => 'Rok', 'Period' => 60 * 60 * 24 * 365), array('Name' => 'Desetiletí', 'Period' => 60 * 60 * 24 * 3650), ); } function AddValue($Value) { $Time = time(); foreach($this->PeriodList as $Index => $Period) { $Resolution = $this->Resolution; if($Resolution > ($Period['Period'] / 60)) $Resolution = $Period['Period'] / 60; $PeriodTime = floor(floor($Time * $Resolution / $Period['Period']) * $Period['Period'] / $Resolution); $PeriodTimeStart = floor((floor($Time / $Period['Period'] * $Resolution) - 1) * $Period['Period'] / $Resolution); //echo($PeriodTimeStart.' - '.$PeriodTime.' = '.($PeriodTime - $PeriodTimeStart).', '); if($Index == 0) { $ValueMinimum = $Value; $ValueAverage = $Value; $ValueMaximum = $Value; } else { $DbResult = $this->Database->query('SELECT MIN(`Minimum`), AVG(`Average`), MAX(`Maximum`) FROM `History` WHERE `Server`='.$this->ServerId.' AND `Measure`='.$this->MeasureId.' AND `Period`='.($Index - 1).' AND `Time` > '.$PeriodTimeStart.' AND `Time` <= '.$PeriodTime); $Value = $DbResult->fetch_row(); $ValueMinimum = $Value[0]; $ValueAverage = $Value[1]; $ValueMaximum = $Value[2]; } $this->Database->replace('History', array('Time' => $PeriodTime, 'Period' => $Index, 'Server' => $this->ServerId, 'Measure' => $this->MeasureId, 'Minimum' => $ValueMinimum, 'Average' => $ValueAverage, 'Maximum' => $ValueMaximum)); } // echo("\n"); } function GetImage($Width, $Height) { } }