From c508992160b1eb30644fcd4cc048b99b2f2332fa Mon Sep 17 00:00:00 2001 From: Gabriel Mariano Marcelino Date: Sun, 6 Oct 2024 18:12:56 -0300 Subject: [PATCH] Loading the list of satellites link from each JSON file --- .../data/ui/spacelab_transmitter.glade | 10 +--- spacelab_transmitter/spacelabtransmitter.py | 46 ++++++++++++++++++- spacelab_transmitter/version.py | 2 +- 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/spacelab_transmitter/data/ui/spacelab_transmitter.glade b/spacelab_transmitter/data/ui/spacelab_transmitter.glade index a460de9..d761ce2 100644 --- a/spacelab_transmitter/data/ui/spacelab_transmitter.glade +++ b/spacelab_transmitter/data/ui/spacelab_transmitter.glade @@ -49,17 +49,9 @@ Author: Vitória Beatriz Bianchin - + - - - Beacon - - - Downlink - - diff --git a/spacelab_transmitter/spacelabtransmitter.py b/spacelab_transmitter/spacelabtransmitter.py index b2b6180..c5794af 100644 --- a/spacelab_transmitter/spacelabtransmitter.py +++ b/spacelab_transmitter/spacelabtransmitter.py @@ -217,6 +217,12 @@ def _build_widgets(self): self.combobox_satellite.add_attribute(cell, "text", 0) self.combobox_satellite.connect("changed", self.on_combobox_satellite_changed) + # Packet type combobox + self.liststore_packet_type = self.builder.get_object("liststore_packet_type") + self.combobox_packet_type = self.builder.get_object("combobox_packet_type") + self.combobox_packet_type.pack_start(cell, True) + self.combobox_packet_type.add_attribute(cell, "text", 0) + # TCP socket self.entry_tcp_address = self.builder.get_object("entry_tcp_address") self.entry_tcp_port = self.builder.get_object("entry_tcp_port") @@ -839,8 +845,44 @@ def on_switch_button_clicked(self, false, button): self.button_get_payload_data.set_sensitive(True) def on_combobox_satellite_changed(self, combobox): - modulation, frequency, baudrate, sync_word, protocol = self._get_link_info() - self.entry_carrier_frequency.set_text(str(int(frequency))) + # Clear the list of packet types + self.liststore_packet_type.clear() + + sat_filename = _SATELLITES[self.combobox_satellite.get_active()][1] + sat_config_file = str() + + if os.path.isfile(_SAT_JSON_LOCAL_PATH + sat_filename): + sat_config_file = _SAT_JSON_LOCAL_PATH + sat_filename + else: + sat_config_file = _SAT_JSON_SYSTEM_PATH + sat_filename + + try: + with open(sat_config_file) as f: + sat_info = json.load(f) + + if 'links' in sat_info: + for i in range(len(sat_info['links'])): + self.liststore_packet_type.append([sat_info['links'][i]['name']]) + else: + self.liststore_packet_type.append(['Uplink']) + + modulation, frequency, baudrate, sync_word, protocol = self._get_link_info() + self.entry_carrier_frequency.set_text(str(int(frequency))) + except FileNotFoundError as e: + error_dialog = Gtk.MessageDialog(None, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, "Error opening the satellite configuration file!") + error_dialog.format_secondary_text(str(e)) + error_dialog.run() + error_dialog.destroy() + + self.combobox_packet_type.set_active(-1) + except: + error_dialog = Gtk.MessageDialog(None, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, "Error opening the satellite configuration file!") + error_dialog.format_secondary_text("Is the configuration file correct?") + error_dialog.run() + error_dialog.destroy() + else: + # Sets the first packet type as the active packet type + self.combobox_packet_type.set_active(0) def on_combobox_sdr_changed(self, combobox): if self.combobox_sdr.get_active() == 0: # USRP diff --git a/spacelab_transmitter/version.py b/spacelab_transmitter/version.py index 93956e7..76025e5 100644 --- a/spacelab_transmitter/version.py +++ b/spacelab_transmitter/version.py @@ -24,7 +24,7 @@ __copyright__ = "Copyright The SpaceLab-Transmitter Contributors" __credits__ = ["Gabriel Mariano Marcelino, Vitória Beatriz Bianchin"] __license__ = "GPLv3" -__version__ = "0.4.18" +__version__ = "0.4.19" __maintainer__ = "Gabriel Mariano Marcelino - PU5GMA" __email__ = "gabriel.mm8@gmail.com" __status__ = "Development"