limp ClearReason

This commit is contained in:
rusefillc 2022-01-08 22:13:20 -05:00
parent d3721823ba
commit 9b38a7d445
8 changed files with 112 additions and 54 deletions

View File

@ -261,7 +261,8 @@ uint16_t rpmAcceleration;dRPM;"RPM/s",1, 0, 0, 0, 0
int16_t autoscale m_requested_pump;"DI: Pump Angle";"deg",{1/@@PACK_MULT_ANGLE@@}, 0, 0, 0, 0 int16_t autoscale m_requested_pump;"DI: Pump Angle";"deg",{1/@@PACK_MULT_ANGLE@@}, 0, 0, 0, 0
int16_t autoscale boostControlTarget;"Pump Angle";"deg",{1/@@PACK_MULT_PRESSURE@@}, 0, 0, 0, 0 int16_t autoscale boostControlTarget;"Pump Angle";"deg",{1/@@PACK_MULT_PRESSURE@@}, 0, 0, 0, 0
int16_t autoscale unusedHere1111;"Pump Angle";"deg",{1/@@PACK_MULT_PRESSURE@@}, 0, 0, 0, 0 int8_t sparkCutReason;"Spark Cut Code";"code",1, 0, 0, 0, 0
int8_t fuelCutReason;"Fuel Cut Code";"code",1, 0, 0, 0, 0
float fuel_requested_percent;"DI: fuel_requested_percent";"v", 1, 0, 0, 100, 0 float fuel_requested_percent;"DI: fuel_requested_percent";"v", 1, 0, 0, 100, 0
float fuel_requested_percent_pi;"DI: fuel_requested_percent_pi";"v", 1, 0, 0, 100, 0 float fuel_requested_percent_pi;"DI: fuel_requested_percent_pi";"v", 1, 0, 0, 100, 0
float m_I_sum_percent;"DI: m_I_sum_percent";"v", 1, 0, 0, 100, 0 float m_I_sum_percent;"DI: m_I_sum_percent";"v", 1, 0, 0, 100, 0

View File

