auto-sync
This commit is contained in:
parent
ae7820f863
commit
2d87e53d12
|
@ -143,10 +143,10 @@ void printSensors(Engine *engine) {
|
|||
reportSensorF(getCaption(LP_THROTTLE), getTPS(engine->engineConfiguration), 2);
|
||||
|
||||
if (engineConfiguration->hasCltSensor) {
|
||||
reportSensorF(getCaption(LP_ECT), getCoolantTemperature(engineConfiguration2), 2);
|
||||
reportSensorF(getCaption(LP_ECT), getCoolantTemperature(engine), 2);
|
||||
}
|
||||
|
||||
reportSensorF(getCaption(LP_IAT), getIntakeAirTemperature(engineConfiguration2), 2);
|
||||
reportSensorF(getCaption(LP_IAT), getIntakeAirTemperature(engine), 2);
|
||||
|
||||
// debugFloat(&logger, "tch", getTCharge1(tps), 2);
|
||||
|
||||
|
@ -311,8 +311,8 @@ static void showFuelInfo2(float rpm, float engineLoad, Engine *engine) {
|
|||
scheduleMsg(&logger2, "cranking fuel: %f", getCrankingFuel(engine));
|
||||
|
||||
if (engine->rpmCalculator->isRunning()) {
|
||||
float iatCorrection = getIatCorrection(engineConfiguration, getIntakeAirTemperature(engineConfiguration2));
|
||||
float cltCorrection = getCltCorrection(engineConfiguration, getCoolantTemperature(engineConfiguration2));
|
||||
float iatCorrection = getIatCorrection(engineConfiguration, getIntakeAirTemperature(engine));
|
||||
float cltCorrection = getCltCorrection(engineConfiguration, getCoolantTemperature(engine));
|
||||
float injectorLag = getInjectorLag(engineConfiguration, getVBatt());
|
||||
scheduleMsg(&logger2, "rpm=%f engineLoad=%f", rpm, engineLoad);
|
||||
scheduleMsg(&logger2, "baseFuel=%f", baseFuelMs);
|
||||
|
@ -409,8 +409,8 @@ void updateTunerStudioState(Engine *engine, TunerStudioOutputChannels *tsOutputC
|
|||
#endif
|
||||
|
||||
float tps = getTPS(engineConfiguration);
|
||||
float coolant = getCoolantTemperature(engineConfiguration2);
|
||||
float intake = getIntakeAirTemperature(engineConfiguration2);
|
||||
float coolant = getCoolantTemperature(engine);
|
||||
float intake = getIntakeAirTemperature(engine);
|
||||
|
||||
float engineLoad = getEngineLoadT(engine);
|
||||
float baseFuelMs = getBaseTableFuel(engineConfiguration, (int) rpm, engineLoad);
|
||||
|
@ -438,11 +438,11 @@ void updateTunerStudioState(Engine *engine, TunerStudioOutputChannels *tsOutputC
|
|||
tsOutputChannels->ignition_enabled = engineConfiguration->isIgnitionEnabled;
|
||||
tsOutputChannels->injection_enabled = engineConfiguration->isInjectionEnabled;
|
||||
tsOutputChannels->cylinder_cleanup_enabled = engineConfiguration->isCylinderCleanupEnabled;
|
||||
tsOutputChannels->cylinder_cleanup_activated = engineConfiguration2->isCylinderCleanupMode;
|
||||
tsOutputChannels->cylinder_cleanup_activated = engine->isCylinderCleanupMode;
|
||||
tsOutputChannels->secondTriggerChannelEnabled = engineConfiguration->secondTriggerChannelEnabled;
|
||||
|
||||
tsOutputChannels->isCltError = !isValidCoolantTemperature(getCoolantTemperature(engineConfiguration2));
|
||||
tsOutputChannels->isIatError = !isValidIntakeAirTemperature(getIntakeAirTemperature(engineConfiguration2));
|
||||
tsOutputChannels->isCltError = !isValidCoolantTemperature(getCoolantTemperature(engine));
|
||||
tsOutputChannels->isIatError = !isValidIntakeAirTemperature(getIntakeAirTemperature(engine));
|
||||
#endif
|
||||
tsOutputChannels->tCharge = getTCharge(rpm, tps, coolant, intake);
|
||||
tsOutputChannels->sparkDwell = getSparkDwellMs(rpm);
|
||||
|
|
|
@ -44,28 +44,16 @@ class engine_configuration2_s {
|
|||
public:
|
||||
engine_configuration2_s();
|
||||
|
||||
// todo: this should go, too
|
||||
engine_configuration_s *engineConfiguration;
|
||||
|
||||
Thermistor iat;
|
||||
Thermistor clt;
|
||||
|
||||
trigger_shape_s triggerShape;
|
||||
|
||||
EventHandlerConfiguration engineEventConfiguration;
|
||||
|
||||
/**
|
||||
* This coefficient translates ADC value directly into voltage adjusted according to
|
||||
* voltage divider configuration. This is a future (?) performance optimization.
|
||||
*/
|
||||
float adcToVoltageInputDividerCoefficient;
|
||||
|
||||
/**
|
||||
* This field is true if we are in 'cylinder cleanup' state right now
|
||||
* see isCylinderCleanupEnabled
|
||||
*/
|
||||
bool isCylinderCleanupMode;
|
||||
};
|
||||
|
||||
// todo: eliminate this structure? we have Engine and engineConfiguration2 now references engineConfiguration
|
||||
typedef struct {
|
||||
engine_configuration_s *engineConfiguration;
|
||||
engine_configuration2_s *engineConfiguration2;
|
||||
|
|
|
@ -22,8 +22,8 @@ static Logging logger;
|
|||
* We are executing these heavy (logarithm) methods from outside the trigger callbacks for performance reasons.
|
||||
*/
|
||||
void Engine::updateSlowSensors() {
|
||||
engineState.iat = getIntakeAirTemperature(engineConfiguration2);
|
||||
engineState.clt = getCoolantTemperature(engineConfiguration2);
|
||||
engineState.iat = getIntakeAirTemperature(this);
|
||||
engineState.clt = getCoolantTemperature(this);
|
||||
}
|
||||
|
||||
void Engine::onTriggerEvent(uint64_t nowUs) {
|
||||
|
|
|
@ -31,10 +31,26 @@ public:
|
|||
engine_configuration_s *engineConfiguration;
|
||||
engine_configuration2_s *engineConfiguration2;
|
||||
|
||||
Thermistor iat;
|
||||
Thermistor clt;
|
||||
|
||||
void onTriggerEvent(uint64_t nowUs);
|
||||
EngineState engineState;
|
||||
uint64_t lastTriggerEventTimeUs;
|
||||
|
||||
/**
|
||||
* This coefficient translates ADC value directly into voltage adjusted according to
|
||||
* voltage divider configuration. This is a future (?) performance optimization.
|
||||
*/
|
||||
float adcToVoltageInputDividerCoefficient;
|
||||
|
||||
/**
|
||||
* This field is true if we are in 'cylinder cleanup' state right now
|
||||
* see isCylinderCleanupEnabled
|
||||
*/
|
||||
bool isCylinderCleanupMode;
|
||||
|
||||
|
||||
void updateSlowSensors();
|
||||
void watchdog();
|
||||
private:
|
||||
|
|
|
@ -511,6 +511,7 @@ void resetConfigurationExt(Logging * logger, engine_type_e engineType, engine_co
|
|||
}
|
||||
|
||||
engine_configuration2_s::engine_configuration2_s() {
|
||||
engineConfiguration = NULL;
|
||||
}
|
||||
|
||||
void applyNonPersistentConfiguration(Logging * logger, engine_configuration_s *engineConfiguration,
|
||||
|
|
|
@ -87,8 +87,8 @@ float getFuelMs(int rpm, Engine *engine) {
|
|||
|
||||
float getRunningFuel(float baseFuelMs, Engine *engine, int rpm) {
|
||||
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
||||
float iatCorrection = getIatCorrection(engineConfiguration, getIntakeAirTemperature(engine->engineConfiguration2));
|
||||
float cltCorrection = getCltCorrection(engineConfiguration, getCoolantTemperature(engine->engineConfiguration2));
|
||||
float iatCorrection = getIatCorrection(engineConfiguration, getIntakeAirTemperature(engine));
|
||||
float cltCorrection = getCltCorrection(engineConfiguration, getCoolantTemperature(engine));
|
||||
|
||||
#if EFI_ACCEL_ENRICHMENT
|
||||
float accelEnrichment = getAccelEnrichment();
|
||||
|
@ -155,8 +155,7 @@ float getBaseTableFuel(engine_configuration_s *engineConfiguration, int rpm, flo
|
|||
* @return Duration of fuel injection while craning, in milliseconds
|
||||
*/
|
||||
float getCrankingFuel(Engine *engine) {
|
||||
return getStartingFuel(engine->engineConfiguration,
|
||||
getCoolantTemperature(engine->engineConfiguration2));
|
||||
return getStartingFuel(engine->engineConfiguration, getCoolantTemperature(engine));
|
||||
}
|
||||
|
||||
float getStartingFuel(engine_configuration_s *engineConfiguration, float coolantTemperature) {
|
||||
|
|
|
@ -32,9 +32,9 @@ float getLEValue(Engine *engine, le_action_e action) {
|
|||
// case LE_METHOD_FAN:
|
||||
// return ;
|
||||
case LE_METHOD_COOLANT:
|
||||
return getCoolantTemperature(engine->engineConfiguration2);
|
||||
return getCoolantTemperature(engine);
|
||||
case LE_METHOD_INTAKE_AIR:
|
||||
return getIntakeAirTemperature(engine->engineConfiguration2);
|
||||
return getIntakeAirTemperature(engine);
|
||||
case LE_METHOD_RPM:
|
||||
return engine->rpmCalculator->rpm();
|
||||
case LE_METHOD_TIME_SINCE_BOOT:
|
||||
|
|
|
@ -127,9 +127,9 @@ static void updateErrorCodes(void) {
|
|||
/**
|
||||
* technically we can set error codes right inside the getMethods, but I a bit on a fence about it
|
||||
*/
|
||||
setError(isValidIntakeAirTemperature(getIntakeAirTemperature(engineConfiguration2)),
|
||||
setError(isValidIntakeAirTemperature(getIntakeAirTemperature(&engine)),
|
||||
OBD_Intake_Air_Temperature_Circuit_Malfunction);
|
||||
setError(isValidCoolantTemperature(getCoolantTemperature(engineConfiguration2)),
|
||||
setError(isValidCoolantTemperature(getCoolantTemperature(&engine)),
|
||||
OBD_Engine_Coolant_Temperature_Circuit_Malfunction);
|
||||
}
|
||||
|
||||
|
@ -141,9 +141,9 @@ static void fanRelayControl(void) {
|
|||
int newValue;
|
||||
if (isCurrentlyOn) {
|
||||
// if the fan is already on, we keep it on till the 'fanOff' temperature
|
||||
newValue = getCoolantTemperature(engineConfiguration2) > engineConfiguration->fanOffTemperature;
|
||||
newValue = getCoolantTemperature(&engine) > engineConfiguration->fanOffTemperature;
|
||||
} else {
|
||||
newValue = getCoolantTemperature(engineConfiguration2) > engineConfiguration->fanOnTemperature;
|
||||
newValue = getCoolantTemperature(&engine) > engineConfiguration->fanOnTemperature;
|
||||
}
|
||||
|
||||
if (isCurrentlyOn != newValue) {
|
||||
|
@ -182,8 +182,8 @@ static void cylinderCleanupControl(Engine *engine) {
|
|||
} else {
|
||||
newValue = false;
|
||||
}
|
||||
if (newValue != engineConfiguration2->isCylinderCleanupMode) {
|
||||
engineConfiguration2->isCylinderCleanupMode = newValue;
|
||||
if (newValue != engine->isCylinderCleanupMode) {
|
||||
engine->isCylinderCleanupMode = newValue;
|
||||
scheduleMsg(&logger, "isCylinderCleanupMode %s", boolToString(newValue));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,13 +41,12 @@ static char * prepareVBattMapLine(char *buffer) {
|
|||
}
|
||||
|
||||
static char * prepareCltIatTpsLine(Engine *engine, char *buffer) {
|
||||
engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2;
|
||||
char *ptr = buffer;
|
||||
*ptr++ = 'C';
|
||||
ptr = ftoa(ptr, getCoolantTemperature(engineConfiguration2), 10.0f);
|
||||
ptr = ftoa(ptr, getCoolantTemperature(engine), 10.0f);
|
||||
|
||||
ptr = appendStr(ptr, " C");
|
||||
ptr = ftoa(ptr, getIntakeAirTemperature(engineConfiguration2), 10.0f);
|
||||
ptr = ftoa(ptr, getIntakeAirTemperature(engine), 10.0f);
|
||||
|
||||
ptr = appendStr(ptr, " TP");
|
||||
ptr = itoa10(ptr, (int) getTPS(engine->engineConfiguration));
|
||||
|
|
|
@ -67,8 +67,8 @@ float getSpeedDensityFuel(Engine *engine, int rpm) {
|
|||
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
||||
|
||||
float tps = getTPS(engineConfiguration);
|
||||
float coolantC = getCoolantTemperature(engine->engineConfiguration2);
|
||||
float intakeC = getIntakeAirTemperature(engine->engineConfiguration2);
|
||||
float coolantC = getCoolantTemperature(engine);
|
||||
float intakeC = getIntakeAirTemperature(engine);
|
||||
float tChargeK = convertCelsiusToKelvin(getTCharge(rpm, tps, coolantC, intakeC));
|
||||
float map = getMap();
|
||||
float VE = veMap.getValue(map, engineConfiguration->veLoadBins, rpm,
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "adc_inputs.h"
|
||||
#include "engine_configuration.h"
|
||||
#include "engine_math.h"
|
||||
#include "ec2.h"
|
||||
|
||||
// Celsius
|
||||
#define LIMPING_MODE_IAT_TEMPERATURE 30.0f
|
||||
|
@ -107,9 +106,10 @@ bool isValidIntakeAirTemperature(float temperature) {
|
|||
/**
|
||||
* @return coolant temperature, in Celsius
|
||||
*/
|
||||
float getCoolantTemperature(engine_configuration2_s * engineConfiguration2) {
|
||||
float temperature = getTemperatureC(&engineConfiguration2->clt);
|
||||
float getCoolantTemperature(Engine * engine) {
|
||||
float temperature = getTemperatureC(&engine->clt);
|
||||
if (!isValidCoolantTemperature(temperature)) {
|
||||
efiAssert(engineConfiguration2->engineConfiguration!=NULL, "NULL engineConfiguration", NAN);
|
||||
if (engineConfiguration2->engineConfiguration->hasCltSensor) {
|
||||
warning(OBD_PCM_Processor_Fault, "unrealistic CLT %f", temperature);
|
||||
}
|
||||
|
@ -154,10 +154,11 @@ void prepareThermistorCurve(ThermistorConf * config) {
|
|||
/**
|
||||
* @return Celsius value
|
||||
*/
|
||||
float getIntakeAirTemperature(engine_configuration2_s * engineConfiguration2) {
|
||||
float temperature = getTemperatureC(&engineConfiguration2->iat);
|
||||
float getIntakeAirTemperature(Engine * engine) {
|
||||
float temperature = getTemperatureC(&engine->iat);
|
||||
if (!isValidIntakeAirTemperature(temperature)) {
|
||||
if (engineConfiguration2->engineConfiguration->hasIatSensor) {
|
||||
efiAssert(engine->engineConfiguration!=NULL, "NULL engineConfiguration", NAN);
|
||||
if (engine->engineConfiguration->hasIatSensor) {
|
||||
warning(OBD_PCM_Processor_Fault, "unrealistic IAT %f", temperature);
|
||||
}
|
||||
return LIMPING_MODE_IAT_TEMPERATURE;
|
||||
|
@ -185,9 +186,9 @@ void setCommonNTCSensor(ThermistorConf *thermistorConf) {
|
|||
void initThermistors(Engine *engine) {
|
||||
efiAssertVoid(engine!=NULL, "e NULL initThermistors");
|
||||
efiAssertVoid(engine->engineConfiguration2!=NULL, "e2 NULL initThermistors");
|
||||
initThermistorCurve(&engine->engineConfiguration2->clt, &engine->engineConfiguration->cltThermistorConf,
|
||||
initThermistorCurve(&engine->clt, &engine->engineConfiguration->cltThermistorConf,
|
||||
engine->engineConfiguration->cltAdcChannel);
|
||||
initThermistorCurve(&engine->engineConfiguration2->iat, &engine->engineConfiguration->iatThermistorConf,
|
||||
initThermistorCurve(&engine->iat, &engine->engineConfiguration->iatThermistorConf,
|
||||
engine->engineConfiguration->iatAdcChannel);
|
||||
initialized = TRUE;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#define KELV 273.15
|
||||
|
||||
#include "sensor_types.h"
|
||||
#include "ec2.h"
|
||||
#include "engine.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
|
@ -38,9 +38,9 @@ float convertFtoCelcius(float tempF);
|
|||
float getKelvinTemperature(float resistance, ThermistorConf *thermistor);
|
||||
float getResistance(Thermistor *thermistor);
|
||||
float getTemperatureC(Thermistor *thermistor);
|
||||
float getCoolantTemperature(engine_configuration2_s * engineConfiguration2);
|
||||
float getCoolantTemperature(Engine * engine);
|
||||
bool isValidCoolantTemperature(float temperature);
|
||||
float getIntakeAirTemperature(engine_configuration2_s * engineConfiguration2);
|
||||
float getIntakeAirTemperature(Engine * engine);
|
||||
bool isValidIntakeAirTemperature(float temperature);
|
||||
|
||||
float convertResistanceToKelvinTemperature(float resistance,
|
||||
|
|
|
@ -309,12 +309,12 @@ static void printTPSInfo(void) {
|
|||
}
|
||||
|
||||
static void printTemperatureInfo(void) {
|
||||
printThermistor("CLT", &engineConfiguration2->clt);
|
||||
if (!isValidCoolantTemperature(getCoolantTemperature(engineConfiguration2))) {
|
||||
printThermistor("CLT", &engine.clt);
|
||||
if (!isValidCoolantTemperature(getCoolantTemperature(&engine))) {
|
||||
scheduleMsg(&logger, "CLT sensing error");
|
||||
}
|
||||
printThermistor("IAT", &engineConfiguration2->iat);
|
||||
if (!isValidIntakeAirTemperature(getIntakeAirTemperature(engineConfiguration2))) {
|
||||
printThermistor("IAT", &engine.iat);
|
||||
if (!isValidIntakeAirTemperature(getIntakeAirTemperature(&engine))) {
|
||||
scheduleMsg(&logger, "IAT sensing error");
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ static void handleFuelInjectionEvent(MainTriggerCallback *mainTriggerCallback, A
|
|||
return;
|
||||
}
|
||||
|
||||
if (mainTriggerCallback->engineConfiguration2->isCylinderCleanupMode)
|
||||
if (mainTriggerCallback->engine->isCylinderCleanupMode)
|
||||
return;
|
||||
|
||||
float delay = getOneDegreeTimeMs(rpm) * event->position.angleOffset;
|
||||
|
|
|
@ -21,6 +21,7 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType) {
|
|||
configuration.engineConfiguration = ec;
|
||||
configuration.engineConfiguration2 = &ec2;
|
||||
engine.engineConfiguration2 = &ec2;
|
||||
ec2.engineConfiguration = ec;
|
||||
|
||||
prepareFuelMap(engine.engineConfiguration);
|
||||
|
||||
|
|
|
@ -73,10 +73,10 @@ void testFuelMap(void) {
|
|||
|
||||
engine_configuration_s *engineConfiguration = eth.engine.engineConfiguration;
|
||||
|
||||
assertEquals(NAN, getIntakeAirTemperature(eth.engine.engineConfiguration2));
|
||||
assertEquals(NAN, getIntakeAirTemperature(ð.engine));
|
||||
float iatCorrection = getIatCorrection(engineConfiguration, -KELV);
|
||||
assertEqualsM("IAT", 2, iatCorrection);
|
||||
float cltCorrection = getCltCorrection(engineConfiguration, getCoolantTemperature(eth.engine.engineConfiguration2));
|
||||
float cltCorrection = getCltCorrection(engineConfiguration, getCoolantTemperature(ð.engine));
|
||||
assertEqualsM("CLT", 1, cltCorrection);
|
||||
float injectorLag = getInjectorLag(engineConfiguration, getVBatt());
|
||||
assertEquals(0, injectorLag);
|
||||
|
|
Loading…
Reference in New Issue