Merge remote-tracking branch 'upstream/master' into perf-tracing

This commit is contained in:
Matthew Kennedy 2019-10-14 23:45:39 -07:00
commit d6e065f99e
23 changed files with 94 additions and 85 deletions

View File

@ -54,10 +54,8 @@ FsioState::FsioState() {
void Engine::eInitializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMETER_SUFFIX) {
#if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
#if !EFI_UNIT_TEST
// we have a confusing threading model so some synchronization would not hurt
bool alreadyLocked = lockAnyContext();
#endif /* EFI_UNIT_TEST */
TRIGGER_SHAPE(initializeTriggerShape(logger,
engineConfiguration->ambiguousOperationMode,
@ -87,11 +85,9 @@ void Engine::eInitializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMETER_SU
engine->engineCycleEventCount = TRIGGER_SHAPE(getLength());
}
#if !EFI_UNIT_TEST
if (!alreadyLocked) {
unlockAnyContext();
}
#endif /* EFI_UNIT_TEST */
if (!TRIGGER_SHAPE(shapeDefinitionError)) {
prepareOutputSignals(PASS_ENGINE_PARAMETER_SIGNATURE);

View File

@ -227,9 +227,7 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
void EngineState::updateTChargeK(int rpm, float tps DECLARE_ENGINE_PARAMETER_SUFFIX) {
#if EFI_ENGINE_CONTROL
float coolantC = ENGINE(sensors.clt);
float intakeC = ENGINE(sensors.iat);
float newTCharge = getTCharge(rpm, tps, coolantC, intakeC PASS_ENGINE_PARAMETER_SUFFIX);
float newTCharge = getTCharge(rpm, tps, getCoolantTemperature(), getIntakeAirTemperature() PASS_ENGINE_PARAMETER_SUFFIX);
// convert to microsecs and then to seconds
efitick_t curTime = getTimeNowNt();
float secsPassed = (float)NT2US(curTime - timeSinceLastTChargeK) / 1000000.0f;

View File

@ -73,12 +73,14 @@ DISPLAY(DISPLAY_IF(isCrankingState)) floatms_t getCrankingFuel3(float coolantTem
DISPLAY_SENSOR(TPS);
DISPLAY_TEXT(eol);
DISPLAY_TEXT(Cranking_fuel);
floatms_t crankingFuel = engine->engineState.DISPLAY_PREFIX(cranking).DISPLAY_FIELD(fuel) = baseCrankingFuel
floatms_t crankingFuel = baseCrankingFuel
* engine->engineState.cranking.durationCoefficient
* engine->engineState.cranking.coolantTemperatureCoefficient
* engine->engineState.cranking.tpsCoefficient;
DISPLAY_TEXT(Cranking_fuel);
engine->engineState.DISPLAY_PREFIX(cranking).DISPLAY_FIELD(fuel) = crankingFuel;
if (crankingFuel <= 0) {
warning(CUSTOM_ERR_ZERO_CRANKING_FUEL, "Cranking fuel value %f", crankingFuel);
}

View File

@ -92,6 +92,8 @@
#include "cj125.h"
#endif /* EFI_CJ125 */
EXTERN_ENGINE;
// this method is used by real firmware and simulator and unit test
void mostCommonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
#if !EFI_UNIT_TEST
@ -114,6 +116,12 @@ void mostCommonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMET
initElectronicThrottle(PASS_ENGINE_PARAMETER_SIGNATURE);
#endif /* EFI_ELECTRONIC_THROTTLE_BODY */
#if EFI_MAP_AVERAGING
if (engineConfiguration->isMapAveragingEnabled) {
initMapAveraging(sharedLogger PASS_ENGINE_PARAMETER_SUFFIX);
}
#endif /* EFI_MAP_AVERAGING */
}
EXTERN_ENGINE;
@ -751,12 +759,6 @@ void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX)
initMalfunctionIndicator();
#endif /* EFI_MALFUNCTION_INDICATOR */
#if EFI_MAP_AVERAGING
if (engineConfiguration->isMapAveragingEnabled) {
initMapAveraging(sharedLogger, engine);
}
#endif /* EFI_MAP_AVERAGING */
initEgoAveraging(PASS_ENGINE_PARAMETER_SIGNATURE);
#if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
@ -810,6 +812,6 @@ int getRusEfiVersion(void) {
if (initBootloader() != 0)
return 123;
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
return 20191009;
return 20191013;
}
#endif /* EFI_UNIT_TEST */

View File

@ -111,15 +111,16 @@ static bool isAveraging = false;
static void startAveraging(void *arg) {
(void) arg;
efiAssertVoid(CUSTOM_ERR_6649, getCurrentRemainingStack() > 128, "lowstck#9");
bool wasLocked = lockAnyContext();
;
// with locking we would have a consistent state
mapAdcAccumulator = 0;
mapMeasurementsCounter = 0;
isAveraging = true;
if (!wasLocked)
if (!wasLocked) {
unlockAnyContext();
;
}
mapAveragingPin.setHigh();
}
@ -177,7 +178,9 @@ void mapAveragingAdcCallback(adcsample_t adcValue) {
static void endAveraging(void *arg) {
(void) arg;
#if ! EFI_UNIT_TEST
bool wasLocked = lockAnyContext();
#endif
isAveraging = false;
// with locking we would have a consistent state
#if HAL_USE_ADC
@ -198,13 +201,15 @@ static void endAveraging(void *arg) {
warning(CUSTOM_UNEXPECTED_MAP_VALUE, "No MAP values");
}
#endif
#if ! EFI_UNIT_TEST
if (!wasLocked)
unlockAnyContext();
;
#endif
mapAveragingPin.setLow();
}
static void applyMapMinBufferLength() {
static void applyMapMinBufferLength(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
// check range
mapMinBufferLength = maxI(minI(CONFIGB(mapMinBufferLength), MAX_MAP_BUFFER_LENGTH), 1);
// reset index
@ -215,14 +220,14 @@ static void applyMapMinBufferLength() {
}
}
void postMapState(TunerStudioOutputChannels *tsOutputChannels) {
#if EFI_TUNER_STUDIO
void postMapState(TunerStudioOutputChannels *tsOutputChannels) {
tsOutputChannels->debugFloatField1 = v_averagedMapValue;
tsOutputChannels->debugFloatField2 = engine->engineState.mapAveragingDuration;
tsOutputChannels->debugFloatField3 = currentPressure;
tsOutputChannels->debugIntField1 = mapMeasurementsCounter;
#endif /* EFI_TUNER_STUDIO */
}
#endif /* EFI_TUNER_STUDIO */
void refreshMapAveragingPreCalc(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
int rpm = GET_RPM_VALUE;
@ -237,6 +242,9 @@ void refreshMapAveragingPreCalc(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
angle_t cylinderOffset = getEngineCycle(engine->getOperationMode(PASS_ENGINE_PARAMETER_SIGNATURE)) * i / engineConfiguration->specs.cylindersCount;
efiAssertVoid(CUSTOM_ERR_6692, !cisnan(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?
float cylinderStart = start + cylinderOffset - offsetAngle + tdcPosition();
fixAngle(cylinderStart, "cylinderStart", CUSTOM_ERR_6562);
engine->engineState.mapAveragingStart[i] = cylinderStart;
@ -272,7 +280,7 @@ static void mapAveragingTriggerCallback(trigger_event_e ckpEventType,
}
if (CONFIGB(mapMinBufferLength) != mapMinBufferLength) {
applyMapMinBufferLength();
applyMapMinBufferLength(PASS_ENGINE_PARAMETER_SIGNATURE);
}
measurementsPerRevolution = measurementsPerRevolutionCounter;
@ -301,12 +309,14 @@ static void mapAveragingTriggerCallback(trigger_event_e ckpEventType,
fixAngle(samplingEnd, "samplingEnd", CUSTOM_ERR_6563);
// only if value is already prepared
int structIndex = engine->rpmCalculator.getRevolutionCounter() % 2;
int structIndex = getRevolutionCounter() % 2;
// at the moment we schedule based on time prediction based on current RPM and angle
// we are loosing precision in case of changing RPM - the further away is the event the worse is precision
// todo: schedule this based on closest trigger event, same as ignition works
scheduleByAngle(rpm, &startTimer[i][structIndex], samplingStart,
startAveraging, NULL, &engine->rpmCalculator);
startAveraging, NULL, &engine->rpmCalculator PASS_ENGINE_PARAMETER_SUFFIX);
scheduleByAngle(rpm, &endTimer[i][structIndex], samplingEnd,
endAveraging, NULL, &engine->rpmCalculator);
endAveraging, NULL, &engine->rpmCalculator PASS_ENGINE_PARAMETER_SUFFIX);
engine->m.mapAveragingCbTime = getTimeNowLowerNt()
- engine->m.beforeMapAveragingCb;
}
@ -338,7 +348,7 @@ float getMap(void) {
}
#endif /* EFI_PROD_CODE */
void initMapAveraging(Logging *sharedLogger, Engine *engine) {
void initMapAveraging(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
logger = sharedLogger;
// startTimer[0].name = "map start0";
@ -350,7 +360,7 @@ void initMapAveraging(Logging *sharedLogger, Engine *engine) {
addTriggerEventListener(&mapAveragingTriggerCallback, "MAP averaging", engine);
#endif /* EFI_SHAFT_POSITION_INPUT */
addConsoleAction("faststat", showMapStats);
applyMapMinBufferLength();
applyMapMinBufferLength(PASS_ENGINE_PARAMETER_SIGNATURE);
}
#else

View File

@ -16,9 +16,12 @@
void mapAveragingAdcCallback(adcsample_t newValue);
#endif
void initMapAveraging(Logging *sharedLogger, Engine *engine);
void initMapAveraging(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
void refreshMapAveragingPreCalc(DECLARE_ENGINE_PARAMETER_SIGNATURE);
#if EFI_TUNER_STUDIO
void postMapState(TunerStudioOutputChannels *tsOutputChannels);
#endif
#endif /* EFI_MAP_AVERAGING */

View File

@ -37,7 +37,7 @@
#include "tps.h"
#include "engine_math.h"
#include "fuel_math.h"
#include "allsensors.h"
#include "thermistors.h"
extern CANTxFrame txmsg;

View File

@ -338,7 +338,7 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
static void fuelClosedLoopCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#if ! EFI_UNIT_TEST
if (GET_RPM_VALUE < CONFIG(fuelClosedLoopRpmThreshold) ||
ENGINE(sensors.clt) < CONFIG(fuelClosedLoopCltThreshold) ||
getCoolantTemperature() < CONFIG(fuelClosedLoopCltThreshold) ||
getTPS(PASS_ENGINE_PARAMETER_SIGNATURE) > CONFIG(fuelClosedLoopTpsThreshold) ||
ENGINE(sensors.currentAfr) < CONFIGB(fuelClosedLoopAfrLowThreshold) ||
ENGINE(sensors.currentAfr) > engineConfiguration->fuelClosedLoopAfrHighThreshold) {
@ -583,7 +583,7 @@ void startPrimeInjectionPulse(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
// If 'primeInjFalloffTemperature' is not specified (by default), we have a prime pulse deactivation at zero celsius degrees, which is okay.
const float maxPrimeInjAtTemperature = -40.0f; // at this temperature the pulse is maximal.
floatms_t pulseLength = interpolateClamped(maxPrimeInjAtTemperature, CONFIG(startOfCrankingPrimingPulse),
CONFIG(primeInjFalloffTemperature), 0.0f, ENGINE(sensors.clt));
CONFIG(primeInjFalloffTemperature), 0.0f, getCoolantTemperature());
if (pulseLength > 0) {
startSimultaniousInjection(engine);
efitimeus_t turnOffDelayUs = (efitimeus_t)efiRound(MS2US(pulseLength), 1.0f);

View File

@ -6,8 +6,11 @@
* Actual getRpm() is calculated once per crankshaft revolution, based on the amount of time passed
* since the start of previous shaft revolution.
*
* We also have 'instant RPM' logic separate from this 'cycle RPM' logic. Open question is why do we not use
* instant RPM instead of cycle RPM more often.
*
* @date Jan 1, 2013
* @author Andrey Belomutskiy, (c) 2012-2018
* @author Andrey Belomutskiy, (c) 2012-2019
*/
#include "global.h"
@ -22,8 +25,7 @@
#if EFI_PROD_CODE
#include "os_util.h"
#include "engine.h"
#endif
#endif /* EFI_PROD_CODE */
#if EFI_SENSOR_CHART
#include "sensor_chart.h"
@ -86,8 +88,6 @@ extern bool hasFirmwareErrorFlag;
static Logging * logger;
int revolutionCounterSinceBootForUnitTest = 0;
RpmCalculator::RpmCalculator() {
#if !EFI_PROD_CODE
mockRpm = MOCK_UNDEFINED;
@ -97,7 +97,6 @@ RpmCalculator::RpmCalculator() {
// we need this initial to have not_running at first invocation
lastRpmEventTimeNt = (efitime_t) -10 * US2NT(US_PER_SECOND_LL);
revolutionCounterSinceBootForUnitTest = 0;
}
/**
@ -179,12 +178,9 @@ spinning_state_e RpmCalculator::getState() const {
void RpmCalculator::onNewEngineCycle() {
revolutionCounterSinceBoot++;
revolutionCounterSinceStart++;
#if EFI_UNIT_TEST
revolutionCounterSinceBootForUnitTest = revolutionCounterSinceBoot;
#endif /* EFI_UNIT_TEST */
}
uint32_t RpmCalculator::getRevolutionCounter(void) const {
uint32_t RpmCalculator::getRevolutionCounterM(void) const {
return revolutionCounterSinceBoot;
}
@ -231,9 +227,7 @@ void RpmCalculator::setSpinningUp(efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFI
void rpmShaftPositionCallback(trigger_event_e ckpSignalType,
uint32_t index DECLARE_ENGINE_PARAMETER_SUFFIX) {
efitick_t nowNt = getTimeNowNt();
#if EFI_PROD_CODE
efiAssertVoid(CUSTOM_ERR_6632, getCurrentRemainingStack() > 256, "lowstckRCL");
#endif
RpmCalculator *rpmState = &engine->rpmCalculator;
@ -316,7 +310,7 @@ static void tdcMarkCallback(trigger_event_e ckpSignalType,
(void) ckpSignalType;
bool isTriggerSynchronizationPoint = index0 == 0;
if (isTriggerSynchronizationPoint && ENGINE(isEngineChartEnabled)) {
int revIndex2 = engine->rpmCalculator.getRevolutionCounter() % 2;
int revIndex2 = getRevolutionCounter() % 2;
int rpm = GET_RPM();
// todo: use tooth event-based scheduling, not just time-based scheduling
if (isValidRpm(rpm)) {
@ -327,12 +321,6 @@ static void tdcMarkCallback(trigger_event_e ckpSignalType,
}
#endif
#if EFI_PROD_CODE || EFI_SIMULATOR
int getRevolutionCounter() {
return engine->rpmCalculator.getRevolutionCounter();
}
#endif
/**
* @return Current crankshaft angle, 0 to 720 for four-stroke
*/
@ -362,7 +350,6 @@ void initRpmCalculator(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
addTriggerEventListener(rpmShaftPositionCallback, "rpm reporter", engine);
}
#if EFI_PROD_CODE || EFI_SIMULATOR
/**
* Schedules a callback 'angle' degree of crankshaft from now.
* The callback would be executed once after the duration of time which
@ -370,17 +357,17 @@ void initRpmCalculator(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
*/
void scheduleByAngle(int rpm, scheduling_s *timer, angle_t angle,
schfunc_t callback, void *param, RpmCalculator *calc DECLARE_ENGINE_PARAMETER_SUFFIX) {
// todo: remove 'calc' parameter
UNUSED(rpm);
ScopePerf perf(PE::ScheduleByAngle);
efiAssertVoid(CUSTOM_ANGLE_NAN, !cisnan(angle), "NaN angle?");
efiAssertVoid(CUSTOM_ERR_6634, isValidRpm(rpm), "RPM check expected");
float delayUs = calc->oneDegreeUs * angle;
float delayUs = ENGINE(rpmCalculator.oneDegreeUs) * angle;
efiAssertVoid(CUSTOM_ERR_6635, !cisnan(delayUs), "NaN delay?");
engine->executor.scheduleForLater(timer, (int) delayUs, callback, param);
ENGINE(executor.scheduleForLater(timer, (int) delayUs, callback, param));
}
#endif
#else
RpmCalculator::RpmCalculator() {

View File

@ -89,7 +89,7 @@ public:
* This method is invoked once per engine cycle right after we calculate new RPM value
*/
void onNewEngineCycle();
uint32_t getRevolutionCounter(void) const;
uint32_t getRevolutionCounterM(void) const;
void setRpmValue(int value DECLARE_ENGINE_PARAMETER_SUFFIX);
/**
* The same as setRpmValue() but without state change.
@ -158,7 +158,7 @@ void initRpmCalculator(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
float getCrankshaftAngleNt(efitime_t timeNt DECLARE_ENGINE_PARAMETER_SUFFIX);
int getRevolutionCounter(void);
#define getRevolutionCounter() ENGINE(rpmCalculator.getRevolutionCounterM())
#if EFI_ENGINE_SNIFFER
#define addEngineSnifferEvent(name, msg) if (ENGINE(isEngineChartEnabled)) { waveChart.addEvent3((name), (msg)); }

View File

@ -37,6 +37,10 @@ int isIgnitionTimingError(void) {
}
static void fireSparkBySettingPinLow(IgnitionEvent *event, IgnitionOutputPin *output) {
#if EFI_UNIT_TEST
Engine *engine = event->engine;
#endif /* EFI_UNIT_TEST */
#if SPARK_EXTREME_LOGGING
scheduleMsg(logger, "spark goes low %d %s %d current=%d cnt=%d id=%d", getRevolutionCounter(), output->name, (int)getTimeNowUs(),
output->currentLogicValue, output->outOfOrder, event->sparkId);
@ -162,7 +166,12 @@ if (engineConfiguration->debugMode == DBG_DWELL_METRIC) {
}
static void startDwellByTurningSparkPinHigh(IgnitionEvent *event, IgnitionOutputPin *output) {
#if EFI_UNIT_TEST
Engine *engine = event->engine;
EXPAND_Engine;
#endif /* EFI_UNIT_TEST */
// todo: no reason for this to be disabled in unit_test mode?!
#if ! EFI_UNIT_TEST
if (GET_RPM_VALUE > 2 * engineConfiguration->cranking.rpm) {

View File

@ -77,7 +77,7 @@ static uint32_t skipUntilEngineCycle = 0;
#if ! EFI_UNIT_TEST
extern WaveChart waveChart;
static void resetNow(void) {
skipUntilEngineCycle = engine->rpmCalculator.getRevolutionCounter() + 3;
skipUntilEngineCycle = getRevolutionCounter() + 3;
waveChart.reset();
}
#endif
@ -169,7 +169,7 @@ void WaveChart::addEvent3(const char *name, const char * msg) {
if (!ENGINE(isEngineChartEnabled)) {
return;
}
if (skipUntilEngineCycle != 0 && ENGINE(rpmCalculator.getRevolutionCounter()) < skipUntilEngineCycle)
if (skipUntilEngineCycle != 0 && getRevolutionCounter() < skipUntilEngineCycle)
return;
#if EFI_SIMULATOR
// todo: add UI control to enable this for firmware if desired

View File

@ -39,7 +39,7 @@ void scAddData(float angle, float value) {
return;
}
if (engine->rpmCalculator.getRevolutionCounter() % engineConfiguration->sensorChartFrequency != 0) {
if (getRevolutionCounter() % engineConfiguration->sensorChartFrequency != 0) {
/**
* We are here if we do NOT need to add an event to the analog chart
*/

View File

@ -80,7 +80,7 @@ void WaveReader::onFallEvent() {
efitick_t width = nowUs - widthEventTimeUs;
last_wave_high_widthUs = width;
int revolutionCounter = engine->rpmCalculator.getRevolutionCounter();
int revolutionCounter = getRevolutionCounter();
totalOnTimeAccumulatorUs += width;
if (currentRevolutionCounter != revolutionCounter) {

View File

@ -1,12 +1,12 @@
// This file was generated by Version2Header
// Wed Sep 11 18:20:00 EDT 2019
// Mon Oct 14 12:58:12 EDT 2019
#ifndef GIT_HASH
#define GIT_HASH "33d13a78fc6eb5ba5c56835ab17b7ec1de34ed69"
#define GIT_HASH "7bb8bb7f140d6d96962da164262b42e2ed3f4807"
#endif
#ifndef VCS_VERSION
#define VCS_VERSION "19879"
#define VCS_VERSION "20053"
#endif

View File

@ -120,7 +120,7 @@ void rusEfiFunctionalTest(void) {
initTriggerCentral(&sharedLogger);
initTriggerEmulator(&sharedLogger PASS_ENGINE_PARAMETER_SUFFIX);
#if EFI_MAP_AVERAGING
initMapAveraging(&sharedLogger, engine);
initMapAveraging(&sharedLogger PASS_ENGINE_PARAMETER_SUFFIX);
#endif /* EFI_MAP_AVERAGING */
initMainEventListener(&sharedLogger PASS_ENGINE_PARAMETER_SUFFIX);

View File

@ -64,5 +64,6 @@
#define EFI_BOARD_TEST FALSE
#define EFI_JOYSTICK FALSE
#define EFI_MAP_AVERAGING TRUE
#endif /* EFIFEATURES_H_ */

View File

@ -100,4 +100,8 @@ void print(const char *fmt, ...);
#define CONFIG_PARAM(x) (x)
#define lockAnyContext() false
#define unlockAnyContext() {}
#endif /* GLOBAL_H_ */

View File

@ -34,12 +34,6 @@ efitick_t getTimeNowNt(void) {
LoggingWithStorage sharedLogger("main");
extern int revolutionCounterSinceBootForUnitTest;
int getRevolutionCounter(void) {
return revolutionCounterSinceBootForUnitTest;
}
extern bool printTriggerDebug;
bool verboseMode = false;
@ -47,7 +41,7 @@ GTEST_API_ int main(int argc, char **argv) {
// printTriggerDebug = true;
// resizeMap();
printf("Success 20190825\r\n");
printf("Success 20191013\r\n");
printAllTriggers();
// printConvertedTable();
testing::InitGoogleTest(&argc, argv);

View File

@ -85,11 +85,10 @@ TEST(misc, testFuelMap) {
setFlatInjectorLag(0 PASS_CONFIG_PARAMETER_SUFFIX);
float iat = getIntakeAirTemperature();
ASSERT_FALSE(cisnan(iat));
ASSERT_FALSE(cisnan(getIntakeAirTemperature()));
float iatCorrection = getIatFuelCorrection(-KELV PASS_ENGINE_PARAMETER_SUFFIX);
ASSERT_EQ( 2, iatCorrection) << "IAT";
engine->sensors.clt = getCoolantTemperature();
ASSERT_FALSE(cisnan(getCoolantTemperature()));
float cltCorrection = getCltFuelCorrection(PASS_ENGINE_PARAMETER_SIGNATURE);
ASSERT_EQ( 1, cltCorrection) << "CLT";
float injectorLag = getInjectorLag(getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE) PASS_ENGINE_PARAMETER_SUFFIX);

View File

@ -11,6 +11,7 @@
#include "fsio_impl.h"
#include "cli_registry.h"
#include "engine_test_helper.h"
#include "thermistors.h"
#define TEST_POOL_SIZE 256
@ -19,7 +20,7 @@ float getEngineValue(le_action_e action DECLARE_ENGINE_PARAMETER_SUFFIX) {
case LE_METHOD_FAN:
return engine->fsioState.mockFan;
case LE_METHOD_COOLANT:
return engine->sensors.clt;
return getCoolantTemperature();
case LE_METHOD_RPM:
return engine->fsioState.mockRpm;
case LE_METHOD_CRANKING_RPM:

View File

@ -584,7 +584,7 @@ static void setTestBug299(EngineTestHelper *eth) {
// inj #0 |.......#|........|.......#|........|
// inj #1 |........|.......#|........|.......#|
ASSERT_EQ( 4, engine->executor.size()) << "qs#00";
ASSERT_EQ( 3, engine->rpmCalculator.getRevolutionCounter()) << "rev cnt#3";
ASSERT_EQ( 3, getRevolutionCounter()) << "rev cnt#3";
eth->assertInjectorUpEvent("setTestBug299: 1@0", 0, MS2US(8.5), 0);
eth->assertInjectorDownEvent("@1", 1, MS2US(10), 0);
eth->assertInjectorUpEvent("1@2", 2, MS2US(18.5), 1);
@ -607,7 +607,7 @@ static void setTestBug299(EngineTestHelper *eth) {
// inj #0 |.......#|........|.......#|........|
// inj #1 |........|.......#|........|.......#|
ASSERT_EQ( 8, engine->executor.size()) << "qs#0";
ASSERT_EQ( 3, engine->rpmCalculator.getRevolutionCounter()) << "rev cnt#3";
ASSERT_EQ( 3, getRevolutionCounter()) << "rev cnt#3";
eth->assertInjectorUpEvent("02@0", 0, MS2US(-11.5), 0);
eth->assertInjectorDownEvent("@1", 1, MS2US(-10), 0);
eth->assertInjectorUpEvent("@2", 2, MS2US(-1.5), 1);
@ -650,7 +650,7 @@ static void setTestBug299(EngineTestHelper *eth) {
// inj #0 |.......#|........|........|........|
// inj #1 |........|.......#|........|........|
ASSERT_EQ( 4, engine->executor.size()) << "qs#0-2";
ASSERT_EQ( 4, engine->rpmCalculator.getRevolutionCounter()) << "rev cnt#4";
ASSERT_EQ( 4, getRevolutionCounter()) << "rev cnt#4";
eth->assertInjectorUpEvent("0@0", 0, MS2US(8.5), 0);
eth->assertInjectorDownEvent("0@1", 1, MS2US(10), 0);
eth->assertInjectorUpEvent("0@2", 2, MS2US(18.5), 1);
@ -706,9 +706,9 @@ void doTestFuelSchedulerBug299smallAndMedium(int startUpDelayMs) {
ASSERT_EQ( 0, engine->executor.size()) << "qs#1#2";
ASSERT_EQ( 4, engine->rpmCalculator.getRevolutionCounter()) << "rev cnt#4#0";
ASSERT_EQ( 4, getRevolutionCounter()) << "rev cnt#4#0";
eth.firePrimaryTriggerRise();
ASSERT_EQ( 5, engine->rpmCalculator.getRevolutionCounter()) << "rev cnt#4#1";
ASSERT_EQ( 5, getRevolutionCounter()) << "rev cnt#4#1";
// time...|0.......|10......|20......|30......|40......|50......|60......|
// inj #0 |########|##...###|########|.....###|########|........|........|
// inj #1 |.....###|########|....####|########|........|........|........|
@ -726,7 +726,7 @@ void doTestFuelSchedulerBug299smallAndMedium(int startUpDelayMs) {
// {
// scheduling_s *ev = engine->executor.getForUnitTest(9);
// ASSERT_EQ( 5, engine->rpmCalculator.getRevolutionCounter()) << "rev cnt#4#2";
// ASSERT_EQ( 5, getRevolutionCounter()) << "rev cnt#4#2";
// ASSERT_TRUE(ev == &engineConfiguration->fuelActuators[2].signalPair[1].signalTimerDown) << "down 50";
// }
@ -736,7 +736,7 @@ void doTestFuelSchedulerBug299smallAndMedium(int startUpDelayMs) {
eth.fireFall(20);
ASSERT_EQ( 8, engine->executor.size()) << "qs#2#1";
ASSERT_EQ( 5, engine->rpmCalculator.getRevolutionCounter()) << "rev cnt#5";
ASSERT_EQ( 5, getRevolutionCounter()) << "rev cnt#5";
// using old fuel schedule - but already wider pulses
// time...|-20.....|-10.....|0.......|10......|20......|30......|40......|
// inj #0 |........|.....###|########|.....###|########|........|........|
@ -781,7 +781,7 @@ void doTestFuelSchedulerBug299smallAndMedium(int startUpDelayMs) {
eth.firePrimaryTriggerRise();
ASSERT_EQ( 4, engine->executor.size()) << "qs#2#2";
ASSERT_EQ( 6, engine->rpmCalculator.getRevolutionCounter()) << "rev cnt6";
ASSERT_EQ( 6, getRevolutionCounter()) << "rev cnt6";
// time...|-20.....|-10.....|0.......|10......|20......|30......|40......|
// inj #0 |########|.....###|########|....####|........|........|........|
// inj #1 |.....###|########|.....###|########|........|........|........|
@ -821,7 +821,7 @@ void doTestFuelSchedulerBug299smallAndMedium(int startUpDelayMs) {
eth.firePrimaryTriggerFall();
ASSERT_EQ( 5, engine->executor.size()) << "qs#3";
ASSERT_EQ( 6, engine->rpmCalculator.getRevolutionCounter()) << "rev cnt6";
ASSERT_EQ( 6, getRevolutionCounter()) << "rev cnt6";
ASSERT_EQ( 0, eth.executeActions()) << "executed #6";

View File

@ -12,6 +12,9 @@
#include "gtest/gtest.h"
#include "gmock/gmock.h"
// This lets us inspect private state from unit tests
#define private public
#define EPS1D 0.1
#define EPS2D 0.01
#define EPS3D 0.001