refacoting: making code more consistent

This commit is contained in:
rusefi 2019-01-05 00:57:09 -05:00
parent a354371bb5
commit 0c6f361181
13 changed files with 26 additions and 26 deletions

View File

@ -114,7 +114,7 @@ float AccelEnrichmemnt::getMaxDelta(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
floatms_t AccelEnrichmemnt::getTpsEnrichment(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
int index = getMaxDeltaIndex(PASS_ENGINE_PARAMETER_SIGNATURE);
// FuelSchedule *fs = engine->engineConfigurationPtr2->injectionEvents;
// FuelSchedule *fs = engineConfiguration->injectionEvents;
float tpsTo = cb.get(index);
float tpsFrom = cb.get(index - 1);
float d = tpsTo - tpsFrom;

View File

@ -34,7 +34,6 @@ static TriggerState initState CCM_OPTIONAL;
LoggingWithStorage engineLogger("engine");
// todo: in this file it would be better not to have complete 'EXTERN_ENGINE'
EXTERN_ENGINE
;
@ -92,7 +91,7 @@ void Engine::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
engineState.updateSlowSensors(PASS_ENGINE_PARAMETER_SIGNATURE);
// todo: move this logic somewhere to sensors folder?
if (engineConfiguration->fuelLevelSensor != EFI_ADC_NONE) {
if (CONFIG(fuelLevelSensor) != EFI_ADC_NONE) {
float fuelLevelVoltage = getVoltageDivided("fuel", engineConfiguration->fuelLevelSensor);
sensors.fuelTankGauge = interpolateMsg("fgauge", boardConfiguration->fuelLevelEmptyTankVoltage, 0,
boardConfiguration->fuelLevelFullTankVoltage, 100,
@ -165,12 +164,12 @@ void Engine::reset() {
* Here we have a bunch of stuff which should invoked after configuration change
* so that we can prepare some helper structures
*/
void Engine::preCalculate() {
sparkTable.preCalc(engineConfigurationPtr->sparkDwellRpmBins,
engineConfigurationPtr->sparkDwellValues);
void Engine::preCalculate(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
sparkTable.preCalc(engineConfiguration->sparkDwellRpmBins,
engineConfiguration->sparkDwellValues);
#if ! EFI_UNIT_TEST
adcToVoltageInputDividerCoefficient = adcToVolts(1) * engineConfigurationPtr->analogInputDividerCoefficient;
adcToVoltageInputDividerCoefficient = adcToVolts(1) * engineConfiguration->analogInputDividerCoefficient;
#else
adcToVoltageInputDividerCoefficient = engineConfigurationPtr->analogInputDividerCoefficient;
#endif
@ -197,9 +196,9 @@ void Engine::printKnockState(void) {
scheduleMsg(&engineLogger, "knock now=%s/ever=%s", boolToString(knockNow), boolToString(knockEver));
}
void Engine::knockLogic(float knockVolts) {
void Engine::knockLogic(float knockVolts DECLARE_ENGINE_PARAMETER_SUFFIX) {
this->knockVolts = knockVolts;
knockNow = knockVolts > engineConfigurationPtr->knockVThreshold;
knockNow = knockVolts > engineConfiguration->knockVThreshold;
/**
* KnockCount is directly proportional to the degrees of ignition
* advance removed
@ -216,7 +215,7 @@ void Engine::knockLogic(float knockVolts) {
if (knockNow) {
knockEver = true;
timeOfLastKnockEvent = getTimeNowUs();
if (knockCount < engineConfigurationPtr->maxKnockSubDeg)
if (knockCount < engineConfiguration->maxKnockSubDeg)
knockCount++;
} else if (knockCount >= 1) {
knockCount--;

View File

@ -346,6 +346,7 @@ public:
persistent_config_s *config;
/**
* we use funny unique name to make sure that compiler is not confused between global variable and class member
* todo: this variable is probably a sign of some problem, should we even have it?
*/
engine_configuration_s *engineConfigurationPtr;
@ -473,7 +474,7 @@ public:
*/
float mafDecodingLookup[MAF_DECODING_CACHE_SIZE];
void preCalculate();
void preCalculate(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void watchdog();
@ -490,7 +491,7 @@ public:
monitoring_timestamps_s m;
void knockLogic(float knockVolts);
void knockLogic(float knockVolts DECLARE_ENGINE_PARAMETER_SUFFIX);
void printKnockState(void);
private:

View File

@ -178,7 +178,7 @@ void incrementGlobalConfigurationVersion(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#if EFI_PROD_CODE || defined(__DOXYGEN__)
applyNewHardwareSettings();
#endif /* EFI_PROD_CODE */
engine->preCalculate();
engine->preCalculate(PASS_ENGINE_PARAMETER_SIGNATURE);
#if EFI_ALTERNATOR_CONTROL || defined(__DOXYGEN__)
onConfigurationChangeAlternatorCallback(&activeConfiguration);
#endif /* EFI_ALTERNATOR_CONTROL */

View File

@ -531,7 +531,7 @@ static void setFloat(const char *offsetStr, const char *valueStr) {
scheduleMsg(&logger, "invalid value [%s]", valueStr);
return;
}
float *ptr = (float *) (&((char *) engine->engineConfigurationPtr)[offset]);
float *ptr = (float *) (&((char *) engineConfiguration)[offset]);
*ptr = value;
getFloat(offset);
}

View File

@ -26,5 +26,5 @@ bool getAcToggle(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
* for now we are looking for a pull-up. High level means input switch is floating (which is OFF position)
* low value means input is ground - which means ON.
*/
return getVoltageDivided("A/C", engine->engineConfigurationPtr->acSwitchAdc) < 2.5;
return getVoltageDivided("A/C", engineConfiguration->acSwitchAdc) < 2.5;
}

View File

@ -509,7 +509,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex D
if (trgEventIndex == CONFIG(ignMathCalculateAtIndex)) {
if (CONFIG(externalKnockSenseAdc) != EFI_ADC_NONE) {
float externalKnockValue = getVoltageDivided("knock", engineConfiguration->externalKnockSenseAdc);
engine->knockLogic(externalKnockValue);
engine->knockLogic(externalKnockValue PASS_ENGINE_PARAMETER_SUFFIX);
}
}

View File

@ -94,13 +94,13 @@ static void initECUstimulator(Engine *engine) {
chThdCreateStatic(eeThreadStack, sizeof(eeThreadStack), NORMALPRIO, (tfunc_t)(void*) eeThread, engine);
}
void initEngineEmulator(Logging *sharedLogger, Engine *engine) {
void initEngineEmulator(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
if (hasFirmwareError())
return;
#if EFI_POTENTIOMETER
#if HAL_USE_SPI || defined(__DOXYGEN__)
initPotentiometers(sharedLogger, &engine->engineConfigurationPtr->bc);
initPotentiometers(sharedLogger, &engineConfiguration->bc);
#endif /* HAL_USE_SPI */
#endif /* EFI_POTENTIOMETER */

View File

@ -9,6 +9,6 @@
#define ENGINE_EMULATOR_H_
#include "engine.h"
void initEngineEmulator(Logging *sharedLogger, Engine *engine);
void initEngineEmulator(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
#endif /* ENGINE_EMULATOR_H_ */

View File

@ -217,7 +217,7 @@ void runRusEfi(void) {
#endif
#if EFI_ENGINE_EMULATOR || defined(__DOXYGEN__)
initEngineEmulator(&sharedLogger, engine);
initEngineEmulator(&sharedLogger PASS_ENGINE_PARAMETER_SIGNATURE);
#endif
startStatusThreads();

View File

@ -93,7 +93,7 @@ void testMafLookup(void) {
EXPAND_EngineTestHelper;
setBosch0280218037(config);
engine->preCalculate();
engine->preCalculate(PASS_ENGINE_PARAMETER_SIGNATURE);
assertEqualsM("@0", -34.5000, engine->mafDecodingLookup[0]);
assertEqualsM("@1", -33.7875, engine->mafDecodingLookup[1]);

View File

@ -32,8 +32,8 @@ void testCoastingFuelCut() {
// set cranking threshold
engineConfiguration->cranking.rpm = 999;
// configure TPS
eth.engine.engineConfigurationPtr->tpsMin = 0;
eth.engine.engineConfigurationPtr->tpsMax = 10;
engineConfiguration->tpsMin = 0;
engineConfiguration->tpsMax = 10;
// basic engine setup
setupSimpleTestEngineWithMafAndTT_ONE_trigger(&eth);

View File

@ -258,8 +258,8 @@ void testStartupFuelPumping(void) {
engine->rpmCalculator.mockRpm = 0;
engine->engineConfigurationPtr->tpsMin = 0;
engine->engineConfigurationPtr->tpsMax = 10;
engineConfiguration->tpsMin = 0;
engineConfiguration->tpsMax = 10;
setMockTpsPosition(6);
sf.update(PASS_ENGINE_PARAMETER_SIGNATURE);
@ -834,7 +834,7 @@ void testFuelSchedulerBug299smallAndMedium(void) {
// {
// scheduling_s *ev = schedulingQueue.getForUnitText(9);
// assertEqualsM("rev cnt#4#2", 5, engine->rpmCalculator.getRevolutionCounter());
// assertTrueM("down 50", ev == &engine->engineConfigurationPtr2->fuelActuators[2].signalPair[1].signalTimerDown);
// assertTrueM("down 50", ev == &engineConfiguration->fuelActuators[2].signalPair[1].signalTimerDown);
// }