|
|
|
@ -19,8 +19,8 @@ void OnroadAlerts::clear() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
OnroadAlerts::Alert OnroadAlerts::getAlert(const SubMaster &sm, uint64_t started_frame) { |
|
|
|
|
const cereal::ControlsState::Reader &cs = sm["controlsState"].getControlsState(); |
|
|
|
|
const uint64_t controls_frame = sm.rcv_frame("controlsState"); |
|
|
|
|
const cereal::SelfdriveState::Reader &cs = sm["selfdriveState"].getSelfdriveState(); |
|
|
|
|
const uint64_t controls_frame = sm.rcv_frame("selfdriveState"); |
|
|
|
|
|
|
|
|
|
Alert a = {}; |
|
|
|
|
if (controls_frame >= started_frame) { // Don't get old alert.
|
|
|
|
@ -28,26 +28,26 @@ OnroadAlerts::Alert OnroadAlerts::getAlert(const SubMaster &sm, uint64_t started |
|
|
|
|
cs.getAlertType().cStr(), cs.getAlertSize(), cs.getAlertStatus()}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!sm.updated("controlsState") && (sm.frame - started_frame) > 5 * UI_FREQ) { |
|
|
|
|
if (!sm.updated("selfdriveState") && (sm.frame - started_frame) > 5 * UI_FREQ) { |
|
|
|
|
const int CONTROLS_TIMEOUT = 5; |
|
|
|
|
const int controls_missing = (nanos_since_boot() - sm.rcv_time("controlsState")) / 1e9; |
|
|
|
|
const int controls_missing = (nanos_since_boot() - sm.rcv_time("selfdriveState")) / 1e9; |
|
|
|
|
|
|
|
|
|
// Handle controls timeout
|
|
|
|
|
if (controls_frame < started_frame) { |
|
|
|
|
// car is started, but controlsState hasn't been seen at all
|
|
|
|
|
// car is started, but selfdriveState hasn't been seen at all
|
|
|
|
|
a = {tr("openpilot Unavailable"), tr("Waiting for controls to start"), |
|
|
|
|
"controlsWaiting", cereal::ControlsState::AlertSize::MID, |
|
|
|
|
cereal::ControlsState::AlertStatus::NORMAL}; |
|
|
|
|
"controlsWaiting", cereal::SelfdriveState::AlertSize::MID, |
|
|
|
|
cereal::SelfdriveState::AlertStatus::NORMAL}; |
|
|
|
|
} else if (controls_missing > CONTROLS_TIMEOUT && !Hardware::PC()) { |
|
|
|
|
// car is started, but controls is lagging or died
|
|
|
|
|
if (cs.getEnabled() && (controls_missing - CONTROLS_TIMEOUT) < 10) { |
|
|
|
|
a = {tr("TAKE CONTROL IMMEDIATELY"), tr("Controls Unresponsive"), |
|
|
|
|
"controlsUnresponsive", cereal::ControlsState::AlertSize::FULL, |
|
|
|
|
cereal::ControlsState::AlertStatus::CRITICAL}; |
|
|
|
|
"controlsUnresponsive", cereal::SelfdriveState::AlertSize::FULL, |
|
|
|
|
cereal::SelfdriveState::AlertStatus::CRITICAL}; |
|
|
|
|
} else { |
|
|
|
|
a = {tr("Controls Unresponsive"), tr("Reboot Device"), |
|
|
|
|
"controlsUnresponsivePermanent", cereal::ControlsState::AlertSize::MID, |
|
|
|
|
cereal::ControlsState::AlertStatus::NORMAL}; |
|
|
|
|
"controlsUnresponsivePermanent", cereal::SelfdriveState::AlertSize::MID, |
|
|
|
|
cereal::SelfdriveState::AlertStatus::NORMAL}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -55,19 +55,19 @@ OnroadAlerts::Alert OnroadAlerts::getAlert(const SubMaster &sm, uint64_t started |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void OnroadAlerts::paintEvent(QPaintEvent *event) { |
|
|
|
|
if (alert.size == cereal::ControlsState::AlertSize::NONE) { |
|
|
|
|
if (alert.size == cereal::SelfdriveState::AlertSize::NONE) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
static std::map<cereal::ControlsState::AlertSize, const int> alert_heights = { |
|
|
|
|
{cereal::ControlsState::AlertSize::SMALL, 271}, |
|
|
|
|
{cereal::ControlsState::AlertSize::MID, 420}, |
|
|
|
|
{cereal::ControlsState::AlertSize::FULL, height()}, |
|
|
|
|
static std::map<cereal::SelfdriveState::AlertSize, const int> alert_heights = { |
|
|
|
|
{cereal::SelfdriveState::AlertSize::SMALL, 271}, |
|
|
|
|
{cereal::SelfdriveState::AlertSize::MID, 420}, |
|
|
|
|
{cereal::SelfdriveState::AlertSize::FULL, height()}, |
|
|
|
|
}; |
|
|
|
|
int h = alert_heights[alert.size]; |
|
|
|
|
|
|
|
|
|
int margin = 40; |
|
|
|
|
int radius = 30; |
|
|
|
|
if (alert.size == cereal::ControlsState::AlertSize::FULL) { |
|
|
|
|
if (alert.size == cereal::SelfdriveState::AlertSize::FULL) { |
|
|
|
|
margin = 0; |
|
|
|
|
radius = 0; |
|
|
|
|
} |
|
|
|
@ -94,15 +94,15 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) { |
|
|
|
|
const QPoint c = r.center(); |
|
|
|
|
p.setPen(QColor(0xff, 0xff, 0xff)); |
|
|
|
|
p.setRenderHint(QPainter::TextAntialiasing); |
|
|
|
|
if (alert.size == cereal::ControlsState::AlertSize::SMALL) { |
|
|
|
|
if (alert.size == cereal::SelfdriveState::AlertSize::SMALL) { |
|
|
|
|
p.setFont(InterFont(74, QFont::DemiBold)); |
|
|
|
|
p.drawText(r, Qt::AlignCenter, alert.text1); |
|
|
|
|
} else if (alert.size == cereal::ControlsState::AlertSize::MID) { |
|
|
|
|
} else if (alert.size == cereal::SelfdriveState::AlertSize::MID) { |
|
|
|
|
p.setFont(InterFont(88, QFont::Bold)); |
|
|
|
|
p.drawText(QRect(0, c.y() - 125, width(), 150), Qt::AlignHCenter | Qt::AlignTop, alert.text1); |
|
|
|
|
p.setFont(InterFont(66)); |
|
|
|
|
p.drawText(QRect(0, c.y() + 21, width(), 90), Qt::AlignHCenter, alert.text2); |
|
|
|
|
} else if (alert.size == cereal::ControlsState::AlertSize::FULL) { |
|
|
|
|
} else if (alert.size == cereal::SelfdriveState::AlertSize::FULL) { |
|
|
|
|
bool l = alert.text1.length() > 15; |
|
|
|
|
p.setFont(InterFont(l ? 132 : 177, QFont::Bold)); |
|
|
|
|
p.drawText(QRect(0, r.y() + (l ? 240 : 270), width(), 600), Qt::AlignHCenter | Qt::TextWordWrap, alert.text1); |
|
|
|
|