From 18f86ea6179b07cb1f0d8e402c486fd4d869826e Mon Sep 17 00:00:00 2001 From: GabrielBarberini Date: Mon, 14 Oct 2024 19:04:37 -0300 Subject: [PATCH] fixes faulty motor kind association on service layer --- lib/services/flight.py | 5 ++--- lib/services/motor.py | 8 ++++---- lib/services/rocket.py | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/services/flight.py b/lib/services/flight.py index 3130205..169b9fa 100644 --- a/lib/services/flight.py +++ b/lib/services/flight.py @@ -5,10 +5,9 @@ from rocketpy.simulation.flight import Flight as RocketPyFlight from rocketpy.utilities import get_instance_attributes -from lib.models.flight import Flight from lib.services.environment import EnvironmentService from lib.services.rocket import RocketService -from lib.views.flight import FlightSummary +from lib.views.flight import FlightSummary, FlightView class FlightService: @@ -18,7 +17,7 @@ def __init__(self, flight: RocketPyFlight = None): self._flight = flight @classmethod - def from_flight_model(cls, flight: Flight) -> Self: + def from_flight_model(cls, flight: FlightView) -> Self: """ Get the rocketpy flight object. diff --git a/lib/services/motor.py b/lib/services/motor.py index c83d424..4bf4b35 100644 --- a/lib/services/motor.py +++ b/lib/services/motor.py @@ -15,8 +15,8 @@ TankGeometry, ) -from lib.models.motor import Motor, MotorKinds, TankKinds -from lib.views.motor import MotorSummary +from lib.models.motor import MotorKinds, TankKinds +from lib.views.motor import MotorSummary, MotorView class MotorService: @@ -26,7 +26,7 @@ def __init__(self, motor: RocketPyMotor = None): self._motor = motor @classmethod - def from_motor_model(cls, motor: Motor) -> Self: + def from_motor_model(cls, motor: MotorView) -> Self: """ Get the rocketpy motor object. @@ -46,7 +46,7 @@ def from_motor_model(cls, motor: Motor) -> Self: "reshape_thrust_curve": False or motor.reshape_thrust_curve, } - match motor.motor_kind: + match MotorKinds(motor.selected_motor_kind): case MotorKinds.LIQUID: rocketpy_motor = LiquidMotor(**motor_core) case MotorKinds.HYBRID: diff --git a/lib/services/rocket.py b/lib/services/rocket.py index f3b4f47..b6286a1 100644 --- a/lib/services/rocket.py +++ b/lib/services/rocket.py @@ -14,10 +14,10 @@ from rocketpy.utilities import get_instance_attributes from lib import logger -from lib.models.rocket import Rocket, Parachute +from lib.models.rocket import Parachute from lib.models.aerosurfaces import NoseCone, Tail, Fins from lib.services.motor import MotorService -from lib.views.rocket import RocketSummary +from lib.views.rocket import RocketView, RocketSummary class RocketService: @@ -27,7 +27,7 @@ def __init__(self, rocket: RocketPyRocket = None): self._rocket = rocket @classmethod - def from_rocket_model(cls, rocket: Rocket) -> Self: + def from_rocket_model(cls, rocket: RocketView) -> Self: """ Get the rocketpy rocket object.