From 7ef299c8698299451979fc3fdc4625e6433accee Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 6 Apr 2022 14:50:24 +0200 Subject: [PATCH] Add power field to CAT interface --- application/config/migration.php | 2 +- application/controllers/Radio.php | 5 +++ .../migrations/088_add_power_to_cat.php | 28 +++++++++++++++ application/models/Cat.php | 36 +++++++++++++++++++ application/views/dashboard/index.php | 2 +- application/views/interface_assets/footer.php | 6 ++-- application/views/visitor/index.php | 2 +- 7 files changed, 76 insertions(+), 5 deletions(-) create mode 100644 application/migrations/088_add_power_to_cat.php diff --git a/application/config/migration.php b/application/config/migration.php index 46d1487d..d7742746 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'] = 87; +$config['migration_version'] = 88; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/Radio.php b/application/controllers/Radio.php index ecc00052..78162eba 100755 --- a/application/controllers/Radio.php +++ b/application/controllers/Radio.php @@ -91,6 +91,8 @@ $uplink_freq = $row->uplink_freq; $downlink_freq = $row->downlink_freq; + $power = $row->power; + // Check Mode if(strtoupper($row->uplink_mode) == "FMN"){ $mode = "FM"; @@ -119,6 +121,8 @@ $uplink_freq = $row->frequency; $downlink_freq = ""; + $power = $row->power; + // Check Mode if(strtoupper($row->mode) == "FMN"){ $mode = "FM"; @@ -148,6 +152,7 @@ "mode" => $mode, "satmode" => $sat_mode, "satname" => $sat_name, + "power" => $power, "updated_minutes_ago" => $updated_at, ), JSON_PRETTY_PRINT); } diff --git a/application/migrations/088_add_power_to_cat.php b/application/migrations/088_add_power_to_cat.php new file mode 100644 index 00000000..3f4f60e1 --- /dev/null +++ b/application/migrations/088_add_power_to_cat.php @@ -0,0 +1,28 @@ +db->field_exists('powre', 'cat')) { + $fields = array( + 'power INT NULL DEFAULT 0', + ); + $this->dbforge->add_column('cat', $fields, 'sat_name'); + } + } + + public function down() + { + $this->dbforge->drop_column('cat', 'power'); + } +} diff --git a/application/models/Cat.php b/application/models/Cat.php index 27bf23bb..545011d8 100644 --- a/application/models/Cat.php +++ b/application/models/Cat.php @@ -30,6 +30,27 @@ 'uplink_mode' => $result['uplink_mode'], ); + $this->db->where('id', $radio_id); + $this->db->where('user_id', $user_id); + $this->db->update('cat', $data); + } + } else if($result['radio'] == "CloudLogCATQt") { + // Update the record + foreach ($query->result() as $row) + { + $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']; + } + $this->db->where('id', $radio_id); $this->db->where('user_id', $user_id); $this->db->update('cat', $data); @@ -66,6 +87,21 @@ 'uplink_mode' => $result['uplink_mode'], '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']; + } } else { $data = array( 'radio' => $result['radio'], diff --git a/application/views/dashboard/index.php b/application/views/dashboard/index.php index 5954bbfe..a9a2249b 100644 --- a/application/views/dashboard/index.php +++ b/application/views/dashboard/index.php @@ -141,7 +141,7 @@ function echoQrbCalcLink($mygrid, $grid, $vucc) { - + frequency->hz_to_mhz($row['frequency']); ?> () diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index cf940dbf..d3069a0d 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -1072,6 +1072,7 @@ $(document).on('keypress',function(e) { "mode": "SSB", "satmode": "", "satname": "ES'HAIL-2" + "power": "20" } */ if (data.uplink_freq != "") { @@ -1097,6 +1098,7 @@ $(document).on('keypress',function(e) { } $("#sat_name").val(data.satname); $("#sat_mode").val(data.satmode); + $("#transmit_power").val(data.power); // Display CAT Timeout warnng based on the figure given in the config file var minutes = Math.floor(config->item('cat_timeout_interval'); ?> / 60); @@ -1121,9 +1123,9 @@ $(document).on('keypress',function(e) { // If a radios selected from drop down select radio update. $('.radios').change(updateFromCAT); - // If radio isn't SatPC32 clear sat_name and sat_mode + // If radio isn't SatPC32 or CloudLogCATQt clear sat_name and sat_mode $( ".radios" ).change(function() { - if ($(".radios option:selected").text() != "SatPC32") { + if ($(".radios option:selected").text() != "SatPC32" && $(".radios option:selected").text() != "CloudLogCATQt") { $("#sat_name").val(""); $("#sat_mode").val(""); $("#frequency").val(""); diff --git a/application/views/visitor/index.php b/application/views/visitor/index.php index 6996daa0..4009d7db 100644 --- a/application/views/visitor/index.php +++ b/application/views/visitor/index.php @@ -122,7 +122,7 @@ function echoQrbCalcLink($mygrid, $grid, $vucc) { - + frequency->hz_to_mhz($row['frequency']); ?> ()