@ -1,4 +1,4 @@
// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) console/binary/output_channels.txt Wed Jan 05 06:47:26 UTC 2022 // this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) console/binary/output_channels.txt Sat Jan 08 21:38:58 EST 2022
// by class com.rusefi.output.CHeaderConsumer // by class com.rusefi.output.CHeaderConsumer
// begin // begin
#pragma once #pragma once
@ -864,11 +864,17 @@ struct ts_outputs_s {
*/ */
scaled_channel<int16_t, 30, 1> boostControlTarget = (int16_t)0; scaled_channel<int16_t, 30, 1> boostControlTarget = (int16_t)0;
/** /**
* "Pump Angle" * "Spark Cut Code"
deg code
* offset 338 * offset 338
*/ */
scaled_channel<int16_t, 30, 1> unusedHere1111 = (int16_t)0; int8_t sparkCutReason = (int8_t)0;
/**
* "Fuel Cut Code"
code
* offset 339
*/
int8_t fuelCutReason = (int8_t)0;
/** /**
* "DI: fuel_requested_percent" * "DI: fuel_requested_percent"
v v
@ -920,79 +926,79 @@ struct ts_outputs_s {
bool launchActivatePinState : 1 {}; bool launchActivatePinState : 1 {};
/** /**
offset 468 bit 7 */ offset 468 bit 7 */
bool unusedBit_178_7 : 1 {}; bool unusedBit_179_7 : 1 {};
/** /**
offset 468 bit 8 */ offset 468 bit 8 */
bool unusedBit_178_8 : 1 {}; bool unusedBit_179_8 : 1 {};
/** /**
offset 468 bit 9 */ offset 468 bit 9 */
bool unusedBit_178_9 : 1 {}; bool unusedBit_179_9 : 1 {};
/** /**
offset 468 bit 10 */ offset 468 bit 10 */
bool unusedBit_178_10 : 1 {}; bool unusedBit_179_10 : 1 {};
/** /**
offset 468 bit 11 */ offset 468 bit 11 */
bool unusedBit_178_11 : 1 {}; bool unusedBit_179_11 : 1 {};
/** /**
offset 468 bit 12 */ offset 468 bit 12 */
bool unusedBit_178_12 : 1 {}; bool unusedBit_179_12 : 1 {};
/** /**
offset 468 bit 13 */ offset 468 bit 13 */
bool unusedBit_178_13 : 1 {}; bool unusedBit_179_13 : 1 {};
/** /**
offset 468 bit 14 */ offset 468 bit 14 */
bool unusedBit_178_14 : 1 {}; bool unusedBit_179_14 : 1 {};
/** /**
offset 468 bit 15 */ offset 468 bit 15 */
bool unusedBit_178_15 : 1 {}; bool unusedBit_179_15 : 1 {};
/** /**
offset 468 bit 16 */ offset 468 bit 16 */
bool unusedBit_178_16 : 1 {}; bool unusedBit_179_16 : 1 {};
/** /**
offset 468 bit 17 */ offset 468 bit 17 */
bool unusedBit_178_17 : 1 {}; bool unusedBit_179_17 : 1 {};
/** /**
offset 468 bit 18 */ offset 468 bit 18 */
bool unusedBit_178_18 : 1 {}; bool unusedBit_179_18 : 1 {};
/** /**
offset 468 bit 19 */ offset 468 bit 19 */
bool unusedBit_178_19 : 1 {}; bool unusedBit_179_19 : 1 {};
/** /**
offset 468 bit 20 */ offset 468 bit 20 */
bool unusedBit_178_20 : 1 {}; bool unusedBit_179_20 : 1 {};
/** /**
offset 468 bit 21 */ offset 468 bit 21 */
bool unusedBit_178_21 : 1 {}; bool unusedBit_179_21 : 1 {};
/** /**
offset 468 bit 22 */ offset 468 bit 22 */
bool unusedBit_178_22 : 1 {}; bool unusedBit_179_22 : 1 {};
/** /**
offset 468 bit 23 */ offset 468 bit 23 */
bool unusedBit_178_23 : 1 {}; bool unusedBit_179_23 : 1 {};
/** /**
offset 468 bit 24 */ offset 468 bit 24 */
bool unusedBit_178_24 : 1 {}; bool unusedBit_179_24 : 1 {};
/** /**
offset 468 bit 25 */ offset 468 bit 25 */
bool unusedBit_178_25 : 1 {}; bool unusedBit_179_25 : 1 {};
/** /**
offset 468 bit 26 */ offset 468 bit 26 */
bool unusedBit_178_26 : 1 {}; bool unusedBit_179_26 : 1 {};
/** /**
offset 468 bit 27 */ offset 468 bit 27 */
bool unusedBit_178_27 : 1 {}; bool unusedBit_179_27 : 1 {};
/** /**
offset 468 bit 28 */ offset 468 bit 28 */
bool unusedBit_178_28 : 1 {}; bool unusedBit_179_28 : 1 {};
/** /**
offset 468 bit 29 */ offset 468 bit 29 */
bool unusedBit_178_29 : 1 {}; bool unusedBit_179_29 : 1 {};
/** /**
offset 468 bit 30 */ offset 468 bit 30 */
bool unusedBit_178_30 : 1 {}; bool unusedBit_179_30 : 1 {};
/** /**
offset 468 bit 31 */ offset 468 bit 31 */
bool unusedBit_178_31 : 1 {}; bool unusedBit_179_31 : 1 {};
/** /**
* offset 472 * offset 472
*/ */
@ -1190,4 +1196,4 @@ struct ts_outputs_s {
}; };
// end // end
// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) console/binary/output_channels.txt Wed Jan 05 06:47:26 UTC 2022 // this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) console/binary/output_channels.txt Sat Jan 08 21:38:58 EST 2022

View File

