Skip to content
This repository was archived by the owner on Dec 8, 2024. It is now read-only.

Minor code refactoring #99

Merged
merged 8 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions client/drivers/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

class ControlledData:
"""
Data for passing around in client/drivers/main.do_everything().
Data for passing around in client/drivers/main.run_user_session().

There should only ever be one object of this class at a time.

Expand Down Expand Up @@ -158,19 +158,19 @@ def set_last_plant_time(self, time: datetime) -> None:

def accept_new_posture_data(
self, posture_data: List[float]
) -> None: # TODO: Refine type signature
) -> None:
"""
Update the internal store of posture data for the OLED display.

Args:
posture_data: new posture data to accept and merge with the current state of this object.

TODO: Implement me!
"""
print("<!> accept_new_posture_data()")
for datum in posture_data:
self._posture_data.put_nowait(datum)


class HardwareComponents:
"""
Hardware components packaged together into a class.
Expand Down Expand Up @@ -231,7 +231,7 @@ class HardwareComponents:
_PLANT_MOVER_PERIOD: float = 1000 * 60 / 55
_BASE_FULL_SPEED = 0.1
_FULL_SPEED_UPWARDS = _BASE_FULL_SPEED * (4 / 7) * (8 / 9) * 2
_FULL_SPEED_DOWNWARDS = (-1) * _BASE_FULL_SPEED * (4 / 5) * 2
_FULL_SPEED_DOWNWARDS = (-1) * _BASE_FULL_SPEED * (6 / 10) * 2

# SECTION: Constructors

Expand Down Expand Up @@ -277,7 +277,7 @@ def get_control_messages(self, user_id: int) -> List[str]:
Returns:
The messages to display to the user during the main application loop.
"""
return ["b0: logout", "id: " + str(user_id)]
return ["Left: logout", "ID: " + str(user_id)]

def initialise_posture_graph(self, user_id: int) -> None:
"""
Expand Down Expand Up @@ -326,22 +326,24 @@ def unwind_plant(self) -> None:
"""
self.plant_mover.speed = self._FULL_SPEED_UPWARDS
time.sleep(16 * self._PLANT_MOVER_PERIOD * self._PLANT_GEAR_RATIO / 1000)
self.plant_height = self._PLANT_SHAFT_TURNS - self._PLANT_SHAFT_SAFETY_BUFFER_TURNS
self.plant_mover.speed = 0

def wind_plant_safe(self) -> None:
"""
Wind the plant down to its minimum (safe) height.
Will also reset the `plant_height` to `0`.
"""
self.plant_mover.speed = self._FULL_SPEED_DOWNWARDS
time.sleep(
(self._PLANT_SHAFT_TURNS - self._PLANT_SHAFT_SAFETY_BUFFER_TURNS)
* self._PLANT_MOVER_PERIOD
* self._PLANT_GEAR_RATIO
/ 1000
)
self.plant_mover.speed = 0
self.plant_height = 0
self.set_plant_height(0)
# self.plant_mover.speed = self._FULL_SPEED_DOWNWARDS
# time.sleep(
# (self._PLANT_SHAFT_TURNS - self._PLANT_SHAFT_SAFETY_BUFFER_TURNS)
# * self._PLANT_MOVER_PERIOD
# * self._PLANT_GEAR_RATIO
# / 1000
# )
# self.plant_mover.speed = 0
# self.plant_height = 0

def set_plant_height(self, new_height: int) -> None:
"""
Expand Down
Loading