@@ -28,8 +28,34 @@ class MotorController:
28
28
- Create a rocketpy.Motor object from a Motor model object.
29
29
"""
30
30
31
- def __init__ (self , motor : Motor , motor_kind ):
31
+ def __init__ (self , motor : Motor , motor_kind : MotorKinds ):
32
32
self .guard (motor , motor_kind )
33
+ self ._motor = motor
34
+ self ._motor_kind = motor_kind
35
+
36
+ @property
37
+ def motor (self ) -> Motor :
38
+ return self ._motor
39
+
40
+ @motor .setter
41
+ def motor (self , motor : Motor ):
42
+ self ._motor = motor
43
+
44
+ @property
45
+ def motor_kind (self ) -> MotorKinds :
46
+ return self ._motor_kind
47
+
48
+ @staticmethod
49
+ def get_rocketpy_motor (
50
+ motor : Motor ,
51
+ ) -> Union [LiquidMotor , HybridMotor , SolidMotor ]:
52
+ """
53
+ Get the rocketpy motor object.
54
+
55
+ Returns:
56
+ Union[LiquidMotor, HybridMotor, SolidMotor]
57
+ """
58
+
33
59
motor_core = {
34
60
"thrust_source" : f"lib/data/engines/{ motor .thrust_source .value } .eng" ,
35
61
"burn_time" : motor .burn_time ,
@@ -39,7 +65,7 @@ def __init__(self, motor: Motor, motor_kind):
39
65
"center_of_dry_mass_position" : motor .center_of_dry_mass_position ,
40
66
}
41
67
42
- match motor_kind :
68
+ match motor . motor_kind :
43
69
case MotorKinds .liquid :
44
70
rocketpy_motor = LiquidMotor (** motor_core )
45
71
case MotorKinds .hybrid :
@@ -68,13 +94,11 @@ def __init__(self, motor: Motor, motor_kind):
68
94
interpolation_method = motor .interpolation_method ,
69
95
)
70
96
71
- if motor_kind != MotorKinds .solid :
97
+ if motor . motor_kind != MotorKinds .solid :
72
98
for tank in motor .tanks :
73
99
rocketpy_motor .add_tank (tank .tank , tank .position )
74
100
75
- self .motor_kind = motor_kind # tracks motor kind state
76
- self .rocketpy_motor = rocketpy_motor
77
- self .motor = motor
101
+ return rocketpy_motor
78
102
79
103
def guard (self , motor : Motor , motor_kind ):
80
104
if motor_kind != MotorKinds .solid and motor .tanks is None :
0 commit comments