예제 #1
0
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;
	}
}
예제 #2
0
파일: driver.c 프로젝트: lonbon7/cpe101
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;
}