From 2595decb58d36ca516951d243823a43afa4e7872 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Wed, 2 Feb 2022 11:57:19 -0800 Subject: [PATCH] delayedShutoffRequested (#3881) --- firmware/controllers/actuators/main_relay.cpp | 6 ++---- firmware/util/containers/type_list.h | 5 +++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/firmware/controllers/actuators/main_relay.cpp b/firmware/controllers/actuators/main_relay.cpp index a03d3006d6..bd39f92158 100644 --- a/firmware/controllers/actuators/main_relay.cpp +++ b/firmware/controllers/actuators/main_relay.cpp @@ -12,11 +12,9 @@ void MainRelayController::onSlowCallback() { m_lastIgnitionTime.reset(); } - delayedShutoffRequested = engine->module()->needsDelayedShutoff(); - // Query whether any engine modules want to keep the lights on -// todo: fix this amazing C++ lambda magic -// delayedShutoffRequested = engine->engineModules.aggregate([](auto& m, bool prev) { return m->needsDelayedShutoff() | prev; }, false); + delayedShutoffRequested = engine->engineModules.aggregate([](auto& m, bool prev) { return m.needsDelayedShutoff() | prev; }, false); + // TODO: delayed shutoff timeout? mainRelayState = isBenchTest | hasIgnitionVoltage | delayedShutoffRequested; diff --git a/firmware/util/containers/type_list.h b/firmware/util/containers/type_list.h index 7f4aaedfd1..e9fa6e85e0 100644 --- a/firmware/util/containers/type_list.h +++ b/firmware/util/containers/type_list.h @@ -159,6 +159,11 @@ public: f(*me); } + template + auto aggregate(func_t const& accumulator, return_t seed) { + return accumulator(*me, seed); + } + template static constexpr bool has() { return std::is_same_v;