@@ -14,14 +14,16 @@ def __init__(self, signal_controller: SignalController, infrastructure_providers
1414 self .points : dict [str , Point ] = {}
1515 self .infrastructure_providers = infrastructure_providers
1616 self .settings = settings
17- self .flank_protection_controller = FlankProtectionController (self , signal_controller )
17+ if self .settings .activate_flank_protection is True :
18+ self .flank_protection_controller = FlankProtectionController (self , signal_controller )
1819
1920 def reset (self ):
2021 for point_id in self .points :
2122 self .points [point_id ].orientation = "undefined"
2223 self .points [point_id ].state = OccupancyState .FREE
2324 self .points [point_id ].used_by = set ()
24- self .flank_protection_controller .reset ()
25+ if self .settings .activate_flank_protection is True :
26+ self .flank_protection_controller .reset ()
2527
2628 async def set_route (self , route , train_id : str ):
2729 tasks = []
@@ -34,7 +36,8 @@ async def set_route(self, route, train_id: str):
3436 if orientation == "left" or orientation == "right" :
3537 self .set_point_reserved (point , train_id )
3638 tasks .append (tg .create_task (self .turn_point (point , orientation )))
37- tasks .append (tg .create_task (self .flank_protection_controller .add_flank_protection_for_point (point , orientation , route , train_id )))
39+ if self .settings .activate_flank_protection is True :
40+ tasks .append (tg .create_task (self .flank_protection_controller .add_flank_protection_for_point (point , orientation , route , train_id )))
3841 else :
3942 raise ValueError ("Turn should happen but is not possible" )
4043
@@ -89,7 +92,9 @@ def set_point_free(self, point, train_id: str):
8992 logging .info (f"--- Set point { point .point_id } to free" )
9093 point .state = OccupancyState .FREE
9194 point .used_by .remove (train_id )
92- self .flank_protection_controller .free_flank_protection_of_point (point , point .orientation )
95+
96+ if self .settings .activate_flank_protection is True :
97+ self .flank_protection_controller .free_flank_protection_of_point (point , point .orientation )
9398
9499 def reset_route (self , route , train_id : str ):
95100 for point in route .get_points_of_route ():
0 commit comments