auto-sync

This commit is contained in:
rusEfi 2014-11-24 21:03:19 -06:00
parent f575e7bd55
commit 217333941d
12 changed files with 27 additions and 22 deletions

View File

@ -140,7 +140,7 @@ void printSensors(Engine *engine) {
reportSensorF("TRG_0_DUTY", getTriggerDutyCycle(0), 2); reportSensorF("TRG_0_DUTY", getTriggerDutyCycle(0), 2);
reportSensorF("TRG_1_DUTY", getTriggerDutyCycle(1), 2); reportSensorF("TRG_1_DUTY", getTriggerDutyCycle(1), 2);
reportSensorF(getCaption(LP_THROTTLE), getTPS(engineConfiguration), 2); reportSensorF(getCaption(LP_THROTTLE), getTPS(PASS_ENGINE_PARAMETER_F), 2);
if (engineConfiguration->hasCltSensor) { if (engineConfiguration->hasCltSensor) {
reportSensorF(getCaption(LP_ECT), getCoolantTemperature(engine), 2); reportSensorF(getCaption(LP_ECT), getCoolantTemperature(engine), 2);
@ -416,7 +416,7 @@ void updateTunerStudioState(Engine *engine, TunerStudioOutputChannels *tsOutputC
engine_configuration_s *engineConfiguration = engine->engineConfiguration; engine_configuration_s *engineConfiguration = engine->engineConfiguration;
float tps = getTPS(engineConfiguration); float tps = getTPS(PASS_ENGINE_PARAMETER_F);
float coolant = getCoolantTemperature(engine); float coolant = getCoolantTemperature(engine);
float intake = getIntakeAirTemperature(engine); float intake = getIntakeAirTemperature(engine);

View File

@ -24,6 +24,8 @@
static Logging logger; static Logging logger;
#endif #endif
EXTERN_ENGINE;
/** /**
* 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.
*/ */
@ -119,10 +121,9 @@ void StartupFuelPumping::setPumpsCounter(engine_configuration_s *engineConfigura
} }
} }
void StartupFuelPumping::update(Engine *engine) { void StartupFuelPumping::update(DECLARE_ENGINE_PARAMETER_F) {
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
if (engine->rpmCalculator.rpm() == 0) { if (engine->rpmCalculator.rpm() == 0) {
bool isTpsAbove50 = getTPS(engineConfiguration) >= 50; bool isTpsAbove50 = getTPS(PASS_ENGINE_PARAMETER_F) >= 50;
if (this->isTpsAbove50 != isTpsAbove50) { if (this->isTpsAbove50 != isTpsAbove50) {
setPumpsCounter(engineConfiguration, pumpsCounter + 1); setPumpsCounter(engineConfiguration, pumpsCounter + 1);

View File

@ -79,7 +79,7 @@ private:
class StartupFuelPumping { class StartupFuelPumping {
public: public:
StartupFuelPumping(); StartupFuelPumping();
void update(Engine *engine); void update(DECLARE_ENGINE_PARAMETER_F);
bool isTpsAbove50; bool isTpsAbove50;
int pumpsCounter; int pumpsCounter;
private: private:

View File

@ -179,7 +179,7 @@ int getTimeNowSeconds(void) {
static void cylinderCleanupControl(Engine *engine) { static void cylinderCleanupControl(Engine *engine) {
bool newValue; bool newValue;
if (engineConfiguration->isCylinderCleanupEnabled) { if (engineConfiguration->isCylinderCleanupEnabled) {
newValue = isCrankingE(engine) && getTPS(engine->engineConfiguration) > CLEANUP_MODE_TPS; newValue = isCrankingE(engine) && getTPS(PASS_ENGINE_PARAMETER_F) > CLEANUP_MODE_TPS;
} else { } else {
newValue = false; newValue = false;
} }

View File

@ -51,7 +51,7 @@ static char * prepareCltIatTpsLine(Engine *engine, char *buffer) {
ptr = ftoa(ptr, getIntakeAirTemperature(engine), 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(PASS_ENGINE_PARAMETER_F));
return ptr; return ptr;
} }

View File

@ -77,7 +77,7 @@ float getEngineLoadT(DECLARE_ENGINE_PARAMETER_F) {
case LM_MAP: case LM_MAP:
return getMap(); return getMap();
case LM_ALPHA_N: case LM_ALPHA_N:
return getTPS(engineConfiguration); return getTPS(PASS_ENGINE_PARAMETER_F);
default: default:
firmwareError("Unexpected engine load parameter: %d", engineConfiguration->algorithm); firmwareError("Unexpected engine load parameter: %d", engineConfiguration->algorithm);
return -1; return -1;

View File

@ -66,7 +66,7 @@ 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(PASS_ENGINE_PARAMETER_F);
float coolantC = getCoolantTemperature(engine); float coolantC = getCoolantTemperature(engine);
float intakeC = getIntakeAirTemperature(engine); float intakeC = getIntakeAirTemperature(engine);
float tChargeK = convertCelsiusToKelvin(getTCharge(rpm, tps, coolantC, intakeC)); float tChargeK = convertCelsiusToKelvin(getTCharge(rpm, tps, coolantC, intakeC));

View File

@ -12,6 +12,8 @@ extern engine_configuration_s *engineConfiguration;
int mockTps; int mockTps;
#endif #endif
EXTERN_ENGINE;
/** /**
* We are using one instance for read and another for modification, this is how we get lock-free thread-safety * We are using one instance for read and another for modification, this is how we get lock-free thread-safety
* *
@ -91,7 +93,7 @@ int getTPS10bitAdc(void) {
/** /**
* @brief Position on physical primary TPS * @brief Position on physical primary TPS
*/ */
static float getPrimatyRawTPS(engine_configuration_s *engineConfiguration) { static float getPrimatyRawTPS(DECLARE_ENGINE_PARAMETER_F) {
// blue, 1st board // blue, 1st board
/* PA7 - blue TP */ /* PA7 - blue TP */
float tpsValue = getTpsValue(engineConfiguration, getTPS10bitAdc()); float tpsValue = getTpsValue(engineConfiguration, getTPS10bitAdc());
@ -105,12 +107,12 @@ static float getPrimatyRawTPS(engine_configuration_s *engineConfiguration) {
* *
* @return Current TPS position, percent of WOT. 0 means idle and 100 means Wide Open Throttle * @return Current TPS position, percent of WOT. 0 means idle and 100 means Wide Open Throttle
*/ */
float getTPS(engine_configuration_s *engineConfiguration) { float getTPS(DECLARE_ENGINE_PARAMETER_F) {
// todo: if (config->isDualTps) // todo: if (config->isDualTps)
// todo: blah blah // todo: blah blah
// todo: if two TPS do not match - show OBD code via malfunction_central.c // todo: if two TPS do not match - show OBD code via malfunction_central.c
return getPrimatyRawTPS(engineConfiguration); return getPrimatyRawTPS(PASS_ENGINE_PARAMETER_F);
} }
int convertVoltageTo10bitADC(float voltage) { int convertVoltageTo10bitADC(float voltage) {

View File

@ -13,7 +13,7 @@
#include "global.h" #include "global.h"
#include "engine_configuration.h" #include "engine_configuration.h"
float getTPS(engine_configuration_s *engineConfiguration); float getTPS(DECLARE_ENGINE_PARAMETER_F);
int convertVoltageTo10bitADC(float voltage); int convertVoltageTo10bitADC(float voltage);
int getTPS10bitAdc(void); int getTPS10bitAdc(void);
float getTPSVoltage(void); float getTPSVoltage(void);

View File

@ -315,7 +315,7 @@ static void printTPSInfo(void) {
scheduleMsg(&logger, "tps min %d/max %d v=%f @%s%d", engineConfiguration->tpsMin, engineConfiguration->tpsMax, scheduleMsg(&logger, "tps min %d/max %d v=%f @%s%d", engineConfiguration->tpsMin, engineConfiguration->tpsMax,
getTPSVoltage(), portname(port), pin); getTPSVoltage(), portname(port), pin);
#endif #endif
scheduleMsg(&logger, "current 10bit=%d value=%f rate=%f", getTPS10bitAdc(), getTPS(engineConfiguration), scheduleMsg(&logger, "current 10bit=%d value=%f rate=%f", getTPS10bitAdc(), getTPS(PASS_ENGINE_PARAMETER_F),
getTpsRateOfChange()); getTpsRateOfChange());
} }

View File

@ -336,6 +336,7 @@ static void testStartupFuelPumping(void) {
StartupFuelPumping sf; StartupFuelPumping sf;
Engine * engine = &eth.engine; Engine * engine = &eth.engine;
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
engine->rpmCalculator.mockRpm = 0; engine->rpmCalculator.mockRpm = 0;
@ -343,31 +344,31 @@ static void testStartupFuelPumping(void) {
engine->engineConfiguration->tpsMax = 10; engine->engineConfiguration->tpsMax = 10;
mockTps = 6; mockTps = 6;
sf.update(engine); sf.update(PASS_ENGINE_PARAMETER_F);
assertEqualsM("pc#1", 1, sf.pumpsCounter); assertEqualsM("pc#1", 1, sf.pumpsCounter);
mockTps = 3; mockTps = 3;
sf.update(engine); sf.update(PASS_ENGINE_PARAMETER_F);
assertEqualsM("pc#2", 1, sf.pumpsCounter); assertEqualsM("pc#2", 1, sf.pumpsCounter);
sf.update(engine); sf.update(PASS_ENGINE_PARAMETER_F);
assertEqualsM("pc#3", 1, sf.pumpsCounter); assertEqualsM("pc#3", 1, sf.pumpsCounter);
engine->rpmCalculator.mockRpm = 10; engine->rpmCalculator.mockRpm = 10;
sf.update(engine); sf.update(PASS_ENGINE_PARAMETER_F);
assertEqualsM("pc#4", 0, sf.pumpsCounter); assertEqualsM("pc#4", 0, sf.pumpsCounter);
mockTps = 7; mockTps = 7;
engine->rpmCalculator.mockRpm = 0; engine->rpmCalculator.mockRpm = 0;
sf.update(engine); sf.update(PASS_ENGINE_PARAMETER_F);
assertEqualsM("pc#5", 1, sf.pumpsCounter); assertEqualsM("pc#5", 1, sf.pumpsCounter);
mockTps = 3; mockTps = 3;
sf.update(engine); sf.update(PASS_ENGINE_PARAMETER_F);
assertEqualsM("pc#6", 1, sf.pumpsCounter); assertEqualsM("pc#6", 1, sf.pumpsCounter);
mockTps = 7; mockTps = 7;
sf.update(engine); sf.update(PASS_ENGINE_PARAMETER_F);
assertEqualsM("pc#7", 2, sf.pumpsCounter); assertEqualsM("pc#7", 2, sf.pumpsCounter);
} }

View File

@ -94,4 +94,5 @@ typedef EventListener event_listener_t;
#define DECLARE_ENGINE_PARAMETER_F void #define DECLARE_ENGINE_PARAMETER_F void
#define DECLARE_ENGINE_PARAMETER_S #define DECLARE_ENGINE_PARAMETER_S
#define PASS_ENGINE_PARAMETER_F
#define PASS_ENGINE_PARAMETER #define PASS_ENGINE_PARAMETER