|  |  | @ -32,9 +32,6 @@ class AlertManager: | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.activealerts: List[Alert] = [] |  |  |  |     self.activealerts: List[Alert] = [] | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.clear_current_alert() |  |  |  |     self.clear_current_alert() | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   def alert_present(self) -> bool: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     return len(self.activealerts) > 0 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   def clear_current_alert(self) -> None: |  |  |  |   def clear_current_alert(self) -> None: | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.alert_type: str = "" |  |  |  |     self.alert_type: str = "" | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.alert_text_1: str = "" |  |  |  |     self.alert_text_1: str = "" | 
			
		
	
	
		
		
			
				
					|  |  | @ -46,34 +43,32 @@ class AlertManager: | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.alert_rate: float = 0. |  |  |  |     self.alert_rate: float = 0. | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   def add_many(self, frame: int, alerts: List[Alert], enabled: bool = True) -> None: |  |  |  |   def add_many(self, frame: int, alerts: List[Alert], enabled: bool = True) -> None: | 
			
		
	
		
		
			
				
					
					|  |  |  |     for a in alerts: |  |  |  |     for alert in alerts: | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |       self.add(frame, a, enabled=enabled) |  |  |  |       added_alert = copy.copy(alert) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |       added_alert.start_time = frame * DT_CTRL | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   def add(self, frame: int, alert: Alert, enabled: bool = True) -> None: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     added_alert = copy.copy(alert) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     added_alert.start_time = frame * DT_CTRL |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     # if new alert is higher priority, log it |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     if not self.alert_present() or added_alert.alert_priority > self.activealerts[0].alert_priority: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       cloudlog.event('alert_add', alert_type=added_alert.alert_type, enabled=enabled) |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.activealerts.append(added_alert) |  |  |  |       # if new alert is higher priority, log it | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       if not len(self.activealerts) or added_alert.alert_priority > self.activealerts[0].alert_priority: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         cloudlog.event('alert_add', alert_type=added_alert.alert_type, enabled=enabled) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     # sort by priority first and then by start_time |  |  |  |       self.activealerts.append(added_alert) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     self.activealerts.sort(key=lambda k: (k.alert_priority, k.start_time), reverse=True) |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   def process_alerts(self, frame: int) -> None: |  |  |  |   def process_alerts(self, frame: int, clear_event_type=None) -> None: | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     cur_time = frame * DT_CTRL |  |  |  |     cur_time = frame * DT_CTRL | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     # first get rid of all the expired alerts |  |  |  |     # first get rid of all the expired alerts | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.activealerts = [a for a in self.activealerts if a.start_time + |  |  |  |     self.activealerts = [a for a in self.activealerts if a.event_type != clear_event_type and | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                          max(a.duration_sound, a.duration_hud_alert, a.duration_text) > cur_time] |  |  |  |                          a.start_time + max(a.duration_sound, a.duration_hud_alert, a.duration_text) > cur_time] | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     # sort by priority first and then by start_time | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     self.activealerts.sort(key=lambda k: (k.alert_priority, k.start_time), reverse=True) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     # start with assuming no alerts |  |  |  |     # start with assuming no alerts | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.clear_current_alert() |  |  |  |     self.clear_current_alert() | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     current_alert = self.activealerts[0] if self.alert_present() else None |  |  |  |     if len(self.activealerts): | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     if current_alert is not None: |  |  |  |       current_alert = self.activealerts[0] | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |       self.alert_type = current_alert.alert_type |  |  |  |       self.alert_type = current_alert.alert_type | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |       if current_alert.start_time + current_alert.duration_sound > cur_time: |  |  |  |       if current_alert.start_time + current_alert.duration_sound > cur_time: | 
			
		
	
	
		
		
			
				
					|  |  | 
 |