Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Refactoring #20

Merged
merged 30 commits into from
May 31, 2024
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b7e48ff
implements pyproject toml and change test filesystem
GabrielBarberini Apr 14, 2024
9eac5dc
enhances error log parsing
GabrielBarberini May 9, 2024
7798064
refactors controllers/flight
GabrielBarberini May 19, 2024
d252369
adjusts controllers.environment method signatures
GabrielBarberini May 19, 2024
c6198e0
sanitizes controllers.flight dependencies
GabrielBarberini May 19, 2024
1c26784
initiates controllers.motor refactoring
GabrielBarberini May 19, 2024
72b3321
refactors controllers.rocket
GabrielBarberini May 19, 2024
e9e392f
adapts rocket repository to comply with rocket controller
GabrielBarberini May 20, 2024
169a8c7
adapts rocket routes to comply with refactored rocket controller
GabrielBarberini May 20, 2024
c02b505
refactors repositories
GabrielBarberini May 20, 2024
873f96e
removes forward reference and improves logs wording
GabrielBarberini May 20, 2024
f2a89a9
refactors motor controller nad adapts adjacent controllers accordingly
GabrielBarberini May 21, 2024
1008c5a
renames engine files
GabrielBarberini May 21, 2024
e516fd6
refactors models
GabrielBarberini May 21, 2024
ff4859f
refactors repositories
GabrielBarberini May 21, 2024
ae9dbd2
refactors routes
GabrielBarberini May 21, 2024
803f0db
general refactoring
GabrielBarberini May 22, 2024
7f50464
addresses review comments
GabrielBarberini May 22, 2024
7879742
fixes missing importing
GabrielBarberini May 22, 2024
77efcc2
implements db context manager
GabrielBarberini May 24, 2024
dc40720
addresses review comments
GabrielBarberini May 24, 2024
288ad39
Update lib/repositories/rocket.py
GabrielBarberini May 24, 2024
7d615c7
updates repositories init
GabrielBarberini May 24, 2024
fc730e6
implements async context manager and threading lock
GabrielBarberini May 29, 2024
05aa6fd
fixes async issues
GabrielBarberini May 29, 2024
ff510c8
minor bug fixing
GabrielBarberini May 29, 2024
95a99fc
addresses pylint complains
GabrielBarberini May 29, 2024
fea731f
removes redundant event set and ensures thread lock on finalization
GabrielBarberini May 29, 2024
5b5fa81
removes useless collection setter
GabrielBarberini May 30, 2024
9ac550b
implements stdout log handler
GabrielBarberini May 30, 2024
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
Prev Previous commit
Next Next commit
initiates controllers.motor refactoring
GabrielBarberini committed May 20, 2024
commit 1c2678457643a11905edc295edcdca064986ea5e
36 changes: 30 additions & 6 deletions lib/controllers/motor.py
Original file line number Diff line number Diff line change
@@ -28,8 +28,34 @@ class MotorController:
- Create a rocketpy.Motor object from a Motor model object.
"""

def __init__(self, motor: Motor, motor_kind):
def __init__(self, motor: Motor, motor_kind: MotorKinds):
self.guard(motor, motor_kind)
self._motor = motor
self._motor_kind = motor_kind

@property
def motor(self) -> Motor:
return self._motor

@motor.setter
def motor(self, motor: Motor):
self._motor = motor

@property
def motor_kind(self) -> MotorKinds:
return self._motor_kind

@staticmethod
def get_rocketpy_motor(
motor: Motor,
) -> Union[LiquidMotor, HybridMotor, SolidMotor]:
"""
Get the rocketpy motor object.

Returns:
Union[LiquidMotor, HybridMotor, SolidMotor]
"""

motor_core = {
"thrust_source": f"lib/data/engines/{motor.thrust_source.value}.eng",
"burn_time": motor.burn_time,
@@ -39,7 +65,7 @@ def __init__(self, motor: Motor, motor_kind):
"center_of_dry_mass_position": motor.center_of_dry_mass_position,
}

match motor_kind:
match motor.motor_kind:
case MotorKinds.liquid:
rocketpy_motor = LiquidMotor(**motor_core)
case MotorKinds.hybrid:
@@ -68,13 +94,11 @@ def __init__(self, motor: Motor, motor_kind):
interpolation_method=motor.interpolation_method,
)

if motor_kind != MotorKinds.solid:
if motor.motor_kind != MotorKinds.solid:
for tank in motor.tanks:
rocketpy_motor.add_tank(tank.tank, tank.position)

self.motor_kind = motor_kind # tracks motor kind state
self.rocketpy_motor = rocketpy_motor
self.motor = motor
return rocketpy_motor

def guard(self, motor: Motor, motor_kind):
if motor_kind != MotorKinds.solid and motor.tanks is None: