VVT refactoring & assertions for VVT test

This commit is contained in:
rusefi 2020-01-31 01:49:10 -05:00
parent b6e0bc7ed1
commit f6e7e8871a
8 changed files with 20 additions and 7 deletions

View File

@ -308,7 +308,7 @@ static void printSensors(Logging *log) {
if (hasMapSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) {
reportSensorF(log, GAUGE_NAME_FUEL_VE, "%", engine->engineState.currentBaroCorrectedVE * PERCENT_MULT, 2);
}
reportSensorF(log, GAUGE_NAME_VVT, "deg", engine->triggerCentral.vvtPosition, 1);
reportSensorF(log, GAUGE_NAME_VVT, "deg", engine->triggerCentral.getVVTPosition(), 1);
float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE);
reportSensorF(log, GAUGE_NAME_ENGINE_LOAD, "x", engineLoad, 2);
@ -782,7 +782,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
efitimesec_t timeSeconds = getTimeNowSeconds();
tsOutputChannels->timeSeconds = timeSeconds;
// 248
tsOutputChannels->vvtPosition = engine->triggerCentral.vvtPosition;
tsOutputChannels->vvtPosition = engine->triggerCentral.getVVTPosition();
// 252
tsOutputChannels->engineMode = packEngineMode(PASS_ENGINE_PARAMETER_SIGNATURE);
// 120

View File

@ -84,7 +84,7 @@ public:
}
float value = engine->triggerCentral.vvtPosition;
float value = engine->triggerCentral.getVVTPosition();
float targetValue = table->getValue(rpm, getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE));
percent_t pwm = auxPid.getOutput(targetValue, value);

View File

@ -137,7 +137,7 @@ float getEngineValue(le_action_e action DECLARE_ENGINE_PARAMETER_SUFFIX) {
return getMap(PASS_ENGINE_PARAMETER_SIGNATURE);
case LE_METHOD_INTAKE_VVT:
case LE_METHOD_EXHAUST_VVT:
return engine->triggerCentral.vvtPosition;
return engine->triggerCentral.getVVTPosition();
case LE_METHOD_TIME_SINCE_BOOT:
return getTimeNowSeconds();

View File

@ -72,6 +72,10 @@ void TriggerCentral::addEventListener(ShaftPositionListener listener, const char
triggerListeneres.registerCallback((VoidInt)(void*)listener, engine);
}
angle_t TriggerCentral::getVVTPosition() {
return vvtPosition;
}
/**
* @brief Adds a trigger event listener
*

View File

@ -46,6 +46,8 @@ public:
TriggerNoiseFilter noiseFilter;
angle_t getVVTPosition();
angle_t vvtPosition = 0;
/**
* this is similar to TriggerState#startOfCycleNt but with the crank-only sensor magic

View File

@ -1,12 +1,12 @@
// This file was generated by Version2Header
// Mon Nov 18 15:37:47 EST 2019
// Fri Jan 31 01:23:06 EST 2020
#ifndef GIT_HASH
#define GIT_HASH "919b7393d75467a0cac9b97ed34e29192d782bfc"
#define GIT_HASH "d48a57d599dcaa48b15e95be2a9fa0c4fb9361ff"
#endif
#ifndef VCS_VERSION
#define VCS_VERSION "21021"
#define VCS_VERSION "21477"
#endif

View File

@ -134,7 +134,11 @@ TEST(sensors, testNB2CamInput) {
// this second important front would give us first real VVT gap duration
hwHandleVvtCamSignal(TV_RISE, getTimeNowNt() PASS_ENGINE_PARAMETER_SUFFIX);
ASSERT_FLOAT_EQ(0, engine->triggerCentral.getVVTPosition());
eth.moveTimeForwardUs(MS2US(130));
// this third important front would give us first comparison between two real gaps
hwHandleVvtCamSignal(TV_RISE, getTimeNowNt() PASS_ENGINE_PARAMETER_SUFFIX);
ASSERT_NEAR(-46, engine->triggerCentral.getVVTPosition(), EPS3D);
}

View File

@ -16,6 +16,9 @@ using ::testing::Return;
// This lets us inspect private state from unit tests
#define private public
/**
* These are usually used with ASSETR_NEAR(val1, val2, abs_error)
*/
#define EPS0D 1
#define EPS1D 0.1
#define EPS2D 0.01