@ -656,8 +656,8 @@ static void updateFlags() {
engine->outputChannels.isFanOn = enginePins.fanRelay.getLogicValue(); engine->outputChannels.isFanOn = enginePins.fanRelay.getLogicValue();
engine->outputChannels.isFan2On = enginePins.fanRelay2.getLogicValue(); engine->outputChannels.isFan2On = enginePins.fanRelay2.getLogicValue();
engine->outputChannels.isO2HeaterOn = enginePins.o2heater.getLogicValue(); engine->outputChannels.isO2HeaterOn = enginePins.o2heater.getLogicValue();
engine->outputChannels.isIgnitionEnabledIndicator = engine->limpManager.allowIgnition(); engine->outputChannels.isIgnitionEnabledIndicator = engine->limpManager.allowIgnition().value;
engine->outputChannels.isInjectionEnabledIndicator = engine->limpManager.allowInjection(); engine->outputChannels.isInjectionEnabledIndicator = engine->limpManager.allowInjection().value;
engine->outputChannels.isCylinderCleanupActivated = engine->isCylinderCleanupMode; engine->outputChannels.isCylinderCleanupActivated = engine->isCylinderCleanupMode;
#if EFI_LAUNCH_CONTROL #if EFI_LAUNCH_CONTROL

View File

@ -398,8 +398,13 @@ void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp) {
return; return;
} }
bool limitedSpark = !engine->limpManager.allowIgnition(); LimpState limitedSparkState = engine->limpManager.allowIgnition();
bool limitedFuel = !engine->limpManager.allowInjection(); engine->outputChannels.sparkCutReason = (int8_t)limitedSparkState.reason;
bool limitedSpark = !limitedSparkState.value;
LimpState limitedFuelState = engine->limpManager.allowInjection();
engine->outputChannels.fuelCutReason = (int8_t)limitedFuelState.reason;
bool limitedFuel = !limitedFuelState.value;
#if EFI_LAUNCH_CONTROL #if EFI_LAUNCH_CONTROL
if (engine->launchController.isLaunchCondition && !limitedSpark && !limitedFuel) { if (engine->launchController.isLaunchCondition && !limitedSpark && !limitedFuel) {

View File

@ -9,23 +9,23 @@ void LimpManager::updateState(int rpm, efitick_t nowNt) {
// User-configured hard RPM limit // User-configured hard RPM limit
if (rpm > engineConfiguration->rpmHardLimit) { if (rpm > engineConfiguration->rpmHardLimit) {
if (engineConfiguration->cutFuelOnHardLimit) { if (engineConfiguration->cutFuelOnHardLimit) {
allowFuel.clear(); allowFuel.clear(ClearReason::HardLimit);
} }
if (engineConfiguration->cutSparkOnHardLimit) { if (engineConfiguration->cutSparkOnHardLimit) {
allowSpark.clear(); allowSpark.clear(ClearReason::HardLimit);
} }
} }
// Force fuel limiting on the fault rev limit // Force fuel limiting on the fault rev limit
if (rpm > m_faultRevLimit) { if (rpm > m_faultRevLimit) {
allowFuel.clear(); allowFuel.clear(ClearReason::FaultRevLimit);
} }
// Limit fuel only on boost pressure (limiting spark bends valves) // Limit fuel only on boost pressure (limiting spark bends valves)
if (engineConfiguration->boostCutPressure != 0) { if (engineConfiguration->boostCutPressure != 0) {
if (Sensor::getOrZero(SensorType::Map) > engineConfiguration->boostCutPressure) { if (Sensor::getOrZero(SensorType::Map) > engineConfiguration->boostCutPressure) {
allowFuel.clear(); allowFuel.clear(ClearReason::BoostCut);
} }
} }
@ -51,7 +51,7 @@ void LimpManager::updateState(int rpm, efitick_t nowNt) {
// If time is up, the sensor works, and no pressure, kill the engine. // If time is up, the sensor works, and no pressure, kill the engine.
if (isTimedOut && !m_hadOilPressureAfterStart) { if (isTimedOut && !m_hadOilPressureAfterStart) {
allowFuel.clear(); allowFuel.clear(ClearReason::OilPressure);
} }
} }
} else { } else {
@ -63,7 +63,7 @@ void LimpManager::updateState(int rpm, efitick_t nowNt) {
/** /**
* todo: we need explicit clarification on why do we cut fuel but do not cut spark here! * todo: we need explicit clarification on why do we cut fuel but do not cut spark here!
*/ */
allowFuel.clear(); allowFuel.clear(ClearReason::StopRequested);
} }
if (!engine->isMainRelayEnabled()) { if (!engine->isMainRelayEnabled()) {
@ -79,15 +79,15 @@ todo AndreiKA this change breaks 22 unit tests?
} }
void LimpManager::etbProblem() { void LimpManager::etbProblem() {
m_allowEtb.clear(); m_allowEtb.clear(ClearReason::EtbProblem);
setFaultRevLimit(1500); setFaultRevLimit(1500);
} }
void LimpManager::fatalError() { void LimpManager::fatalError() {
m_allowEtb.clear(); m_allowEtb.clear(ClearReason::Fatal);
m_allowIgnition.clear(); m_allowIgnition.clear(ClearReason::Fatal);
m_allowInjection.clear(); m_allowInjection.clear(ClearReason::Fatal);
m_allowTriggerInput.clear(); m_allowTriggerInput.clear(ClearReason::Fatal);
setFaultRevLimit(0); setFaultRevLimit(0);
} }
@ -106,10 +106,22 @@ bool LimpManager::allowTriggerInput() const {
return m_allowTriggerInput; return m_allowTriggerInput;
} }
bool LimpManager::allowInjection() const { LimpState LimpManager::allowInjection() const {
return m_transientAllowInjection && m_allowInjection; if (!m_allowInjection) {
return {false, m_allowInjection.clearReason};
}
if (!m_transientAllowInjection) {
return {false, ClearReason::Fatal};
}
return {true, ClearReason::None};
} }
bool LimpManager::allowIgnition() const { LimpState LimpManager::allowIgnition() const {
return m_transientAllowIgnition && m_allowIgnition; if (!m_allowIgnition) {
return {false, m_allowIgnition.clearReason};
}
if (!m_transientAllowIgnition) {
return {false, ClearReason::Fatal};
}
return {true, ClearReason::None};
} }

