only: refactoring: InjectionEvent knows it's index

This commit is contained in:
Andrey 2024-01-07 12:58:07 -05:00
parent c16581c316
commit 0a301a08d5
3 changed files with 5 additions and 15 deletions

View File

@ -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();

View File

@ -85,7 +85,6 @@ public:
* Calculate injector opening angle, pins, and mode for all injectors
*/
void addFuelEvents();
bool addFuelEventsForCylinder(int cylinderIndex);
void resetOverlapping();

View File

@ -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()) {