Ejemplo n.º 1
0
 public function actionAwsPanel()
 {
     $tableCount = isset($_GET['tableCount']) ? $_GET['tableCount'] : 2;
     $tableSize = isset($_GET['tableSize']) ? $_GET['tableSize'] : 10;
     $pages = new CPagination();
     $pages->pageSize = $tableCount * $tableSize;
     //group station
     $stationGroup = StationGroup::getGroupName();
     $selectStationGroupIds = StationGroup::getStationArrFromGroup($_GET['group_id']);
     //data for view
     $stations = $handlers = $handlersCalc = $sensorData = $handlerGroup = $stationGroupView = array();
     $stationsId = Station::stationFromGroup($stations, $selectStationGroupIds, $pages);
     if (count($stations)) {
         $lastLogsId = ListenerLog::lastMsgIds($stationsId, $stations);
         if ($lastLogsId) {
             SensorHandler::getGroupAwsPanel($handlerGroup);
             $handlersId = SensorDBHandler::handlerWithFeature($handlers, 'aws_panel');
             SensorData::addSensorsData($sensorData, $lastLogsId, $handlers);
             $handlersCalcId = CalculationDBHandler::handlerWithFeatureAndMetric($handlersCalc);
             StationCalculationData::addCalculationData($sensorData, $lastLogsId, $handlersCalcId);
             // sensor data
             if (isset($sensorData['handlers'])) {
                 foreach ($sensorData['handlers'] as $handler_id => &$handler) {
                     SensorHandler::setGroupAwsPanel($handlerGroup, $handlers[$handler_id]->handler_id_code, $handler_id, 'handlers');
                     foreach ($handler['code'] as &$code) {
                         SensorHandler::getDataForAwsPanel($code, $handlers[$handler_id], $stations);
                     }
                 }
             }
             //calculationData
             if (isset($sensorData['handlersCalc'])) {
                 foreach ($sensorData['handlersCalc'] as $handler_id => &$handler) {
                     SensorHandler::setGroupAwsPanel($handlerGroup, $handlersCalc[$handler_id]->handler_id_code, $handler_id, 'handlersCalc');
                     foreach ($handler['stations'] as $station_id => &$station) {
                         CalculationHandler::getDataForAwsPanel($station, $stations[$station_id]->lastMessage->log_id, $handlersCalc[$handler_id]->handler_id_code);
                     }
                 }
             }
         }
         //station groups view
         $stationGroupView = array_chunk($stationsId, $tableSize);
     }
     $render_data = array('stations' => $stations, 'handlers' => $handlers, 'handlersCalc' => $handlersCalc, 'sensorData' => $sensorData, 'handlerGroup' => $handlerGroup, 'stationGroup' => $stationGroupView);
     if (Yii::app()->request->isAjaxRequest) {
         $this->renderPartial('aws_panel', array('render_data' => $render_data), false, true);
     } else {
         $this->render('autorefresh_aws_panel', array('render_data' => $render_data, 'template' => 'aws_panel', 'pages' => $pages, 'stationGroup' => $stationGroup));
     }
 }