|  |  | @ -1,7 +1,7 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | from cereal import log, car |  |  |  | from cereal import log, car | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | from common.realtime import DT_CTRL | 
			
		
	
		
		
			
				
					
					|  |  |  | from selfdrive.config import Conversions as CV |  |  |  | from selfdrive.config import Conversions as CV | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | from selfdrive.locationd.calibration_helpers import Filter |  |  |  | from selfdrive.locationd.calibration_helpers import Filter | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | AlertSize = log.ControlsState.AlertSize |  |  |  | AlertSize = log.ControlsState.AlertSize | 
			
		
	
	
		
		
			
				
					|  |  | @ -37,6 +37,7 @@ class Events: | 
			
		
	
		
		
			
				
					
					|  |  |  |   def __init__(self): |  |  |  |   def __init__(self): | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.events = [] |  |  |  |     self.events = [] | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.static_events = [] |  |  |  |     self.static_events = [] | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     self.events_prev = dict.fromkeys(EVENTS.keys(), 0) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   @property |  |  |  |   @property | 
			
		
	
		
		
			
				
					
					|  |  |  |   def names(self): |  |  |  |   def names(self): | 
			
		
	
	
		
		
			
				
					|  |  | @ -51,6 +52,7 @@ class Events: | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.events.append(event_name) |  |  |  |     self.events.append(event_name) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   def clear(self): |  |  |  |   def clear(self): | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     self.events_prev = {k: (v+1 if k in self.events else 0) for k, v in self.events_prev.items()} | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.events = self.static_events.copy() |  |  |  |     self.events = self.static_events.copy() | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   def any(self, event_type): |  |  |  |   def any(self, event_type): | 
			
		
	
	
		
		
			
				
					|  |  | @ -71,6 +73,8 @@ class Events: | 
			
		
	
		
		
			
				
					
					|  |  |  |           alert = EVENTS[e][et] |  |  |  |           alert = EVENTS[e][et] | 
			
		
	
		
		
			
				
					
					|  |  |  |           if not isinstance(alert, Alert): |  |  |  |           if not isinstance(alert, Alert): | 
			
		
	
		
		
			
				
					
					|  |  |  |             alert = alert(*callback_args) |  |  |  |             alert = alert(*callback_args) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           if DT_CTRL * (self.events_prev[e] + 1) >= alert.creation_delay: | 
			
		
	
		
		
			
				
					
					|  |  |  |             alert.alert_type = EVENT_NAME[e] |  |  |  |             alert.alert_type = EVENT_NAME[e] | 
			
		
	
		
		
			
				
					
					|  |  |  |             ret.append(alert) |  |  |  |             ret.append(alert) | 
			
		
	
		
		
			
				
					
					|  |  |  |     return ret |  |  |  |     return ret | 
			
		
	
	
		
		
			
				
					|  |  | @ -101,7 +105,8 @@ class Alert: | 
			
		
	
		
		
			
				
					
					|  |  |  |                duration_sound, |  |  |  |                duration_sound, | 
			
		
	
		
		
			
				
					
					|  |  |  |                duration_hud_alert, |  |  |  |                duration_hud_alert, | 
			
		
	
		
		
			
				
					
					|  |  |  |                duration_text, |  |  |  |                duration_text, | 
			
		
	
		
		
			
				
					
					|  |  |  |                alert_rate=0.): |  |  |  |                alert_rate=0., | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                creation_delay=0.): | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.alert_type = "" |  |  |  |     self.alert_type = "" | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.alert_text_1 = alert_text_1 |  |  |  |     self.alert_text_1 = alert_text_1 | 
			
		
	
	
		
		
			
				
					|  |  | @ -118,6 +123,7 @@ class Alert: | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.start_time = 0. |  |  |  |     self.start_time = 0. | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.alert_rate = alert_rate |  |  |  |     self.alert_rate = alert_rate | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     self.creation_delay = creation_delay | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     # typecheck that enums are valid on startup |  |  |  |     # typecheck that enums are valid on startup | 
			
		
	
		
		
			
				
					
					|  |  |  |     tst = car.CarControl.new_message() |  |  |  |     tst = car.CarControl.new_message() | 
			
		
	
	
		
		
			
				
					|  |  | @ -308,14 +314,6 @@ EVENTS = { | 
			
		
	
		
		
			
				
					
					|  |  |  |       Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimePrompt, 1., 2., 3.), |  |  |  |       Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimePrompt, 1., 2., 3.), | 
			
		
	
		
		
			
				
					
					|  |  |  |   }, |  |  |  |   }, | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   EventName.canErrorPersistent: { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     ET.PERMANENT: Alert( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       "CAN Error: Check Connections", |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       "", |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       AlertStatus.normal, AlertSize.small, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2), |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   }, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   # ********** events only containing alerts that display while engaged ********** |  |  |  |   # ********** events only containing alerts that display while engaged ********** | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   EventName.vehicleModelInvalid: { |  |  |  |   EventName.vehicleModelInvalid: { | 
			
		
	
	
		
		
			
				
					|  |  | @ -515,7 +513,7 @@ EVENTS = { | 
			
		
	
		
		
			
				
					
					|  |  |  |       "No Data from Device Sensors", |  |  |  |       "No Data from Device Sensors", | 
			
		
	
		
		
			
				
					
					|  |  |  |       "Reboot your Device", |  |  |  |       "Reboot your Device", | 
			
		
	
		
		
			
				
					
					|  |  |  |       AlertStatus.normal, AlertSize.mid, |  |  |  |       AlertStatus.normal, AlertSize.mid, | 
			
		
	
		
		
			
				
					
					|  |  |  |       Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2), |  |  |  |       Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2, creation_delay=1.), | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     ET.NO_ENTRY: NoEntryAlert("No Data from Device Sensors"), |  |  |  |     ET.NO_ENTRY: NoEntryAlert("No Data from Device Sensors"), | 
			
		
	
		
		
			
				
					
					|  |  |  |   }, |  |  |  |   }, | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -617,6 +615,11 @@ EVENTS = { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   EventName.canError: { |  |  |  |   EventName.canError: { | 
			
		
	
		
		
			
				
					
					|  |  |  |     ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("CAN Error: Check Connections"), |  |  |  |     ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("CAN Error: Check Connections"), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     ET.PERMANENT: Alert( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       "CAN Error: Check Connections", | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       "", | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       AlertStatus.normal, AlertSize.small, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2, creation_delay=1.), | 
			
		
	
		
		
			
				
					
					|  |  |  |     ET.NO_ENTRY: NoEntryAlert("CAN Error: Check Connections"), |  |  |  |     ET.NO_ENTRY: NoEntryAlert("CAN Error: Check Connections"), | 
			
		
	
		
		
			
				
					
					|  |  |  |   }, |  |  |  |   }, | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |