auto-sync

This commit is contained in:
rusEfi 2014-10-31 14:03:00 -05:00
parent ae7820f863
commit 2d87e53d12
16 changed files with 65 additions and 60 deletions

View File

@ -143,10 +143,10 @@ void printSensors(Engine *engine) {
reportSensorF(getCaption(LP_THROTTLE), getTPS(engine->engineConfiguration), 2); reportSensorF(getCaption(LP_THROTTLE), getTPS(engine->engineConfiguration), 2);
if (engineConfiguration->hasCltSensor) { 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); // 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)); scheduleMsg(&logger2, "cranking fuel: %f", getCrankingFuel(engine));
if (engine->rpmCalculator->isRunning()) { if (engine->rpmCalculator->isRunning()) {
float iatCorrection = getIatCorrection(engineConfiguration, getIntakeAirTemperature(engineConfiguration2)); float iatCorrection = getIatCorrection(engineConfiguration, getIntakeAirTemperature(engine));
float cltCorrection = getCltCorrection(engineConfiguration, getCoolantTemperature(engineConfiguration2)); float cltCorrection = getCltCorrection(engineConfiguration, getCoolantTemperature(engine));
float injectorLag = getInjectorLag(engineConfiguration, getVBatt()); float injectorLag = getInjectorLag(engineConfiguration, getVBatt());
scheduleMsg(&logger2, "rpm=%f engineLoad=%f", rpm, engineLoad); scheduleMsg(&logger2, "rpm=%f engineLoad=%f", rpm, engineLoad);
scheduleMsg(&logger2, "baseFuel=%f", baseFuelMs); scheduleMsg(&logger2, "baseFuel=%f", baseFuelMs);
@ -409,8 +409,8 @@ void updateTunerStudioState(Engine *engine, TunerStudioOutputChannels *tsOutputC
#endif #endif
float tps = getTPS(engineConfiguration); float tps = getTPS(engineConfiguration);
float coolant = getCoolantTemperature(engineConfiguration2); float coolant = getCoolantTemperature(engine);
float intake = getIntakeAirTemperature(engineConfiguration2); float intake = getIntakeAirTemperature(engine);
float engineLoad = getEngineLoadT(engine); float engineLoad = getEngineLoadT(engine);
float baseFuelMs = getBaseTableFuel(engineConfiguration, (int) rpm, engineLoad); float baseFuelMs = getBaseTableFuel(engineConfiguration, (int) rpm, engineLoad);
@ -438,11 +438,11 @@ void updateTunerStudioState(Engine *engine, TunerStudioOutputChannels *tsOutputC
tsOutputChannels->ignition_enabled = engineConfiguration->isIgnitionEnabled; tsOutputChannels->ignition_enabled = engineConfiguration->isIgnitionEnabled;
tsOutputChannels->injection_enabled = engineConfiguration->isInjectionEnabled; tsOutputChannels->injection_enabled = engineConfiguration->isInjectionEnabled;
tsOutputChannels->cylinder_cleanup_enabled = engineConfiguration->isCylinderCleanupEnabled; tsOutputChannels->cylinder_cleanup_enabled = engineConfiguration->isCylinderCleanupEnabled;
tsOutputChannels->cylinder_cleanup_activated = engineConfiguration2->isCylinderCleanupMode; tsOutputChannels->cylinder_cleanup_activated = engine->isCylinderCleanupMode;
tsOutputChannels->secondTriggerChannelEnabled = engineConfiguration->secondTriggerChannelEnabled; tsOutputChannels->secondTriggerChannelEnabled = engineConfiguration->secondTriggerChannelEnabled;
tsOutputChannels->isCltError = !isValidCoolantTemperature(getCoolantTemperature(engineConfiguration2)); tsOutputChannels->isCltError = !isValidCoolantTemperature(getCoolantTemperature(engine));
tsOutputChannels->isIatError = !isValidIntakeAirTemperature(getIntakeAirTemperature(engineConfiguration2)); tsOutputChannels->isIatError = !isValidIntakeAirTemperature(getIntakeAirTemperature(engine));
#endif #endif
tsOutputChannels->tCharge = getTCharge(rpm, tps, coolant, intake); tsOutputChannels->tCharge = getTCharge(rpm, tps, coolant, intake);
tsOutputChannels->sparkDwell = getSparkDwellMs(rpm); tsOutputChannels->sparkDwell = getSparkDwellMs(rpm);

View File

@ -44,28 +44,16 @@ class engine_configuration2_s {
public: public:
engine_configuration2_s(); engine_configuration2_s();
// todo: this should go, too
engine_configuration_s *engineConfiguration; engine_configuration_s *engineConfiguration;
Thermistor iat;
Thermistor clt;
trigger_shape_s triggerShape; trigger_shape_s triggerShape;
EventHandlerConfiguration engineEventConfiguration; 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 { typedef struct {
engine_configuration_s *engineConfiguration; engine_configuration_s *engineConfiguration;
engine_configuration2_s *engineConfiguration2; engine_configuration2_s *engineConfiguration2;

View File

@ -22,8 +22,8 @@ static Logging logger;
* We are executing these heavy (logarithm) methods from outside the trigger callbacks for performance reasons. * We are executing these heavy (logarithm) methods from outside the trigger callbacks for performance reasons.
*/ */
void Engine::updateSlowSensors() { void Engine::updateSlowSensors() {
engineState.iat = getIntakeAirTemperature(engineConfiguration2); engineState.iat = getIntakeAirTemperature(this);
engineState.clt = getCoolantTemperature(engineConfiguration2); engineState.clt = getCoolantTemperature(this);
} }
void Engine::onTriggerEvent(uint64_t nowUs) { void Engine::onTriggerEvent(uint64_t nowUs) {

View File

@ -31,10 +31,26 @@ public:
engine_configuration_s *engineConfiguration; engine_configuration_s *engineConfiguration;
engine_configuration2_s *engineConfiguration2; engine_configuration2_s *engineConfiguration2;
Thermistor iat;
Thermistor clt;
void onTriggerEvent(uint64_t nowUs); void onTriggerEvent(uint64_t nowUs);
EngineState engineState; EngineState engineState;
uint64_t lastTriggerEventTimeUs; 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 updateSlowSensors();
void watchdog(); void watchdog();
private: private:

View File

@ -511,6 +511,7 @@ void resetConfigurationExt(Logging * logger, engine_type_e engineType, engine_co
} }
engine_configuration2_s::engine_configuration2_s() { engine_configuration2_s::engine_configuration2_s() {
engineConfiguration = NULL;
} }
void applyNonPersistentConfiguration(Logging * logger, engine_configuration_s *engineConfiguration, void applyNonPersistentConfiguration(Logging * logger, engine_configuration_s *engineConfiguration,

View File

@ -87,8 +87,8 @@ float getFuelMs(int rpm, Engine *engine) {
float getRunningFuel(float baseFuelMs, Engine *engine, int rpm) { float getRunningFuel(float baseFuelMs, Engine *engine, int rpm) {
engine_configuration_s *engineConfiguration = engine->engineConfiguration; engine_configuration_s *engineConfiguration = engine->engineConfiguration;
float iatCorrection = getIatCorrection(engineConfiguration, getIntakeAirTemperature(engine->engineConfiguration2)); float iatCorrection = getIatCorrection(engineConfiguration, getIntakeAirTemperature(engine));
float cltCorrection = getCltCorrection(engineConfiguration, getCoolantTemperature(engine->engineConfiguration2)); float cltCorrection = getCltCorrection(engineConfiguration, getCoolantTemperature(engine));
#if EFI_ACCEL_ENRICHMENT #if EFI_ACCEL_ENRICHMENT
float accelEnrichment = getAccelEnrichment(); 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 * @return Duration of fuel injection while craning, in milliseconds
*/ */
float getCrankingFuel(Engine *engine) { float getCrankingFuel(Engine *engine) {
return getStartingFuel(engine->engineConfiguration, return getStartingFuel(engine->engineConfiguration, getCoolantTemperature(engine));
getCoolantTemperature(engine->engineConfiguration2));
} }
float getStartingFuel(engine_configuration_s *engineConfiguration, float coolantTemperature) { float getStartingFuel(engine_configuration_s *engineConfiguration, float coolantTemperature) {

View File

@ -32,9 +32,9 @@ float getLEValue(Engine *engine, le_action_e action) {
// case LE_METHOD_FAN: // case LE_METHOD_FAN:
// return ; // return ;
case LE_METHOD_COOLANT: case LE_METHOD_COOLANT:
return getCoolantTemperature(engine->engineConfiguration2); return getCoolantTemperature(engine);
case LE_METHOD_INTAKE_AIR: case LE_METHOD_INTAKE_AIR:
return getIntakeAirTemperature(engine->engineConfiguration2); return getIntakeAirTemperature(engine);
case LE_METHOD_RPM: case LE_METHOD_RPM:
return engine->rpmCalculator->rpm(); return engine->rpmCalculator->rpm();
case LE_METHOD_TIME_SINCE_BOOT: case LE_METHOD_TIME_SINCE_BOOT:

View File

@ -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 * 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); OBD_Intake_Air_Temperature_Circuit_Malfunction);
setError(isValidCoolantTemperature(getCoolantTemperature(engineConfiguration2)), setError(isValidCoolantTemperature(getCoolantTemperature(&engine)),
OBD_Engine_Coolant_Temperature_Circuit_Malfunction); OBD_Engine_Coolant_Temperature_Circuit_Malfunction);
} }
@ -141,9 +141,9 @@ static void fanRelayControl(void) {
int newValue; int newValue;
if (isCurrentlyOn) { if (isCurrentlyOn) {
// if the fan is already on, we keep it on till the 'fanOff' temperature // 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 { } else {
newValue = getCoolantTemperature(engineConfiguration2) > engineConfiguration->fanOnTemperature; newValue = getCoolantTemperature(&engine) > engineConfiguration->fanOnTemperature;
} }
if (isCurrentlyOn != newValue) { if (isCurrentlyOn != newValue) {
@ -182,8 +182,8 @@ static void cylinderCleanupControl(Engine *engine) {
} else { } else {
newValue = false; newValue = false;
} }
if (newValue != engineConfiguration2->isCylinderCleanupMode) { if (newValue != engine->isCylinderCleanupMode) {
engineConfiguration2->isCylinderCleanupMode = newValue; engine->isCylinderCleanupMode = newValue;
scheduleMsg(&logger, "isCylinderCleanupMode %s", boolToString(newValue)); scheduleMsg(&logger, "isCylinderCleanupMode %s", boolToString(newValue));
} }
} }

View File

@ -41,13 +41,12 @@ static char * prepareVBattMapLine(char *buffer) {
} }
static char * prepareCltIatTpsLine(Engine *engine, char *buffer) { static char * prepareCltIatTpsLine(Engine *engine, char *buffer) {
engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2;
char *ptr = buffer; char *ptr = buffer;
*ptr++ = 'C'; *ptr++ = 'C';
ptr = ftoa(ptr, getCoolantTemperature(engineConfiguration2), 10.0f); ptr = ftoa(ptr, getCoolantTemperature(engine), 10.0f);
ptr = appendStr(ptr, " C"); ptr = appendStr(ptr, " C");
ptr = ftoa(ptr, getIntakeAirTemperature(engineConfiguration2), 10.0f); ptr = ftoa(ptr, getIntakeAirTemperature(engine), 10.0f);
ptr = appendStr(ptr, " TP"); ptr = appendStr(ptr, " TP");
ptr = itoa10(ptr, (int) getTPS(engine->engineConfiguration)); ptr = itoa10(ptr, (int) getTPS(engine->engineConfiguration));

View File

@ -67,8 +67,8 @@ float getSpeedDensityFuel(Engine *engine, int rpm) {
engine_configuration_s *engineConfiguration = engine->engineConfiguration; engine_configuration_s *engineConfiguration = engine->engineConfiguration;
float tps = getTPS(engineConfiguration); float tps = getTPS(engineConfiguration);
float coolantC = getCoolantTemperature(engine->engineConfiguration2); float coolantC = getCoolantTemperature(engine);
float intakeC = getIntakeAirTemperature(engine->engineConfiguration2); float intakeC = getIntakeAirTemperature(engine);
float tChargeK = convertCelsiusToKelvin(getTCharge(rpm, tps, coolantC, intakeC)); float tChargeK = convertCelsiusToKelvin(getTCharge(rpm, tps, coolantC, intakeC));
float map = getMap(); float map = getMap();
float VE = veMap.getValue(map, engineConfiguration->veLoadBins, rpm, float VE = veMap.getValue(map, engineConfiguration->veLoadBins, rpm,

View File

@ -15,7 +15,6 @@
#include "adc_inputs.h" #include "adc_inputs.h"
#include "engine_configuration.h" #include "engine_configuration.h"
#include "engine_math.h" #include "engine_math.h"
#include "ec2.h"
// Celsius // Celsius
#define LIMPING_MODE_IAT_TEMPERATURE 30.0f #define LIMPING_MODE_IAT_TEMPERATURE 30.0f
@ -107,9 +106,10 @@ bool isValidIntakeAirTemperature(float temperature) {
/** /**
* @return coolant temperature, in Celsius * @return coolant temperature, in Celsius
*/ */
float getCoolantTemperature(engine_configuration2_s * engineConfiguration2) { float getCoolantTemperature(Engine * engine) {
float temperature = getTemperatureC(&engineConfiguration2->clt); float temperature = getTemperatureC(&engine->clt);
if (!isValidCoolantTemperature(temperature)) { if (!isValidCoolantTemperature(temperature)) {
efiAssert(engineConfiguration2->engineConfiguration!=NULL, "NULL engineConfiguration", NAN);
if (engineConfiguration2->engineConfiguration->hasCltSensor) { if (engineConfiguration2->engineConfiguration->hasCltSensor) {
warning(OBD_PCM_Processor_Fault, "unrealistic CLT %f", temperature); warning(OBD_PCM_Processor_Fault, "unrealistic CLT %f", temperature);
} }
@ -154,10 +154,11 @@ void prepareThermistorCurve(ThermistorConf * config) {
/** /**
* @return Celsius value * @return Celsius value
*/ */
float getIntakeAirTemperature(engine_configuration2_s * engineConfiguration2) { float getIntakeAirTemperature(Engine * engine) {
float temperature = getTemperatureC(&engineConfiguration2->iat); float temperature = getTemperatureC(&engine->iat);
if (!isValidIntakeAirTemperature(temperature)) { 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); warning(OBD_PCM_Processor_Fault, "unrealistic IAT %f", temperature);
} }
return LIMPING_MODE_IAT_TEMPERATURE; return LIMPING_MODE_IAT_TEMPERATURE;
@ -185,9 +186,9 @@ void setCommonNTCSensor(ThermistorConf *thermistorConf) {
void initThermistors(Engine *engine) { void initThermistors(Engine *engine) {
efiAssertVoid(engine!=NULL, "e NULL initThermistors"); efiAssertVoid(engine!=NULL, "e NULL initThermistors");
efiAssertVoid(engine->engineConfiguration2!=NULL, "e2 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); engine->engineConfiguration->cltAdcChannel);
initThermistorCurve(&engine->engineConfiguration2->iat, &engine->engineConfiguration->iatThermistorConf, initThermistorCurve(&engine->iat, &engine->engineConfiguration->iatThermistorConf,
engine->engineConfiguration->iatAdcChannel); engine->engineConfiguration->iatAdcChannel);
initialized = TRUE; initialized = TRUE;
} }

View File

@ -14,7 +14,7 @@
#define KELV 273.15 #define KELV 273.15
#include "sensor_types.h" #include "sensor_types.h"
#include "ec2.h" #include "engine.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
@ -38,9 +38,9 @@ float convertFtoCelcius(float tempF);
float getKelvinTemperature(float resistance, ThermistorConf *thermistor); float getKelvinTemperature(float resistance, ThermistorConf *thermistor);
float getResistance(Thermistor *thermistor); float getResistance(Thermistor *thermistor);
float getTemperatureC(Thermistor *thermistor); float getTemperatureC(Thermistor *thermistor);
float getCoolantTemperature(engine_configuration2_s * engineConfiguration2); float getCoolantTemperature(Engine * engine);
bool isValidCoolantTemperature(float temperature); bool isValidCoolantTemperature(float temperature);
float getIntakeAirTemperature(engine_configuration2_s * engineConfiguration2); float getIntakeAirTemperature(Engine * engine);
bool isValidIntakeAirTemperature(float temperature); bool isValidIntakeAirTemperature(float temperature);
float convertResistanceToKelvinTemperature(float resistance, float convertResistanceToKelvinTemperature(float resistance,

View File

@ -309,12 +309,12 @@ static void printTPSInfo(void) {
} }
static void printTemperatureInfo(void) { static void printTemperatureInfo(void) {
printThermistor("CLT", &engineConfiguration2->clt); printThermistor("CLT", &engine.clt);
if (!isValidCoolantTemperature(getCoolantTemperature(engineConfiguration2))) { if (!isValidCoolantTemperature(getCoolantTemperature(&engine))) {
scheduleMsg(&logger, "CLT sensing error"); scheduleMsg(&logger, "CLT sensing error");
} }
printThermistor("IAT", &engineConfiguration2->iat); printThermistor("IAT", &engine.iat);
if (!isValidIntakeAirTemperature(getIntakeAirTemperature(engineConfiguration2))) { if (!isValidIntakeAirTemperature(getIntakeAirTemperature(&engine))) {
scheduleMsg(&logger, "IAT sensing error"); scheduleMsg(&logger, "IAT sensing error");
} }

View File

@ -87,7 +87,7 @@ static void handleFuelInjectionEvent(MainTriggerCallback *mainTriggerCallback, A
return; return;
} }
if (mainTriggerCallback->engineConfiguration2->isCylinderCleanupMode) if (mainTriggerCallback->engine->isCylinderCleanupMode)
return; return;
float delay = getOneDegreeTimeMs(rpm) * event->position.angleOffset; float delay = getOneDegreeTimeMs(rpm) * event->position.angleOffset;

View File

@ -21,6 +21,7 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType) {
configuration.engineConfiguration = ec; configuration.engineConfiguration = ec;
configuration.engineConfiguration2 = &ec2; configuration.engineConfiguration2 = &ec2;
engine.engineConfiguration2 = &ec2; engine.engineConfiguration2 = &ec2;
ec2.engineConfiguration = ec;
prepareFuelMap(engine.engineConfiguration); prepareFuelMap(engine.engineConfiguration);

View File

@ -73,10 +73,10 @@ void testFuelMap(void) {
engine_configuration_s *engineConfiguration = eth.engine.engineConfiguration; engine_configuration_s *engineConfiguration = eth.engine.engineConfiguration;
assertEquals(NAN, getIntakeAirTemperature(eth.engine.engineConfiguration2)); assertEquals(NAN, getIntakeAirTemperature(&eth.engine));
float iatCorrection = getIatCorrection(engineConfiguration, -KELV); float iatCorrection = getIatCorrection(engineConfiguration, -KELV);
assertEqualsM("IAT", 2, iatCorrection); assertEqualsM("IAT", 2, iatCorrection);
float cltCorrection = getCltCorrection(engineConfiguration, getCoolantTemperature(eth.engine.engineConfiguration2)); float cltCorrection = getCltCorrection(engineConfiguration, getCoolantTemperature(&eth.engine));
assertEqualsM("CLT", 1, cltCorrection); assertEqualsM("CLT", 1, cltCorrection);
float injectorLag = getInjectorLag(engineConfiguration, getVBatt()); float injectorLag = getInjectorLag(engineConfiguration, getVBatt());
assertEquals(0, injectorLag); assertEquals(0, injectorLag);