mirror of https://github.com/rusefi/rusefi.git
only:minor encapsulation
This commit is contained in:
parent
b721882952
commit
4e32f39070
|
@ -124,10 +124,8 @@ bool InjectionEvent::updateInjectionAngle() {
|
||||||
/**
|
/**
|
||||||
* @returns false in case of error, true if success
|
* @returns false in case of error, true if success
|
||||||
*/
|
*/
|
||||||
bool FuelSchedule::addFuelEventsForCylinder(int i) {
|
bool InjectionEvent::update() {
|
||||||
InjectionEvent *ev = &elements[i];
|
bool updatedAngle = updateInjectionAngle();
|
||||||
|
|
||||||
bool updatedAngle = ev->updateInjectionAngle();
|
|
||||||
|
|
||||||
if (!updatedAngle) {
|
if (!updatedAngle) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -142,7 +140,7 @@ bool FuelSchedule::addFuelEventsForCylinder(int i) {
|
||||||
injectorIndex = 0;
|
injectorIndex = 0;
|
||||||
} else if (mode == IM_SEQUENTIAL || mode == IM_BATCH) {
|
} else if (mode == IM_SEQUENTIAL || mode == IM_BATCH) {
|
||||||
// Map order index -> cylinder index (firing order)
|
// Map order index -> cylinder index (firing order)
|
||||||
injectorIndex = getCylinderId(i) - 1;
|
injectorIndex = getCylinderId(ownIndex) - 1;
|
||||||
} else {
|
} else {
|
||||||
firmwareError(ObdCode::CUSTOM_OBD_UNEXPECTED_INJECTION_MODE, "Unexpected injection mode %d", mode);
|
firmwareError(ObdCode::CUSTOM_OBD_UNEXPECTED_INJECTION_MODE, "Unexpected injection mode %d", mode);
|
||||||
injectorIndex = 0;
|
injectorIndex = 0;
|
||||||
|
@ -157,7 +155,7 @@ bool FuelSchedule::addFuelEventsForCylinder(int i) {
|
||||||
// Compute the position of this cylinder's twin in the firing order
|
// Compute the position of this cylinder's twin in the firing order
|
||||||
// Each injector gets fired as a primary (the same as sequential), but also
|
// Each injector gets fired as a primary (the same as sequential), but also
|
||||||
// fires the injector 360 degrees later in the firing order.
|
// fires the injector 360 degrees later in the firing order.
|
||||||
int secondOrder = (i + (engineConfiguration->cylindersCount / 2)) % engineConfiguration->cylindersCount;
|
int secondOrder = (ownIndex + (engineConfiguration->cylindersCount / 2)) % engineConfiguration->cylindersCount;
|
||||||
int secondIndex = getCylinderId(secondOrder) - 1;
|
int secondIndex = getCylinderId(secondOrder) - 1;
|
||||||
secondOutput = &enginePins.injectors[secondIndex];
|
secondOutput = &enginePins.injectors[secondIndex];
|
||||||
} else {
|
} else {
|
||||||
|
@ -167,11 +165,11 @@ bool FuelSchedule::addFuelEventsForCylinder(int i) {
|
||||||
InjectorOutputPin *output = &enginePins.injectors[injectorIndex];
|
InjectorOutputPin *output = &enginePins.injectors[injectorIndex];
|
||||||
bool isSimultaneous = mode == IM_SIMULTANEOUS;
|
bool isSimultaneous = mode == IM_SIMULTANEOUS;
|
||||||
|
|
||||||
ev->outputs[0] = output;
|
outputs[0] = output;
|
||||||
ev->outputs[1] = secondOutput;
|
outputs[1] = secondOutput;
|
||||||
ev->isSimultaneous = isSimultaneous;
|
isSimultaneous = isSimultaneous;
|
||||||
// Stash the cylinder number so we can select the correct fueling bank later
|
// Stash the cylinder number so we can select the correct fueling bank later
|
||||||
ev->cylinderNumber = injectorIndex;
|
cylinderNumber = injectorIndex;
|
||||||
|
|
||||||
if (!isSimultaneous && !output->isInitialized()) {
|
if (!isSimultaneous && !output->isInitialized()) {
|
||||||
// todo: extract method for this index math
|
// todo: extract method for this index math
|
||||||
|
@ -183,7 +181,7 @@ bool FuelSchedule::addFuelEventsForCylinder(int i) {
|
||||||
|
|
||||||
void FuelSchedule::addFuelEvents() {
|
void FuelSchedule::addFuelEvents() {
|
||||||
for (size_t cylinderIndex = 0; cylinderIndex < engineConfiguration->cylindersCount; cylinderIndex++) {
|
for (size_t cylinderIndex = 0; cylinderIndex < engineConfiguration->cylindersCount; cylinderIndex++) {
|
||||||
bool result = addFuelEventsForCylinder(cylinderIndex);
|
bool result = elements[cylinderIndex].update();
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
invalidate();
|
invalidate();
|
||||||
|
|
|
@ -18,11 +18,7 @@ class InjectionEvent {
|
||||||
public:
|
public:
|
||||||
InjectionEvent();
|
InjectionEvent();
|
||||||
|
|
||||||
// Update the injection start angle
|
bool update();
|
||||||
bool updateInjectionAngle();
|
|
||||||
|
|
||||||
// Compute the injection start angle, compensating for injection duration and injection phase settings.
|
|
||||||
expected<float> computeInjectionAngle() const;
|
|
||||||
|
|
||||||
// Call this every decoded trigger tooth. It will schedule any relevant events for this injector.
|
// Call this every decoded trigger tooth. It will schedule any relevant events for this injector.
|
||||||
void onTriggerTooth(int rpm, efitick_t nowNt, float currentPhase, float nextPhase);
|
void onTriggerTooth(int rpm, efitick_t nowNt, float currentPhase, float nextPhase);
|
||||||
|
@ -33,6 +29,13 @@ public:
|
||||||
ownIndex = index;
|
ownIndex = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Update the injection start angle
|
||||||
|
bool updateInjectionAngle();
|
||||||
|
|
||||||
|
// Compute the injection start angle, compensating for injection duration and injection phase settings.
|
||||||
|
expected<float> computeInjectionAngle() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a performance optimization for IM_SIMULTANEOUS fuel strategy.
|
* This is a performance optimization for IM_SIMULTANEOUS fuel strategy.
|
||||||
* It's more efficient to handle all injectors together if that's the case
|
* It's more efficient to handle all injectors together if that's the case
|
||||||
|
@ -41,6 +44,7 @@ public:
|
||||||
uint8_t ownIndex = 0;
|
uint8_t ownIndex = 0;
|
||||||
uint8_t cylinderNumber = 0;
|
uint8_t cylinderNumber = 0;
|
||||||
|
|
||||||
|
public:
|
||||||
scheduling_s signalTimerUp;
|
scheduling_s signalTimerUp;
|
||||||
scheduling_s endOfInjectionEvent;
|
scheduling_s endOfInjectionEvent;
|
||||||
|
|
||||||
|
@ -53,6 +57,7 @@ public:
|
||||||
*/
|
*/
|
||||||
bool isScheduled = false;
|
bool isScheduled = false;
|
||||||
|
|
||||||
|
private:
|
||||||
WallFuel wallFuel;
|
WallFuel wallFuel;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
void endSimultaneousInjection(InjectionEvent *event) {
|
void endSimultaneousInjection(InjectionEvent *event) {
|
||||||
event->isScheduled = false;
|
event->isScheduled = false;
|
||||||
endSimultaneousInjectionOnlyTogglePins();
|
endSimultaneousInjectionOnlyTogglePins();
|
||||||
getFuelSchedule()->addFuelEventsForCylinder(event->ownIndex);
|
event->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void turnInjectionPinLow(InjectionEvent *event) {
|
void turnInjectionPinLow(InjectionEvent *event) {
|
||||||
|
@ -63,7 +63,7 @@ void turnInjectionPinLow(InjectionEvent *event) {
|
||||||
output->close(nowNt);
|
output->close(nowNt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getFuelSchedule()->addFuelEventsForCylinder(event->ownIndex);
|
event->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InjectionEvent::onTriggerTooth(int rpm, efitick_t nowNt, float currentPhase, float nextPhase) {
|
void InjectionEvent::onTriggerTooth(int rpm, efitick_t nowNt, float currentPhase, float nextPhase) {
|
||||||
|
|
Loading…
Reference in New Issue