From ca67249522a4a5836e56c18aa5c6b75bd6309c0f Mon Sep 17 00:00:00 2001 From: rusefi Date: Tue, 8 Oct 2019 00:54:19 -0400 Subject: [PATCH] refactoring: better field name --- firmware/controllers/math/engine_math.cpp | 2 +- .../trigger/decoders/trigger_structure.cpp | 2 +- .../trigger/decoders/trigger_structure.h | 2 +- .../controllers/trigger/main_trigger_callback.cpp | 2 +- firmware/controllers/trigger/spark_logic.cpp | 14 +++++++------- unit_tests/tests/test_fuel_map.cpp | 12 ++++++------ unit_tests/tests/test_trigger_decoder.cpp | 8 ++++---- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index 8a4d4795dc..bc8f0a6498 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -212,7 +212,7 @@ bool FuelSchedule::addFuelEventsForCylinder(int i DECLARE_ENGINE_PARAMETER_SUFF assertAngleRange(angle, "findAngle#a33", CUSTOM_ERR_6544); TRIGGER_SHAPE(findTriggerPosition(&ev->injectionStart, angle PASS_CONFIG_PARAM(engineConfiguration->globalTriggerAngleOffset))); #if EFI_UNIT_TEST - printf("registerInjectionEvent angle=%.2f trgIndex=%d inj %d\r\n", angle, ev->injectionStart.eventIndex, injectorIndex); + printf("registerInjectionEvent angle=%.2f trgIndex=%d inj %d\r\n", angle, ev->injectionStart.triggerEventIndex, injectorIndex); #endif return true; } diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index a330d2c050..248c489b8c 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -372,7 +372,7 @@ void TriggerShape::findTriggerPosition(event_trigger_position_s *position, return; } - position->eventIndex = triggerEventIndex; + position->triggerEventIndex = triggerEventIndex; position->eventAngle = triggerEventAngle; position->angleOffset = angle - triggerEventAngle; } diff --git a/firmware/controllers/trigger/decoders/trigger_structure.h b/firmware/controllers/trigger/decoders/trigger_structure.h index e2236777cb..3f6895d9e5 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.h +++ b/firmware/controllers/trigger/decoders/trigger_structure.h @@ -50,7 +50,7 @@ public: /** * That's trigger event index */ - uint32_t eventIndex = 0; + uint32_t triggerEventIndex = 0; angle_t eventAngle = 0; /** * Angle offset from the trigger event diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index b8a23bad09..c04ed5c94c 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -406,7 +406,7 @@ static ALWAYS_INLINE void handleFuel(const bool limitedFuel, uint32_t trgEventIn for (int injEventIndex = 0; injEventIndex < CONFIG(specs.cylindersCount); injEventIndex++) { InjectionEvent *event = &fs->elements[injEventIndex]; - uint32_t eventIndex = event->injectionStart.eventIndex; + uint32_t eventIndex = event->injectionStart.triggerEventIndex; // right after trigger change we are still using old & invalid fuel schedule. good news is we do not change trigger on the fly in real life // efiAssertVoid(CUSTOM_ERR_ASSERT_VOID, eventIndex < ENGINE(triggerShape.getLength()), "handleFuel/event sch index"); if (eventIndex != trgEventIndex) { diff --git a/firmware/controllers/trigger/spark_logic.cpp b/firmware/controllers/trigger/spark_logic.cpp index c6aaff2838..98284d5ee8 100644 --- a/firmware/controllers/trigger/spark_logic.cpp +++ b/firmware/controllers/trigger/spark_logic.cpp @@ -115,7 +115,7 @@ static void prepareCylinderIgnitionSchedule(angle_t dwellAngle, floatms_t sparkD TRIGGER_SHAPE(findTriggerPosition(&event->dwellPosition, a PASS_CONFIG_PARAM(engineConfiguration->globalTriggerAngleOffset))); #if FUEL_MATH_EXTREME_LOGGING - printf("addIgnitionEvent %s ind=%d\n", output->name, event->dwellPosition.eventIndex); + printf("addIgnitionEvent %s ind=%d\n", output->name, event->dwellPosition.triggerEventIndex); // scheduleMsg(logger, "addIgnitionEvent %s ind=%d", output->name, event->dwellPosition->eventIndex); #endif /* FUEL_MATH_EXTREME_LOGGING */ } @@ -273,8 +273,8 @@ static ALWAYS_INLINE void handleSparkEvent(bool limitedSpark, uint32_t trgEventI #if EFI_UNIT_TEST if (verboseMode) { - printf("spark dwell@ %d/%d spark@ %d/%d id=%d\r\n", iEvent->dwellPosition.eventIndex, (int)iEvent->dwellPosition.angleOffset, - iEvent->sparkPosition.eventIndex, (int)iEvent->sparkPosition.angleOffset, + printf("spark dwell@ %d/%d spark@ %d/%d id=%d\r\n", iEvent->dwellPosition.triggerEventIndex, (int)iEvent->dwellPosition.angleOffset, + iEvent->sparkPosition.triggerEventIndex, (int)iEvent->sparkPosition.angleOffset, iEvent->sparkId); } #endif @@ -292,7 +292,7 @@ static ALWAYS_INLINE void handleSparkEvent(bool limitedSpark, uint32_t trgEventI * time-based schedule. This case we would be firing events with best possible angle precision. * */ - if (iEvent->sparkPosition.eventIndex == trgEventIndex) { + if (iEvent->sparkPosition.triggerEventIndex == trgEventIndex) { /** * Spark should be fired before the next trigger event - time-based delay is best precision possible */ @@ -305,7 +305,7 @@ static ALWAYS_INLINE void handleSparkEvent(bool limitedSpark, uint32_t trgEventI engine->executor.scheduleForLater(sDown, (int) timeTillIgnitionUs, (schfunc_t) &fireSparkAndPrepareNextSchedule, iEvent); } else { #if SPARK_EXTREME_LOGGING - scheduleMsg(logger, "to queue sparkDown ind=%d %d %s %d for %d", trgEventIndex, getRevolutionCounter(), iEvent->getOutputForLoggins()->name, (int)getTimeNowUs(), iEvent->sparkPosition.eventIndex); + scheduleMsg(logger, "to queue sparkDown ind=%d %d %s %d for %d", trgEventIndex, getRevolutionCounter(), iEvent->getOutputForLoggins()->name, (int)getTimeNowUs(), iEvent->sparkPosition.triggerEventIndex); #endif /* FUEL_MATH_EXTREME_LOGGING */ /** * Spark should be scheduled in relation to some future trigger event, this way we get better firing precision @@ -381,7 +381,7 @@ static void scheduleAllSparkEventsUntilNextTriggerTooth(uint32_t trgEventIndex D LL_FOREACH_SAFE(ENGINE(iHead), current, tmp) { - if (current->sparkPosition.eventIndex == trgEventIndex) { + if (current->sparkPosition.triggerEventIndex == trgEventIndex) { // time to fire a spark which was scheduled previously LL_DELETE(ENGINE(iHead), current); @@ -422,7 +422,7 @@ void onTriggerEventSparkLogic(bool limitedSpark, uint32_t trgEventIndex, int rpm if (ENGINE(ignitionEvents.isReady)) { for (int i = 0; i < CONFIG(specs.cylindersCount); i++) { IgnitionEvent *event = &ENGINE(ignitionEvents.elements[i]); - if (event->dwellPosition.eventIndex != trgEventIndex) + if (event->dwellPosition.triggerEventIndex != trgEventIndex) continue; handleSparkEvent(limitedSpark, trgEventIndex, event, rpm PASS_ENGINE_PARAMETER_SUFFIX); } diff --git a/unit_tests/tests/test_fuel_map.cpp b/unit_tests/tests/test_fuel_map.cpp index 35be7f6e4c..44973ac804 100644 --- a/unit_tests/tests/test_fuel_map.cpp +++ b/unit_tests/tests/test_fuel_map.cpp @@ -182,32 +182,32 @@ TEST(misc, testAngleResolver) { printf("*************************************************** testAngleResolver 0\r\n"); TRIGGER_SHAPE(findTriggerPosition(&injectionStart, -122, engineConfiguration->globalTriggerAngleOffset)); - ASSERT_EQ( 2, injectionStart.eventIndex) << "eventIndex@0"; + ASSERT_EQ( 2, injectionStart.triggerEventIndex) << "eventIndex@0"; ASSERT_NEAR(0.24, injectionStart.angleOffset, EPS5D); printf("*************************************************** testAngleResolver 0.1\r\n"); TRIGGER_SHAPE(findTriggerPosition(&injectionStart, -80, engineConfiguration->globalTriggerAngleOffset)); - ASSERT_EQ( 2, injectionStart.eventIndex) << "eventIndex@0"; + ASSERT_EQ( 2, injectionStart.triggerEventIndex) << "eventIndex@0"; ASSERT_FLOAT_EQ(42.24, injectionStart.angleOffset); printf("*************************************************** testAngleResolver 0.2\r\n"); TRIGGER_SHAPE(findTriggerPosition(&injectionStart, -54, engineConfiguration->globalTriggerAngleOffset)); - ASSERT_EQ( 2, injectionStart.eventIndex) << "eventIndex@0"; + ASSERT_EQ( 2, injectionStart.triggerEventIndex) << "eventIndex@0"; ASSERT_FLOAT_EQ(68.2400, injectionStart.angleOffset); printf("*************************************************** testAngleResolver 0.3\r\n"); TRIGGER_SHAPE(findTriggerPosition(&injectionStart, -53, engineConfiguration->globalTriggerAngleOffset)); - ASSERT_EQ(2, injectionStart.eventIndex); + ASSERT_EQ(2, injectionStart.triggerEventIndex); ASSERT_FLOAT_EQ(69.24, injectionStart.angleOffset); printf("*************************************************** testAngleResolver 1\r\n"); TRIGGER_SHAPE(findTriggerPosition(&injectionStart, 0, engineConfiguration->globalTriggerAngleOffset)); - ASSERT_EQ(2, injectionStart.eventIndex); + ASSERT_EQ(2, injectionStart.triggerEventIndex); ASSERT_FLOAT_EQ(122.24, injectionStart.angleOffset); printf("*************************************************** testAngleResolver 2\r\n"); TRIGGER_SHAPE(findTriggerPosition(&injectionStart, 56, engineConfiguration->globalTriggerAngleOffset)); - ASSERT_EQ(2, injectionStart.eventIndex); + ASSERT_EQ(2, injectionStart.triggerEventIndex); ASSERT_FLOAT_EQ(178.24, injectionStart.angleOffset); TriggerShape t; diff --git a/unit_tests/tests/test_trigger_decoder.cpp b/unit_tests/tests/test_trigger_decoder.cpp index 2ac26e8576..f3ef85e8f8 100644 --- a/unit_tests/tests/test_trigger_decoder.cpp +++ b/unit_tests/tests/test_trigger_decoder.cpp @@ -103,7 +103,7 @@ static void testDodgeNeonDecoder(void) { } static void assertTriggerPosition(event_trigger_position_s *position, int eventIndex, float angleOffset) { - assertEqualsM("eventIndex", eventIndex, position->eventIndex); + assertEqualsM("eventIndex", eventIndex, position->triggerEventIndex); assertEqualsM("angleOffset", angleOffset, position->angleOffset); } @@ -176,10 +176,10 @@ TEST(misc, test1995FordInline6TriggerDecoder) { IgnitionEventList *ecl = &engine->ignitionEvents; ASSERT_EQ( 1, ecl->isReady) << "ford inline ignition events size"; - ASSERT_EQ( 0, ecl->elements[0].dwellPosition.eventIndex) << "event index"; + ASSERT_EQ( 0, ecl->elements[0].dwellPosition.triggerEventIndex) << "event index"; ASSERT_NEAR(7.8621, ecl->elements[0].dwellPosition.angleOffset, EPS4D) << "angle offset#1"; - ASSERT_EQ( 10, ecl->elements[5].dwellPosition.eventIndex) << "event index"; + ASSERT_EQ( 10, ecl->elements[5].dwellPosition.triggerEventIndex) << "event index"; ASSERT_NEAR(7.8621, ecl->elements[5].dwellPosition.angleOffset, EPS4D) << "angle offset#2"; @@ -554,7 +554,7 @@ extern fuel_Map3D_t fuelMap; static void assertInjectionEvent(const char *msg, InjectionEvent *ev, int injectorIndex, int eventIndex, angle_t angleOffset, bool isOverlapping) { assertEqualsM4(msg, "inj index", injectorIndex, ev->outputs[0]->injectorIndex); - assertEqualsM4(msg, " event index", eventIndex, ev->injectionStart.eventIndex); + assertEqualsM4(msg, " event index", eventIndex, ev->injectionStart.triggerEventIndex); assertEqualsM4(msg, " event offset", angleOffset, ev->injectionStart.angleOffset); }