1111
1212
1313class AirbrakeConfig (LibraryEntry ):
14- sampling_rate_hz : float
15- controller_name : str
1614 controller_function : t .Callable
17- drag_curve_filename_without_folder : str
1815 drag_curve_filepath : Path
19- drag_curve_standard_deviation_factor : float
2016
2117 def __init__ (self , data : dict , airbrake_folder : Path ) -> None :
18+ self .extend_field_links (
19+ [
20+ ("sampling_rate_hz" , float ),
21+ ("controller_function_name" , str ),
22+ ("drag_curve_file" , str ),
23+ ("drag_curve_standard_deviation_factor" , float ),
24+ ]
25+ )
2226 super ().__init__ (data )
2327
24- self .sampling_rate_hz = float (data ["sampling_rate_hz" ])
25-
26- self .controller_name = str (data ["controller_function_name" ])
27-
28- match self .controller_name :
28+ match self .controller_function_name : # type: ignore
2929 case "disabled_controller" :
3030 self .controller_function = disabled_controller
3131 case "enabled_controller" :
@@ -37,30 +37,17 @@ def __init__(self, data: dict, airbrake_folder: Path) -> None:
3737 case _:
3838 raise NotImplementedError
3939
40- self .drag_curve_filename_without_folder = str (data ["drag_curve_file" ])
4140 self .drag_curve_filepath = airbrake_folder / str (data ["drag_curve_file" ])
42- self .drag_curve_standard_deviation_factor = float (
43- data ["drag_curve_standard_deviation_factor" ]
44- )
4541
4642 @classmethod
4743 def new_default (cls , id : str ) -> "AirbrakeConfig" :
4844 return AirbrakeConfig (
4945 {
50- "ID " : id ,
46+ "id " : id ,
5147 "sampling_rate_hz" : 10.0 ,
5248 "controller_function_name" : "disabled_controller" ,
5349 "drag_curve_file" : "stargaze_airbrake_drag_curve.csv" ,
5450 "drag_curve_standard_deviation_factor" : 0.1 ,
5551 },
5652 airbrake_folder = Path ("" ),
5753 )
58-
59- def serialize (self ) -> dict :
60- return {
61- "ID" : self .id ,
62- "sampling_rate_hz" : self .sampling_rate_hz ,
63- "controller_function_name" : self .controller_name ,
64- "drag_curve_file" : self .drag_curve_filename_without_folder ,
65- "drag_curve_standard_deviation_factor" : self .drag_curve_standard_deviation_factor ,
66- }
0 commit comments