This commit is contained in:
Andrey 2024-01-07 16:39:15 -05:00
parent fe0080c4c0
commit ca18c5ba4e
3 changed files with 12 additions and 14 deletions

View File

@ -44,8 +44,6 @@ private:
uint8_t cylinderNumber = 0;
public:
scheduling_s signalTimerUp;
scheduling_s endOfInjectionEvent;
/**
* we need atomic flag so that we do not schedule a new pair of up/down before previous down was executed.

View File

@ -136,7 +136,7 @@ void InjectionEvent::onTriggerTooth(int rpm, efitick_t nowNt, float currentPhase
}
#endif /*EFI_PRINTF_FUEL_DETAILS */
if (isScheduled) {
if (isScheduled) {
#if EFI_PRINTF_FUEL_DETAILS
if (printFuelDebug) {
InjectorOutputPin *output = outputs[0];
@ -164,9 +164,9 @@ void InjectionEvent::onTriggerTooth(int rpm, efitick_t nowNt, float currentPhase
angleFromNow += getEngineState()->engineCycle;
}
efitick_t startTime = scheduleByAngle(&signalTimerUp, nowNt, angleFromNow, startAction);
efitick_t startTime = scheduleByAngle(nullptr, nowNt, angleFromNow, startAction);
efitick_t turnOffTime = startTime + US2NT((int)durationUs);
getExecutorInterface()->scheduleByTimestampNt("inj", &endOfInjectionEvent, turnOffTime, endAction);
getExecutorInterface()->scheduleByTimestampNt("inj", nullptr, turnOffTime, endAction);
#if EFI_UNIT_TEST
printf("scheduling injection angle=%.2f/delay=%.2f injectionDuration=%.2f\r\n", angleFromNow, NT2US(startTime - nowNt), injectionDuration);

View File

@ -33,12 +33,12 @@ TEST(injectionScheduling, InjectionIsScheduled) {
// rising edge 5 degrees from now
float nt5deg = USF2NT(engine->rpmCalculator.oneDegreeUs * 5);
efitick_t startTime = nowNt + nt5deg;
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), &event.signalTimerUp, startTime, _));
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, startTime, _));
// falling edge 20ms later
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), &event.endOfInjectionEvent, startTime + MS2NT(20), _));
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, startTime + MS2NT(20), _));
}
// Event scheduled at 125 degrees
event.injectionStartAngle = 125;
@ -73,9 +73,9 @@ TEST(injectionScheduling, InjectionIsScheduledBeforeWraparound) {
// rising edge 5 degrees from now
float nt5deg = USF2NT(engine->rpmCalculator.oneDegreeUs * 5);
efitick_t startTime = nowNt + nt5deg;
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), &event.signalTimerUp, startTime, _));
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, startTime, _));
// falling edge 20ms later
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), &event.endOfInjectionEvent, startTime + MS2NT(20), _));
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, startTime + MS2NT(20), _));
}
// Event scheduled at 715 degrees
@ -112,9 +112,9 @@ TEST(injectionScheduling, InjectionIsScheduledAfterWraparound) {
// rising edge 15 degrees from now
float nt5deg = USF2NT(engine->rpmCalculator.oneDegreeUs * 15);
efitick_t startTime = nowNt + nt5deg;
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), &event.signalTimerUp, startTime, _));
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, startTime, _));
// falling edge 20ms later
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), &event.endOfInjectionEvent, startTime + MS2NT(20), _));
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, startTime + MS2NT(20), _));
}
// Event scheduled at 5 degrees
@ -150,10 +150,10 @@ TEST(injectionScheduling, InjectionNotScheduled) {
// Expect no scheduler calls!
}
// Event scheduled at 125 degrees
event.injectionStartAngle = 125;
// We are at 130 degrees now, next tooth 140
event.onTriggerTooth(1000, nowNt, 130, 140);
}
}