From 0a301a08d5139b00e0db28f1f6d4a7efd66a473f Mon Sep 17 00:00:00 2001 From: Andrey Date: Sun, 7 Jan 2024 12:58:07 -0500 Subject: [PATCH] only: refactoring: InjectionEvent knows it's index --- firmware/controllers/engine_cycle/fuel_schedule.cpp | 11 +---------- firmware/controllers/engine_cycle/fuel_schedule.h | 1 - .../engine_cycle/main_trigger_callback.cpp | 8 ++++---- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/firmware/controllers/engine_cycle/fuel_schedule.cpp b/firmware/controllers/engine_cycle/fuel_schedule.cpp index 83ca872bf3..ce738fbe79 100644 --- a/firmware/controllers/engine_cycle/fuel_schedule.cpp +++ b/firmware/controllers/engine_cycle/fuel_schedule.cpp @@ -127,15 +127,6 @@ bool InjectionEvent::updateInjectionAngle() { /** * @returns false in case of error, true if success */ -bool FuelSchedule::addFuelEventsForCylinder(int i) { - InjectionEvent *ev = &elements[i]; -#if EFU_UNIT_TEST - if (ev->ownIndex != i) - throw std::logic_error("index issue"); -#endif - return ev->update(); -} - bool InjectionEvent::update() { bool updatedAngle = updateInjectionAngle(); @@ -192,7 +183,7 @@ bool InjectionEvent::update() { void FuelSchedule::addFuelEvents() { for (size_t cylinderIndex = 0; cylinderIndex < engineConfiguration->cylindersCount; cylinderIndex++) { - bool result = addFuelEventsForCylinder(cylinderIndex); + bool result = elements[cylinderIndex].update(); if (!result) { invalidate(); diff --git a/firmware/controllers/engine_cycle/fuel_schedule.h b/firmware/controllers/engine_cycle/fuel_schedule.h index d734624acd..94a5746a12 100644 --- a/firmware/controllers/engine_cycle/fuel_schedule.h +++ b/firmware/controllers/engine_cycle/fuel_schedule.h @@ -85,7 +85,6 @@ public: * Calculate injector opening angle, pins, and mode for all injectors */ void addFuelEvents(); - bool addFuelEventsForCylinder(int cylinderIndex); void resetOverlapping(); diff --git a/firmware/controllers/engine_cycle/main_trigger_callback.cpp b/firmware/controllers/engine_cycle/main_trigger_callback.cpp index bc7391c5fe..eb08b83dfc 100644 --- a/firmware/controllers/engine_cycle/main_trigger_callback.cpp +++ b/firmware/controllers/engine_cycle/main_trigger_callback.cpp @@ -50,7 +50,7 @@ void endSimultaneousInjection(InjectionEvent *event) { event->isScheduled = false; endSimultaneousInjectionOnlyTogglePins(); - getFuelSchedule()->addFuelEventsForCylinder(event->ownIndex); + event->update(); } void turnInjectionPinLow(InjectionEvent *event) { @@ -63,7 +63,7 @@ void turnInjectionPinLow(InjectionEvent *event) { output->close(nowNt); } } - getFuelSchedule()->addFuelEventsForCylinder(event->ownIndex); + event->update(); } void InjectionEvent::onTriggerTooth(int rpm, efitick_t nowNt, float currentPhase, float nextPhase) { @@ -183,7 +183,7 @@ void InjectionEvent::onTriggerTooth(int rpm, efitick_t nowNt, float currentPhase static void handleFuel(int rpm, efitick_t nowNt, float currentPhase, float nextPhase) { ScopePerf perf(PE::HandleFuel); - + efiAssertVoid(ObdCode::CUSTOM_STACK_6627, hasLotsOfRemainingStack(), "lowstck#3"); LimpState limitedFuelState = getLimpManager()->allowInjection(); @@ -244,7 +244,7 @@ void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp, angle_ return; } - + if (trgEventIndex == 0) { if (getTriggerCentral()->checkIfTriggerConfigChanged()) {