refactoring around GET_RPM

This commit is contained in:
rusefi 2019-01-21 21:48:58 -05:00
parent ad64e1b410
commit 53e8d10c55
19 changed files with 50 additions and 51 deletions

View File

@ -185,7 +185,7 @@ static void printSensors(Logging *log, bool fileFormat) {
int rpm = 0; int rpm = 0;
#if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__) #if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__)
rpm = getRpmE(engine); rpm = GET_RPM();
reportSensorI(log, fileFormat, "rpm", "RPM", rpm); // log column 2 reportSensorI(log, fileFormat, "rpm", "RPM", rpm); // log column 2
#endif #endif
// why do we still send data into console in text mode? // why do we still send data into console in text mode?
@ -535,7 +535,7 @@ static void showFuelInfo2(float rpm, float engineLoad) {
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__) #if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
static void showFuelInfo(void) { static void showFuelInfo(void) {
showFuelInfo2((float) getRpmE(engine), getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE)); showFuelInfo2((float) GET_RPM(), getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE));
} }
#endif #endif
@ -660,7 +660,7 @@ extern HIP9011 instance;
void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ENGINE_PARAMETER_SUFFIX) { void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ENGINE_PARAMETER_SUFFIX) {
#if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__) #if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__)
int rpm = getRpmE(engine); int rpm = GET_RPM();
#else /* EFI_SHAFT_POSITION_INPUT */ #else /* EFI_SHAFT_POSITION_INPUT */
int rpm = 0; int rpm = 0;
#endif /* EFI_SHAFT_POSITION_INPUT */ #endif /* EFI_SHAFT_POSITION_INPUT */

View File

@ -100,7 +100,7 @@ floatms_t WallFuel::adjust(int injectorIndex, floatms_t M_des DECLARE_ENGINE_PAR
} }
// Ignore really slow RPM // Ignore really slow RPM
int rpm = getRpmE(engine); int rpm = GET_RPM();
if(rpm < 100) if(rpm < 100)
{ {
return M_des; return M_des;

View File

@ -125,7 +125,7 @@ void Engine::periodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
* See also periodicFastCallback * See also periodicFastCallback
*/ */
void Engine::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) { void Engine::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
int rpm = rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE); int rpm = GET_RPM();
isEngineChartEnabled = CONFIG(isEngineChartEnabled) && rpm < CONFIG(engineSnifferRpmThreshold); isEngineChartEnabled = CONFIG(isEngineChartEnabled) && rpm < CONFIG(engineSnifferRpmThreshold);
sensorChartMode = rpm < CONFIG(sensorSnifferRpmThreshold) ? CONFIGB(sensorChartMode) : SC_OFF; sensorChartMode = rpm < CONFIG(sensorSnifferRpmThreshold) ? CONFIGB(sensorChartMode) : SC_OFF;
@ -334,7 +334,7 @@ void Engine::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
engineState.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE); engineState.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
engine->m.beforeFuelCalc = GET_TIMESTAMP(); engine->m.beforeFuelCalc = GET_TIMESTAMP();
int rpm = rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE); int rpm = GET_RPM();
ENGINE(injectionDuration) = getInjectionDuration(rpm PASS_ENGINE_PARAMETER_SUFFIX); ENGINE(injectionDuration) = getInjectionDuration(rpm PASS_ENGINE_PARAMETER_SUFFIX);
engine->m.fuelCalcTime = GET_TIMESTAMP() - engine->m.beforeFuelCalc; engine->m.fuelCalcTime = GET_TIMESTAMP() - engine->m.beforeFuelCalc;

View File

