public function processData($callback) { $this->rows = parent::getData(); $tuples = array(); $last = $this->getFrom(); foreach ($this->rows as $row) { $delta = $row[0] - $last; $tuple = $callback(array((double) $row[0], (double) $row[1] / $row[2], (int) $row[2])); if (is_null($this->max) || $tuple[1] > $this->max[1]) { $this->max = $tuple; } if (is_null($this->min) || $tuple[1] < $this->min[1]) { $this->min = $tuple; } $this->consumption += $tuple[1] * $delta; $tuples[] = $tuple; $last = $row[0]; } return $tuples; }
/** * Raw pulse to power conversion * * @param $callback a callback called each iteration for output * @return array with timestamp, values, and pulse count */ public function processData($callback) { $tuples = array(); $this->rows = parent::getData(); $this->resolution = $this->channel->getProperty('resolution'); $this->pulseCount = 0; $last = $this->getFrom(); foreach ($this->rows as $row) { $delta = $row[0] - $last; $tuple = $callback(array((double) $last, (double) ($row[1] * 3600000000.0) / ($this->resolution * $delta), (int) $row[2])); if (is_null($this->max) || $tuple[1] > $this->max[1]) { $this->max = $tuple; } if (is_null($this->min) || $tuple[1] < $this->min[1]) { $this->min = $tuple; } $this->pulseCount += $row[1]; $tuples[] = $tuple; $last = $row[0]; } return $tuples; }