Ejemplo n.º 1
0
 public function init()
 {
     $this->stations = Station::getStationName();
     $this->groups = StationGroup::getGroupName();
     $this->data = StationGroupDestination::getStationGroupArray();
 }
Ejemplo n.º 2
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));
     }
 }
Ejemplo n.º 3
0
 /**
  * station groups
  */
 public function actionStationGroups()
 {
     $accessEdit = Yii::app()->user->isSuperAdmin();
     $group = new StationGroup();
     if (isset($_GET['group_id'])) {
         $group_id = $_GET['group_id'];
         if ($_GET['action'] == 'delete') {
             StationGroup::deleteGroupId($group_id);
             $this->redirect($this->createUrl('admin/StationGroups'));
         }
         $group = StationGroup::model()->findByPk($group_id);
     }
     if (isset($_POST['StationGroup']['name']) && $_POST['StationGroup']['name']) {
         if (isset($_POST['StationGroup']['group_id']) && $_POST['StationGroup']['group_id']) {
             $group = StationGroup::model()->findByPk($_POST['StationGroup']['group_id']);
         }
         $group->name = $_POST['StationGroup']['name'];
         if ($group->validate()) {
             $group->save();
             $this->redirect($this->createUrl('admin/StationGroups'));
         }
     }
     if (isset($_POST['StationGroupsForm'])) {
         StationGroupDestination::setStationGroupArray($_POST['StationGroupsForm']['data']);
     }
     $form = new StationGroupsForm();
     $this->render('station_groups', array('form' => $form, 'group' => $group, 'accessEdit' => $accessEdit));
 }