@ -256,7 +256,7 @@ void StartupFuelPumping::setPumpsCounter(int newValue) {
} }
void StartupFuelPumping::update(DECLARE_ENGINE_PARAMETER_SIGNATURE) { void StartupFuelPumping::update(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE) == 0) { if (GET_RPM() == 0) {
bool isTpsAbove50 = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE) >= 50; bool isTpsAbove50 = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE) >= 50;
if (this->isTpsAbove50 != isTpsAbove50) { if (this->isTpsAbove50 != isTpsAbove50) {

View File

@ -307,7 +307,7 @@ floatms_t getBaseTableFuel(int rpm, float engineLoad) {
float getBaroCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) { float getBaroCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (hasBaroSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) { if (hasBaroSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) {
return baroCorrMap.getValue(getRpmE(engine), getBaroPressure(PASS_ENGINE_PARAMETER_SIGNATURE)); return baroCorrMap.getValue(GET_RPM(), getBaroPressure(PASS_ENGINE_PARAMETER_SIGNATURE));
} else { } else {
return 1; return 1;
} }

View File

@ -217,7 +217,7 @@ static percent_t automaticIdleController() {
// check if within the dead zone // check if within the dead zone
int rpm = getRpmE(engine); int rpm = GET_RPM();
if (absI(rpm - targetRpm) <= CONFIG(idlePidRpmDeadZone)) { if (absI(rpm - targetRpm) <= CONFIG(idlePidRpmDeadZone)) {
idleState = RPM_DEAD_ZONE; idleState = RPM_DEAD_ZONE;
// current RPM is close enough, no need to change anything // current RPM is close enough, no need to change anything

View File

@ -212,7 +212,7 @@ static void showLine(lcd_line_e line, int screenY) {
case LL_RPM: case LL_RPM:
{ {
int seconds = minI(9999, getTimeNowSeconds()); int seconds = minI(9999, getTimeNowSeconds());
lcdPrintf("RPM %d %d ", getRpmE(engine), seconds); lcdPrintf("RPM %d %d ", GET_RPM(), seconds);
} }
#if EFI_FILE_LOGGING || defined(__DOXYGEN__) #if EFI_FILE_LOGGING || defined(__DOXYGEN__)
{ {
@ -372,7 +372,7 @@ void updateHD44780lcd(void) {
// } // }
// lcd_HD44780_set_position(0, 10); // lcd_HD44780_set_position(0, 10);
// //
// char * ptr = itoa10(buffer, getRpmE(engine)); // char * ptr = itoa10(buffer, GET_RPM());
// ptr[0] = 0; // ptr[0] = 0;
// int len = ptr - buffer; // int len = ptr - buffer;
// for (int i = 0; i < 6 - len; i++) { // for (int i = 0; i < 6 - len; i++) {

View File

@ -147,7 +147,7 @@ static void handleGetDataRequest(CANRxFrame *rx) {
break; break;
case PID_RPM: case PID_RPM:
scheduleMsg(&logger, "Got RPM request"); scheduleMsg(&logger, "Got RPM request");
obdSendValue(1, pid, 2, getRpmE(engine) * 4.0f); // rotation/min. (A*256+B)/4 obdSendValue(1, pid, 2, GET_RPM() * 4.0f); // rotation/min. (A*256+B)/4
break; break;
case PID_SPEED: case PID_SPEED:
scheduleMsg(&logger, "Got speed request"); scheduleMsg(&logger, "Got speed request");

View File

@ -615,7 +615,7 @@ static void showTriggerHistogram(void) {
static void showMainInfo(Engine *engine) { static void showMainInfo(Engine *engine) {
#if EFI_PROD_CODE || defined(__DOXYGEN__) #if EFI_PROD_CODE || defined(__DOXYGEN__)
int rpm = engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE); int rpm = GET_RPM();
float el = getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE); float el = getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE);
scheduleMsg(logger, "rpm %d engine_load %.2f", rpm, el); scheduleMsg(logger, "rpm %d engine_load %.2f", rpm, el);
scheduleMsg(logger, "fuel %.2fms timing %.2f", getInjectionDuration(rpm PASS_ENGINE_PARAMETER_SUFFIX), engine->engineState.timingAdvance); scheduleMsg(logger, "fuel %.2fms timing %.2f", getInjectionDuration(rpm PASS_ENGINE_PARAMETER_SUFFIX), engine->engineState.timingAdvance);

View File

@ -296,7 +296,7 @@ static char rpmBuffer[_MAX_FILLER];
* digital sniffer. * digital sniffer.
*/ */
static void onTdcCallback(void) { static void onTdcCallback(void) {
itoa10(rpmBuffer, getRpmE(engine)); itoa10(rpmBuffer, GET_RPM());
addEngineSnifferEvent(TOP_DEAD_CENTER_MESSAGE, (char* ) rpmBuffer); addEngineSnifferEvent(TOP_DEAD_CENTER_MESSAGE, (char* ) rpmBuffer);
} }
@ -309,7 +309,7 @@ static void tdcMarkCallback(trigger_event_e ckpSignalType,
bool isTriggerSynchronizationPoint = index0 == 0; bool isTriggerSynchronizationPoint = index0 == 0;
if (isTriggerSynchronizationPoint && ENGINE(isEngineChartEnabled)) { if (isTriggerSynchronizationPoint && ENGINE(isEngineChartEnabled)) {
int revIndex2 = engine->rpmCalculator.getRevolutionCounter() % 2; int revIndex2 = engine->rpmCalculator.getRevolutionCounter() % 2;
int rpm = ENGINE(rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)); int rpm = GET_RPM();
// todo: use tooth event-based scheduling, not just time-based scheduling // todo: use tooth event-based scheduling, not just time-based scheduling
if (isValidRpm(rpm)) { if (isValidRpm(rpm)) {
scheduleByAngle(rpm, &tdcScheduler[revIndex2], tdcPosition(), scheduleByAngle(rpm, &tdcScheduler[revIndex2], tdcPosition(),
@ -337,7 +337,7 @@ float getCrankshaftAngleNt(efitime_t timeNt DECLARE_ENGINE_PARAMETER_SUFFIX) {
* compiler is not smart enough to figure out that "A / ( B / C)" could be optimized into * compiler is not smart enough to figure out that "A / ( B / C)" could be optimized into
* "A * C / B" in order to replace a slower division with a faster multiplication. * "A * C / B" in order to replace a slower division with a faster multiplication.
*/ */
int rpm = engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE); int rpm = GET_RPM();
return rpm == 0 ? NAN : timeSinceZeroAngleNt / getOneDegreeTimeNt(rpm); return rpm == 0 ? NAN : timeSinceZeroAngleNt / getOneDegreeTimeNt(rpm);
} }

View File

@ -94,7 +94,7 @@ public:
/** /**
* Just a getter for rpmValue * Just a getter for rpmValue
* Also hangles mockRpm if not EFI_PROD_CODE * Also handles mockRpm if not EFI_PROD_CODE
*/ */
int getRpm(DECLARE_ENGINE_PARAMETER_SIGNATURE) const; int getRpm(DECLARE_ENGINE_PARAMETER_SIGNATURE) const;
/** /**
@ -154,11 +154,10 @@ private:
bool isSpinning = false; bool isSpinning = false;
}; };
/** // Just a getter for rpmValue which also handles mockRpm if not EFI_PROD_CODE
* @brief Current RPM #define GET_RPM() ( ENGINE(rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) )
*/
#define getRpmE(engine) (engine)->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)
// simple variable access, theoretically could be faster than getter method but that's a long stretch
#define GET_RPM_VALUE ( ENGINE(rpmCalculator.rpmValue) ) #define GET_RPM_VALUE ( ENGINE(rpmCalculator.rpmValue) )
#define isValidRpm(rpm) ((rpm) > 0 && (rpm) < UNREALISTIC_RPM) #define isValidRpm(rpm) ((rpm) > 0 && (rpm) < UNREALISTIC_RPM)

View File

@ -243,7 +243,7 @@ static void reportWave(Logging *logging, int index) {
appendPrintf(logging, "%s", DELIMETER); appendPrintf(logging, "%s", DELIMETER);
uint32_t offsetUs = getWaveOffset(index); uint32_t offsetUs = getWaveOffset(index);
int rpm = getRpmE(engine); int rpm = GET_RPM();
if (rpm != 0) { if (rpm != 0) {
float oneDegreeUs = getOneDegreeTimeUs(rpm); float oneDegreeUs = getOneDegreeTimeUs(rpm);

View File

@ -135,7 +135,7 @@ static void canDashboardBMW(void) {
sendCanMessage(); sendCanMessage();
commonTxInit(CAN_BMW_E46_RPM); commonTxInit(CAN_BMW_E46_RPM);
setShortValue(&txmsg, (int) (getRpmE(engine) * 6.4), 2); setShortValue(&txmsg, (int) (GET_RPM() * 6.4), 2);
sendCanMessage(); sendCanMessage();
commonTxInit(CAN_BMW_E46_DME2); commonTxInit(CAN_BMW_E46_DME2);
@ -152,7 +152,7 @@ static void canMazdaRX8(void) {
float kph = getVehicleSpeed(); float kph = getVehicleSpeed();
setShortValue(&txmsg, SWAP_UINT16(getRpmE(engine) * 4), 0); setShortValue(&txmsg, SWAP_UINT16(GET_RPM() * 4), 0);
setShortValue(&txmsg, 0xFFFF, 2); setShortValue(&txmsg, 0xFFFF, 2);
setShortValue(&txmsg, SWAP_UINT16((int )(100 * kph + 10000)), 4); setShortValue(&txmsg, SWAP_UINT16((int )(100 * kph + 10000)), 4);
setShortValue(&txmsg, 0, 6); setShortValue(&txmsg, 0, 6);
@ -177,7 +177,7 @@ static void canMazdaRX8(void) {
txmsg.data8[4] = 0x01; //Oil Pressure (not really a gauge) txmsg.data8[4] = 0x01; //Oil Pressure (not really a gauge)
txmsg.data8[5] = 0x00; //check engine light txmsg.data8[5] = 0x00; //check engine light
txmsg.data8[6] = 0x00; //Coolant, oil and battery txmsg.data8[6] = 0x00; //Coolant, oil and battery
if ((getRpmE(engine)>0) && (engine->sensors.vBatt<13)) { if ((GET_RPM()>0) && (engine->sensors.vBatt<13)) {
setTxBit(6, 6); // battery light setTxBit(6, 6); // battery light
} }
if (engine->sensors.clt > 105) { if (engine->sensors.clt > 105) {
@ -192,14 +192,14 @@ static void canDashboardFiat(void) {
//Fiat Dashboard //Fiat Dashboard
commonTxInit(CAN_FIAT_MOTOR_INFO); commonTxInit(CAN_FIAT_MOTOR_INFO);
setShortValue(&txmsg, (int) (engine->sensors.clt - 40), 3); //Coolant Temp setShortValue(&txmsg, (int) (engine->sensors.clt - 40), 3); //Coolant Temp
setShortValue(&txmsg, getRpmE(engine) / 32, 6); //RPM setShortValue(&txmsg, GET_RPM() / 32, 6); //RPM
sendCanMessage(); sendCanMessage();
} }
static void canDashboardVAG(void) { static void canDashboardVAG(void) {
//VAG Dashboard //VAG Dashboard
commonTxInit(CAN_VAG_RPM); commonTxInit(CAN_VAG_RPM);
setShortValue(&txmsg, getRpmE(engine) * 4, 2); //RPM setShortValue(&txmsg, GET_RPM() * 4, 2); //RPM
sendCanMessage(); sendCanMessage();
commonTxInit(CAN_VAG_CLT); commonTxInit(CAN_VAG_CLT);

View File

@ -183,7 +183,7 @@ void EngineTestHelper::applyTriggerShape() {
} }
void assertRpm(const char *msg, int expectedRpm DECLARE_ENGINE_PARAMETER_SUFFIX) { void assertRpm(const char *msg, int expectedRpm DECLARE_ENGINE_PARAMETER_SUFFIX) {
EXPECT_EQ(expectedRpm, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << msg; EXPECT_EQ(expectedRpm, GET_RPM()) << msg;
} }
void setupSimpleTestEngineWithMaf(EngineTestHelper *eth, injection_mode_e injectionMode, void setupSimpleTestEngineWithMaf(EngineTestHelper *eth, injection_mode_e injectionMode,

View File

@ -28,7 +28,7 @@ TEST(cranking, testFasterEngineSpinningUp) {
// check if the engine has the right state // check if the engine has the right state
ASSERT_EQ(STOPPED, engine->rpmCalculator.getState()); ASSERT_EQ(STOPPED, engine->rpmCalculator.getState());
// check RPM // check RPM
ASSERT_EQ( 0, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << "RPM=0"; ASSERT_EQ( 0, GET_RPM()) << "RPM=0";
// the queue should be empty, no trigger events yet // the queue should be empty, no trigger events yet
ASSERT_EQ(0, engine->executor.size()) << "plain#1"; ASSERT_EQ(0, engine->executor.size()) << "plain#1";
@ -41,7 +41,7 @@ TEST(cranking, testFasterEngineSpinningUp) {
// check if the mode is changed // check if the mode is changed
ASSERT_EQ(SPINNING_UP, engine->rpmCalculator.getState()); ASSERT_EQ(SPINNING_UP, engine->rpmCalculator.getState());
// due to isFasterEngineSpinUp=true, we should have already detected RPM! // due to isFasterEngineSpinUp=true, we should have already detected RPM!
ASSERT_EQ( 300, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << "spinning-RPM#1"; ASSERT_EQ( 300, GET_RPM()) << "spinning-RPM#1";
// two simultaneous injections // two simultaneous injections
ASSERT_EQ(4, engine->executor.size()) << "plain#2"; ASSERT_EQ(4, engine->executor.size()) << "plain#2";
// test if they are simultaneous // test if they are simultaneous
@ -63,7 +63,7 @@ TEST(cranking, testFasterEngineSpinningUp) {
// check if the mode is changed when fully synched // check if the mode is changed when fully synched
ASSERT_EQ(CRANKING, engine->rpmCalculator.getState()); ASSERT_EQ(CRANKING, engine->rpmCalculator.getState());
// check RPM // check RPM
ASSERT_EQ( 200, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << "RPM#2"; ASSERT_EQ( 200, GET_RPM()) << "RPM#2";
// test if they are simultaneous in cranking mode too // test if they are simultaneous in cranking mode too
ASSERT_EQ(IM_SIMULTANEOUS, engine->getCurrentInjectionMode(PASS_ENGINE_PARAMETER_SIGNATURE)); ASSERT_EQ(IM_SIMULTANEOUS, engine->getCurrentInjectionMode(PASS_ENGINE_PARAMETER_SIGNATURE));
// test if ignition mode is restored to ind.coils // test if ignition mode is restored to ind.coils
@ -84,7 +84,7 @@ TEST(cranking, testFasterEngineSpinningUp) {
// check if the mode is now changed to 'running' at higher RPM // check if the mode is now changed to 'running' at higher RPM
ASSERT_EQ(RUNNING, engine->rpmCalculator.getState()); ASSERT_EQ(RUNNING, engine->rpmCalculator.getState());
// check RPM // check RPM
ASSERT_EQ( 1000, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << "RPM#3"; ASSERT_EQ( 1000, GET_RPM()) << "RPM#3";
// check if the injection mode is back to sequential now // check if the injection mode is back to sequential now
ASSERT_EQ(IM_SEQUENTIAL, engine->getCurrentInjectionMode(PASS_ENGINE_PARAMETER_SIGNATURE)); ASSERT_EQ(IM_SEQUENTIAL, engine->getCurrentInjectionMode(PASS_ENGINE_PARAMETER_SIGNATURE));
// 4 sequential injections for the full cycle // 4 sequential injections for the full cycle

View File

@ -17,7 +17,7 @@ TEST(big, testSpeedDensity) {
eth.applyTriggerShape(); eth.applyTriggerShape();
eth.fireTriggerEvents(36); eth.fireTriggerEvents(36);
ASSERT_EQ( 1500, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << "RPM"; ASSERT_EQ( 1500, GET_RPM()) << "RPM";
// 427 cubic inches, that's a LOT of engine // 427 cubic inches, that's a LOT of engine
engineConfiguration->specs.displacement = 6.99728; engineConfiguration->specs.displacement = 6.99728;

View File

@ -13,15 +13,15 @@ TEST(engine, testPlainCrankingWithoutAdvancedFeatures) {
WITH_ENGINE_TEST_HELPER(TEST_ENGINE); WITH_ENGINE_TEST_HELPER(TEST_ENGINE);
setupSimpleTestEngineWithMafAndTT_ONE_trigger(&eth); setupSimpleTestEngineWithMafAndTT_ONE_trigger(&eth);
ASSERT_EQ( 0, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << "RPM=0"; ASSERT_EQ( 0, GET_RPM()) << "RPM=0";
eth.fireTriggerEventsWithDuration(/* durationMs */ 200); eth.fireTriggerEventsWithDuration(/* durationMs */ 200);
// still no RPM since need to cycles measure cycle duration // still no RPM since need to cycles measure cycle duration
ASSERT_EQ( 0, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << "start-RPM#1"; ASSERT_EQ( 0, GET_RPM()) << "start-RPM#1";
eth.fireRise(/* delayMs */ 200); eth.fireRise(/* delayMs */ 200);
ASSERT_EQ( 300, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << "RPM#2"; ASSERT_EQ( 300, GET_RPM()) << "RPM#2";
// two simultaneous injections // two simultaneous injections
ASSERT_EQ( 4, engine->executor.size()) << "plain#2"; ASSERT_EQ( 4, engine->executor.size()) << "plain#2";
@ -38,7 +38,7 @@ TEST(engine, testStartOfCrankingPrimingPulse) {
engineConfiguration->startOfCrankingPrimingPulse = 4; engineConfiguration->startOfCrankingPrimingPulse = 4;
setupSimpleTestEngineWithMafAndTT_ONE_trigger(&eth); setupSimpleTestEngineWithMafAndTT_ONE_trigger(&eth);
ASSERT_EQ( 0, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << "RPM=0"; ASSERT_EQ( 0, GET_RPM()) << "RPM=0";
// this -70 value comes from CLT error handling code // this -70 value comes from CLT error handling code
ASSERT_NEAR( 70, engine->sensors.clt, EPS4D) << "CLT#1"; ASSERT_NEAR( 70, engine->sensors.clt, EPS4D) << "CLT#1";

View File

@ -306,7 +306,7 @@ TEST(misc, testRpmCalculator) {
engine->sensors.clt = 70; // 'testCltValue' does not give us exact number so we have to hack here. todo: migrate test engine->sensors.clt = 70; // 'testCltValue' does not give us exact number so we have to hack here. todo: migrate test
engine->sensors.iat = 30; // 'testIatValue' does not give us exact number so we have to hack here. todo: migrate test engine->sensors.iat = 30; // 'testIatValue' does not give us exact number so we have to hack here. todo: migrate test
ASSERT_EQ(0, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)); ASSERT_EQ(0, GET_RPM());
// triggerIndexByAngle update is now fixed! prepareOutputSignals() wasn't reliably called // triggerIndexByAngle update is now fixed! prepareOutputSignals() wasn't reliably called
ASSERT_EQ(5, TRIGGER_SHAPE(triggerIndexByAngle[240])); ASSERT_EQ(5, TRIGGER_SHAPE(triggerIndexByAngle[240]));
@ -314,7 +314,7 @@ TEST(misc, testRpmCalculator) {
eth.fireTriggerEvents(/* count */ 48); eth.fireTriggerEvents(/* count */ 48);
ASSERT_EQ( 1500, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << "RPM"; ASSERT_EQ( 1500, GET_RPM()) << "RPM";
ASSERT_EQ( 15, engine->triggerCentral.triggerState.getCurrentIndex()) << "index #1"; ASSERT_EQ( 15, engine->triggerCentral.triggerState.getCurrentIndex()) << "index #1";
@ -676,10 +676,10 @@ static void setTestBug299(EngineTestHelper *eth) {
testMafValue = 0; testMafValue = 0;
ASSERT_EQ( 0, getMaf(PASS_ENGINE_PARAMETER_SIGNATURE)) << "maf"; ASSERT_EQ( 0, getMaf(PASS_ENGINE_PARAMETER_SIGNATURE)) << "maf";
ASSERT_EQ( 3000, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << "setTestBug299: RPM"; ASSERT_EQ( 3000, GET_RPM()) << "setTestBug299: RPM";
assertEqualsM("fuel#1", 1.5, engine->injectionDuration); assertEqualsM("fuel#1", 1.5, engine->injectionDuration);
assertEqualsM("duty for maf=0", 7.5, getInjectorDutyCycle(engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE) PASS_ENGINE_PARAMETER_SUFFIX)); assertEqualsM("duty for maf=0", 7.5, getInjectorDutyCycle(GET_RPM() PASS_ENGINE_PARAMETER_SUFFIX));
testMafValue = 3; testMafValue = 3;
ASSERT_EQ( 3, getMaf(PASS_ENGINE_PARAMETER_SIGNATURE)) << "maf"; ASSERT_EQ( 3, getMaf(PASS_ENGINE_PARAMETER_SIGNATURE)) << "maf";
@ -708,7 +708,7 @@ TEST(big, testFuelSchedulerBug299smallAndMedium) {
engine->periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE); engine->periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
assertEqualsM("fuel#2", 12.5, engine->injectionDuration); assertEqualsM("fuel#2", 12.5, engine->injectionDuration);
assertEqualsM("duty for maf=3", 62.5, getInjectorDutyCycle(eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE) PASS_ENGINE_PARAMETER_SUFFIX)); assertEqualsM("duty for maf=3", 62.5, getInjectorDutyCycle(GET_RPM() PASS_ENGINE_PARAMETER_SUFFIX));
ASSERT_EQ( 4, engine->executor.size()) << "qs#1"; ASSERT_EQ( 4, engine->executor.size()) << "qs#1";
eth.moveTimeForwardUs(MS2US(20)); eth.moveTimeForwardUs(MS2US(20));
@ -869,7 +869,7 @@ TEST(big, testFuelSchedulerBug299smallAndMedium) {
engine->periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE); engine->periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
assertEqualsM("fuel#3", 17.5, engine->injectionDuration); assertEqualsM("fuel#3", 17.5, engine->injectionDuration);
// duty cycle above 75% is a special use-case because 'special' fuel event overlappes the next normal event in batch mode // duty cycle above 75% is a special use-case because 'special' fuel event overlappes the next normal event in batch mode
assertEqualsM("duty for maf=3", 87.5, getInjectorDutyCycle(eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE) PASS_ENGINE_PARAMETER_SUFFIX)); assertEqualsM("duty for maf=3", 87.5, getInjectorDutyCycle(GET_RPM() PASS_ENGINE_PARAMETER_SUFFIX));
assertInjectionEvent("#03", &t->elements[0], 0, 0, 315, false); assertInjectionEvent("#03", &t->elements[0], 0, 0, 315, false);
@ -987,7 +987,7 @@ TEST(big, testFuelSchedulerBug299smallAndLarge) {
engine->periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE); engine->periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
assertEqualsM("Lfuel#2", 17.5, engine->injectionDuration); assertEqualsM("Lfuel#2", 17.5, engine->injectionDuration);
assertEqualsM("Lduty for maf=3", 87.5, getInjectorDutyCycle(engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE) PASS_ENGINE_PARAMETER_SUFFIX)); assertEqualsM("Lduty for maf=3", 87.5, getInjectorDutyCycle(GET_RPM() PASS_ENGINE_PARAMETER_SUFFIX));
ASSERT_EQ( 4, engine->executor.size()) << "Lqs#1"; ASSERT_EQ( 4, engine->executor.size()) << "Lqs#1";
@ -1051,7 +1051,7 @@ TEST(big, testFuelSchedulerBug299smallAndLarge) {
engine->periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE); engine->periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
ASSERT_EQ( 2, engine->injectionDuration) << "Lfuel#4"; ASSERT_EQ( 2, engine->injectionDuration) << "Lfuel#4";
ASSERT_EQ( 10, getInjectorDutyCycle(eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE) PASS_ENGINE_PARAMETER_SUFFIX)) << "Lduty for maf=3"; ASSERT_EQ( 10, getInjectorDutyCycle(GET_RPM() PASS_ENGINE_PARAMETER_SUFFIX)) << "Lduty for maf=3";
eth.firePrimaryTriggerRise(); eth.firePrimaryTriggerRise();
@ -1117,7 +1117,7 @@ TEST(big, testSparkReverseOrderBug319) {
eth.fireRise(20); eth.fireRise(20);
eth.fireFall(20); eth.fireFall(20);
ASSERT_EQ( 3000, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << "testSparkReverseOrderBug319: RPM"; ASSERT_EQ( 3000, GET_RPM()) << "testSparkReverseOrderBug319: RPM";
ASSERT_EQ( 7, engine->executor.size()) << "testSparkReverseOrderBug319: queue size"; ASSERT_EQ( 7, engine->executor.size()) << "testSparkReverseOrderBug319: queue size";
@ -1148,7 +1148,7 @@ TEST(big, testSparkReverseOrderBug319) {
eth.fireRise(20); eth.fireRise(20);
eth.executeActions(); eth.executeActions();
ASSERT_EQ( 545, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << "RPM#2"; ASSERT_EQ( 545, GET_RPM()) << "RPM#2";
ASSERT_EQ( 0, enginePins.coils[3].outOfOrder) << "out-of-order #3"; ASSERT_EQ( 0, enginePins.coils[3].outOfOrder) << "out-of-order #3";
@ -1162,7 +1162,7 @@ TEST(big, testSparkReverseOrderBug319) {
eth.fireRise(20); eth.fireRise(20);
eth.executeActions(); eth.executeActions();
ASSERT_EQ( 3000, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << "RPM#3"; ASSERT_EQ( 3000, GET_RPM()) << "RPM#3";
ASSERT_EQ( 1, enginePins.coils[3].outOfOrder) << "out-of-order #5 on c4"; ASSERT_EQ( 1, enginePins.coils[3].outOfOrder) << "out-of-order #5 on c4";
@ -1176,7 +1176,7 @@ TEST(big, testSparkReverseOrderBug319) {
eth.fireRise(20); eth.fireRise(20);
eth.executeActions(); eth.executeActions();
ASSERT_EQ( 3000, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << "RPM#4"; ASSERT_EQ( 3000, GET_RPM()) << "RPM#4";
ASSERT_EQ( 1, enginePins.coils[3].outOfOrder) << "out-of-order #7"; ASSERT_EQ( 1, enginePins.coils[3].outOfOrder) << "out-of-order #7";

View File

@ -106,7 +106,7 @@ static void testNoiselessDecoderProcedure(EngineTestHelper &eth, int errorTolera
// check if we're imitating the 60-2 signal correctly // check if we're imitating the 60-2 signal correctly
ASSERT_EQ( 0, eth.engine.triggerCentral.triggerState.getCurrentIndex()) << "index #1"; ASSERT_EQ( 0, eth.engine.triggerCentral.triggerState.getCurrentIndex()) << "index #1";
// check rpm (60secs / (1000us * 60teeth)) = 1000rpm // check rpm (60secs / (1000us * 60teeth)) = 1000rpm
ASSERT_EQ( 1000, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << "testNoiselessDecoder RPM"; ASSERT_EQ( 1000, GET_RPM()) << "testNoiselessDecoder RPM";
// add noise1 - 1 spike in the middle of the 2nd rising pulse // add noise1 - 1 spike in the middle of the 2nd rising pulse
fireNoisyCycle60_2(&eth, 2, 1000, 2, 10, 500, 1); fireNoisyCycle60_2(&eth, 2, 1000, 2, 10, 500, 1);
@ -182,7 +182,7 @@ TEST(big, testNoiselessDecoder) {
eth.applyTriggerShape(); eth.applyTriggerShape();
ASSERT_EQ(0, engine->triggerCentral.triggerState.totalTriggerErrorCounter); ASSERT_EQ(0, engine->triggerCentral.triggerState.totalTriggerErrorCounter);
ASSERT_EQ( 0, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << "testNoiselessDecoder RPM"; ASSERT_EQ( 0, GET_RPM()) << "testNoiselessDecoder RPM";
//printTriggerDebug = true; //printTriggerDebug = true;