From f6feea53bd766f6cf39fbd481795f8dc1cd4a63d Mon Sep 17 00:00:00 2001 From: phl0 Date: Fri, 8 Apr 2022 21:47:50 +0200 Subject: [PATCH] Add CAT support for other propmodes for CloudLogCATQt --- application/config/migration.php | 2 +- application/controllers/Radio.php | 38 ++++++--- .../migrations/089_add_propmode_to_cat.php | 28 +++++++ .../090_make_mode_frequency_null.php | 53 ++++++++++++ application/models/Cat.php | 80 ++++++++++++++----- application/views/interface_assets/footer.php | 8 +- 6 files changed, 173 insertions(+), 36 deletions(-) create mode 100644 application/migrations/089_add_propmode_to_cat.php create mode 100644 application/migrations/090_make_mode_frequency_null.php diff --git a/application/config/migration.php b/application/config/migration.php index d7742746..ce1144fc 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE; | be upgraded / downgraded to. | */ -$config['migration_version'] = 88; +$config['migration_version'] = 90; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/Radio.php b/application/controllers/Radio.php index 78162eba..54ab7a15 100755 --- a/application/controllers/Radio.php +++ b/application/controllers/Radio.php @@ -87,12 +87,14 @@ { - if($row->sat_name != "") { + if($row->prop_mode == "SAT") { $uplink_freq = $row->uplink_freq; $downlink_freq = $row->downlink_freq; $power = $row->power; + $prop_mode = $row->prop_mode; + // Check Mode if(strtoupper($row->uplink_mode) == "FMN"){ $mode = "FM"; @@ -118,11 +120,12 @@ } } else { - $uplink_freq = $row->frequency; - $downlink_freq = ""; + $frequency = $row->frequency; $power = $row->power; + $prop_mode = $row->prop_mode; + // Check Mode if(strtoupper($row->mode) == "FMN"){ $mode = "FM"; @@ -146,15 +149,26 @@ $updated_at = $minutes; // Return Json data - echo json_encode(array( - "uplink_freq" => $uplink_freq, - "downlink_freq" => $downlink_freq, - "mode" => $mode, - "satmode" => $sat_mode, - "satname" => $sat_name, - "power" => $power, - "updated_minutes_ago" => $updated_at, - ), JSON_PRETTY_PRINT); + if ($prop_mode == "SAT") { + echo json_encode(array( + "uplink_freq" => $uplink_freq, + "downlink_freq" => $downlink_freq, + "mode" => $mode, + "satmode" => $sat_mode, + "satname" => $sat_name, + "power" => $power, + "prop_mode" => $prop_mode, + "updated_minutes_ago" => $updated_at, + ), JSON_PRETTY_PRINT); + } else { + echo json_encode(array( + "frequency" => $frequency, + "mode" => $mode, + "power" => $power, + "prop_mode" => $prop_mode, + "updated_minutes_ago" => $updated_at, + ), JSON_PRETTY_PRINT); + } } } diff --git a/application/migrations/089_add_propmode_to_cat.php b/application/migrations/089_add_propmode_to_cat.php new file mode 100644 index 00000000..66e85104 --- /dev/null +++ b/application/migrations/089_add_propmode_to_cat.php @@ -0,0 +1,28 @@ +db->field_exists('prop_mode', 'cat')) { + $fields = array( + 'prop_mode VARCHAR(10) DEFAULT NULL', + ); + $this->dbforge->add_column('cat', $fields, 'sat_name'); + } + } + + public function down() + { + $this->dbforge->drop_column('cat', 'propmode'); + } +} diff --git a/application/migrations/090_make_mode_frequency_null.php b/application/migrations/090_make_mode_frequency_null.php new file mode 100644 index 00000000..af2d4aa3 --- /dev/null +++ b/application/migrations/090_make_mode_frequency_null.php @@ -0,0 +1,53 @@ +db->field_exists('frequency', 'cat')) { + $fields = array( + 'frequency' => array( + 'type' => 'VARCHAR(10) NULL', + ), + ); + $this->dbforge->modify_column('cat', $fields); + } + if ($this->db->field_exists('mode', 'cat')) { + $fields = array( + 'mode' => array( + 'type' => 'VARCHAR(10) NULL', + ), + ); + $this->dbforge->modify_column('cat', $fields); + } + } + + public function down() + { + if ($this->db->field_exists('frequency', 'cat')) { + $fields = array( + 'frequency' => array( + 'type' => 'VARCHAR(10) NOT NULL', + ), + ); + $this->dbforge->modify_column('cat', $fields); + } + if ($this->db->field_exists('mode', 'cat')) { + $fields = array( + 'mode' => array( + 'type' => 'VARCHAR(10) NOT NULL', + ), + ); + $this->dbforge->modify_column('cat', $fields); + } + } +} diff --git a/application/models/Cat.php b/application/models/Cat.php index 545011d8..6d2b490c 100644 --- a/application/models/Cat.php +++ b/application/models/Cat.php @@ -40,15 +40,33 @@ { $radio_id = $row->id; - $data = array( - 'sat_name' => $result['sat_name'], - 'downlink_freq' => $result['downlink_freq'], - 'uplink_freq' => $result['uplink_freq'], - 'downlink_mode' => $result['downlink_mode'], - 'uplink_mode' => $result['uplink_mode'], - ); - if (isset($result['power'])) { - $data['power'] = $result['power']; + if ($result['prop_mode'] == "SAT") { + $data = array( + 'sat_name' => $result['sat_name'], + 'prop_mode' => $result['prop_mode'], + 'mode' => NULL, + 'frequency' => NULL, + 'downlink_freq' => $result['downlink_freq'], + 'uplink_freq' => $result['uplink_freq'], + 'downlink_mode' => $result['downlink_mode'], + 'uplink_mode' => $result['uplink_mode'], + ); + if (isset($result['power'])) { + $data['power'] = $result['power']; + } + } else { + $data = array( + 'prop_mode' => $result['prop_mode'], + 'mode' => $result['mode'], + 'frequency' => $result['frequency'], + 'downlink_freq' => NULL, + 'downlink_mode' => NULL, + 'uplink_freq' => NULL, + 'uplink_mode' => NULL, + ); + if (isset($result['power'])) { + $data['power'] = $result['power']; + } } $this->db->where('id', $radio_id); @@ -88,19 +106,37 @@ 'user_id' => $user_id, ); } else if($result['radio'] == "CloudLogCATQt") { - $data = array( - 'radio' => $result['radio'], - 'frequency' => $result['frequency'], - 'mode' => $result['mode'], - 'sat_name' => $result['sat_name'], - 'downlink_freq' => $result['downlink_freq'], - 'uplink_freq' => $result['uplink_freq'], - 'downlink_mode' => $result['downlink_mode'], - 'uplink_mode' => $result['uplink_mode'], - 'user_id' => $user_id, - ); - if (isset($result['power'])) { - $data['power'] = $result['power']; + if ($result['prop_mode'] == "SAT") { + $data = array( + 'radio' => $result['radio'], + 'sat_name' => $result['sat_name'], + 'prop_mode' => $result['prop_mode'], + 'mode' => NULL, + 'frequency' => NULL, + 'downlink_freq' => $result['downlink_freq'], + 'uplink_freq' => $result['uplink_freq'], + 'downlink_mode' => $result['downlink_mode'], + 'uplink_mode' => $result['uplink_mode'], + 'user_id' => $user_id, + ); + if (isset($result['power'])) { + $data['power'] = $result['power']; + } + } else { + $data = array( + 'radio' => $result['radio'], + 'prop_mode' => $result['prop_mode'], + 'mode' => $result['mode'], + 'frequency' => $result['frequency'], + 'downlink_freq' => NULL, + 'downlink_mode' => NULL, + 'uplink_freq' => NULL, + 'uplink_mode' => NULL, + 'user_id' => $user_id, + ); + if (isset($result['power'])) { + $data['power'] = $result['power']; + } } } else { $data = array( diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 021639d3..9655334f 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -1073,11 +1073,16 @@ $(document).on('keypress',function(e) { "satmode": "", "satname": "ES'HAIL-2" "power": "20" + "prop_mode": "SAT" } */ - if (data.uplink_freq != "") + if (data.prop_mode == "SAT") + //if (data.uplink_freq != "") { $('#frequency').val(data.uplink_freq); $("#band").val(frequencyToBand(data.uplink_freq)); + } else { + $('#frequency').val(data.frequency); + $("#band").val(frequencyToBand(data.frequency)); } if (data.downlink_freq != "") { @@ -1101,6 +1106,7 @@ $(document).on('keypress',function(e) { if(data.power != 0) { $("#power").val(data.power); } + $("#selectPropagation").val(data.prop_mode); // Display CAT Timeout warnng based on the figure given in the config file var minutes = Math.floor(config->item('cat_timeout_interval'); ?> / 60);