コード例 #1
0
 /**
  * put your comment there...
  *
  * @param mixed $sensorInformationArray
  */
 private function _addSensor($sensorInformationArray)
 {
     $fiedsList = array('f_station_code', 'f_sensor_ch', 'f_sensor_code', 'f_chain_code', 'f_group_code', 'f_unit_code', 'f_name', 'f_unit', 'f_div', 'f_mul', 'f_val_neg', 'f_val_log', 'f_val_last', 'f_val_sum', 'f_val_aver', 'f_val_min', 'f_val_max', 'f_val_time', 'f_val_user', 'f_create_time', 'f_val_axilary', 'f_user_app', 'f_color', 'f_sensor_user_name', 'f_user_unit_code', 'graph_type', 'min_expected', 'max_expected', 'custom_name', 'custom_desc', 'custom_image', 'enable_sensor', 'chilling_hours_related', 'degrees_day_related', 'priority', 'last_editor');
     foreach ($fiedsList as $key) {
         if (!isset($sensorInformationArray->{$key})) {
             $sensorInformationArray->{$key} = NULL;
         } else {
             // continue
         }
     }
     /**
      * Fix, ETo debe mostrarse como SUM y no como AVER como declara el server remoto
      */
     if ($sensorInformationArray->f_sensor_code == 1201) {
         $sensorInformationArray->f_val_aver = 0;
         $sensorInformationArray->f_val_sum = 1;
     }
     $newSensor = new Sensor(0, $sensorInformationArray->f_station_code, $sensorInformationArray->f_sensor_ch, $sensorInformationArray->f_sensor_code, $sensorInformationArray->f_chain_code, $sensorInformationArray->f_group_code, $sensorInformationArray->f_unit_code, $sensorInformationArray->f_name, $sensorInformationArray->f_unit, $sensorInformationArray->f_div, $sensorInformationArray->f_mul, $sensorInformationArray->f_val_neg, $sensorInformationArray->f_val_log, $sensorInformationArray->f_val_last, $sensorInformationArray->f_val_sum, $sensorInformationArray->f_val_aver, $sensorInformationArray->f_val_min, $sensorInformationArray->f_val_max, $sensorInformationArray->f_val_time, $sensorInformationArray->f_val_user, $sensorInformationArray->f_create_time, $sensorInformationArray->f_val_axilary, $sensorInformationArray->f_user_app, $sensorInformationArray->f_color, $sensorInformationArray->f_sensor_user_name, $sensorInformationArray->f_user_unit_code, $graph_type = null, $min_expected = null, $max_expected = null, $custom_name = null, $custom_desc = null, $custom_image = null, $enable_sensor = 1, $chilling_hours_related = preg_match("/air[\\s| ]+temp/i", $sensorInformationArray->f_name) ? 1 : NULL, $degrees_day_related = preg_match("/air[\\s| ]+temp/i", $sensorInformationArray->f_name) ? 1 : NULL, $wind_rose_related = preg_match("/wind/i", $sensorInformationArray->f_name) ? 1 : NULL, $priority = null, $last_edition_time = null, $last_editor = '');
     if ($newSensor->save()) {
         return $sensorInformationArray->f_station_code . "_" . $sensorInformationArray->f_sensor_code . "_" . $sensorInformationArray->f_sensor_ch . " added";
     } else {
         return $sensorInformationArray->f_station_code . "_" . $sensorInformationArray->f_sensor_code . "_" . $sensorInformationArray->f_sensor_ch . " ERROR SAVING DATA";
     }
 }