Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Eshco93 authored Apr 21, 2023
1 parent 6c19ce9 commit 6da864b
Show file tree
Hide file tree
Showing 10 changed files with 1,485 additions and 423 deletions.
32 changes: 17 additions & 15 deletions SondeHubUploader/SondeHubUploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


# Modules
import logging
import threading
import queue

Expand Down Expand Up @@ -39,32 +38,35 @@ def __init__(self, args):
# Used to break out of while-loops when the SondeHubUploader is terminated
self.running = True

# Queue for storing the received APRS packages after receiving and before parsing
self.aprs_queue = queue.Queue(self.qaprs)
# Queue for storing the telemetry packages after parsing and before uploading
# Queue for storing the incoming packages before processing
self.input_queue = queue.Queue(self.qin)
# Queue for storing telemetry packages before uploading
self.upload_queue = queue.Queue(self.qupl)

# Set the source address to not mandatory if a user callsign was provided
self.shuConfig.telemetry['source_address']['mandatory'] = False

# Stores the last time the station was uploaded
self.last_station_upload = 0
# Stores the last time the telemetry was uploaded
# Stores the last time telemetry was uploaded
self.last_telemetry_upload = 0

# Create a thread for receiving the APRS packages
self.udp_receive_thread = threading.Thread(target=self.threads.udp_receive, args=(self,))
self.udp_receive_thread.start()
# Create a thread for receiving packages
self.receive_thread = threading.Thread(target=self.threads.receive, args=(self,))
self.receive_thread.start()
self.loggerObj.debug('udp_receive thread started')

# Create a thread for processing the received APRS packages
self.process_aprs_queue_thread = threading.Thread(target=self.threads.process_aprs_queue, args=(self,))
self.process_aprs_queue_thread.start()
self.loggerObj.debug('process_aprs_queue thread started')
# Create a thread for processing packages
self.process_input_queue_thread = threading.Thread(target=self.threads.process_input_queue, args=(self,))
self.process_input_queue_thread.start()
self.loggerObj.debug('process_input_queue thread started')

# Create a thread for uploading the station
self.upload_station_thread = threading.Thread(target=self.threads.upload_station, args=(self,))
self.upload_station_thread.start()
self.loggerObj.debug('upload_station thread started')

# Create a thread for uploading the telemetry
# Create a thread for uploading telemetry
self.process_upload_queue_thread = threading.Thread(target=self.threads.process_upload_queue, args=(self,))
self.process_upload_queue_thread.start()
self.loggerObj.debug('process_upload_queue thread started')
Expand All @@ -74,7 +76,7 @@ def close(self):
# Setting running to 'False' will cause breaking out of the while-loops in the threads
self.running = False
# Join the threads
self.udp_receive_thread.join()
self.process_aprs_queue_thread.join()
self.receive_thread.join()
self.process_input_queue_thread.join()
self.upload_station_thread.join()
self.process_upload_queue_thread.join()
2 changes: 1 addition & 1 deletion SondeHubUploader/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ def gms_to_gmm(degree, minute, second, direction, precision):

# Convert coordinates in GMM to GMS
def gmm_to_gms(degree, minute, direction, precision):
return {'degree': degree, 'minute': int(minute), 'second': round((minute - int(minute)) * 60, precision), 'direction': direction}
return {'degree': degree, 'minute': int(minute), 'second': round((minute - int(minute)) * 60, precision), 'direction': direction}
393 changes: 293 additions & 100 deletions SondeHubUploader/handleData.py

Large diffs are not rendered by default.

35 changes: 18 additions & 17 deletions SondeHubUploader/printData.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ def print_raw_data(raw_data):
print(raw_data)


# Print telemetry
def print_telemetry(self, telemetry):
# Print unified telemetry
def print_unified_telemetry(self, unified_telemetry):
print('Telemetry:')
# The telemetry parameter names are printed at a fixed length
# This fixed length is based on the length of the longest telemetry parameter name
# The unified telemetry parameter names are printed at a fixed length
# This fixed length is based on the length of the longest unified telemetry parameter name
# This results in a nicely formatted and easily readable output
parameter_string = '{:<' + str(len(max(self.shuConfig.print_write_telemetry.keys(), key=len)) + 1) + '} {} {}'
# Go through all possible telemetry parameters
for name, (parameter, unit, conversion_function) in self.shuConfig.print_write_telemetry.items():
# Print all telemetry parameters that are included in 'telemetry'
if all(item in telemetry.keys() for item in parameter):
# Some printed parameters are composed or calculated from several telemetry parameters
# These telemetry parameters must be added to a list in order to be passed to the conversion function
parameter_list = []
for element in parameter:
parameter_list.append(telemetry[element])
# Print the telemetry parameters with their name, value and unit (optional)
print(parameter_string.format(name + ':', conversion_function(*parameter_list), '' if unit is None else unit))
# Therefore the longest unified telemetry parameter name must be found in order to compile the parameter string
names = []
for parameter in self.shuConfig.telemetry:
if parameter in unified_telemetry:
names.append(self.shuConfig.telemetry[parameter]['name'])
parameter_string = '{:<' + str(len(max(names, key=len)) + 1) + '} {} {}'
# Go through all possible unified telemetry parameters
for parameter in self.shuConfig.telemetry:
# Print all unified telemetry parameters that are included in 'unified_telemetry'
if parameter in unified_telemetry:
# Print the unified telemetry parameters with their name, value and unit (optional)
print(parameter_string.format(self.shuConfig.telemetry[parameter]['name'] + ':', unified_telemetry[parameter], '' if self.shuConfig.telemetry[parameter]['unit'] is None else self.shuConfig.telemetry[parameter]['unit']))


# Print reformatted telemetry
Expand All @@ -37,8 +37,9 @@ def print_reformatted_telemetry(self, reformatted_telemetry):
# The reformatted telemetry parameter names are printed at a fixed length
# This fixed length is based on the length of the longest reformatted telemetry parameter name
# This results in a nicely formatted and easily readable output
# Therefore the longest reformatted telemetry parameter name must be found in order to compile the parameter string
parameter_string = '{:<' + str(len(max(reformatted_telemetry.keys(), key=len)) + 1) + '} {} {}'
# Go through all reformatted telemetry parameters existing in 'reformatted_telemetry'
for name, unit in reformatted_telemetry.items():
# Print the reformatted telemetry parameters with their name, value and unit (optional)
print(parameter_string.format(name + ':', unit, '' if self.shuConfig.write_reformatted[name] is None else self.shuConfig.write_reformatted[name]))
print(parameter_string.format(name + ':', unit, '' if self.shuConfig.reformatted_telemetry[name] is None else self.shuConfig.reformatted_telemetry[name]))
Loading

0 comments on commit 6da864b

Please sign in to comment.