delayedShutoffRequested (#3881)

This commit is contained in:
Matthew Kennedy 2022-02-02 11:57:19 -08:00 committed by GitHub
parent e98ab8433e
commit 2595decb58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -12,11 +12,9 @@ void MainRelayController::onSlowCallback() {
m_lastIgnitionTime.reset(); m_lastIgnitionTime.reset();
} }
delayedShutoffRequested = engine->module<MainRelayController>()->needsDelayedShutoff();
// Query whether any engine modules want to keep the lights on // 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? // TODO: delayed shutoff timeout?
mainRelayState = isBenchTest | hasIgnitionVoltage | delayedShutoffRequested; mainRelayState = isBenchTest | hasIgnitionVoltage | delayedShutoffRequested;

View File

@ -159,6 +159,11 @@ public:
f(*me); f(*me);
} }
template<typename return_t, typename func_t>
auto aggregate(func_t const& accumulator, return_t seed) {
return accumulator(*me, seed);
}
template<typename has_t> template<typename has_t>
static constexpr bool has() { static constexpr bool has() {
return std::is_same_v<has_t, base_t>; return std::is_same_v<has_t, base_t>;