2020-12-26 14:30:46 -08:00
|
|
|
#pragma once
|
|
|
|
|
2021-06-16 14:20:28 -07:00
|
|
|
#include "rusefi_types.h"
|
2020-12-26 14:30:46 -08:00
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
// Only allows clearing the value, but never resetting it.
|
|
|
|
class Clearable {
|
|
|
|
public:
|
2021-01-27 18:28:53 -08:00
|
|
|
Clearable() : m_value(true) {}
|
|
|
|
Clearable(bool value) : m_value(value) {}
|
|
|
|
|
2020-12-26 14:30:46 -08:00
|
|
|
void clear() {
|
|
|
|
m_value = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
operator bool() const {
|
|
|
|
return m_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_value = true;
|
|
|
|
};
|
|
|
|
|
2021-11-16 13:52:11 -08:00
|
|
|
class LimpManager {
|
2020-12-26 14:30:46 -08:00
|
|
|
public:
|
|
|
|
// This is called from periodicFastCallback to update internal state
|
2021-06-16 14:20:28 -07:00
|
|
|
void updateState(int rpm, efitick_t nowNt);
|
2020-12-26 14:30:46 -08:00
|
|
|
|
|
|
|
// Other subsystems call these APIs to determine their behavior
|
|
|
|
bool allowElectronicThrottle() const;
|
|
|
|
|
|
|
|
bool allowInjection() const;
|
|
|
|
bool allowIgnition() const;
|
|
|
|
|
|
|
|
bool allowTriggerInput() const;
|
|
|
|
|
|
|
|
// Other subsystems call these APIs to indicate a problem has occured
|
|
|
|
void etbProblem();
|
|
|
|
void fatalError();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void setFaultRevLimit(int limit);
|
|
|
|
|
|
|
|
// Start with no fault rev limit
|
|
|
|
int32_t m_faultRevLimit = INT32_MAX;
|
|
|
|
|
|
|
|
Clearable m_allowEtb;
|
|
|
|
Clearable m_allowInjection;
|
|
|
|
Clearable m_allowIgnition;
|
|
|
|
Clearable m_allowTriggerInput;
|
|
|
|
|
2021-01-27 18:28:53 -08:00
|
|
|
bool m_transientAllowInjection = true;
|
|
|
|
bool m_transientAllowIgnition = true;
|
2021-06-16 14:20:28 -07:00
|
|
|
|
|
|
|
bool m_hadOilPressureAfterStart = false;
|
2020-12-26 14:30:46 -08:00
|
|
|
};
|