/** * Load data by request parameters and return a JSON encoded string. * * @return array */ protected function _getIntervallData() { $request = $this->getRequest(); $dataModel = new Diagram_Model_IntervallMapper(); $sensor = null; $returnData = array(); $dataModel->setIntervallType($this->_intervallType); $dataModel->setMeasurementUnit($this->_measurementUnit); $dataModel->setSensor($this->_sensor); $dataModel->setIntervallStart($this->_intervallStart); $sensor = $dataModel->getSensor(); /* @var $dateHelper Diagram_View_Helper_Date */ $dateHelper = $this->view->getHelper('date'); $startTimestamp = $dateHelper->getStartDateTimestamp($this->_intervallType, $this->_intervallStart); $startDatetime = $dateHelper->getStartDate($this->_intervallType, $this->_intervallStart); $endDatetime = $dateHelper->getEndDate($this->_intervallType, $this->_intervallStart); $returnData['sensor'] = $sensor->equipId; $returnData['intervallTimes'] = array(); $returnData['intervallTimes']['startTimestamp'] = $startTimestamp; $returnData['intervallTimes']['startDatetime'] = $startDatetime; $returnData['intervallTimes']['endDatetime'] = $endDatetime; $returnData['measurements'] = array('data' => $dataModel->getIntervallValues(), 'label' => $startDatetime . ' - ' . $sensor->externName); return $returnData; }
/** * * @return array */ public function getAllSensors() { return Diagram_Model_IntervallMapper::getAllSensors(); }
/** * * @return Zend_Date */ protected function _getLastMeasurementDate() { return Diagram_Model_IntervallMapper::getLastMeasurementDate(); }
/** * For comparisons in Flot the returning manipulationtime must be made of a flattened value, * to show multiple intervallStarts over each other instead of drawing them behind or later. * * It's only necessary to flatten the intervalls to a specific datetime for given intervallType. * * ATTENTION: We use >Monday, January 1, 1973 1:00:00 AM< with timestamp >94694400< for all calculations. * TODO Check if 1:00 is all right. wouldn't be 12:00 AM be the first time of the day? e.g. (timestamp(0) - 60sec * 60min) * * ATTENTION: if multiple intervallStarts are leapYear or not won't be handled. * Means, if one year is leap and another isn't, * then the timestamp-values will differ in 1 day from Feb 28. on. * TODO fix leap year issue if neccessary. * * @return int */ protected function _getStartTimeToSubtract() { $origStartTime = $flattenedStartTime = Diagram_Model_IntervallMapper::getPreparedStartDate($this->_intervallType, $this->_intervallStart)->getTimestamp(); return $origStartTime - 94694400; }