2020-06-22 17:25:44 -06:00
|
|
|
#!/usr/bin/env python3
|
2020-06-22 17:45:39 -06:00
|
|
|
# flake8: noqa
|
|
|
|
# pylint: skip-file
|
|
|
|
# type: ignore
|
|
|
|
|
2020-06-22 17:25:44 -06:00
|
|
|
import time
|
|
|
|
|
|
|
|
import cereal.messaging as messaging
|
2020-09-09 11:04:28 -06:00
|
|
|
from selfdrive.car.honda.interface import CarInterface
|
2020-09-10 16:23:57 -06:00
|
|
|
from selfdrive.controls.lib.events import ET, EVENTS, Events
|
2020-09-09 11:04:28 -06:00
|
|
|
from selfdrive.controls.lib.alertmanager import AlertManager
|
2020-06-22 17:25:44 -06:00
|
|
|
|
|
|
|
|
2020-09-09 11:04:28 -06:00
|
|
|
def cycle_alerts(duration=200, is_metric=False):
|
|
|
|
alerts = list(EVENTS.keys())
|
|
|
|
print(alerts)
|
2020-06-22 17:25:44 -06:00
|
|
|
|
2020-09-09 11:04:28 -06:00
|
|
|
CP = CarInterface.get_params("HONDA CIVIC 2016 TOURING")
|
|
|
|
sm = messaging.SubMaster(['thermal', 'health', 'frame', 'model', 'liveCalibration',
|
|
|
|
'dMonitoringState', 'plan', 'pathPlan', 'liveLocationKalman'])
|
2020-06-22 17:25:44 -06:00
|
|
|
|
|
|
|
controls_state = messaging.pub_sock('controlsState')
|
2020-09-09 11:04:28 -06:00
|
|
|
thermal = messaging.pub_sock('thermal')
|
2020-06-22 17:25:44 -06:00
|
|
|
|
|
|
|
idx, last_alert_millis = 0, 0
|
2020-09-09 11:04:28 -06:00
|
|
|
|
|
|
|
events = Events()
|
|
|
|
AM = AlertManager()
|
|
|
|
|
|
|
|
frame = 0
|
|
|
|
|
2020-06-22 17:25:44 -06:00
|
|
|
while 1:
|
2020-09-09 11:04:28 -06:00
|
|
|
if frame % duration == 0:
|
2020-06-22 17:25:44 -06:00
|
|
|
idx = (idx + 1) % len(alerts)
|
2020-09-09 11:04:28 -06:00
|
|
|
events.clear()
|
|
|
|
events.add(alerts[idx])
|
|
|
|
|
|
|
|
|
|
|
|
current_alert_types = [ET.PERMANENT, ET.USER_DISABLE, ET.IMMEDIATE_DISABLE,
|
|
|
|
ET.SOFT_DISABLE, ET.PRE_ENABLE, ET.NO_ENTRY,
|
|
|
|
ET.ENABLE, ET.WARNING]
|
|
|
|
a = events.create_alerts(current_alert_types, [CP, sm, is_metric])
|
|
|
|
AM.add_many(frame, a)
|
|
|
|
AM.process_alerts(frame)
|
2020-06-22 17:25:44 -06:00
|
|
|
|
|
|
|
dat = messaging.new_message()
|
|
|
|
dat.init('controlsState')
|
|
|
|
|
2020-09-09 11:04:28 -06:00
|
|
|
dat.controlsState.alertText1 = AM.alert_text_1
|
|
|
|
dat.controlsState.alertText2 = AM.alert_text_2
|
|
|
|
dat.controlsState.alertSize = AM.alert_size
|
|
|
|
dat.controlsState.alertStatus = AM.alert_status
|
|
|
|
dat.controlsState.alertBlinkingRate = AM.alert_rate
|
|
|
|
dat.controlsState.alertType = AM.alert_type
|
|
|
|
dat.controlsState.alertSound = AM.audible_alert
|
2020-06-22 17:25:44 -06:00
|
|
|
controls_state.send(dat.to_bytes())
|
2020-06-22 17:45:39 -06:00
|
|
|
|
2020-09-09 11:04:28 -06:00
|
|
|
dat = messaging.new_message()
|
|
|
|
dat.init('thermal')
|
|
|
|
dat.thermal.started = True
|
|
|
|
thermal.send(dat.to_bytes())
|
|
|
|
|
|
|
|
frame += 1
|
2020-06-22 17:25:44 -06:00
|
|
|
time.sleep(0.01)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2020-09-09 11:04:28 -06:00
|
|
|
cycle_alerts()
|