public function __construct(TESTReader &$reader, OPTIONS &$opts, &$items, INTERVAL &$ivl, $resample) { $period = $opts->Get('period'); $this->multiplier = $reader->GetFractionalMultiplier($period); $this->period = $this->multiplier * $period; $this->resample = $this->multiplier * $resample; $from = $this->multiplier * $ivl->GetWindowStart(); $ifrom = ceil($from); $rem = $ifrom % $this->period; if ($rem) { $this->from = $ifrom + ($this->period - $rem); } else { $this->from = $ifrom; } $this->to = $this->multiplier * $ivl->GetWindowEnd(); $limit = $ivl->GetItemLimit(); if ($limit) { if ($limit > 0) { $to = $this->from + $this->period * $limit; if ($to < $this->to) { $this->to = $to; } } else { $from = $this->to + $this->period * $limit; if ($from > $this->from) { $this->from = $from; } } } $this->items =& $items; $limit = $opts->GetDateLimit(TESTData::DEFAULT_START, time()); $this->start = $limit[0]; }
protected function ExportData(DATAHandler $h = NULL, LOGGROUP $grp, MASK $mask, INTERVAL $ivl = NULL, $resample = 0, array &$names, $opts = 0, $dmcb = NULL) { global $DEFAULT_MISSING_VALUE; $dm = new DOWNLOADMANAGER(); if (!$h) { $h = new CSVHandler(); } $filter = $this->CreateDataFilter($grp, $mask, $resample, $ivl->GetItemLimit()); if (!$h->nullwriter) { $filter->AddFilter(new NULLCorrector($this->GetGroupOption($grp, "null_value", $DEFAULT_MISSING_VALUE))); } $data = $this->GetFilteredData($grp, $ivl->GetWindowStart(), $ivl->GetWindowEnd(), $filter); $columns = sizeof($names); $h->Start($columns); $h->DataHeaders($names); if ($dmcb != NULL) { $action = "start"; $current_time = $ivl->GetWindowStart(); $onepercent = ($ivl->GetWindowEnd() - $ivl->GetWindowStart()) / 100; $download = call_user_func_array($dmcb, array($action, "")); } foreach ($data as $time => $row) { $h->DataVector($time, $row); if ($dmcb != NULL) { $action = "progress"; $thisupdate = time(); $updateinterval = $thisupdate - $lastupdate; if ($time >= $current_time + $onepercent && $updateinterval >= 2) { $current_time = $time; $lastupdate = time(); $prog = round(($time - $ivl->GetWindowStart()) / $onepercent, 0); if (!call_user_func_array($dmcb, array($action, $prog, $download))) { $action = "finish"; call_user_func_array($dmcb, array($action, "cancelled")); unset($dmcb); break; } } } } if ($dmcb != NULL) { $action = "finish"; call_user_func_array($dmcb, array($action, "", $download)); } $h->End(); }
public function __construct(RRDReader &$reader, OPTIONS &$opts, &$items, INTERVAL &$ivl, $resample) { parent::__construct($props); $data_start = $opts->Get('data_start'); $data_start = date("F j, Y", $data_start); $this->period = $opts->Get('step'); $this->file = $reader->rrd_folder . "/" . $reader->rrd_prefix . $opts->Get('file') . ".rrd"; $this->info = $reader::GetRRDInfo($opts->Get('file'), $reader); //get information on the rrd and its archives $this->resample = $resample; $from = $ivl->GetWindowStart(); $ifrom = ceil($from); //get start point as integer $rem = $ifrom % $this->period; //checks whether start point as integer is a multiple of period if ($rem) { $this->from = $ifrom + ($this->period - $rem); } else { $this->from = $ifrom; } //if yes, from is ifrom $this->pos = $this->from; $this->to = $ivl->GetWindowEnd(); $limit = $ivl->GetItemLimit(); //get interval's item limit, if any (defines how many datapoints to show and adjusts to or from based on that?) if ($limit) { if ($limit > 0) { $to = $this->from + $this->period * $limit; if ($to < $this->to) { $this->to = $to; } } else { $from = $this->to + $this->period * $limit; if ($from > $this->from) { $this->from = $from; } } } $this->items =& $items; //items to show (rra:s in this case) //this sets the caching starting point based on the longest rra:s datapoints $limit = $opts->GetDateLimit($data_start, time()); //$limit = $opts->GetDateLimit($this::DEFAULT_START, time());//gets the window limits (as in, the first and last possible timestamp values) $this->start = $limit[0]; }