only:minor encapsulation
This commit is contained in:
parent
0a7dba9e16
commit
3db5c6e3f7
|
@ -161,7 +161,7 @@ const trigger_state_primary_s* getLiveData(size_t) {
|
|||
template<>
|
||||
const wall_fuel_state_s* getLiveData(size_t) {
|
||||
#if EFI_ENGINE_CONTROL
|
||||
return &engine->injectionEvents.elements[0].wallFuel;
|
||||
return &engine->injectionEvents.elements[0].getWallFuel();
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
|
|
|
@ -68,7 +68,7 @@ InjectionEvent::InjectionEvent() {
|
|||
|
||||
// Returns the start angle of this injector in engine coordinates (0-720 for a 4 stroke),
|
||||
// or unexpected if unable to calculate the start angle due to missing information.
|
||||
expected<float> InjectionEvent::computeInjectionAngle(int cylinderIndex) const {
|
||||
expected<float> InjectionEvent::computeInjectionAngle() const {
|
||||
floatus_t oneDegreeUs = getEngineRotationState()->getOneDegreeUs(); // local copy
|
||||
if (cisnan(oneDegreeUs)) {
|
||||
// in order to have fuel schedule we need to have current RPM
|
||||
|
@ -91,7 +91,7 @@ expected<float> InjectionEvent::computeInjectionAngle(int cylinderIndex) const {
|
|||
assertAngleRange(openingAngle, "openingAngle_r", ObdCode::CUSTOM_ERR_6554);
|
||||
|
||||
// Convert from cylinder-relative to cylinder-1-relative
|
||||
openingAngle += getPerCylinderFiringOrderOffset(cylinderIndex, cylinderNumber);
|
||||
openingAngle += getPerCylinderFiringOrderOffset(ownIndex, cylinderNumber);
|
||||
|
||||
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !cisnan(openingAngle), "findAngle#3", false);
|
||||
assertAngleRange(openingAngle, "findAngle#a33", ObdCode::CUSTOM_ERR_6544);
|
||||
|
@ -105,8 +105,8 @@ expected<float> InjectionEvent::computeInjectionAngle(int cylinderIndex) const {
|
|||
return openingAngle;
|
||||
}
|
||||
|
||||
bool InjectionEvent::updateInjectionAngle(int cylinderIndex) {
|
||||
auto result = computeInjectionAngle(cylinderIndex);
|
||||
bool InjectionEvent::updateInjectionAngle() {
|
||||
auto result = computeInjectionAngle();
|
||||
|
||||
if (result) {
|
||||
// If injector duty cycle is high, lock injection SOI so that we
|
||||
|
@ -127,7 +127,7 @@ bool InjectionEvent::updateInjectionAngle(int cylinderIndex) {
|
|||
bool FuelSchedule::addFuelEventsForCylinder(int i) {
|
||||
InjectionEvent *ev = &elements[i];
|
||||
|
||||
bool updatedAngle = ev->updateInjectionAngle(i);
|
||||
bool updatedAngle = ev->updateInjectionAngle();
|
||||
|
||||
if (!updatedAngle) {
|
||||
return false;
|
||||
|
|
|
@ -19,10 +19,10 @@ public:
|
|||
InjectionEvent();
|
||||
|
||||
// Update the injection start angle
|
||||
bool updateInjectionAngle(int cylinderIndex);
|
||||
bool updateInjectionAngle();
|
||||
|
||||
// Compute the injection start angle, compensating for injection duration and injection phase settings.
|
||||
expected<float> computeInjectionAngle(int cylinderIndex) const;
|
||||
expected<float> computeInjectionAngle() const;
|
||||
|
||||
// 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);
|
||||
|
@ -38,12 +38,9 @@ public:
|
|||
* It's more efficient to handle all injectors together if that's the case
|
||||
*/
|
||||
bool isSimultaneous = false;
|
||||
InjectorOutputPin *outputs[MAX_WIRES_COUNT];
|
||||
uint8_t ownIndex = 0;
|
||||
uint8_t cylinderNumber = 0;
|
||||
|
||||
float injectionStartAngle = 0;
|
||||
|
||||
scheduling_s signalTimerUp;
|
||||
scheduling_s endOfInjectionEvent;
|
||||
|
||||
|
@ -57,6 +54,12 @@ public:
|
|||
bool isScheduled = false;
|
||||
|
||||
WallFuel wallFuel;
|
||||
|
||||
public:
|
||||
// TODO: this should be private
|
||||
InjectorOutputPin *outputs[MAX_WIRES_COUNT];
|
||||
float injectionStartAngle = 0;
|
||||
|
||||
};
|
||||
|
||||
void turnInjectionPinHigh(InjectionEvent *event);
|
||||
|
|
|
@ -76,11 +76,11 @@ TEST(fuel, testWallWettingEnrichmentScheduling) {
|
|||
int expectedInvocationCounter = 1;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
ASSERT_EQ(expectedInvocationCounter, engine->injectionEvents.elements[i].wallFuel.invocationCounter);
|
||||
ASSERT_EQ(expectedInvocationCounter, engine->injectionEvents.elements[i].getWallFuel().invocationCounter);
|
||||
}
|
||||
|
||||
// Cylinder 5 doesn't exist - shouldn't have been called!
|
||||
ASSERT_EQ(0, engine->injectionEvents.elements[5].wallFuel.invocationCounter);
|
||||
ASSERT_EQ(0, engine->injectionEvents.elements[5].getWallFuel().invocationCounter);
|
||||
|
||||
eth.engine.periodicFastCallback();
|
||||
eth.engine.periodicFastCallback();
|
||||
|
@ -88,9 +88,9 @@ TEST(fuel, testWallWettingEnrichmentScheduling) {
|
|||
|
||||
// still same 1 per cylinder - wall wetting is NOT invoked from 'periodicFastCallback'
|
||||
for (int i = 0; i < 4; i++) {
|
||||
ASSERT_EQ(expectedInvocationCounter, engine->injectionEvents.elements[i].wallFuel.invocationCounter);
|
||||
ASSERT_EQ(expectedInvocationCounter, engine->injectionEvents.elements[i].getWallFuel().invocationCounter);
|
||||
}
|
||||
|
||||
// Cylinder 5 doesn't exist - shouldn't have been called!
|
||||
ASSERT_EQ(0, engine->injectionEvents.elements[5].wallFuel.invocationCounter);
|
||||
ASSERT_EQ(0, engine->injectionEvents.elements[5].getWallFuel().invocationCounter);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue