Skip to content

Commit

Permalink
refactors models
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielBarberini committed May 21, 2024
1 parent 1008c5a commit e516fd6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
4 changes: 4 additions & 0 deletions lib/models/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ class Env(BaseModel, frozen=True):
date: Optional[datetime.datetime] = (
datetime.datetime.today() + datetime.timedelta(days=1)
)

@property
def env_id(self) -> str:
return str(hash(self))
4 changes: 4 additions & 0 deletions lib/models/flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ class Flight(BaseModel, frozen=True):
inclination: int = 85
heading: int = 0
rail_length: float = 5.2

@property
def flight_id(self) -> str:
return str(hash(self))
28 changes: 16 additions & 12 deletions lib/models/motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@


class MotorKinds(str, Enum):
hybrid: str = "Hybrid"
solid: str = "Solid"
liquid: str = "Liquid"
HYBRID: str = "HYBRID"
SOLID: str = "SOLID"
LIQUID: str = "LIQUID"


class MotorEngines(str, Enum):
cesaroni: str = "Cesaroni_M1670"
custom: str = "Custom"
CESARONI: str = "CESARONI_M1670"
CUSTOM: str = "CUSTOM"


class TankKinds(str, Enum):
level: str = "Level"
mass: str = "Mass"
mass_flow: str = "MassFlow"
ullage: str = "Ullage"
LEVEL: str = "LEVEL"
MASS: str = "MASS"
MASS_FLOW: str = "MASSFlOW"
ULLAGE: str = "ULLAGE"


class TankFluids(BaseModel, frozen=True):
name: str = "FluidName"
name: str = "FLUIDNAME"
density: float = 100.0


Expand All @@ -39,7 +39,7 @@ class MotorTank(BaseModel, frozen=True):
((0, 5), 1),
((5, 10), 2),
]
tank_kind: TankKinds = TankKinds.mass_flow
tank_kind: TankKinds = TankKinds.MASS_FLOW
gas: TankFluids = TankFluids()
liquid: TankFluids = TankFluids()
name: str = "Tank"
Expand Down Expand Up @@ -81,7 +81,7 @@ def __init__(self, **kwargs):
liquid_mass=self.liquid_mass,
gas_mass=self.gas_mass,
)
case TankKinds.mass_flow:
case TankKinds.MASS_FLOW:
tank = MassFlowRateBasedTank(
**tank_core,
gas_mass_flow_rate_in=self.gas_mass_flow_rate_in,
Expand Down Expand Up @@ -136,6 +136,10 @@ def __init__(self, motor_kind=MotorKinds.solid, **kwargs):
def motor_kind(self) -> MotorKinds:
return self._motor_kind

@property
def motor_id(self) -> str:
return str(hash(self))

def __hash__(self):
temp = vars(self)
temp = str(temp)
Expand Down
8 changes: 6 additions & 2 deletions lib/models/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@


class RocketOptions(str, Enum):
CALISTO: str = "Calisto"
CUSTOM: str = "Custom"
CALISTO: str = "CALISTO"
CUSTOM: str = "CUSTOM"


class Rocket(BaseModel, frozen=True):
Expand Down Expand Up @@ -48,6 +48,10 @@ def __init__(self, rocket_option=RocketOptions.CALISTO, **kwargs):
def rocket_option(self) -> RocketOptions:
return self._rocket_option

@property
def rocket_id(self) -> str:
return str(hash(self))

def __hash__(self):
temp = vars(self)
temp = str(temp)
Expand Down

0 comments on commit e516fd6

Please sign in to comment.