cisnan -> std::isnan
This commit is contained in:
parent
e5370da2a0
commit
5d63e41a4b
|
@ -14,7 +14,7 @@ AirmassResult SpeedDensityAirmass::getAirmass(float rpm, float map, bool postSta
|
|||
* most of the values are pre-calculated for performance reasons
|
||||
*/
|
||||
float tChargeK = engine->engineState.sd.tChargeK;
|
||||
if (cisnan(tChargeK)) {
|
||||
if (std::isnan(tChargeK)) {
|
||||
warning(ObdCode::CUSTOM_ERR_TCHARGE_NOT_READY2, "tChargeK not ready"); // this would happen before we have CLT reading for example
|
||||
return {};
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ AirmassResult SpeedDensityAirmass::getAirmass(float rpm, float map, bool postSta
|
|||
float ve = getVe(rpm, map, postState);
|
||||
|
||||
float airMass = getAirmassImpl(ve, map, tChargeK);
|
||||
if (cisnan(airMass)) {
|
||||
if (std::isnan(airMass)) {
|
||||
warning(ObdCode::CUSTOM_ERR_6685, "NaN airMass");
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -189,15 +189,15 @@ void refreshMapAveragingPreCalc() {
|
|||
if (isValidRpm(rpm)) {
|
||||
MAP_sensor_config_s * c = &engineConfiguration->map;
|
||||
angle_t start = interpolate2d(rpm, c->samplingAngleBins, c->samplingAngle);
|
||||
efiAssertVoid(ObdCode::CUSTOM_ERR_MAP_START_ASSERT, !cisnan(start), "start");
|
||||
efiAssertVoid(ObdCode::CUSTOM_ERR_MAP_START_ASSERT, !std::isnan(start), "start");
|
||||
|
||||
angle_t offsetAngle = engine->triggerCentral.triggerFormDetails.eventAngles[engineConfiguration->mapAveragingSchedulingAtIndex];
|
||||
efiAssertVoid(ObdCode::CUSTOM_ERR_MAP_AVG_OFFSET, !cisnan(offsetAngle), "offsetAngle");
|
||||
efiAssertVoid(ObdCode::CUSTOM_ERR_MAP_AVG_OFFSET, !std::isnan(offsetAngle), "offsetAngle");
|
||||
|
||||
for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
|
||||
// todo: potential micro-optimization to reuse getEngineState()->engineCycle?
|
||||
angle_t cylinderOffset = getEngineCycle(getEngineRotationState()->getOperationMode()) * i / engineConfiguration->cylindersCount;
|
||||
efiAssertVoid(ObdCode::CUSTOM_ERR_MAP_CYL_OFFSET, !cisnan(cylinderOffset), "cylinderOffset");
|
||||
efiAssertVoid(ObdCode::CUSTOM_ERR_MAP_CYL_OFFSET, !std::isnan(cylinderOffset), "cylinderOffset");
|
||||
// part of this formula related to specific cylinder offset is never changing - we can
|
||||
// move the loop into start-up calculation and not have this loop as part of periodic calculation
|
||||
// todo: change the logic as described above in order to reduce periodic CPU usage?
|
||||
|
@ -252,7 +252,7 @@ void mapAveragingTriggerCallback(
|
|||
|
||||
angle_t samplingEnd = samplingStart + samplingDuration;
|
||||
|
||||
if (cisnan(samplingEnd)) {
|
||||
if (std::isnan(samplingEnd)) {
|
||||
// todo: when would this happen?
|
||||
warning(ObdCode::CUSTOM_ERR_6549, "no map angles");
|
||||
return;
|
||||
|
|
|
@ -116,7 +116,7 @@ static void prepareCylinderIgnitionSchedule(angle_t dwellAngleDuration, floatms_
|
|||
// Offset by this cylinder's position in the cycle
|
||||
+ getPerCylinderFiringOrderOffset(event->cylinderIndex, coilIndex);
|
||||
|
||||
efiAssertVoid(ObdCode::CUSTOM_SPARK_ANGLE_1, !cisnan(sparkAngle), "sparkAngle#1");
|
||||
efiAssertVoid(ObdCode::CUSTOM_SPARK_ANGLE_1, !std::isnan(sparkAngle), "sparkAngle#1");
|
||||
wrapAngle(sparkAngle, "findAngle#2", ObdCode::CUSTOM_ERR_6550);
|
||||
event->sparkAngle = sparkAngle;
|
||||
|
||||
|
@ -145,7 +145,7 @@ static void prepareCylinderIgnitionSchedule(angle_t dwellAngleDuration, floatms_
|
|||
|
||||
|
||||
angle_t dwellStartAngle = sparkAngle - dwellAngleDuration;
|
||||
efiAssertVoid(ObdCode::CUSTOM_ERR_6590, !cisnan(dwellStartAngle), "findAngle#5");
|
||||
efiAssertVoid(ObdCode::CUSTOM_ERR_6590, !std::isnan(dwellStartAngle), "findAngle#5");
|
||||
|
||||
assertAngleRange(dwellStartAngle, "findAngle dwellStartAngle", ObdCode::CUSTOM_ERR_6550);
|
||||
wrapAngle(dwellStartAngle, "findAngle#7", ObdCode::CUSTOM_ERR_6550);
|
||||
|
@ -240,7 +240,7 @@ if (engineConfiguration->debugMode == DBG_DWELL_METRIC) {
|
|||
|
||||
angle_t dwellAngleDuration = engine->ignitionState.dwellDurationAngle;
|
||||
floatms_t sparkDwell = engine->ignitionState.sparkDwell;
|
||||
if (cisnan(dwellAngleDuration) || cisnan(sparkDwell)) {
|
||||
if (std::isnan(dwellAngleDuration) || std::isnan(sparkDwell)) {
|
||||
// we are here if engine has just stopped
|
||||
return;
|
||||
}
|
||||
|
@ -376,11 +376,11 @@ static void scheduleSparkEvent(bool limitedSpark, IgnitionEvent *event,
|
|||
|
||||
angle_t sparkAngle = event->sparkAngle;
|
||||
const floatms_t dwellMs = engine->ignitionState.sparkDwell;
|
||||
if (cisnan(dwellMs) || dwellMs <= 0) {
|
||||
if (std::isnan(dwellMs) || dwellMs <= 0) {
|
||||
warning(ObdCode::CUSTOM_DWELL, "invalid dwell to handle: %.2f at %d", dwellMs, rpm);
|
||||
return;
|
||||
}
|
||||
if (cisnan(sparkAngle)) {
|
||||
if (std::isnan(sparkAngle)) {
|
||||
warning(ObdCode::CUSTOM_ADVANCE_SPARK, "NaN advance");
|
||||
return;
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ static void scheduleSparkEvent(bool limitedSpark, IgnitionEvent *event,
|
|||
* Spark event is often happening during a later trigger event timeframe
|
||||
*/
|
||||
|
||||
efiAssertVoid(ObdCode::CUSTOM_ERR_6591, !cisnan(sparkAngle), "findAngle#4");
|
||||
efiAssertVoid(ObdCode::CUSTOM_ERR_6591, !std::isnan(sparkAngle), "findAngle#4");
|
||||
assertAngleRange(sparkAngle, "findAngle#a5", ObdCode::CUSTOM_ERR_6549);
|
||||
|
||||
bool isTimeScheduled = engine->module<TriggerScheduler>()->scheduleOrQueue(
|
||||
|
@ -493,7 +493,7 @@ void initializeIgnitionActions() {
|
|||
IgnitionEventList *list = &engine->ignitionEvents;
|
||||
angle_t dwellAngle = engine->ignitionState.dwellDurationAngle;
|
||||
floatms_t sparkDwell = engine->ignitionState.sparkDwell;
|
||||
if (cisnan(engine->engineState.timingAdvance[0]) || cisnan(dwellAngle)) {
|
||||
if (std::isnan(engine->engineState.timingAdvance[0]) || std::isnan(dwellAngle)) {
|
||||
// error should already be reported
|
||||
// need to invalidate previous ignition schedule
|
||||
list->isReady = false;
|
||||
|
|
|
@ -80,7 +80,7 @@ floatms_t IgnitionState::getSparkDwell(int rpm) {
|
|||
if (engine->rpmCalculator.isCranking()) {
|
||||
dwellMs = engineConfiguration->ignitionDwellForCrankingMs;
|
||||
} else {
|
||||
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !cisnan(rpm), "invalid rpm", NAN);
|
||||
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !std::isnan(rpm), "invalid rpm", NAN);
|
||||
|
||||
baseDwell = interpolate2d(rpm, config->sparkDwellRpmBins, config->sparkDwellValues);
|
||||
dwellVoltageCorrection = interpolate2d(
|
||||
|
@ -97,7 +97,7 @@ floatms_t IgnitionState::getSparkDwell(int rpm) {
|
|||
dwellMs = baseDwell * dwellVoltageCorrection;
|
||||
}
|
||||
|
||||
if (cisnan(dwellMs) || dwellMs <= 0) {
|
||||
if (std::isnan(dwellMs) || dwellMs <= 0) {
|
||||
// this could happen during engine configuration reset
|
||||
warning(ObdCode::CUSTOM_ERR_DWELL_DURATION, "invalid dwell: %.2f at rpm=%d", dwellMs, rpm);
|
||||
return 0;
|
||||
|
|
|
@ -95,7 +95,7 @@ temperature_t IFuelComputer::getTCharge(int rpm, float tps) {
|
|||
|
||||
sdTcharge_coff = getTChargeCoefficient(rpm, tps);
|
||||
|
||||
if (cisnan(sdTcharge_coff)) {
|
||||
if (std::isnan(sdTcharge_coff)) {
|
||||
warning(ObdCode::CUSTOM_ERR_T2_CHARGE, "t2-getTCharge NaN");
|
||||
return coolantTemp;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ temperature_t IFuelComputer::getTCharge(int rpm, float tps) {
|
|||
// 1.0 coefficient -> use IAT (no heat transfer)
|
||||
float Tcharge = interpolateClamped(0.0f, coolantTemp, 1.0f, airTemp, sdTcharge_coff);
|
||||
|
||||
if (cisnan(Tcharge)) {
|
||||
if (std::isnan(Tcharge)) {
|
||||
// we can probably end up here while resetting engine state - interpolation would fail
|
||||
warning(ObdCode::CUSTOM_ERR_TCHARGE_NOT_READY, "getTCharge NaN");
|
||||
return coolantTemp;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
static float validateBaroMap(float mapKPa) {
|
||||
// Highest interstate is the Eisenhower Tunnel at 11158 feet -> 66 kpa
|
||||
// Lowest point is the Dead Sea, -1411 feet -> 106 kpa
|
||||
if (cisnan(mapKPa) || mapKPa > 110 || mapKPa < 60) {
|
||||
if (std::isnan(mapKPa) || mapKPa > 110 || mapKPa < 60) {
|
||||
warning(ObdCode::OBD_Barometric_Press_Circ, "Invalid start-up baro pressure = %.2fkPa", mapKPa);
|
||||
return NAN;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ void initMapDecoder() {
|
|||
efiPrintf("Get initial baro MAP pressure = %.2fkPa", storedInitialBaroPressure);
|
||||
// validate if it's within a reasonable range (the engine should not be spinning etc.)
|
||||
storedInitialBaroPressure = validateBaroMap(storedInitialBaroPressure);
|
||||
if (!cisnan(storedInitialBaroPressure)) {
|
||||
if (!std::isnan(storedInitialBaroPressure)) {
|
||||
efiPrintf("Using this fixed MAP pressure to override the baro correction!");
|
||||
|
||||
// TODO: do literally anything other than this
|
||||
|
|
|
@ -51,7 +51,7 @@ void SimplePwm::setSimplePwmDutyCycle(float dutyCycle) {
|
|||
// we are here in order to not change pin once PWM stop was requested
|
||||
return;
|
||||
}
|
||||
if (cisnan(dutyCycle)) {
|
||||
if (std::isnan(dutyCycle)) {
|
||||
warning(ObdCode::CUSTOM_DUTY_INVALID, "%s spwd:dutyCycle %.2f", m_name, dutyCycle);
|
||||
return;
|
||||
} else if (dutyCycle < 0) {
|
||||
|
|
|
@ -63,7 +63,7 @@ float InstantRpmCalculator::calculateInstantRpm(
|
|||
|
||||
// Determine where we currently are in the revolution
|
||||
angle_t currentAngle = triggerFormDetails->eventAngles[current_index];
|
||||
efiAssert(ObdCode::OBD_PCM_Processor_Fault, !cisnan(currentAngle), "eventAngles", 0);
|
||||
efiAssert(ObdCode::OBD_PCM_Processor_Fault, !std::isnan(currentAngle), "eventAngles", 0);
|
||||
|
||||
// Hunt for a tooth ~90 degrees ago to compare to the current time
|
||||
angle_t previousAngle = currentAngle - 90;
|
||||
|
|
|
@ -75,7 +75,7 @@ angle_t TriggerCentral::getVVTPosition(uint8_t bankIndex, uint8_t camIndex) {
|
|||
expected<float> TriggerCentral::getCurrentEnginePhase(efitick_t nowNt) const {
|
||||
floatus_t oneDegreeUs = engine->rpmCalculator.oneDegreeUs;
|
||||
|
||||
if (cisnan(oneDegreeUs)) {
|
||||
if (std::isnan(oneDegreeUs)) {
|
||||
return unexpected;
|
||||
}
|
||||
|
||||
|
|
|
@ -362,7 +362,7 @@ int handleActionWithParameter(TokenCallback *current, char *argv[], int argc) {
|
|||
case FLOAT_PARAMETER:
|
||||
{
|
||||
float value = atoff(argv[0]);
|
||||
if (cisnan(value)) {
|
||||
if (std::isnan(value)) {
|
||||
efiPrintf("invalid float [%s]", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ int handleActionWithParameter(TokenCallback *current, char *argv[], int argc) {
|
|||
float value[2];
|
||||
for (int i = 0; i < 2; i++) {
|
||||
value[i] = atoff(argv[i]);
|
||||
if (cisnan(value[i])) {
|
||||
if (std::isnan(value[i])) {
|
||||
efiPrintf("invalid float [%s]", argv[i]);
|
||||
return -1;
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ int handleActionWithParameter(TokenCallback *current, char *argv[], int argc) {
|
|||
float value[3];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
value[i] = atoff(argv[i]);
|
||||
if (cisnan(value[i])) {
|
||||
if (std::isnan(value[i])) {
|
||||
efiPrintf("invalid float [%s]", argv[i]);
|
||||
return -1;
|
||||
}
|
||||
|
@ -410,7 +410,7 @@ int handleActionWithParameter(TokenCallback *current, char *argv[], int argc) {
|
|||
float value[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
value[i] = atoff(argv[i]);
|
||||
if (cisnan(value[i])) {
|
||||
if (std::isnan(value[i])) {
|
||||
efiPrintf("invalid float [%s]", argv[i]);
|
||||
return -1;
|
||||
}
|
||||
|
@ -429,7 +429,7 @@ int handleActionWithParameter(TokenCallback *current, char *argv[], int argc) {
|
|||
return -1;
|
||||
}
|
||||
float value2 = atoff(argv[1]);
|
||||
if (cisnan(value2)) {
|
||||
if (std::isnan(value2)) {
|
||||
efiPrintf("invalid float [%s]", argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue