Exemplo n.º 1
0
 function GetScaleInfo()
 {
     global $GRAPH_MARGINS;
     //$num = $this->graph_axes->GetAxesNumber();
     $aids = array();
     $ymin = array();
     $ymax = array();
     $ylog = array();
     $yzoom = array();
     $colors = array();
     $names = array();
     foreach ($this->graph_axes as $i => $axis) {
         array_push($aids, $axis->aid);
         if ($axis->GetRange()) {
             array_push($yzoom, 1);
         } else {
             array_push($yzoom, 0);
         }
         array_push($colors, $axis->GetColor());
         array_push($names, $axis->GetName());
         array_push($ymin, $this->graph->ynaxis[$i]->scale->GetMinVal());
         array_push($ymax, $this->graph->ynaxis[$i]->scale->GetMaxVal());
         array_push($ylog, $axis->IsLogarithmic() ? 1 : 0);
     }
     return array("xmin" => dsMathPreciseAdd($this->graph->xaxis->scale->scale[0] / $this->scale_coef, $this->scale_start), "xmax" => dsMathPreciseAdd($this->graph->xaxis->scale->scale[1] / $this->scale_coef, $this->scale_start), "imin" => $this->graph_interval->GetIntervalStart(), "imax" => $this->graph_interval->GetIntervalEnd(), "yzoom" => $yzoom, "ymin" => $ymin, "ymax" => $ymax, "ylog" => $ylog, "axis" => $aids, "color" => $colors, "name" => $names, "precision" => $this->precision, "margins" => $this->graph_margin, "axis_size" => $this->graph_yaxis_size);
 }
Exemplo n.º 2
0
 function GetPoint(&$key1, &$ivl1, &$key2, &$ivl2)
 {
     $this->row = array();
     switch ($this->type) {
         case CACHE::TYPE_MEAN:
             if ($this->empty_key) {
                 $nextkey = dsMathPreciseAdd($this->empty_key, $this->expected_gap);
                 if ($nextkey > $key1) {
                     $this->empty_key = false;
                 } else {
                     $this->key = $this->empty_key;
                     $this->row[0] = false;
                     $this->empty_key = $nextkey;
                     return false;
                 }
             }
             $this->missing = 0;
             if ($ivl1) {
                 if ($ivl2 && ($this->flags & CACHE::REPORT_EMPTY || $this->flags & CACHE::MISSING_INFO)) {
                     $key1end = dsMathPreciseAdd($key1, $ivl1['width']);
                     $distance = dsMathPreciseSubstract($key2, $key1end);
                     if ($this->allowed_gap && $distance > $this->allowed_gap) {
                         $this->missing = $distance;
                         if ($this->expected_gap && $distance > 2 * $this->expected_gap) {
                             $this->gaps = true;
                             if ($this->flags & CACHE::REPORT_EMPTY) {
                                 $this->empty_key = dsMathPreciseAdd($key1end, $this->expected_gap);
                             }
                         }
                     }
                 }
                 $ivl =& $ivl1;
                 $this->key = dsMathPreciseAdd($key1, $ivl['width'] / 2);
             } else {
                 $ivl =& $ivl2;
                 $this->key = dsMathPreciseAdd($key2, $ivl['width'] / 2);
             }
             if ($this->allowed_gap && !$this->missing && $ivl['maxgap'] > $this->allowed_gap) {
                 $this->missing = $ivl['maxgap'];
             }
             for ($i = 0; $i < $this->ids; $i++) {
                 $this->row[$i] = $ivl['mean' . $i];
             }
             break;
         case CACHE::TYPE_MINMAX:
             if ($this->started) {
                 $key1end = dsMathPreciseAdd($key1, $ivl1['width']);
                 if ($ivl2) {
                     $distance = dsMathPreciseSubstract($key2, $key1end);
                     if ($this->expected_gap && $distance > 2 * $this->expected_gap) {
                         $this->MINMAXLast($key1end, $ivl1);
                         if ($this->allowed_gap && $distance > $this->allowed_gap) {
                             $this->missing = $distance;
                             $this->gaps = true;
                             if ($this->flags & CACHE::REPORT_EMPTY) {
                                 $this->empty_key = dsMathPreciseAdd($key1end, $this->expected_gap);
                             }
                         }
                         return false;
                     }
                     if ($distance > 0) {
                         $this->MINMAXStep($key1end, $ivl1, $key2, $ivl2);
                     } else {
                         $this->MINMAXStep($key1end = false, $ivl1, $key2, $ivl2);
                     }
                 } else {
                     if ($ivl1) {
                         $this->MINMAXLast($key1end, $ivl1);
                     }
                 }
             } else {
                 if ($ivl2) {
                     if ($this->empty_key) {
                         $nextkey = dsMathPreciseAdd($this->empty_key, $this->expected_gap);
                         if ($nextkey > $key2) {
                             $this->empty_key = false;
                         } else {
                             $this->key = $this->empty_key;
                             $this->row[0] = false;
                             $this->empty_key = $nextkey;
                             return false;
                         }
                     } else {
                         if ($ivl1 && $this->allowed_gap) {
                             $key1end = dsMathPreciseAdd($key1, $ivl1['width']);
                             $distance = dsMathPreciseSubstract($key2, $key1end);
                             if ($distance > $this->allowed_gap) {
                                 $this->gaps = true;
                                 if ($this->flags & CACHE::REPORT_EMPTY) {
                                     $this->empty_key = dsMathPreciseAdd($key1end, $this->expected_gap);
                                     return false;
                                 }
                             }
                         }
                     }
                     if (!$ivl2['width']) {
                         $this->key = $key2;
                         for ($i = 0; $i < $this->ids; $i++) {
                             $this->row[$i] = $ivl2['mean' . $i];
                         }
                         $this->missing = 0;
                         if ($this->flags & CACHE::MISSING_INFO && $this->allowed_gap) {
                             if ($this->interval && $this->interval->valid()) {
                                 $this->row3 = $this->interval->current();
                                 $this->key3 = $this->interval->key();
                                 $this->interval->next();
                                 $distance = dsMathPreciseSubstract($key3, $key2);
                                 if ($distance > $this->allowed_gap) {
                                     $this->missing = $distance;
                                 }
                             }
                         }
                     } else {
                         $this->MINMAXFirst($key2, $ivl2);
                     }
                 } else {
                     /* if not started and no ivl2 - we are done */
                     unset($this->irow);
                 }
             }
             break;
         default:
             throw new ADEIException(translate("Invalid interval aggregation mode (%u) is specified", $this->type));
     }
     return true;
     //    print_r($ivl1);
 }