View File

@ -4,24 +4,52 @@
#include <cstdint> #include <cstdint>
enum class ClearReason : uint8_t {
None, // 0
Fatal,
Settings,
HardLimit,
FaultRevLimit,
BoostCut, // 5
OilPressure,
StopRequested,
EtbProblem,
};
// Only allows clearing the value, but never resetting it. // Only allows clearing the value, but never resetting it.
class Clearable { class Clearable {
public: public:
Clearable() : m_value(true) {} Clearable() : m_value(true) {}
Clearable(bool value) : m_value(value) {} Clearable(bool value) : m_value(value) {
if (!m_value) {
clearReason = ClearReason::Settings;
}
}
void clear() { void clear(ClearReason clearReason) {
m_value = false; m_value = false;
this->clearReason = clearReason;
} }
operator bool() const { operator bool() const {
return m_value; return m_value;
} }
ClearReason clearReason = ClearReason::None;
private: private:
bool m_value = true; bool m_value = true;
}; };
struct LimpState {
const bool value;
const ClearReason reason;
// Implicit conversion operator to bool, so you can do things like if (myResult) { ... }
constexpr explicit operator bool() const {
return value;
}
};
class LimpManager { class LimpManager {
public: public:
// This is called from periodicFastCallback to update internal state // This is called from periodicFastCallback to update internal state
@ -30,8 +58,8 @@ public:
// Other subsystems call these APIs to determine their behavior // Other subsystems call these APIs to determine their behavior
bool allowElectronicThrottle() const; bool allowElectronicThrottle() const;
bool allowInjection() const; LimpState allowInjection() const;
bool allowIgnition() const; LimpState allowIgnition() const;
bool allowTriggerInput() const; bool allowTriggerInput() const;

View File

@ -316,6 +316,10 @@ float getOutputValueByName(const char *name) {
return engine->outputChannels.m_requested_pump; return engine->outputChannels.m_requested_pump;
if (strEqualCaseInsensitive(name, "boostControlTarget")) if (strEqualCaseInsensitive(name, "boostControlTarget"))
return engine->outputChannels.boostControlTarget; return engine->outputChannels.boostControlTarget;
if (strEqualCaseInsensitive(name, "sparkCutReason"))
return engine->outputChannels.sparkCutReason;
if (strEqualCaseInsensitive(name, "fuelCutReason"))
return engine->outputChannels.fuelCutReason;
if (strEqualCaseInsensitive(name, "fuel_requested_percent")) if (strEqualCaseInsensitive(name, "fuel_requested_percent"))
return engine->outputChannels.fuel_requested_percent; return engine->outputChannels.fuel_requested_percent;
if (strEqualCaseInsensitive(name, "fuel_requested_percent_pi")) if (strEqualCaseInsensitive(name, "fuel_requested_percent_pi"))

View File

@ -1064,6 +1064,7 @@ gaugeCategory = VVT
vvtTargets4Gauge = vvtTargets4, @@GAUGE_NAME_VVT_TARGET_B2E@@, "deg", -60, 60, -60, -60, 60, 60, 0, 0 vvtTargets4Gauge = vvtTargets4, @@GAUGE_NAME_VVT_TARGET_B2E@@, "deg", -60, 60, -60, -60, 60, 60, 0, 0
gaugeCategory = Ignition gaugeCategory = Ignition
sparkCutReasonGauge = sparkCutReason,"Spark Cut Code", "code", 0.0,0.0, 0.0,0.0, 0.0,0.0, 0,0
ignadvGauge = ignitionAdvance, "Ignition timing", "degrees", -100, 100, -999, -999, 999, 999, 1, 1 ignadvGauge = ignitionAdvance, "Ignition timing", "degrees", -100, 100, -999, -999, 999, 999, 1, 1
dwellGauge = sparkDwellValue, "Dwell", "mSec", 0, 10, 0.5, 1.0, 6.0, 8.0, 1, 1 dwellGauge = sparkDwellValue, "Dwell", "mSec", 0, 10, 0.5, 1.0, 6.0, 8.0, 1, 1
coilDutyCycleGauge = coilDutyCycle, @@GAUGE_NAME_DWELL_DUTY@@, "%", 0, 110, 0, 0, 90, 100, 1, 1 coilDutyCycleGauge = coilDutyCycle, @@GAUGE_NAME_DWELL_DUTY@@, "%", 0, 110, 0, 0, 90, 100, 1, 1
@ -1077,6 +1078,7 @@ gaugeCategory = Acceleration Enrichment
gaugeCategory = Fueling gaugeCategory = Fueling
;Name Var Title Units Lo Hi LoD LoW HiW HiD vd ld ;Name Var Title Units Lo Hi LoD LoW HiW HiD vd ld
fuelCutReasonGauge = fuelCutReason,"Fuel Cut Code", "code", 0.0,0.0, 0.0,0.0, 0.0,0.0, 0,0
tChargeGauge = tCharge, @@GAUGE_NAME_FUEL_CHARGE_TEMP@@, "C", -40, 140, -15, 1, 95, 110, 1, 1 tChargeGauge = tCharge, @@GAUGE_NAME_FUEL_CHARGE_TEMP@@, "C", -40, 140, -15, 1, 95, 110, 1, 1
baroCorrectionGauge = baroCorrection,@@GAUGE_NAME_FUEL_BARO_CORR@@, "ratio", 0.5, 1.5, 0.6, 0.7, 1.3, 1.4, 1, 1 baroCorrectionGauge = baroCorrection,@@GAUGE_NAME_FUEL_BARO_CORR@@, "ratio", 0.5, 1.5, 0.6, 0.7, 1.3, 1.4, 1, 1
crankingFuelGauge = crankingFuelMs, @@GAUGE_NAME_FUEL_CRANKING@@, "mg", 0, 100, 0, 0, 100, 100, 3, 1 crankingFuelGauge = crankingFuelMs, @@GAUGE_NAME_FUEL_CRANKING@@, "mg", 0, 100, 0, 0, 100, 100, 3, 1