/**
  * Do the main job.
  *
  * @since    2.0.0
  * @access   public
  */
 public function cron_run()
 {
     try {
         $this->get_datas();
         $weather = new Weather_Computer();
         $weather->compute();
         $ephemeris = new Ephemeris_Computer();
         $ephemeris->compute();
     } catch (Exception $ex) {
         error_log(LWS_PLUGIN_NAME . ' / ' . LWS_VERSION . ' / OWM Updater / Error code: ' . $ex->getCode() . ' / Error message: ' . $ex->getMessage());
     }
 }
 /**
  * Display the main configuration page.
  *
  * @since    1.0.0
  * @access   public
  */
 public function display_configuration_page()
 {
     $view = 'config';
     $args = array();
     $owm_station_id = 0;
     $owm_station_error = 0;
     $owm_station_delete = array();
     $station = array();
     if (isset($_GET['view'])) {
         $view = $_GET['view'];
     } elseif (isset($_POST['view'])) {
         $view = $_POST['view'];
     }
     if (isset($_POST['action']) && $_POST['action'] == 'set-values') {
         $this->set_values();
     }
     if (isset($_POST['action']) && $_POST['action'] == 'do-add-edit-owm') {
         $station = $this->construct_station();
         if (array_key_exists('error', $station)) {
             $owm_station_error = $station['error'];
             $view = 'add-edit-owm';
         } else {
             $this->update_owm_station_table($station);
         }
     }
     if (isset($_GET['action']) && $_GET['action'] == 'disconnect-netatmo') {
         $this->disconnect_netatmo();
     }
     if (isset($_GET['action']) && $_GET['action'] == 'disconnect-owm') {
         $this->disconnect_owm();
     }
     if (isset($_GET['action']) && ($_GET['action'] == 'add-edit-owm' || $_GET['action'] == 'add-edit-owm')) {
         if (isset($_GET['owm-station'])) {
             $owm_station_id = $_GET['owm-station'];
         }
     }
     if (isset($_GET['action']) && $_GET['action'] == 'manage-owm') {
         if (isset($_GET['subaction']) && $_GET['subaction'] == 'delete' || isset($_GET['subaction2']) && $_GET['subaction2'] == 'delete') {
             if (isset($_GET['station'])) {
                 $owm_station_delete = $_GET['station'];
             }
             if (count($owm_station_delete) > 0) {
                 $view = 'delete-owm';
             }
         }
         if (isset($_GET['subaction']) && $_GET['subaction'] == 'confirm-delete') {
             if (isset($_GET['delstation'])) {
                 $owm_station_delete = $_GET['delstation'];
             }
             if (count($owm_station_delete) > 0) {
                 $this->delete_owm_station_table($owm_station_delete);
             }
         }
     }
     if (isset($_GET['action']) && $_GET['action'] == 'delete-owm') {
         if (isset($_GET['owm-station'])) {
             $owm_station_delete[] = $_GET['owm-station'];
         }
         if (count($owm_station_delete) > 0) {
             $view = 'delete-owm';
         }
     }
     switch ($view) {
         case 'config':
             $temperature = $this->get_temperature_unit_name_array();
             $pressure = $this->get_pressure_unit_name_array();
             $wind = $this->get_wind_speed_unit_name_array();
             $altitude = $this->get_altitude_unit_name_array();
             $distance = $this->get_distance_unit_name_array();
             $viewing_options = $this->get_viewing_options_array();
             $mode_options = $this->get_mode_options_array();
             $obsolescence = $this->get_obsolescence_array();
             $minmax = $this->get_minmax_array();
             $netatmo = new Netatmo_Collector();
             $owm = new Owm_Collector();
             $weather = new Weather_Computer();
             $ephemeris = new Ephemeris_Computer();
             $datas = $this->merge_data($netatmo->get_datas(true), $owm->get_datas(), $weather->compute(), $ephemeris->compute());
             if ($this->netatmo_error == '') {
                 $error = $netatmo->last_netatmo_error;
             } else {
                 $error = $this->netatmo_error;
             }
             if ($this->netatmo_warning == '') {
                 $warning = $netatmo->last_netatmo_warning;
             } else {
                 $warning = $this->netatmo_warning;
             }
             $oerror = $owm->last_owm_error;
             $owarning = $owm->last_owm_warning;
             if (count($datas) > 0) {
                 $js_array_textual = $this->get_js_array($datas, true, false, false, true);
                 $js_array_lcd = $this->get_js_array($datas, false, true, true);
                 $js_array_justgage = $this->get_js_array($datas, false, false, true, true, true);
                 $js_array_steelmeter = $this->get_js_array($datas, false, false, true, true, false);
             }
             $js_array_lcd_design = $this->get_lcd_design_js_array();
             $js_array_lcd_size = $this->get_size_js_array();
             $js_array_lcd_speed = $this->get_lcd_speed_js_array();
             $js_array_justgage_design = $this->get_justgage_design_js_array();
             $js_array_justgage_color = $this->get_justgage_color_js_array();
             $js_array_justgage_pointer = $this->get_justgage_pointer_js_array();
             $js_array_justgage_title = $this->get_justgage_title_js_array();
             $js_array_justgage_unit = $this->get_justgage_unit_js_array();
             $js_array_justgage_size = $this->get_size_js_array(true);
             $js_array_justgage_background = $this->get_justgage_background_js_array();
             $js_array_steelmeter_design = $this->get_steelmeter_design_js_array();
             $js_array_steelmeter_frame = $this->get_steelmeter_frame_js_array();
             $js_array_steelmeter_background = $this->get_steelmeter_background_js_array();
             $js_array_steelmeter_orientation = $this->get_steelmeter_orientation_js_array();
             $js_array_steelmeter_glass = $this->get_steelmeter_glass_js_array();
             $js_array_steelmeter_pointer_type = $this->get_steelmeter_pointer_type_js_array();
             $js_array_steelmeter_pointer_color = $this->get_steelmeter_pointer_color_js_array();
             $js_array_steelmeter_knob = $this->get_steelmeter_knob_js_array();
             $js_array_steelmeter_lcd_color = $this->get_steelmeter_lcd_design_js_array();
             $js_array_steelmeter_led_color = $this->get_steelmeter_led_color_js_array();
             $js_array_steelmeter_minmax = $this->get_steelmeter_minmax_js_array();
             $js_array_steelmeter_index_color = $this->get_steelmeter_index_color_js_array();
             $js_array_steelmeter_index_style = $this->get_steelmeter_index_style_js_array();
             $js_array_steelmeter_size = $this->get_size_js_array(false, true, false);
             $status = $this->get_status($oerror != '');
             $args = compact('error', 'warning', 'oerror', 'owarning', 'status', 'temperature', 'pressure', 'wind', 'altitude', 'distance', 'mode_options', 'viewing_options', 'obsolescence', 'minmax', 'datas', 'js_array_textual', 'js_array_lcd', 'js_array_lcd_design', 'js_array_lcd_size', 'js_array_lcd_speed', 'js_array_justgage', 'js_array_justgage_design', 'js_array_justgage_size', 'js_array_justgage_color', 'js_array_justgage_pointer', 'js_array_justgage_title', 'js_array_justgage_unit', 'js_array_justgage_background', 'js_array_steelmeter', 'js_array_steelmeter_design', 'js_array_steelmeter_size', 'js_array_steelmeter_frame', 'js_array_steelmeter_background', 'js_array_steelmeter_orientation', 'js_array_steelmeter_glass', 'js_array_steelmeter_pointer_type', 'js_array_steelmeter_pointer_color', 'js_array_steelmeter_knob', 'js_array_steelmeter_lcd_color', 'js_array_steelmeter_led_color', 'js_array_steelmeter_minmax', 'js_array_steelmeter_index_style', 'js_array_steelmeter_index_color');
             break;
         case 'add-edit-owm':
             if (count($station) == 0) {
                 $station = $this->get_owm_station($owm_station_id);
             }
             $countries = $this->get_country_names();
             $timezones = $this->get_timezones_js_array();
             $error = $owm_station_error;
             $args = compact('station', 'countries', 'timezones', 'error');
             break;
         case 'delete-owm':
             $stations = $this->get_owm_stations($owm_station_delete);
             if (count($stations) > 0) {
                 foreach ($stations as &$item) {
                     $item['country'] = $this->get_country_name($item['loc_country_code']);
                 }
             }
             $args = compact('stations');
             break;
     }
     $this->view_page($view, $args);
 }