Exemplo n.º 3
0
 function DataVector(&$time, &$values, $flags = 0)
 {
     if ($this->subseconds) {
         if ($this->time_subsec_format) {
             $val = dsMathPreciseAdd($time, 2209161600.0) / 86400;
             /* 86400 * 25569 */
             $this->sheet->write(++$this->row, 0, $val, $this->xls_time_subsec_format);
         } else {
             $subsec = strchr(sprintf("%.6F", $time), '.');
             $val = date($this->string_format, $time) . $subsec;
             $this->sheet->write(++$this->row, 0, $val);
         }
     } else {
         $val = ($time + 2209161600.0) / 86400;
         /* 86400 * 25569 */
         $this->sheet->write(++$this->row, 0, $val, $this->xls_time_format);
     }
     foreach (array_keys($values) as $i) {
         $this->sheet->write($this->row, $i + 1, $values[$i], $this->xls_data_format);
     }
 }
Exemplo n.º 4
0
 function GetWindowEnd($default = NULL)
 {
     if ($this->IsEmpty()) {
         return 0;
         //throw new ADEIException(translate("INTERVAL window is empty"));
     }
     if ($this->window_start === false) {
         if ($default === NULL) {
             throw new ADEIException(translate("INTERVAL window have undefined start"));
         } else {
             if ($default === true) {
                 return gettimeofday(true);
             }
         }
         return $default;
     }
     if ($this->window_size === false) {
         if ($default === NULL) {
             throw new ADEIException(translate("INTERVAL window have undefined size"));
         } else {
             if ($default === true) {
                 return gettimeofday(true);
             }
         }
         return $default;
     }
     return dsMathPreciseAdd($this->window_start, $this->window_size);
 }
Exemplo n.º 5
0
 function ImportUnixTime($unix_time)
 {
     if (!$unix_time) {
         return 0;
     }
     return dsMathPreciseAdd($unix_time, 2082837600 + 7200);
 }