void FuelConsumptionState::update(efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) { efitick_t deltaNt = nowNt - accumulatedSecondPrevNt; if (deltaNt >= US2NT(US_PER_SECOND_LL)) { perSecondConsumption = getFuelRate(perSecondAccumulator, deltaNt PASS_ENGINE_PARAMETER_SUFFIX); perSecondAccumulator = 0; accumulatedSecondPrevNt = nowNt; } deltaNt = nowNt - accumulatedMinutePrevNt; if (deltaNt >= US2NT(US_PER_SECOND_LL * 60)) { perMinuteConsumption = getFuelRate(perMinuteAccumulator, deltaNt PASS_ENGINE_PARAMETER_SUFFIX); perMinuteAccumulator = 0; accumulatedMinutePrevNt = nowNt; } }
int testGetFuelRate(int currentFuel) { int fuelRate; printf("***Testing getFuelRate...***\n\n"); printf("TEST 1: When prompted, input a number between 0 and 9, inclusive. You should not see an error.\n\n"); fuelRate = getFuelRate(currentFuel); printf("\nFule rate returned was: %d\n", fuelRate); printf("\nTEST 2: When prompted, input a number less than 0. You should see an error and then be prompted again.\n"); printf("Then enter a number greater than 9. You should see the same error message and be prompted again.\n"); printf("\nFinally, eter a number between 0 and 9, inclusive.\n"); fuelRate = getFuelRate(currentFuel); printf("\nFuel rate returned was: %d\n", fuelRate); return fuelRate; }