Skip to content

Commit

Permalink
Merge pull request #101 from MihaMi27/main
Browse files Browse the repository at this point in the history
Minor update to documentation
  • Loading branch information
firefly-cpp authored Dec 12, 2024
2 parents 57bcb60 + 1c3a5dd commit d8a80f2
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 70 deletions.
6 changes: 3 additions & 3 deletions ast_monitor/basic_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class BasicData:
Class for storing and tracking the basic training data in real time.\n
Args:
hr_data_path (str):
path to the file that contains HR data
path to the file that contains heart rate data
gps_data_path (str):
path to the file that contains GPS data
"""
Expand All @@ -17,7 +17,7 @@ def __init__(self, hr_data_path: str, gps_data_path: str) -> None:
Initialization method for BasicData class.\n
Args:
hr_data_path (str):
path to the file that contains HR data
path to the file that contains heart rate data
gps_data_path (str):
path to the file that contains GPS data
"""
Expand All @@ -36,7 +36,7 @@ def __init__(self, hr_data_path: str, gps_data_path: str) -> None:

def read_current_hr(self) -> None:
"""
Reading the current HR from the file.
Reading the current heart rate from the file.
"""
if not os.path.exists(self.hr_data_path):
self.current_heart_rate = None
Expand Down
2 changes: 1 addition & 1 deletion ast_monitor/digital_twin.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def calculate_prediction(
expected_trackpoints (int):
the number of expected trackpoints
Returns:
float: the proposed heart rate
float: the predicted heart rate
"""
if trimp_delta < 0:
self.minus += trimp_delta
Expand Down
7 changes: 4 additions & 3 deletions ast_monitor/gps_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, gps_path: str = 'sensor_data/gps.txt') -> None:
Initialisation method for GpsSensor class.\n
Args:
gps_path (str):
path to file for storing gps data
path to file for storing GPS data
"""
self.gps_path = gps_path

Expand Down Expand Up @@ -50,8 +50,9 @@ def write_gps_data_to_file(
def get_gps_data(self) -> None:
"""
Method for listening the channel for obtaining GPS data from sensor.\n
Note: Example is based on source code from
https://github.com/adafruit/Adafruit_CircuitPython_GPS
Note:
Example is based on source code from
https://github.com/adafruit/Adafruit_CircuitPython_GPS
"""
uart = serial.Serial('/dev/serial0', baudrate=9600, timeout=10)
gps = adafruit_gps.GPS(uart, debug=False)
Expand Down
15 changes: 8 additions & 7 deletions ast_monitor/hr_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@

class HrSensor():
"""
Class for working with HR sensor.\n
Class for working with heart rate sensor.\n
Args:
hr_path (str):
path to file for storing HR data
path to file for storing heart rate data
"""
def __init__(self, hr_path='sensor_data/hr.txt') -> None:
"""
Initialisation method for HrSensor class.\n
Args:
hr_path (str):
path to file for storing HR data
path to file for storing heart rate data
"""
self.hr_path = hr_path

def write_hr_data_to_file(self, hr: int) -> None:
"""
Method for writing hr data to text file.\n
Method for writing heart rate data to text file.\n
Args:
hr (int):
heart rate
Expand All @@ -36,7 +36,7 @@ def on_data(self, data) -> None:
"""
Extracting and writing heart rate data to file.\n
Args:
data ():
data (list):
list that contains heart rate
"""
heartrate = data[7]
Expand All @@ -46,8 +46,9 @@ def on_data(self, data) -> None:
def get_hr_data(self) -> None:
"""
Method for listening the channel for obtaining HR data from sensor.\n
Note: Example is based on source code from
https://github.com/Tigge/openant/blob/master/examples/heart_rate_monitor.py
Note:
Example is based on source code from
https://github.com/Tigge/openant/blob/master/examples/heart_rate_monitor.py
"""
NETWORK_KEY = [0xB9, 0xA5, 0x21, 0xFB, 0xBD, 0x72, 0xC3, 0x45]

Expand Down
3 changes: 1 addition & 2 deletions ast_monitor/html_request_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ def translate_path(self, path):
Method that allows the server to serve the html files from the dist folder instead of the root folder.
Args:
path: url path
Returns:
translated_path (str): translated url path
"""
parsed_path = urlparse(path).path
current_file_directory = os.path.dirname(os.path.abspath(__file__))
Expand Down
37 changes: 11 additions & 26 deletions ast_monitor/interval_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,21 @@ class IntervalTraining:
Initialization method of the IntervalTraining class.\n
Args:
training: dict
training (dict):
an interval training
tick_time: int
tick_time (int):
tick time in milliseconds
Returns:
None
"""

def __init__(self, training: dict, basic_data) -> None:
"""
Initialization method of the IntervalTraining class.\n
Args:
training: dict
training (dict):
an interval training
tick_time: int
tick_time (int):
tick time in milliseconds
Returns:
None
"""
self.file = training['file']
self.name = training['interval'][0]['name']
Expand All @@ -57,7 +51,7 @@ def __eq__(self, __o: object) -> bool:
Method for comparing two IntervalTraining objects.\n
Args:
__o: IntervalTraining
__o (IntervalTraining):
an interval training to be compared to
Returns:
Expand All @@ -80,11 +74,8 @@ def start(self, write_log: bool = False) -> None:
Starting an interval training.\n
Args:
write_log: bool
writing log if True
Returns:
None
write_log (bool):
if True, write log
"""
# Writing the header of the training.
if write_log:
Expand All @@ -104,13 +95,10 @@ def start_speed_phase(self, interval: int, write_log: bool) -> None:
Starting a speed phase of an interval.\n
Args:
interval: int
interval (int):
index of the interval
write_log: bool
writing log if True
Returns:
None
write_log (bool):
if True, write log
"""
self.current_interval = interval, 'speed'
self.speed_notification = True
Expand Down Expand Up @@ -149,10 +137,7 @@ def start_recovery_phase(self, interval: int, write_log: bool) -> None:
interval: int
index of the interval
write_log: bool
writing log if True
Returns:
None
if True, write log
"""
self.current_interval = interval, 'recovery'
self.recovery_notification = True
Expand Down
29 changes: 13 additions & 16 deletions ast_monitor/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AST(QMainWindow, Ui_MainWindow):
Main class for the manipulation with the GUI of the application.\n
Args:
hr_data_path (str):
path to the file that contains HR data
path to the file that contains heart rate data
gps_data_path (str):
path to the file that contains GPS data
"""
Expand All @@ -46,7 +46,7 @@ def __init__(self, hr_data_path: str, gps_data_path: str, route_data_path=None)
Initialization method for AST class.\n
Args:
hr_data_path (str):
path to the file that contains HR data
path to the file that contains heart rate data
gps_data_path (str):
path to the file that contains GPS data
route_dict (dict):
Expand Down Expand Up @@ -128,11 +128,11 @@ def update_map_component(self, progress: float = None, remaining_distance: float
"""
Updating method for the (Vue.js rendered) map component with the new data.
Args:
progress:
remaining_distance:
remaining_ascent:
speed:
heartrate:
progress (float):
remaining_distance (float):
remaining_ascent (float):
speed (float):
heartrate (int):
duration:
distance:
lat_lng:
Expand Down Expand Up @@ -180,7 +180,7 @@ def start_training_session(self, show_feedback: bool = True) -> None:
Start of the training session.\n
Args:
show_feedback (bool):
showing notification for session start if True
if True, show notification for starting a training session
"""
self.session = TrainingSession()
self.widget_start_stop.setCurrentIndex(1)
Expand All @@ -200,7 +200,7 @@ def end_training_session(self, show_feedback: bool = True) -> None:
End of the training session.\n
Args:
show_feedback (bool):
showing notification for session end if True
if True, show notification for ending a training session
"""
del self.session
self.widget_start_stop.setCurrentIndex(0)
Expand Down Expand Up @@ -245,6 +245,9 @@ def menu_right(self) -> None:
def load_training(self, show_feedback: bool = True) -> None:
"""
Loading an interval training from a JSON file.
Args:
show_feedback (bool):
if True, show notification for successful training
"""
# Getting all available trainings.
trainings = glob.glob(os.path.join(os.path.dirname(
Expand Down Expand Up @@ -502,8 +505,6 @@ def __init__(self):
def run(self):
"""
Method that runs the HTTP server.
Returns:
None
"""
PORT = 8000
Handler = CustomHandler
Expand All @@ -513,9 +514,5 @@ def run(self):
httpd.handle_request()

def stop(self):
"""
Method that stops the HTTP server.
Returns:
"""
"""Method that stops the HTTP server."""
self.running = False
2 changes: 1 addition & 1 deletion ast_monitor/route_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def merge_dicts(self, dict_list):
"""
Helper method that merges dictionaries.
Args:
dict_list:
dict_list: list of dictionaries to be merged.
Returns:
merged_dict: merged dictionary
Expand Down
19 changes: 8 additions & 11 deletions ast_monitor/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ def write_gps_to_file(self, lon: float, lat: float, alt: float) -> None:
print('Lon: ' + str(lon) + ' Lat: ' + str(lat))

def simulate_hr(self) -> None:
"""
Randomly generate heart rate between 150 and 160 beats per minute.
"""
"""Randomly generate heart rate between 150 and 160 beats per minute."""
while True:
for i in range(25):
time.sleep(1)
Expand All @@ -90,14 +88,10 @@ def simulate_hr(self) -> None:
self.write_hr_to_file(new_rand)

def simulate_gps(self) -> None:
"""
GPS simulation.
"""
tcx_reader = TCXReader()
file_location = os.path.join(os.path.dirname(os.path.abspath(
__file__)), '..', 'development', 'datasets', '15.tcx')
"""
TCX file test2.tcx was taken from the following dataset:
f"""
GPS simulation.\n
Note:
TCX file 15.tcx was taken from the following dataset:
S. Rauter, I. Jr. Fister, I. Fister.
A collection of sport activity files
Expand All @@ -106,6 +100,9 @@ def simulate_gps(self) -> None:
Technical report 0201, University of Ljubljana
and University of Maribor, 2015.
"""
tcx_reader = TCXReader()
file_location = os.path.join(os.path.dirname(os.path.abspath(
__file__)), '..', 'development', 'datasets', '15.tcx')
data = tcx_reader.read(file_location)

for i in range(len(data.trackpoints)):
Expand Down

0 comments on commit d8a80f2

Please sign in to comment.