/** * A typical "Hello, Bob!" type example. This uses a ViewModel to * show how to use them. * * @access public * @return Response */ public function action_home() { // get sensors list $m_sensor_mains = DB::select("m_sensor_main.*", "m_sensor_information.name", "m_sensor_information.conversion_rate")->from('m_sensor_main')->join('m_sensor_information', 'left')->on('m_sensor_main.m_sensor_information_id', '=', 'm_sensor_information.m_sensor_information_id')->order_by('m_sensor_main.view_order', 'ASC')->execute()->as_array(); // convert int value \Model\Dbutil::recordCastInt($m_sensor_mains); // convert to device id list $device_ids = \Model\Dbutil::getDeviceIdList($m_sensor_mains); // get recent data $recents = \Model\Sensors::getRecentRecord($device_ids); // get aggregation data $aggregations = \Model\Sensors::getAggregation($device_ids); // get peaks data // $peaks = \Model\Sensors::getPeakSummary($device_ids); // attach summary value // \Model\Sensors::attachMeasurements($m_sensor_mains, $averages, $peaks); // attach recents aggregations data \Model\Sensors::attachAggregations($m_sensor_mains, $recents, $aggregations); $this->response(array('topic' => array(), 'sensors' => $m_sensor_mains)); }