Skip to content

Commit

Permalink
Loading the list of satellites link from each JSON file
Browse files Browse the repository at this point in the history
  • Loading branch information
mgm8 committed Oct 6, 2024
1 parent b374b81 commit c508992
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 12 deletions.
10 changes: 1 addition & 9 deletions spacelab_transmitter/data/ui/spacelab_transmitter.glade
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,9 @@ Author: Vitória Beatriz Bianchin <vitoriabbianchin@gmail.com>
</object>
<object class="GtkListStore" id="liststore_packet_type">
<columns>
<!-- column-name gchararray1 -->
<!-- column-name link -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0">Beacon</col>
</row>
<row>
<col id="0">Downlink</col>
</row>
</data>
</object>
<object class="GtkListStore" id="liststore_satellite">
<columns>
Expand Down
46 changes: 44 additions & 2 deletions spacelab_transmitter/spacelabtransmitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spacelab_transmitter/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit c508992

Please sign in to comment.