|  |  | @ -16,28 +16,35 @@ if __name__ == "__main__": | 
			
		
	
		
		
			
				
					
					|  |  |  |   cams = [s for s in SERVICE_LIST if s.endswith('CameraState')] |  |  |  |   cams = [s for s in SERVICE_LIST if s.endswith('CameraState')] | 
			
		
	
		
		
			
				
					
					|  |  |  |   cnt_cameras = dict.fromkeys(cams, 0) |  |  |  |   cnt_cameras = dict.fromkeys(cams, 0) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   events = [] | 
			
		
	
		
		
			
				
					
					|  |  |  |   alerts: List[Tuple[float, str]] = [] |  |  |  |   alerts: List[Tuple[float, str]] = [] | 
			
		
	
		
		
			
				
					
					|  |  |  |   start_time = math.inf |  |  |  |   start_time = math.inf | 
			
		
	
		
		
			
				
					
					|  |  |  |   end_time = -math.inf |  |  |  |   end_time = -math.inf | 
			
		
	
		
		
			
				
					
					|  |  |  |   ignition_off = None |  |  |  |   ignition_off = None | 
			
		
	
		
		
			
				
					
					|  |  |  |   for msg in LogReader(sys.argv[1], ReadMode.QLOG): |  |  |  |   for msg in LogReader(sys.argv[1], ReadMode.QLOG): | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     t = (msg.logMonoTime - start_time) / 1e9 | 
			
		
	
		
		
			
				
					
					|  |  |  |     end_time = max(end_time, msg.logMonoTime) |  |  |  |     end_time = max(end_time, msg.logMonoTime) | 
			
		
	
		
		
			
				
					
					|  |  |  |     start_time = min(start_time, msg.logMonoTime) |  |  |  |     start_time = min(start_time, msg.logMonoTime) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     if msg.which() == 'onroadEvents': |  |  |  |     if msg.which() == 'onroadEvents': | 
			
		
	
		
		
			
				
					
					|  |  |  |       for e in msg.onroadEvents: |  |  |  |       for e in msg.onroadEvents: | 
			
		
	
		
		
			
				
					
					|  |  |  |         cnt_events[e.name] += 1 |  |  |  |         cnt_events[e.name] += 1 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       ae = {str(e.name) for e in msg.onroadEvents if e.name not in ('pedalPressed', 'steerOverride', 'gasPressedOverride')} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       if len(events) == 0 or ae != events[-1][1]: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         events.append((t, ae)) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     elif msg.which() == 'controlsState': |  |  |  |     elif msg.which() == 'controlsState': | 
			
		
	
		
		
			
				
					
					|  |  |  |       at = msg.controlsState.alertType |  |  |  |       at = msg.controlsState.alertType | 
			
		
	
		
		
			
				
					
					|  |  |  |       if "/override" not in at or "lanechange" in at.lower(): |  |  |  |       if "/override" not in at or "lanechange" in at.lower(): | 
			
		
	
		
		
			
				
					
					|  |  |  |         if len(alerts) == 0 or alerts[-1][1] != at: |  |  |  |         if len(alerts) == 0 or alerts[-1][1] != at: | 
			
		
	
		
		
			
				
					
					|  |  |  |           t = (msg.logMonoTime - start_time) / 1e9 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |           alerts.append((t, at)) |  |  |  |           alerts.append((t, at)) | 
			
		
	
		
		
			
				
					
					|  |  |  |     elif msg.which() == 'pandaStates': |  |  |  |     elif msg.which() == 'pandaStates': | 
			
		
	
		
		
			
				
					
					|  |  |  |       if ignition_off is None: |  |  |  |       if ignition_off is None: | 
			
		
	
		
		
			
				
					
					|  |  |  |         ign = any(ps.ignitionLine or ps.ignitionCan for ps in msg.pandaStates) |  |  |  |         ign = any(ps.ignitionLine or ps.ignitionCan for ps in msg.pandaStates) | 
			
		
	
		
		
			
				
					
					|  |  |  |         if not ign: |  |  |  |         if not ign: | 
			
		
	
		
		
			
				
					
					|  |  |  |           ignition_off = msg.logMonoTime |  |  |  |           ignition_off = msg.logMonoTime | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           break | 
			
		
	
		
		
			
				
					
					|  |  |  |     elif msg.which() in cams: |  |  |  |     elif msg.which() in cams: | 
			
		
	
		
		
			
				
					
					|  |  |  |       cnt_cameras[msg.which()] += 1 |  |  |  |       cnt_cameras[msg.which()] += 1 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -64,9 +71,14 @@ if __name__ == "__main__": | 
			
		
	
		
		
			
				
					
					|  |  |  |   print("Alerts") |  |  |  |   print("Alerts") | 
			
		
	
		
		
			
				
					
					|  |  |  |   for t, a in alerts: |  |  |  |   for t, a in alerts: | 
			
		
	
		
		
			
				
					
					|  |  |  |     print(f"{t:8.2f} {a}") |  |  |  |     print(f"{t:8.2f} {a}") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   print("\n") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   print("Events") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   for t, a in events: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     print(f"{t:8.2f} {a}") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   print("\n") | 
			
		
	
		
		
			
				
					
					|  |  |  |   if ignition_off is not None: |  |  |  |   if ignition_off is not None: | 
			
		
	
		
		
			
				
					
					|  |  |  |     ignition_off = round((ignition_off - start_time) / 1e9, 2) |  |  |  |     ignition_off = round((ignition_off - start_time) / 1e9, 2) | 
			
		
	
		
		
			
				
					
					|  |  |  |   print("Ignition off at",  ignition_off) |  |  |  |   print("Ignition off at",  ignition_off) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   print("\n") |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   print("Route duration", datetime.timedelta(seconds=duration)) |  |  |  |   print("Route duration", datetime.timedelta(seconds=duration)) | 
			
		
	
	
		
		
			
				
					|  |  | 
 |