better error handling

This commit is contained in:
rusefi 2017-11-19 21:30:59 -05:00
parent 5d9ba5e99b
commit 67fc168368
1 changed files with 8 additions and 0 deletions

View File

@ -28,12 +28,20 @@ baroCorr_Map3D_t baroCorrMap("baro");
#define tpMax 100
// http://rusefi.com/math/t_charge.html
float getTCharge(int rpm, float tps, float coolantTemp, float airTemp DECLARE_ENGINE_PARAMETER_SUFFIX) {
if (cisnan(coolantTemp) || cisnan(airTemp)) {
warning(CUSTOM_ERR_6147, "t-getTCharge NaN");
return coolantTemp;
}
float minRpmKcurrentTPS = interpolate(tpMin, engineConfiguration->tChargeMinRpmMinTps, tpMax,
engineConfiguration->tChargeMinRpmMaxTps, tps);
float maxRpmKcurrentTPS = interpolate(tpMin, engineConfiguration->tChargeMaxRpmMinTps, tpMax,
engineConfiguration->tChargeMaxRpmMaxTps, tps);
float Tcharge_coff = interpolate(rpmMin, minRpmKcurrentTPS, rpmMax, maxRpmKcurrentTPS, rpm);
if (cisnan(Tcharge_coff)) {
warning(CUSTOM_ERR_6148, "t2-getTCharge NaN");
return coolantTemp;
}
float Tcharge = coolantTemp * (1 - Tcharge_coff) + airTemp * Tcharge_coff;