|
|
@ -970,10 +970,10 @@ EVENTS: Dict[int, Dict[str, Union[Alert, AlertCallbackType]]] = { |
|
|
|
if __name__ == '__main__': |
|
|
|
if __name__ == '__main__': |
|
|
|
# print all alerts by type and priority |
|
|
|
# print all alerts by type and priority |
|
|
|
from cereal.services import SERVICE_LIST |
|
|
|
from cereal.services import SERVICE_LIST |
|
|
|
from collections import defaultdict, OrderedDict |
|
|
|
from collections import defaultdict |
|
|
|
|
|
|
|
|
|
|
|
event_names = {v: k for k, v in EventName.schema.enumerants.items()} |
|
|
|
event_names = {v: k for k, v in EventName.schema.enumerants.items()} |
|
|
|
alerts_by_type: Dict[str, Dict[int, List[str]]] = defaultdict(lambda: defaultdict(list)) |
|
|
|
alerts_by_type: Dict[str, Dict[Priority, List[str]]] = defaultdict(lambda: defaultdict(list)) |
|
|
|
|
|
|
|
|
|
|
|
CP = car.CarParams.new_message() |
|
|
|
CP = car.CarParams.new_message() |
|
|
|
CS = car.CarState.new_message() |
|
|
|
CS = car.CarState.new_message() |
|
|
@ -983,18 +983,14 @@ if __name__ == '__main__': |
|
|
|
for et, alert in alerts.items(): |
|
|
|
for et, alert in alerts.items(): |
|
|
|
if callable(alert): |
|
|
|
if callable(alert): |
|
|
|
alert = alert(CP, CS, sm, False, 1) |
|
|
|
alert = alert(CP, CS, sm, False, 1) |
|
|
|
priority = alert.priority |
|
|
|
alerts_by_type[et][alert.priority].append(event_names[i]) |
|
|
|
alerts_by_type[et][priority].append(event_names[i]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
all_alerts = {} |
|
|
|
all_alerts: Dict[str, List[tuple[Priority, List[str]]]] = {} |
|
|
|
for et, priority_alerts in alerts_by_type.items(): |
|
|
|
for et, priority_alerts in alerts_by_type.items(): |
|
|
|
all_alerts[et] = OrderedDict([ |
|
|
|
all_alerts[et] = sorted(priority_alerts.items(), key=lambda x: x[0], reverse=True) |
|
|
|
(str(priority), l) |
|
|
|
|
|
|
|
for priority, l in sorted(priority_alerts.items(), key=lambda x: -int(x[0])) |
|
|
|
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for status, evs in sorted(all_alerts.items(), key=lambda x: x[0]): |
|
|
|
for status, evs in sorted(all_alerts.items(), key=lambda x: x[0]): |
|
|
|
print(f"**** {status} ****") |
|
|
|
print(f"**** {status} ****") |
|
|
|
for p, alert_list in evs.items(): |
|
|
|
for p, alert_list in evs: |
|
|
|
print(f" {p}:") |
|
|
|
print(f" {repr(p)}:") |
|
|
|
print(" ", ', '.join(alert_list), "\n") |
|
|
|
print(" ", ', '.join(alert_list), "\n") |
|
|
|