mirror of https://github.com/FOME-Tech/fome-fw.git
rename Executor -> Scheduler
This commit is contained in:
parent
07b61ee0b4
commit
dd8dea61c0
|
@ -94,7 +94,7 @@ const BigBufferHandle& triggerScopeGetBuffer() {
|
||||||
|
|
||||||
// Start the next sample once we've read out this one
|
// Start the next sample once we've read out this one
|
||||||
if (isRunning) {
|
if (isRunning) {
|
||||||
engine->executor.scheduleByTimestampNt("trigger scope", &restartTimer, getTimeNowNt() + MS2NT(10), startSampling);
|
engine->scheduler.schedule("trigger scope", &restartTimer, getTimeNowNt() + MS2NT(10), startSampling);
|
||||||
}
|
}
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
|
|
|
@ -88,7 +88,7 @@ void initAlternatorCtrl() {
|
||||||
|
|
||||||
startSimplePwm(&alternatorControl,
|
startSimplePwm(&alternatorControl,
|
||||||
"Alternator control",
|
"Alternator control",
|
||||||
&engine->executor,
|
&engine->scheduler,
|
||||||
&enginePins.alternatorPin,
|
&enginePins.alternatorPin,
|
||||||
engineConfiguration->alternatorPwmFrequency, 0);
|
engineConfiguration->alternatorPwmFrequency, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,7 +229,7 @@ void startBoostPin() {
|
||||||
startSimplePwm(
|
startSimplePwm(
|
||||||
&boostPwmControl,
|
&boostPwmControl,
|
||||||
"Boost",
|
"Boost",
|
||||||
&engine->executor,
|
&engine->scheduler,
|
||||||
&enginePins.boostPin,
|
&enginePins.boostPin,
|
||||||
engineConfiguration->boostPwmFrequency,
|
engineConfiguration->boostPwmFrequency,
|
||||||
0
|
0
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
brain_pin_e pinDir2,
|
brain_pin_e pinDir2,
|
||||||
brain_pin_e pinDisable,
|
brain_pin_e pinDisable,
|
||||||
bool isInverted,
|
bool isInverted,
|
||||||
ExecutorInterface* executor,
|
Scheduler* executor,
|
||||||
int frequency) {
|
int frequency) {
|
||||||
|
|
||||||
if (isStarted) {
|
if (isStarted) {
|
||||||
|
@ -99,7 +99,7 @@ DcMotor* initDcMotor(const dc_io& io, size_t index, bool useTwoWires) {
|
||||||
io.disablePin,
|
io.disablePin,
|
||||||
// todo You would not believe how you invert TLE9201 #4579
|
// todo You would not believe how you invert TLE9201 #4579
|
||||||
engineConfiguration->stepperDcInvertedPins,
|
engineConfiguration->stepperDcInvertedPins,
|
||||||
&engine->executor,
|
&engine->scheduler,
|
||||||
engineConfiguration->etbFreq
|
engineConfiguration->etbFreq
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ DcMotor* initDcMotor(brain_pin_e coil_p, brain_pin_e coil_m, size_t index) {
|
||||||
coil_m,
|
coil_m,
|
||||||
Gpio::Unassigned, /* pinDisable */
|
Gpio::Unassigned, /* pinDisable */
|
||||||
engineConfiguration->stepperDcInvertedPins,
|
engineConfiguration->stepperDcInvertedPins,
|
||||||
&engine->executor,
|
&engine->scheduler,
|
||||||
engineConfiguration->etbFreq /* same in case of stepper? */
|
engineConfiguration->etbFreq /* same in case of stepper? */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ public:
|
||||||
brain_pin_e pinDir2,
|
brain_pin_e pinDir2,
|
||||||
brain_pin_e pinDisable,
|
brain_pin_e pinDisable,
|
||||||
bool isInverted,
|
bool isInverted,
|
||||||
ExecutorInterface* executor,
|
Scheduler* executor,
|
||||||
int frequency);
|
int frequency);
|
||||||
|
|
||||||
TwoPinDcMotor dcMotor;
|
TwoPinDcMotor dcMotor;
|
||||||
|
|
|
@ -44,7 +44,7 @@ void initGpPwm() {
|
||||||
// Setup pin & pwm
|
// Setup pin & pwm
|
||||||
pins[i].initPin("gp pwm", cfg.pin);
|
pins[i].initPin("gp pwm", cfg.pin);
|
||||||
if (usePwm) {
|
if (usePwm) {
|
||||||
startSimplePwm(&outputs[i], channelNames[i], &engine->executor, &pins[i], freq, 0);
|
startSimplePwm(&outputs[i], channelNames[i], &engine->scheduler, &pins[i], freq, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up this channel's lookup table
|
// Set up this channel's lookup table
|
||||||
|
|
|
@ -148,7 +148,7 @@ void initIdleHardware() {
|
||||||
*/
|
*/
|
||||||
// todo: even for double-solenoid mode we can probably use same single SimplePWM
|
// todo: even for double-solenoid mode we can probably use same single SimplePWM
|
||||||
startSimplePwm(&idleSolenoidOpen, "Idle Valve Open",
|
startSimplePwm(&idleSolenoidOpen, "Idle Valve Open",
|
||||||
&engine->executor,
|
&engine->scheduler,
|
||||||
&enginePins.idleSolenoidPin,
|
&enginePins.idleSolenoidPin,
|
||||||
engineConfiguration->idle.solenoidFrequency, PERCENT_TO_DUTY(engineConfiguration->manIdlePosition));
|
engineConfiguration->idle.solenoidFrequency, PERCENT_TO_DUTY(engineConfiguration->manIdlePosition));
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ void initIdleHardware() {
|
||||||
}
|
}
|
||||||
|
|
||||||
startSimplePwm(&idleSolenoidClose, "Idle Valve Close",
|
startSimplePwm(&idleSolenoidClose, "Idle Valve Close",
|
||||||
&engine->executor,
|
&engine->scheduler,
|
||||||
&enginePins.secondIdleSolenoidPin,
|
&enginePins.secondIdleSolenoidPin,
|
||||||
engineConfiguration->idle.solenoidFrequency, PERCENT_TO_DUTY(engineConfiguration->manIdlePosition));
|
engineConfiguration->idle.solenoidFrequency, PERCENT_TO_DUTY(engineConfiguration->manIdlePosition));
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,7 +165,7 @@ static void turnVvtPidOn(int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
startSimplePwmExt(&vvtPwms[index], vvtOutputNames[index],
|
startSimplePwmExt(&vvtPwms[index], vvtOutputNames[index],
|
||||||
&engine->executor,
|
&engine->scheduler,
|
||||||
engineConfiguration->vvtPins[index],
|
engineConfiguration->vvtPins[index],
|
||||||
&vvtPins[index],
|
&vvtPins[index],
|
||||||
engineConfiguration->vvtOutputFrequency, 0);
|
engineConfiguration->vvtOutputFrequency, 0);
|
||||||
|
|
|
@ -492,8 +492,8 @@ TunerStudioOutputChannels *getTunerStudioOutputChannels() {
|
||||||
return &engine->outputChannels;
|
return &engine->outputChannels;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExecutorInterface *getExecutorInterface() {
|
Scheduler *getScheduler() {
|
||||||
return &engine->executor;
|
return &engine->scheduler;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EFI_SHAFT_POSITION_INPUT
|
#if EFI_SHAFT_POSITION_INPUT
|
||||||
|
|
|
@ -241,13 +241,13 @@ public:
|
||||||
// a pointer with interface type would make this code nicer but would carry extra runtime
|
// a pointer with interface type would make this code nicer but would carry extra runtime
|
||||||
// cost to resolve pointer, we use instances as a micro optimization
|
// cost to resolve pointer, we use instances as a micro optimization
|
||||||
#if EFI_SIGNAL_EXECUTOR_ONE_TIMER
|
#if EFI_SIGNAL_EXECUTOR_ONE_TIMER
|
||||||
SingleTimerExecutor executor;
|
SingleTimerExecutor scheduler;
|
||||||
#endif
|
#endif
|
||||||
#if EFI_SIGNAL_EXECUTOR_SLEEP
|
#if EFI_SIGNAL_EXECUTOR_SLEEP
|
||||||
SleepExecutor executor;
|
SleepExecutor scheduler;
|
||||||
#endif
|
#endif
|
||||||
#if EFI_UNIT_TEST
|
#if EFI_UNIT_TEST
|
||||||
TestExecutor executor;
|
TestExecutor scheduler;
|
||||||
|
|
||||||
std::function<void(IgnitionEvent*, bool)> onIgnitionEvent;
|
std::function<void(IgnitionEvent*, bool)> onIgnitionEvent;
|
||||||
#endif // EFI_UNIT_TEST
|
#endif // EFI_UNIT_TEST
|
||||||
|
|
|
@ -101,8 +101,8 @@ static void runBench(BenchParams& params) {
|
||||||
efitick_t endTime = startTime + US2NT(onTimeUs);
|
efitick_t endTime = startTime + US2NT(onTimeUs);
|
||||||
|
|
||||||
// Schedule both events
|
// Schedule both events
|
||||||
engine->executor.scheduleByTimestampNt("bstart", nullptr, startTime, {benchOn, params.Pin});
|
engine->scheduler.schedule("bstart", nullptr, startTime, {benchOn, params.Pin});
|
||||||
engine->executor.scheduleByTimestampNt("bend", nullptr, endTime, {benchOff, params.Pin});
|
engine->scheduler.schedule("bend", nullptr, endTime, {benchOff, params.Pin});
|
||||||
|
|
||||||
// Wait one full cycle time for the event + delay to happen
|
// Wait one full cycle time for the event + delay to happen
|
||||||
chThdSleepMicroseconds(onTimeUs + offTimeUs);
|
chThdSleepMicroseconds(onTimeUs + offTimeUs);
|
||||||
|
|
|
@ -39,8 +39,8 @@ void turnInjectionPinLow(uintptr_t arg) {
|
||||||
efitick_t openTime = getTimeNowNt() + MS2NT(2);
|
efitick_t openTime = getTimeNowNt() + MS2NT(2);
|
||||||
efitick_t closeTime = openTime + nextSplitDuration;
|
efitick_t closeTime = openTime + nextSplitDuration;
|
||||||
|
|
||||||
getExecutorInterface()->scheduleByTimestampNt("inj", nullptr, openTime, { &turnInjectionPinHigh, arg });
|
getScheduler()->schedule("inj", nullptr, openTime, { &turnInjectionPinHigh, arg });
|
||||||
getExecutorInterface()->scheduleByTimestampNt("inj", nullptr, closeTime, { turnInjectionPinLow, arg });
|
getScheduler()->schedule("inj", nullptr, closeTime, { turnInjectionPinLow, arg });
|
||||||
} else {
|
} else {
|
||||||
event->update();
|
event->update();
|
||||||
}
|
}
|
||||||
|
@ -214,12 +214,12 @@ void InjectionEvent::onTriggerTooth(efitick_t nowNt, float currentPhase, float n
|
||||||
this->splitInjectionDuration = {};
|
this->splitInjectionDuration = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
getExecutorInterface()->scheduleByTimestampNt("inj", nullptr, turnOffTimeStage1, endActionStage1);
|
getScheduler()->schedule("inj", nullptr, turnOffTimeStage1, endActionStage1);
|
||||||
|
|
||||||
// Schedule closing stage 2 (if applicable)
|
// Schedule closing stage 2 (if applicable)
|
||||||
if (hasStage2Injection && endActionStage2) {
|
if (hasStage2Injection && endActionStage2) {
|
||||||
efitick_t turnOffTimeStage2 = startTime + US2NT((int)durationUsStage2);
|
efitick_t turnOffTimeStage2 = startTime + US2NT((int)durationUsStage2);
|
||||||
getExecutorInterface()->scheduleByTimestampNt("inj stage 2", nullptr, turnOffTimeStage2, endActionStage2);
|
getScheduler()->schedule("inj stage 2", nullptr, turnOffTimeStage2, endActionStage2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EFI_UNIT_TEST
|
#if EFI_UNIT_TEST
|
||||||
|
|
|
@ -64,7 +64,7 @@ void PrimeController::onIgnitionStateChanged(bool ignitionOn) {
|
||||||
uint32_t primeDelayNt = MSF2NT(engineConfiguration->primingDelay * 1000 + minimumPrimeDelayMs);
|
uint32_t primeDelayNt = MSF2NT(engineConfiguration->primingDelay * 1000 + minimumPrimeDelayMs);
|
||||||
|
|
||||||
auto startTime = getTimeNowNt() + primeDelayNt;
|
auto startTime = getTimeNowNt() + primeDelayNt;
|
||||||
getExecutorInterface()->scheduleByTimestampNt("prime start", nullptr, startTime, { PrimeController::onPrimeStartAdapter, this });
|
getScheduler()->schedule("prime start", nullptr, startTime, { PrimeController::onPrimeStartAdapter, this });
|
||||||
} else {
|
} else {
|
||||||
efiPrintf("Skipped priming pulse since ignSwitchCounter = %lu", ignSwitchCounter);
|
efiPrintf("Skipped priming pulse since ignSwitchCounter = %lu", ignSwitchCounter);
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ void PrimeController::onPrimeStart() {
|
||||||
// Open all injectors, schedule closing later
|
// Open all injectors, schedule closing later
|
||||||
m_isPriming = true;
|
m_isPriming = true;
|
||||||
startSimultaneousInjection();
|
startSimultaneousInjection();
|
||||||
getExecutorInterface()->scheduleByTimestampNt("prime end", nullptr, endTime, { onPrimeEndAdapter, this });
|
getScheduler()->schedule("prime end", nullptr, endTime, { onPrimeEndAdapter, this });
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimeController::onPrimeEnd() {
|
void PrimeController::onPrimeEnd() {
|
||||||
|
|
|
@ -393,7 +393,7 @@ efitick_t scheduleByAngle(scheduling_s *timer, efitick_t edgeTimestamp, angle_t
|
||||||
int32_t delayNt = USF2NT(delayUs);
|
int32_t delayNt = USF2NT(delayUs);
|
||||||
efitick_t delayedTime = edgeTimestamp + efidur_t{delayNt};
|
efitick_t delayedTime = edgeTimestamp + efidur_t{delayNt};
|
||||||
|
|
||||||
engine->executor.scheduleByTimestampNt("angle", timer, delayedTime, action);
|
engine->scheduler.schedule("angle", timer, delayedTime, action);
|
||||||
|
|
||||||
return delayedTime;
|
return delayedTime;
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,8 +224,8 @@ if (engineConfiguration->debugMode == DBG_DWELL_METRIC) {
|
||||||
#endif /* SPARK_EXTREME_LOGGING */
|
#endif /* SPARK_EXTREME_LOGGING */
|
||||||
|
|
||||||
// We can schedule both of these right away, since we're going for "asap" not "particular angle"
|
// We can schedule both of these right away, since we're going for "asap" not "particular angle"
|
||||||
engine->executor.scheduleByTimestampNt("dwell", &event->dwellStartTimer, nextDwellStart, { &turnSparkPinHigh, event });
|
engine->scheduler.schedule("dwell", &event->dwellStartTimer, nextDwellStart, { &turnSparkPinHigh, event });
|
||||||
engine->executor.scheduleByTimestampNt("firing", &event->sparkEvent.scheduling, nextFiring, { fireSparkAndPrepareNextSchedule, event });
|
engine->scheduler.schedule("firing", &event->sparkEvent.scheduling, nextFiring, { fireSparkAndPrepareNextSchedule, event });
|
||||||
} else {
|
} else {
|
||||||
if (engineConfiguration->enableTrailingSparks) {
|
if (engineConfiguration->enableTrailingSparks) {
|
||||||
#if SPARK_EXTREME_LOGGING
|
#if SPARK_EXTREME_LOGGING
|
||||||
|
@ -382,7 +382,7 @@ static void scheduleSparkEvent(bool limitedSpark, IgnitionEvent *event,
|
||||||
if (!limitedSpark && engine->enableOverdwellProtection) {
|
if (!limitedSpark && engine->enableOverdwellProtection) {
|
||||||
// auto fire spark at 1.5x nominal dwell
|
// auto fire spark at 1.5x nominal dwell
|
||||||
efitick_t fireTime = chargeTime + (uint32_t)MSF2NT(1.5f * dwellMs);
|
efitick_t fireTime = chargeTime + (uint32_t)MSF2NT(1.5f * dwellMs);
|
||||||
engine->executor.scheduleByTimestampNt("overdwell", &event->sparkEvent.scheduling, fireTime, { overFireSparkAndPrepareNextSchedule, event });
|
engine->scheduler.schedule("overdwell", &event->sparkEvent.scheduling, fireTime, { overFireSparkAndPrepareNextSchedule, event });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ void initSpeedometer() {
|
||||||
|
|
||||||
startSimplePwm(&speedoPwm,
|
startSimplePwm(&speedoPwm,
|
||||||
"Speedometer",
|
"Speedometer",
|
||||||
&engine->executor,
|
&engine->scheduler,
|
||||||
&enginePins.speedoOut,
|
&enginePins.speedoOut,
|
||||||
NAN, 0.5f);
|
NAN, 0.5f);
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ void initTachometer() {
|
||||||
|
|
||||||
startSimplePwm(&tachControl,
|
startSimplePwm(&tachControl,
|
||||||
"Tachometer",
|
"Tachometer",
|
||||||
&engine->executor,
|
&engine->scheduler,
|
||||||
&enginePins.tachOut,
|
&enginePins.tachOut,
|
||||||
NAN, 0.1f);
|
NAN, 0.1f);
|
||||||
|
|
||||||
|
|
|
@ -250,7 +250,7 @@ static int lua_startPwm(lua_State* l) {
|
||||||
freq = clampF(1, freq, 1000);
|
freq = clampF(1, freq, 1000);
|
||||||
|
|
||||||
startSimplePwmExt(
|
startSimplePwmExt(
|
||||||
&p.pwm, "lua", &engine->executor,
|
&p.pwm, "lua", &engine->scheduler,
|
||||||
engineConfiguration->luaOutputPins[p.idx], &enginePins.luaOutputPins[p.idx],
|
engineConfiguration->luaOutputPins[p.idx], &enginePins.luaOutputPins[p.idx],
|
||||||
freq, duty
|
freq, duty
|
||||||
);
|
);
|
||||||
|
|
|
@ -45,7 +45,7 @@ void initVrPwm() {
|
||||||
}
|
}
|
||||||
|
|
||||||
startSimplePwmHard(&pwms[i], "VR PWM",
|
startSimplePwmHard(&pwms[i], "VR PWM",
|
||||||
&engine->executor,
|
&engine->scheduler,
|
||||||
cfg.pin,
|
cfg.pin,
|
||||||
&pins[i],
|
&pins[i],
|
||||||
10000, // it's guaranteed to be hardware PWM, the faster the PWM, the less noise makes it through
|
10000, // it's guaranteed to be hardware PWM, the faster the PWM, the less noise makes it through
|
||||||
|
|
|
@ -266,7 +266,7 @@ static void timerCallback(PwmConfig *state) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
state->m_executor->scheduleByTimestampNt(state->m_name, &state->scheduling, switchTimeNt, { timerCallback, state });
|
state->m_executor->schedule(state->m_name, &state->scheduling, switchTimeNt, { timerCallback, state });
|
||||||
state->dbgNestingLevel--;
|
state->dbgNestingLevel--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ void copyPwmParameters(PwmConfig *state, MultiChannelStateSequence const * seq)
|
||||||
* this method also starts the timer cycle
|
* this method also starts the timer cycle
|
||||||
* See also startSimplePwm
|
* See also startSimplePwm
|
||||||
*/
|
*/
|
||||||
void PwmConfig::weComplexInit(ExecutorInterface *executor,
|
void PwmConfig::weComplexInit(Scheduler *executor,
|
||||||
MultiChannelStateSequence const * seq,
|
MultiChannelStateSequence const * seq,
|
||||||
pwm_cycle_callback *pwmCycleCallback, pwm_gen_callback *stateChangeCallback) {
|
pwm_cycle_callback *pwmCycleCallback, pwm_gen_callback *stateChangeCallback) {
|
||||||
m_executor = executor;
|
m_executor = executor;
|
||||||
|
@ -315,7 +315,7 @@ void PwmConfig::weComplexInit(ExecutorInterface *executor,
|
||||||
timerCallback(this);
|
timerCallback(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void startSimplePwm(SimplePwm *state, const char *msg, ExecutorInterface *executor,
|
void startSimplePwm(SimplePwm *state, const char *msg, Scheduler *executor,
|
||||||
OutputPin *output, float frequency, float dutyCycle) {
|
OutputPin *output, float frequency, float dutyCycle) {
|
||||||
efiAssertVoid(ObdCode::CUSTOM_ERR_PWM_STATE_ASSERT, state != NULL, "state");
|
efiAssertVoid(ObdCode::CUSTOM_ERR_PWM_STATE_ASSERT, state != NULL, "state");
|
||||||
efiAssertVoid(ObdCode::CUSTOM_ERR_PWM_DUTY_ASSERT, dutyCycle >= 0 && dutyCycle <= 1, "dutyCycle");
|
efiAssertVoid(ObdCode::CUSTOM_ERR_PWM_DUTY_ASSERT, dutyCycle >= 0 && dutyCycle <= 1, "dutyCycle");
|
||||||
|
@ -337,7 +337,7 @@ void startSimplePwm(SimplePwm *state, const char *msg, ExecutorInterface *execut
|
||||||
}
|
}
|
||||||
|
|
||||||
void startSimplePwmExt(SimplePwm *state, const char *msg,
|
void startSimplePwmExt(SimplePwm *state, const char *msg,
|
||||||
ExecutorInterface *executor,
|
Scheduler *executor,
|
||||||
brain_pin_e brainPin, OutputPin *output, float frequency,
|
brain_pin_e brainPin, OutputPin *output, float frequency,
|
||||||
float dutyCycle) {
|
float dutyCycle) {
|
||||||
|
|
||||||
|
@ -350,7 +350,7 @@ void startSimplePwmExt(SimplePwm *state, const char *msg,
|
||||||
* @param dutyCycle value between 0 and 1
|
* @param dutyCycle value between 0 and 1
|
||||||
*/
|
*/
|
||||||
void startSimplePwmHard(SimplePwm *state, const char *msg,
|
void startSimplePwmHard(SimplePwm *state, const char *msg,
|
||||||
ExecutorInterface *executor,
|
Scheduler *executor,
|
||||||
brain_pin_e brainPin, OutputPin *output, float frequency,
|
brain_pin_e brainPin, OutputPin *output, float frequency,
|
||||||
float dutyCycle) {
|
float dutyCycle) {
|
||||||
#if EFI_PROD_CODE && HAL_USE_PWM
|
#if EFI_PROD_CODE && HAL_USE_PWM
|
||||||
|
|
|
@ -52,12 +52,12 @@ public:
|
||||||
PwmConfig();
|
PwmConfig();
|
||||||
|
|
||||||
void weComplexInit(
|
void weComplexInit(
|
||||||
ExecutorInterface *executor,
|
Scheduler *executor,
|
||||||
MultiChannelStateSequence const * seq,
|
MultiChannelStateSequence const * seq,
|
||||||
pwm_cycle_callback *pwmCycleCallback,
|
pwm_cycle_callback *pwmCycleCallback,
|
||||||
pwm_gen_callback *callback);
|
pwm_gen_callback *callback);
|
||||||
|
|
||||||
ExecutorInterface *m_executor = nullptr;
|
Scheduler *m_executor = nullptr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We need to handle zero duty cycle and 100% duty cycle in a special way
|
* We need to handle zero duty cycle and 100% duty cycle in a special way
|
||||||
|
@ -132,7 +132,7 @@ void applyPinState(int stateIndex, PwmConfig* state) /* pwm_gen_callback */;
|
||||||
* This method should be called after scheduling layer is started by initSignalExecutor()
|
* This method should be called after scheduling layer is started by initSignalExecutor()
|
||||||
*/
|
*/
|
||||||
void startSimplePwm(SimplePwm *state, const char *msg,
|
void startSimplePwm(SimplePwm *state, const char *msg,
|
||||||
ExecutorInterface *executor,
|
Scheduler *executor,
|
||||||
OutputPin *output,
|
OutputPin *output,
|
||||||
float frequency, float dutyCycle);
|
float frequency, float dutyCycle);
|
||||||
|
|
||||||
|
@ -143,12 +143,12 @@ void startSimplePwm(SimplePwm *state, const char *msg,
|
||||||
*/
|
*/
|
||||||
void startSimplePwmExt(SimplePwm *state,
|
void startSimplePwmExt(SimplePwm *state,
|
||||||
const char *msg,
|
const char *msg,
|
||||||
ExecutorInterface *executor,
|
Scheduler *executor,
|
||||||
brain_pin_e brainPin, OutputPin *output,
|
brain_pin_e brainPin, OutputPin *output,
|
||||||
float frequency, float dutyCycle);
|
float frequency, float dutyCycle);
|
||||||
|
|
||||||
void startSimplePwmHard(SimplePwm *state, const char *msg,
|
void startSimplePwmHard(SimplePwm *state, const char *msg,
|
||||||
ExecutorInterface *executor,
|
Scheduler *executor,
|
||||||
brain_pin_e brainPin, OutputPin *output, float frequency,
|
brain_pin_e brainPin, OutputPin *output, float frequency,
|
||||||
float dutyCycle);
|
float dutyCycle);
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ struct scheduling_s {
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
struct ExecutorInterface {
|
struct Scheduler {
|
||||||
/**
|
/**
|
||||||
* @brief Schedule an action to be executed in the future.
|
* @brief Schedule an action to be executed in the future.
|
||||||
*
|
*
|
||||||
|
@ -87,7 +87,7 @@ struct ExecutorInterface {
|
||||||
* very near future, it may execute immediately.
|
* very near future, it may execute immediately.
|
||||||
* @param action An action to execute at the specified time.
|
* @param action An action to execute at the specified time.
|
||||||
*/
|
*/
|
||||||
virtual void scheduleByTimestampNt(const char *msg, scheduling_s *scheduling, efitick_t targetTime, action_s action) = 0;
|
virtual void schedule(const char *msg, scheduling_s *scheduling, efitick_t targetTime, action_s action) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Cancel the specified scheduling_s so that, if currently scheduled, it does not execute.
|
* @brief Cancel the specified scheduling_s so that, if currently scheduled, it does not execute.
|
||||||
|
@ -97,5 +97,5 @@ struct ExecutorInterface {
|
||||||
virtual void cancel(scheduling_s* scheduling) = 0;
|
virtual void cancel(scheduling_s* scheduling) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
ExecutorInterface *getExecutorInterface();
|
Scheduler *getScheduler();
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ uint32_t hwSetTimerDuration;
|
||||||
void globalTimerCallback() {
|
void globalTimerCallback() {
|
||||||
efiAssertVoid(ObdCode::CUSTOM_ERR_6624, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstck#2y");
|
efiAssertVoid(ObdCode::CUSTOM_ERR_6624, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstck#2y");
|
||||||
|
|
||||||
___engine.executor.onTimerCallback();
|
___engine.scheduler.onTimerCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
SingleTimerExecutor::SingleTimerExecutor()
|
SingleTimerExecutor::SingleTimerExecutor()
|
||||||
|
@ -45,7 +45,7 @@ SingleTimerExecutor::SingleTimerExecutor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleTimerExecutor::scheduleByTimestampNt(const char *msg, scheduling_s* scheduling, efitick_t nt, action_s action) {
|
void SingleTimerExecutor::schedule(const char *msg, scheduling_s* scheduling, efitick_t nt, action_s action) {
|
||||||
ScopePerf perf(PE::SingleTimerExecutorScheduleByTimestamp);
|
ScopePerf perf(PE::SingleTimerExecutorScheduleByTimestamp);
|
||||||
|
|
||||||
#if EFI_ENABLE_ASSERTS
|
#if EFI_ENABLE_ASSERTS
|
||||||
|
@ -54,7 +54,7 @@ void SingleTimerExecutor::scheduleByTimestampNt(const char *msg, scheduling_s* s
|
||||||
if (deltaTimeNt >= TOO_FAR_INTO_FUTURE_NT) {
|
if (deltaTimeNt >= TOO_FAR_INTO_FUTURE_NT) {
|
||||||
// we are trying to set callback for too far into the future. This does not look right at all
|
// we are trying to set callback for too far into the future. This does not look right at all
|
||||||
int32_t intDeltaTimeNt = (int32_t)deltaTimeNt;
|
int32_t intDeltaTimeNt = (int32_t)deltaTimeNt;
|
||||||
firmwareError(ObdCode::CUSTOM_ERR_TASK_TIMER_OVERFLOW, "scheduleByTimestampNt() too far: %ld %s", intDeltaTimeNt, msg);
|
firmwareError(ObdCode::CUSTOM_ERR_TASK_TIMER_OVERFLOW, "schedule() too far: %ld %s", intDeltaTimeNt, msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -161,11 +161,11 @@ void initSingleTimerExecutorHardware(void) {
|
||||||
void executorStatistics() {
|
void executorStatistics() {
|
||||||
if (engineConfiguration->debugMode == DBG_EXECUTOR) {
|
if (engineConfiguration->debugMode == DBG_EXECUTOR) {
|
||||||
#if EFI_TUNER_STUDIO
|
#if EFI_TUNER_STUDIO
|
||||||
engine->outputChannels.debugIntField1 = ___engine.executor.timerCallbackCounter;
|
engine->outputChannels.debugIntField1 = ___engine.scheduler.timerCallbackCounter;
|
||||||
engine->outputChannels.debugIntField2 = ___engine.executor.executeAllPendingActionsInvocationCounter;
|
engine->outputChannels.debugIntField2 = ___engine.scheduler.executeAllPendingActionsInvocationCounter;
|
||||||
engine->outputChannels.debugIntField3 = ___engine.executor.scheduleCounter;
|
engine->outputChannels.debugIntField3 = ___engine.scheduler.scheduleCounter;
|
||||||
engine->outputChannels.debugIntField4 = ___engine.executor.executeCounter;
|
engine->outputChannels.debugIntField4 = ___engine.scheduler.executeCounter;
|
||||||
engine->outputChannels.debugIntField5 = ___engine.executor.maxExecuteCounter;
|
engine->outputChannels.debugIntField5 = ___engine.scheduler.maxExecuteCounter;
|
||||||
#endif /* EFI_TUNER_STUDIO */
|
#endif /* EFI_TUNER_STUDIO */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
#include "scheduler.h"
|
#include "scheduler.h"
|
||||||
#include "event_queue.h"
|
#include "event_queue.h"
|
||||||
|
|
||||||
class SingleTimerExecutor final : public ExecutorInterface {
|
class SingleTimerExecutor final : public Scheduler {
|
||||||
public:
|
public:
|
||||||
SingleTimerExecutor();
|
SingleTimerExecutor();
|
||||||
void scheduleByTimestampNt(const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s action) override;
|
void schedule(const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s action) override;
|
||||||
void cancel(scheduling_s* scheduling) override;
|
void cancel(scheduling_s* scheduling) override;
|
||||||
|
|
||||||
void onTimerCallback();
|
void onTimerCallback();
|
||||||
|
|
|
@ -121,7 +121,7 @@ void TriggerScheduler::scheduleEventsUntilNextTriggerTooth(int rpm,
|
||||||
|
|
||||||
// In case this event was scheduled by overdwell protection, cancel it so
|
// In case this event was scheduled by overdwell protection, cancel it so
|
||||||
// we can re-schedule at the correct time
|
// we can re-schedule at the correct time
|
||||||
engine->executor.cancel(sDown);
|
engine->scheduler.cancel(sDown);
|
||||||
|
|
||||||
scheduleByAngle(
|
scheduleByAngle(
|
||||||
sDown,
|
sDown,
|
||||||
|
|
|
@ -16,21 +16,21 @@ void Gm4l6xTransmissionController::init() {
|
||||||
enginePins.tcuTccPwmSolenoid.initPin("TCC PWM Solenoid", engineConfiguration->tcu_tcc_pwm_solenoid, engineConfiguration->tcu_tcc_pwm_solenoid_mode);
|
enginePins.tcuTccPwmSolenoid.initPin("TCC PWM Solenoid", engineConfiguration->tcu_tcc_pwm_solenoid, engineConfiguration->tcu_tcc_pwm_solenoid_mode);
|
||||||
startSimplePwm(&tccPwm,
|
startSimplePwm(&tccPwm,
|
||||||
"TCC",
|
"TCC",
|
||||||
&engine->executor,
|
&engine->scheduler,
|
||||||
&enginePins.tcuTccPwmSolenoid,
|
&enginePins.tcuTccPwmSolenoid,
|
||||||
engineConfiguration->tcu_tcc_pwm_solenoid_freq,
|
engineConfiguration->tcu_tcc_pwm_solenoid_freq,
|
||||||
0);
|
0);
|
||||||
enginePins.tcuPcSolenoid.initPin("Pressure Control Solenoid", engineConfiguration->tcu_pc_solenoid_pin, engineConfiguration->tcu_pc_solenoid_pin_mode);
|
enginePins.tcuPcSolenoid.initPin("Pressure Control Solenoid", engineConfiguration->tcu_pc_solenoid_pin, engineConfiguration->tcu_pc_solenoid_pin_mode);
|
||||||
startSimplePwm(&pcPwm,
|
startSimplePwm(&pcPwm,
|
||||||
"Line Pressure",
|
"Line Pressure",
|
||||||
&engine->executor,
|
&engine->scheduler,
|
||||||
&enginePins.tcuPcSolenoid,
|
&enginePins.tcuPcSolenoid,
|
||||||
engineConfiguration->tcu_pc_solenoid_freq,
|
engineConfiguration->tcu_pc_solenoid_freq,
|
||||||
0);
|
0);
|
||||||
enginePins.tcu32Solenoid.initPin("3-2 Shift Solenoid", engineConfiguration->tcu_32_solenoid_pin, engineConfiguration->tcu_32_solenoid_pin_mode);
|
enginePins.tcu32Solenoid.initPin("3-2 Shift Solenoid", engineConfiguration->tcu_32_solenoid_pin, engineConfiguration->tcu_32_solenoid_pin_mode);
|
||||||
startSimplePwm(&shift32Pwm,
|
startSimplePwm(&shift32Pwm,
|
||||||
"3-2 Solenoid",
|
"3-2 Solenoid",
|
||||||
&engine->executor,
|
&engine->scheduler,
|
||||||
&enginePins.tcu32Solenoid,
|
&enginePins.tcu32Solenoid,
|
||||||
engineConfiguration->tcu_32_solenoid_freq,
|
engineConfiguration->tcu_32_solenoid_freq,
|
||||||
0);
|
0);
|
||||||
|
|
|
@ -214,7 +214,7 @@ static void logVvtFront(bool isImportantFront, bool isRising, efitick_t nowNt, i
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
writePad("cam debug", engineConfiguration->camInputsDebug[index], 1);
|
writePad("cam debug", engineConfiguration->camInputsDebug[index], 1);
|
||||||
#endif /* EFI_PROD_CODE */
|
#endif /* EFI_PROD_CODE */
|
||||||
getExecutorInterface()->scheduleByTimestampNt("dbg_on", &debugToggleScheduling, nowNt + DEBUG_PIN_DELAY, &turnOffAllDebugFields);
|
getScheduler()->schedule("dbg_on", &debugToggleScheduling, nowNt + DEBUG_PIN_DELAY, &turnOffAllDebugFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we care about both edges OR displayLogicLevel is set, log every front exactly as it is
|
// If we care about both edges OR displayLogicLevel is set, log every front exactly as it is
|
||||||
|
@ -434,7 +434,7 @@ void handleShaftSignal(int signalIndex, bool isRising, efitick_t timestamp) {
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
writePad("trigger debug", engineConfiguration->triggerInputDebugPins[signalIndex], 1);
|
writePad("trigger debug", engineConfiguration->triggerInputDebugPins[signalIndex], 1);
|
||||||
#endif /* EFI_PROD_CODE */
|
#endif /* EFI_PROD_CODE */
|
||||||
getExecutorInterface()->scheduleByTimestampNt("dbg_off", &debugToggleScheduling, timestamp + DEBUG_PIN_DELAY, &turnOffAllDebugFields);
|
getScheduler()->schedule("dbg_off", &debugToggleScheduling, timestamp + DEBUG_PIN_DELAY, &turnOffAllDebugFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t triggerHandlerEntryTime = getTimeNowLowerNt();
|
uint32_t triggerHandlerEntryTime = getTimeNowLowerNt();
|
||||||
|
|
|
@ -147,7 +147,7 @@ static void startSimulatedTriggerSignal() {
|
||||||
TriggerWaveform *s = &engine->triggerCentral.triggerShape;
|
TriggerWaveform *s = &engine->triggerCentral.triggerShape;
|
||||||
setTriggerEmulatorRPM(engineConfiguration->triggerSimulatorRpm);
|
setTriggerEmulatorRPM(engineConfiguration->triggerSimulatorRpm);
|
||||||
triggerSignal.weComplexInit(
|
triggerSignal.weComplexInit(
|
||||||
&engine->executor,
|
&engine->scheduler,
|
||||||
&s->wave,
|
&s->wave,
|
||||||
updateTriggerWaveformIfNeeded, (pwm_gen_callback*)emulatorApplyPinState);
|
updateTriggerWaveformIfNeeded, (pwm_gen_callback*)emulatorApplyPinState);
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ static void watchDogBuddyCallback(void*) {
|
||||||
* watchdog happy by ensuring that we have scheduler activity even in case of very broken configuration
|
* watchdog happy by ensuring that we have scheduler activity even in case of very broken configuration
|
||||||
* without any PWM or input pins
|
* without any PWM or input pins
|
||||||
*/
|
*/
|
||||||
engine->executor.scheduleByTimestampNt("watch", &watchDogBuddy, getTimeNowNt() + MS2NT(1000), watchDogBuddyCallback);
|
engine->scheduler.schedule("watch", &watchDogBuddy, getTimeNowNt() + MS2NT(1000), watchDogBuddyCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
static volatile bool testSchedulingHappened = false;
|
static volatile bool testSchedulingHappened = false;
|
||||||
|
@ -156,7 +156,7 @@ static void validateHardwareTimer() {
|
||||||
testScheduling.reset();
|
testScheduling.reset();
|
||||||
|
|
||||||
// to save RAM let's use 'watchDogBuddy' here once before we enable watchdog
|
// to save RAM let's use 'watchDogBuddy' here once before we enable watchdog
|
||||||
engine->executor.scheduleByTimestampNt(
|
engine->scheduler.schedule(
|
||||||
"hw-validate",
|
"hw-validate",
|
||||||
&watchDogBuddy,
|
&watchDogBuddy,
|
||||||
getTimeNowNt() + MS2NT(TEST_CALLBACK_DELAY),
|
getTimeNowNt() + MS2NT(TEST_CALLBACK_DELAY),
|
||||||
|
|
|
@ -37,7 +37,7 @@ struct CallbackContext
|
||||||
|
|
||||||
static void doScheduleForLater(scheduling_s *scheduling, int delayUs, action_s action);
|
static void doScheduleForLater(scheduling_s *scheduling, int delayUs, action_s action);
|
||||||
|
|
||||||
void SleepExecutor::scheduleByTimestampNt(const char *msg, scheduling_s* scheduling, efitick_t timeNt, action_s action) {
|
void SleepExecutor::schedule(const char *msg, scheduling_s* scheduling, efitick_t timeNt, action_s action) {
|
||||||
doScheduleForLater(scheduling, NT2US(timeNt) - getTimeNowUs(), action);
|
doScheduleForLater(scheduling, NT2US(timeNt) - getTimeNowUs(), action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
#include "scheduler.h"
|
#include "scheduler.h"
|
||||||
|
|
||||||
class SleepExecutor : public ExecutorInterface {
|
class SleepExecutor : public Scheduler {
|
||||||
public:
|
public:
|
||||||
void scheduleByTimestampNt(const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s action) override;
|
void schedule(const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s action) override;
|
||||||
void cancel(scheduling_s* s) override;
|
void cancel(scheduling_s* s) override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,9 +35,9 @@ scheduling_s* TestExecutor::getForUnitTest(int index) {
|
||||||
return schedulingQueue.getElementAtIndexForUnitText(index);
|
return schedulingQueue.getElementAtIndexForUnitText(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestExecutor::scheduleByTimestampNt(const char *msg, scheduling_s* scheduling, efitick_t timeNt, action_s action) {
|
void TestExecutor::schedule(const char *msg, scheduling_s* scheduling, efitick_t timeNt, action_s action) {
|
||||||
if (m_mockExecutor) {
|
if (m_mockExecutor) {
|
||||||
m_mockExecutor->scheduleByTimestampNt(msg, scheduling, timeNt, action);
|
m_mockExecutor->schedule(msg, scheduling, timeNt, action);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,6 @@ void TestExecutor::cancel(scheduling_s* s) {
|
||||||
schedulingQueue.remove(s);
|
schedulingQueue.remove(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestExecutor::setMockExecutor(ExecutorInterface* exec) {
|
void TestExecutor::setMockExecutor(Scheduler* exec) {
|
||||||
m_mockExecutor = exec;
|
m_mockExecutor = exec;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,11 @@
|
||||||
#include "scheduler.h"
|
#include "scheduler.h"
|
||||||
#include "event_queue.h"
|
#include "event_queue.h"
|
||||||
|
|
||||||
class TestExecutor : public ExecutorInterface {
|
class TestExecutor : public Scheduler {
|
||||||
public:
|
public:
|
||||||
~TestExecutor();
|
~TestExecutor();
|
||||||
|
|
||||||
void scheduleByTimestampNt(const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s action) override;
|
void schedule(const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s action) override;
|
||||||
void cancel(scheduling_s* scheduling) override;
|
void cancel(scheduling_s* scheduling) override;
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
@ -23,8 +23,8 @@ public:
|
||||||
scheduling_s * getHead();
|
scheduling_s * getHead();
|
||||||
scheduling_s * getForUnitTest(int index);
|
scheduling_s * getForUnitTest(int index);
|
||||||
|
|
||||||
void setMockExecutor(ExecutorInterface* exec);
|
void setMockExecutor(Scheduler* exec);
|
||||||
private:
|
private:
|
||||||
EventQueue schedulingQueue;
|
EventQueue schedulingQueue;
|
||||||
ExecutorInterface* m_mockExecutor = nullptr;
|
Scheduler* m_mockExecutor = nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
@ -79,7 +79,7 @@ public:
|
||||||
MockExecutor();
|
MockExecutor();
|
||||||
virtual ~MockExecutor();
|
virtual ~MockExecutor();
|
||||||
|
|
||||||
MOCK_METHOD(void, scheduleByTimestampNt, (const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s action), (override));
|
MOCK_METHOD(void, schedule, (const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s action), (override));
|
||||||
MOCK_METHOD(void, cancel, (scheduling_s*), (override));
|
MOCK_METHOD(void, cancel, (scheduling_s*), (override));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -64,14 +64,14 @@ TEST(fuelControl, transitionIssue1592) {
|
||||||
// Injector 2 should be scheduled to open then close
|
// Injector 2 should be scheduled to open then close
|
||||||
void* inj2 = reinterpret_cast<void*>(&engine->injectionEvents.elements[1]);
|
void* inj2 = reinterpret_cast<void*>(&engine->injectionEvents.elements[1]);
|
||||||
|
|
||||||
ASSERT_EQ(engine->executor.size(), 2);
|
ASSERT_EQ(engine->scheduler.size(), 2);
|
||||||
|
|
||||||
// Check that the action is correct - we don't care about the timing necessarily
|
// Check that the action is correct - we don't care about the timing necessarily
|
||||||
auto sched_open = engine->executor.getForUnitTest(0);
|
auto sched_open = engine->scheduler.getForUnitTest(0);
|
||||||
ASSERT_EQ(sched_open->action.getArgument(), inj2);
|
ASSERT_EQ(sched_open->action.getArgument(), inj2);
|
||||||
ASSERT_EQ(sched_open->action.getCallback(), (void(*)(void*))turnInjectionPinHigh);
|
ASSERT_EQ(sched_open->action.getCallback(), (void(*)(void*))turnInjectionPinHigh);
|
||||||
|
|
||||||
auto sched_close = engine->executor.getForUnitTest(1);
|
auto sched_close = engine->scheduler.getForUnitTest(1);
|
||||||
// Next action should be closing the same injector
|
// Next action should be closing the same injector
|
||||||
ASSERT_EQ(sched_close->action.getArgument(), inj2);
|
ASSERT_EQ(sched_close->action.getArgument(), inj2);
|
||||||
ASSERT_EQ(sched_close->action.getCallback(), (void(*)(void*))turnInjectionPinLow);
|
ASSERT_EQ(sched_close->action.getCallback(), (void(*)(void*))turnInjectionPinLow);
|
||||||
|
|
|
@ -84,7 +84,7 @@ TEST(ignition, trailingSpark) {
|
||||||
EXPECT_EQ(enginePins.trailingCoils[0].getLogicValue(), false);
|
EXPECT_EQ(enginePins.trailingCoils[0].getLogicValue(), false);
|
||||||
|
|
||||||
// Should be a TDC callback + spark firing
|
// Should be a TDC callback + spark firing
|
||||||
EXPECT_EQ(engine->executor.size(), 2);
|
EXPECT_EQ(engine->scheduler.size(), 2);
|
||||||
|
|
||||||
// execute all actions
|
// execute all actions
|
||||||
eth.executeActions();
|
eth.executeActions();
|
||||||
|
|
|
@ -41,7 +41,7 @@ TEST(OddFireRunningMode, hd) {
|
||||||
|
|
||||||
angle_t expectedAngle3 = -360 + cylinderOne - timing;
|
angle_t expectedAngle3 = -360 + cylinderOne - timing;
|
||||||
|
|
||||||
ASSERT_EQ( 12, engine->executor.size());
|
ASSERT_EQ( 12, engine->scheduler.size());
|
||||||
eth.assertEvent5("spark down#1", 1, (void*)fireSparkAndPrepareNextSchedule, eth.angleToTimeUs(expectedAngle3));
|
eth.assertEvent5("spark down#1", 1, (void*)fireSparkAndPrepareNextSchedule, eth.angleToTimeUs(expectedAngle3));
|
||||||
|
|
||||||
angle_t expectedAngle7 = -180 + cylinderOne - timing;
|
angle_t expectedAngle7 = -180 + cylinderOne - timing;
|
||||||
|
|
|
@ -18,19 +18,19 @@ TEST(issues, issueOneCylinderSpecialCase968) {
|
||||||
|
|
||||||
eth.setTriggerType(trigger_type_e::TT_ONE);
|
eth.setTriggerType(trigger_type_e::TT_ONE);
|
||||||
|
|
||||||
ASSERT_EQ( 0, engine->executor.size()) << "start";
|
ASSERT_EQ( 0, engine->scheduler.size()) << "start";
|
||||||
|
|
||||||
eth.fireTriggerEvents2(/* count */ 2, 50 /* ms */);
|
eth.fireTriggerEvents2(/* count */ 2, 50 /* ms */);
|
||||||
ASSERT_EQ( 0, Sensor::getOrZero(SensorType::Rpm)) << "RPM";
|
ASSERT_EQ( 0, Sensor::getOrZero(SensorType::Rpm)) << "RPM";
|
||||||
ASSERT_EQ( 0, engine->executor.size()) << "first revolution(s)";
|
ASSERT_EQ( 0, engine->scheduler.size()) << "first revolution(s)";
|
||||||
|
|
||||||
eth.fireTriggerEvents2(/* count */ 1, 50 /* ms */);
|
eth.fireTriggerEvents2(/* count */ 1, 50 /* ms */);
|
||||||
|
|
||||||
ASSERT_EQ( 2, engine->executor.size()) << "first revolution(s)";
|
ASSERT_EQ( 2, engine->scheduler.size()) << "first revolution(s)";
|
||||||
eth.assertEvent5("spark up#0", 0, (void*)turnSparkPinHigh, -45167);
|
eth.assertEvent5("spark up#0", 0, (void*)turnSparkPinHigh, -45167);
|
||||||
eth.assertEvent5("spark down#0", 1, (void*)fireSparkAndPrepareNextSchedule, -39167);
|
eth.assertEvent5("spark down#0", 1, (void*)fireSparkAndPrepareNextSchedule, -39167);
|
||||||
|
|
||||||
|
|
||||||
eth.fireTriggerEvents2(/* count */ 1, 50 /* ms */);
|
eth.fireTriggerEvents2(/* count */ 1, 50 /* ms */);
|
||||||
ASSERT_EQ( 4, engine->executor.size()) << "first revolution(s)";
|
ASSERT_EQ( 4, engine->scheduler.size()) << "first revolution(s)";
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ TEST(engine, testPlainCrankingWithoutAdvancedFeatures) {
|
||||||
eth.fireRise(/* delayMs */ 200);
|
eth.fireRise(/* delayMs */ 200);
|
||||||
ASSERT_EQ( 300, Sensor::getOrZero(SensorType::Rpm)) << "RPM#2";
|
ASSERT_EQ( 300, Sensor::getOrZero(SensorType::Rpm)) << "RPM#2";
|
||||||
// two simultaneous injections
|
// two simultaneous injections
|
||||||
ASSERT_EQ( 4, engine->executor.size()) << "plain#2";
|
ASSERT_EQ( 4, engine->scheduler.size()) << "plain#2";
|
||||||
|
|
||||||
eth.assertEvent5("sim start", 0, (void*)startSimultaneousInjection, 100000 - 1625);
|
eth.assertEvent5("sim start", 0, (void*)startSimultaneousInjection, 100000 - 1625);
|
||||||
// -1 because ugh floating point math
|
// -1 because ugh floating point math
|
||||||
|
@ -41,7 +41,7 @@ TEST(priming, startScheduling) {
|
||||||
// Turn on the ignition switch!
|
// Turn on the ignition switch!
|
||||||
engine->module<PrimeController>()->onIgnitionStateChanged(true);
|
engine->module<PrimeController>()->onIgnitionStateChanged(true);
|
||||||
|
|
||||||
ASSERT_EQ(1, engine->executor.size()) << "prime fuel";
|
ASSERT_EQ(1, engine->scheduler.size()) << "prime fuel";
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(priming, duration) {
|
TEST(priming, duration) {
|
||||||
|
|
|
@ -236,7 +236,7 @@ TEST(HPFP, Schedule) {
|
||||||
auto & hpfp = *engine->module<HpfpController>();
|
auto & hpfp = *engine->module<HpfpController>();
|
||||||
|
|
||||||
StrictMock<MockExecutor> mockExec;
|
StrictMock<MockExecutor> mockExec;
|
||||||
engine->executor.setMockExecutor(&mockExec);
|
engine->scheduler.setMockExecutor(&mockExec);
|
||||||
engineConfiguration->hpfpActivationAngle = 30;
|
engineConfiguration->hpfpActivationAngle = 30;
|
||||||
|
|
||||||
constexpr angle_t angle0 = 90;
|
constexpr angle_t angle0 = 90;
|
||||||
|
@ -254,13 +254,13 @@ TEST(HPFP, Schedule) {
|
||||||
|
|
||||||
// First call to setRpmValue will cause a dummy call to fast periodic timer.
|
// First call to setRpmValue will cause a dummy call to fast periodic timer.
|
||||||
// Injection Mass will be 0 so expect a no-op.
|
// Injection Mass will be 0 so expect a no-op.
|
||||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), &hpfp.m_event.scheduling, nt0, action_s(HpfpController::pinTurnOff, &hpfp)));
|
EXPECT_CALL(mockExec, schedule(testing::NotNull(), &hpfp.m_event.scheduling, nt0, action_s(HpfpController::pinTurnOff, &hpfp)));
|
||||||
|
|
||||||
// Second call will be the start of a real pump event.
|
// Second call will be the start of a real pump event.
|
||||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), &hpfp.m_event.scheduling, nt1, action_s(HpfpController::pinTurnOn, &hpfp)));
|
EXPECT_CALL(mockExec, schedule(testing::NotNull(), &hpfp.m_event.scheduling, nt1, action_s(HpfpController::pinTurnOn, &hpfp)));
|
||||||
|
|
||||||
// Third call will be off event
|
// Third call will be off event
|
||||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), &hpfp.m_event.scheduling, nt2, action_s(HpfpController::pinTurnOff, &hpfp)));
|
EXPECT_CALL(mockExec, schedule(testing::NotNull(), &hpfp.m_event.scheduling, nt2, action_s(HpfpController::pinTurnOff, &hpfp)));
|
||||||
}
|
}
|
||||||
EXPECT_CALL(mockExec, cancel(_)).Times(2);
|
EXPECT_CALL(mockExec, cancel(_)).Times(2);
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ TEST(cranking, testFasterEngineSpinningUp) {
|
||||||
// check RPM
|
// check RPM
|
||||||
ASSERT_EQ( 0, round(Sensor::getOrZero(SensorType::Rpm))) << "RPM=0";
|
ASSERT_EQ( 0, round(Sensor::getOrZero(SensorType::Rpm))) << "RPM=0";
|
||||||
// the queue should be empty, no trigger events yet
|
// the queue should be empty, no trigger events yet
|
||||||
ASSERT_EQ(0, engine->executor.size()) << "plain#1";
|
ASSERT_EQ(0, engine->scheduler.size()) << "plain#1";
|
||||||
|
|
||||||
// check all events starting from now
|
// check all events starting from now
|
||||||
// advance 1 revolution
|
// advance 1 revolution
|
||||||
|
@ -47,7 +47,7 @@ TEST(cranking, testFasterEngineSpinningUp) {
|
||||||
// due to isFasterEngineSpinUp=true, we should have already detected RPM!
|
// due to isFasterEngineSpinUp=true, we should have already detected RPM!
|
||||||
ASSERT_EQ( 300, round(Sensor::getOrZero(SensorType::Rpm))) << "spinning-RPM#1";
|
ASSERT_EQ( 300, round(Sensor::getOrZero(SensorType::Rpm))) << "spinning-RPM#1";
|
||||||
// two simultaneous injections
|
// two simultaneous injections
|
||||||
ASSERT_EQ(4, engine->executor.size()) << "plain#2";
|
ASSERT_EQ(4, engine->scheduler.size()) << "plain#2";
|
||||||
// test if they are simultaneous
|
// test if they are simultaneous
|
||||||
ASSERT_EQ(IM_SIMULTANEOUS, getCurrentInjectionMode());
|
ASSERT_EQ(IM_SIMULTANEOUS, getCurrentInjectionMode());
|
||||||
// test if ignition mode is temporary changed to wasted spark, if set to individual coils
|
// test if ignition mode is temporary changed to wasted spark, if set to individual coils
|
||||||
|
@ -73,7 +73,7 @@ TEST(cranking, testFasterEngineSpinningUp) {
|
||||||
// Should still be in wasted spark since we don't have cam sync yet
|
// Should still be in wasted spark since we don't have cam sync yet
|
||||||
ASSERT_EQ(IM_WASTED_SPARK, getCurrentIgnitionMode());
|
ASSERT_EQ(IM_WASTED_SPARK, getCurrentIgnitionMode());
|
||||||
// two simultaneous injections
|
// two simultaneous injections
|
||||||
ASSERT_EQ( 4, engine->executor.size()) << "plain#2";
|
ASSERT_EQ( 4, engine->scheduler.size()) << "plain#2";
|
||||||
// check real events
|
// check real events
|
||||||
eth.assertEvent5("inj start#2", 0, (void*)startSimultaneousInjection, 148375);
|
eth.assertEvent5("inj start#2", 0, (void*)startSimultaneousInjection, 148375);
|
||||||
eth.assertEvent5("inj end#2", 1, (void*)endSimultaneousInjection, 149999);
|
eth.assertEvent5("inj end#2", 1, (void*)endSimultaneousInjection, 149999);
|
||||||
|
@ -95,7 +95,7 @@ TEST(cranking, testFasterEngineSpinningUp) {
|
||||||
// check if the injection mode is back to sequential now
|
// check if the injection mode is back to sequential now
|
||||||
ASSERT_EQ(IM_SEQUENTIAL, getCurrentInjectionMode());
|
ASSERT_EQ(IM_SEQUENTIAL, getCurrentInjectionMode());
|
||||||
// 4 sequential injections for the full cycle
|
// 4 sequential injections for the full cycle
|
||||||
ASSERT_EQ( 8, engine->executor.size()) << "plain#3";
|
ASSERT_EQ( 8, engine->scheduler.size()) << "plain#3";
|
||||||
|
|
||||||
// check real events for sequential injection
|
// check real events for sequential injection
|
||||||
// Note: See addFuelEvents() fix inside setRpmValue()!
|
// Note: See addFuelEvents() fix inside setRpmValue()!
|
||||||
|
|
|
@ -19,7 +19,7 @@ TEST(injectionScheduling, InjectionIsScheduled) {
|
||||||
StrictMock<MockExecutor> mockExec;
|
StrictMock<MockExecutor> mockExec;
|
||||||
|
|
||||||
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
||||||
engine->executor.setMockExecutor(&mockExec);
|
engine->scheduler.setMockExecutor(&mockExec);
|
||||||
|
|
||||||
efitick_t nowNt = 1000000;
|
efitick_t nowNt = 1000000;
|
||||||
|
|
||||||
|
@ -42,10 +42,10 @@ TEST(injectionScheduling, InjectionIsScheduled) {
|
||||||
// rising edge 5 degrees from now
|
// rising edge 5 degrees from now
|
||||||
float nt5deg = USF2NT(engine->rpmCalculator.oneDegreeUs * 5);
|
float nt5deg = USF2NT(engine->rpmCalculator.oneDegreeUs * 5);
|
||||||
efitick_t startTime = nowNt + nt5deg;
|
efitick_t startTime = nowNt + nt5deg;
|
||||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, startTime, Not(Truly(ActionArgumentHasLowBitSet))));
|
EXPECT_CALL(mockExec, schedule(testing::NotNull(), _, startTime, Not(Truly(ActionArgumentHasLowBitSet))));
|
||||||
// falling edge 20ms later
|
// falling edge 20ms later
|
||||||
efitick_t endTime = startTime + MS2NT(20);
|
efitick_t endTime = startTime + MS2NT(20);
|
||||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, endTime, Property(&action_s::getArgument, Eq(&event))));
|
EXPECT_CALL(mockExec, schedule(testing::NotNull(), _, endTime, Property(&action_s::getArgument, Eq(&event))));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event scheduled at 125 degrees
|
// Event scheduled at 125 degrees
|
||||||
|
@ -60,7 +60,7 @@ TEST(injectionScheduling, InjectionIsScheduledDualStage) {
|
||||||
StrictMock<MockInjectorModel2> im;
|
StrictMock<MockInjectorModel2> im;
|
||||||
|
|
||||||
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
||||||
engine->executor.setMockExecutor(&mockExec);
|
engine->scheduler.setMockExecutor(&mockExec);
|
||||||
engine->module<InjectorModelPrimary>().set(&im);
|
engine->module<InjectorModelPrimary>().set(&im);
|
||||||
engine->module<InjectorModelSecondary>().set(&im);
|
engine->module<InjectorModelSecondary>().set(&im);
|
||||||
|
|
||||||
|
@ -92,13 +92,13 @@ TEST(injectionScheduling, InjectionIsScheduledDualStage) {
|
||||||
// rising edge 5 degrees from now
|
// rising edge 5 degrees from now
|
||||||
float nt5deg = USF2NT(engine->rpmCalculator.oneDegreeUs * 5);
|
float nt5deg = USF2NT(engine->rpmCalculator.oneDegreeUs * 5);
|
||||||
efitick_t startTime = nowNt + nt5deg;
|
efitick_t startTime = nowNt + nt5deg;
|
||||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, startTime, Truly(ActionArgumentHasLowBitSet)));
|
EXPECT_CALL(mockExec, schedule(testing::NotNull(), _, startTime, Truly(ActionArgumentHasLowBitSet)));
|
||||||
// falling edge (primary) 20ms later
|
// falling edge (primary) 20ms later
|
||||||
efitick_t endTime1 = startTime + MS2NT(20);
|
efitick_t endTime1 = startTime + MS2NT(20);
|
||||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, endTime1, Truly(ActionArgumentHasLowBitSet)));
|
EXPECT_CALL(mockExec, schedule(testing::NotNull(), _, endTime1, Truly(ActionArgumentHasLowBitSet)));
|
||||||
// falling edge (secondary) 10ms later
|
// falling edge (secondary) 10ms later
|
||||||
efitick_t endTime2 = startTime + MS2NT(10);
|
efitick_t endTime2 = startTime + MS2NT(10);
|
||||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, endTime2, Property(&action_s::getArgument, Eq(&event))));
|
EXPECT_CALL(mockExec, schedule(testing::NotNull(), _, endTime2, Property(&action_s::getArgument, Eq(&event))));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event scheduled at 125 degrees
|
// Event scheduled at 125 degrees
|
||||||
|
@ -112,7 +112,7 @@ TEST(injectionScheduling, InjectionIsScheduledBeforeWraparound) {
|
||||||
StrictMock<MockExecutor> mockExec;
|
StrictMock<MockExecutor> mockExec;
|
||||||
|
|
||||||
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
||||||
engine->executor.setMockExecutor(&mockExec);
|
engine->scheduler.setMockExecutor(&mockExec);
|
||||||
|
|
||||||
efitick_t nowNt = 1000000;
|
efitick_t nowNt = 1000000;
|
||||||
|
|
||||||
|
@ -135,10 +135,10 @@ TEST(injectionScheduling, InjectionIsScheduledBeforeWraparound) {
|
||||||
// rising edge 5 degrees from now
|
// rising edge 5 degrees from now
|
||||||
float nt5deg = USF2NT(engine->rpmCalculator.oneDegreeUs * 5);
|
float nt5deg = USF2NT(engine->rpmCalculator.oneDegreeUs * 5);
|
||||||
efitick_t startTime = nowNt + nt5deg;
|
efitick_t startTime = nowNt + nt5deg;
|
||||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, startTime, Not(Truly(ActionArgumentHasLowBitSet))));
|
EXPECT_CALL(mockExec, schedule(testing::NotNull(), _, startTime, Not(Truly(ActionArgumentHasLowBitSet))));
|
||||||
// falling edge 20ms later
|
// falling edge 20ms later
|
||||||
efitick_t endTime = startTime + MS2NT(20);
|
efitick_t endTime = startTime + MS2NT(20);
|
||||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, endTime, Property(&action_s::getArgument, Eq(&event))));
|
EXPECT_CALL(mockExec, schedule(testing::NotNull(), _, endTime, Property(&action_s::getArgument, Eq(&event))));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event scheduled at 715 degrees
|
// Event scheduled at 715 degrees
|
||||||
|
@ -152,7 +152,7 @@ TEST(injectionScheduling, InjectionIsScheduledAfterWraparound) {
|
||||||
StrictMock<MockExecutor> mockExec;
|
StrictMock<MockExecutor> mockExec;
|
||||||
|
|
||||||
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
||||||
engine->executor.setMockExecutor(&mockExec);
|
engine->scheduler.setMockExecutor(&mockExec);
|
||||||
|
|
||||||
efitick_t nowNt = 1000000;
|
efitick_t nowNt = 1000000;
|
||||||
|
|
||||||
|
@ -175,10 +175,10 @@ TEST(injectionScheduling, InjectionIsScheduledAfterWraparound) {
|
||||||
// rising edge 15 degrees from now
|
// rising edge 15 degrees from now
|
||||||
float nt5deg = USF2NT(engine->rpmCalculator.oneDegreeUs * 15);
|
float nt5deg = USF2NT(engine->rpmCalculator.oneDegreeUs * 15);
|
||||||
efitick_t startTime = nowNt + nt5deg;
|
efitick_t startTime = nowNt + nt5deg;
|
||||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, startTime, Not(Truly(ActionArgumentHasLowBitSet))));
|
EXPECT_CALL(mockExec, schedule(testing::NotNull(), _, startTime, Not(Truly(ActionArgumentHasLowBitSet))));
|
||||||
// falling edge 20ms later
|
// falling edge 20ms later
|
||||||
efitick_t endTime = startTime + MS2NT(20);
|
efitick_t endTime = startTime + MS2NT(20);
|
||||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, endTime, Property(&action_s::getArgument, Eq(&event))));
|
EXPECT_CALL(mockExec, schedule(testing::NotNull(), _, endTime, Property(&action_s::getArgument, Eq(&event))));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event scheduled at 5 degrees
|
// Event scheduled at 5 degrees
|
||||||
|
@ -193,7 +193,7 @@ TEST(injectionScheduling, InjectionNotScheduled) {
|
||||||
StrictMock<MockExecutor> mockExec;
|
StrictMock<MockExecutor> mockExec;
|
||||||
|
|
||||||
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
||||||
engine->executor.setMockExecutor(&mockExec);
|
engine->scheduler.setMockExecutor(&mockExec);
|
||||||
|
|
||||||
efitick_t nowNt = 1000000;
|
efitick_t nowNt = 1000000;
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ TEST(injectionScheduling, SplitInjectionScheduled) {
|
||||||
StrictMock<MockExecutor> mockExec;
|
StrictMock<MockExecutor> mockExec;
|
||||||
|
|
||||||
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
||||||
engine->executor.setMockExecutor(&mockExec);
|
engine->scheduler.setMockExecutor(&mockExec);
|
||||||
|
|
||||||
InjectionEvent event;
|
InjectionEvent event;
|
||||||
uintptr_t arg = reinterpret_cast<uintptr_t>(&event);
|
uintptr_t arg = reinterpret_cast<uintptr_t>(&event);
|
||||||
|
@ -243,9 +243,9 @@ TEST(injectionScheduling, SplitInjectionScheduled) {
|
||||||
// - duration 10ms (ends 12ms from now)
|
// - duration 10ms (ends 12ms from now)
|
||||||
efitick_t nowNt = getTimeNowNt();
|
efitick_t nowNt = getTimeNowNt();
|
||||||
efitick_t startTime = nowNt + MS2NT(2);
|
efitick_t startTime = nowNt + MS2NT(2);
|
||||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, startTime, Property(&action_s::getArgument, Eq(&event))));
|
EXPECT_CALL(mockExec, schedule(testing::NotNull(), _, startTime, Property(&action_s::getArgument, Eq(&event))));
|
||||||
efitick_t endTime = startTime + MS2NT(10);
|
efitick_t endTime = startTime + MS2NT(10);
|
||||||
EXPECT_CALL(mockExec, scheduleByTimestampNt(testing::NotNull(), _, endTime, Property(&action_s::getArgument, Eq(&event))));
|
EXPECT_CALL(mockExec, schedule(testing::NotNull(), _, endTime, Property(&action_s::getArgument, Eq(&event))));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Split injection duration of 10ms
|
// Split injection duration of 10ms
|
||||||
|
|
|
@ -28,8 +28,8 @@ TEST(trigger, map_cam_by_magic_point) {
|
||||||
ASSERT_EQ(0, engine->triggerCentral.triggerState.camResyncCounter);
|
ASSERT_EQ(0, engine->triggerCentral.triggerState.camResyncCounter);
|
||||||
|
|
||||||
// Nothing should have been scheduled yet
|
// Nothing should have been scheduled yet
|
||||||
ASSERT_EQ(1, engine->executor.size());
|
ASSERT_EQ(1, engine->scheduler.size());
|
||||||
scheduling_s* next = engine->executor.getForUnitTest(0);
|
scheduling_s* next = engine->scheduler.getForUnitTest(0);
|
||||||
eth.assertEvent5("spark down#0", 0, (void*)fireSparkAndPrepareNextSchedule, 188333);
|
eth.assertEvent5("spark down#0", 0, (void*)fireSparkAndPrepareNextSchedule, 188333);
|
||||||
|
|
||||||
engine->outputChannels.instantMAPValue = 120;
|
engine->outputChannels.instantMAPValue = 120;
|
||||||
|
@ -43,7 +43,7 @@ TEST(trigger, map_cam_by_magic_point) {
|
||||||
ASSERT_EQ(ClearReason::None, getLimpManager()->allowInjection().reason);
|
ASSERT_EQ(ClearReason::None, getLimpManager()->allowInjection().reason);
|
||||||
|
|
||||||
// We have "VVT" sync, things should be scheduled!
|
// We have "VVT" sync, things should be scheduled!
|
||||||
ASSERT_EQ(2, engine->executor.size());
|
ASSERT_EQ(2, engine->scheduler.size());
|
||||||
eth.assertEvent5("spark down#0", 0, (void*)turnSparkPinHigh, 185333);
|
eth.assertEvent5("spark down#0", 0, (void*)turnSparkPinHigh, 185333);
|
||||||
eth.assertEvent5("spark down#1", 1, (void*)fireSparkAndPrepareNextSchedule, 188333);
|
eth.assertEvent5("spark down#1", 1, (void*)fireSparkAndPrepareNextSchedule, 188333);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ static void scheduleTriggerEvents(TriggerWaveform *shape,
|
||||||
|
|
||||||
efitick_t timeNt = efitick_t{US2NT(timeScale * 1000 * angle)};
|
efitick_t timeNt = efitick_t{US2NT(timeScale * 1000 * angle)};
|
||||||
|
|
||||||
engine->executor.scheduleByTimestampNt("test", ¶m->sched, timeNt, { func, param.get() });
|
engine->scheduler.schedule("test", ¶m->sched, timeNt, { func, param.get() });
|
||||||
totalIndex++;
|
totalIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ TEST(nissan, vq_vvt) {
|
||||||
scheduling_s *head;
|
scheduling_s *head;
|
||||||
|
|
||||||
int queueIndex = 0;
|
int queueIndex = 0;
|
||||||
while ((head = engine->executor.getHead()) != nullptr) {
|
while ((head = engine->scheduler.getHead()) != nullptr) {
|
||||||
eth.setTimeAndInvokeEventsUs(head->momentX);
|
eth.setTimeAndInvokeEventsUs(head->momentX);
|
||||||
|
|
||||||
ASSERT_TRUE(tc->vvtState[0][0].getShaftSynchronized());
|
ASSERT_TRUE(tc->vvtState[0][0].getShaftSynchronized());
|
||||||
|
|
|
@ -245,47 +245,47 @@ TEST(misc, testRpmCalculator) {
|
||||||
EXPECT_NEAR(ilist->elements[0].sparkAngle, 13.0f, 1e-3);
|
EXPECT_NEAR(ilist->elements[0].sparkAngle, 13.0f, 1e-3);
|
||||||
|
|
||||||
ASSERT_EQ( 0, eth.engine.triggerCentral.triggerState.getCurrentIndex()) << "index #2";
|
ASSERT_EQ( 0, eth.engine.triggerCentral.triggerState.getCurrentIndex()) << "index #2";
|
||||||
ASSERT_EQ( 4, engine->executor.size()) << "queue size/2";
|
ASSERT_EQ( 4, engine->scheduler.size()) << "queue size/2";
|
||||||
{
|
{
|
||||||
scheduling_s *ev0 = engine->executor.getForUnitTest(0);
|
scheduling_s *ev0 = engine->scheduler.getForUnitTest(0);
|
||||||
|
|
||||||
assertREqualsM("Call@0", (void*)ev0->action.getCallback(), (void*)turnSparkPinHigh);
|
assertREqualsM("Call@0", (void*)ev0->action.getCallback(), (void*)turnSparkPinHigh);
|
||||||
assertEqualsM("ev 0", start + 944, ev0->momentX);
|
assertEqualsM("ev 0", start + 944, ev0->momentX);
|
||||||
assertEqualsLM("coil 0", (uintptr_t)&enginePins.coils[0], (uintptr_t)((IgnitionEvent*)ev0->action.getArgument())->outputs[0]);
|
assertEqualsLM("coil 0", (uintptr_t)&enginePins.coils[0], (uintptr_t)((IgnitionEvent*)ev0->action.getArgument())->outputs[0]);
|
||||||
|
|
||||||
scheduling_s *ev1 = engine->executor.getForUnitTest(1);
|
scheduling_s *ev1 = engine->scheduler.getForUnitTest(1);
|
||||||
assertREqualsM("Call@1", (void*)ev1->action.getCallback(), (void*)fireSparkAndPrepareNextSchedule);
|
assertREqualsM("Call@1", (void*)ev1->action.getCallback(), (void*)fireSparkAndPrepareNextSchedule);
|
||||||
assertEqualsM("ev 1", start + 1444, ev1->momentX);
|
assertEqualsM("ev 1", start + 1444, ev1->momentX);
|
||||||
assertEqualsLM("coil 1", (uintptr_t)&enginePins.coils[0], (uintptr_t)((IgnitionEvent*)ev1->action.getArgument())->outputs[0]);
|
assertEqualsLM("coil 1", (uintptr_t)&enginePins.coils[0], (uintptr_t)((IgnitionEvent*)ev1->action.getArgument())->outputs[0]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
engine->executor.clear();
|
engine->scheduler.clear();
|
||||||
|
|
||||||
eth.fireFall(5);
|
eth.fireFall(5);
|
||||||
eth.fireRise(5);
|
eth.fireRise(5);
|
||||||
eth.fireFall(5);
|
eth.fireFall(5);
|
||||||
ASSERT_EQ( 2, eth.engine.triggerCentral.triggerState.getCurrentIndex()) << "index #3";
|
ASSERT_EQ( 2, eth.engine.triggerCentral.triggerState.getCurrentIndex()) << "index #3";
|
||||||
ASSERT_EQ( 4, engine->executor.size()) << "queue size 3";
|
ASSERT_EQ( 4, engine->scheduler.size()) << "queue size 3";
|
||||||
assertEqualsM("ev 3", start + 13333 - 1515 + 2459, engine->executor.getForUnitTest(0)->momentX);
|
assertEqualsM("ev 3", start + 13333 - 1515 + 2459, engine->scheduler.getForUnitTest(0)->momentX);
|
||||||
assertEqualsM2("ev 5", start + 14277 + 500, engine->executor.getForUnitTest(1)->momentX, 2);
|
assertEqualsM2("ev 5", start + 14277 + 500, engine->scheduler.getForUnitTest(1)->momentX, 2);
|
||||||
assertEqualsM("3/3", start + 14777 + 677, engine->executor.getForUnitTest(2)->momentX);
|
assertEqualsM("3/3", start + 14777 + 677, engine->scheduler.getForUnitTest(2)->momentX);
|
||||||
engine->executor.clear();
|
engine->scheduler.clear();
|
||||||
|
|
||||||
ASSERT_EQ(4, engine->triggerCentral.triggerShape.findAngleIndex(&engine->triggerCentral.triggerFormDetails, 240));
|
ASSERT_EQ(4, engine->triggerCentral.triggerShape.findAngleIndex(&engine->triggerCentral.triggerFormDetails, 240));
|
||||||
ASSERT_EQ(4, engine->triggerCentral.triggerShape.findAngleIndex(&engine->triggerCentral.triggerFormDetails, 241));
|
ASSERT_EQ(4, engine->triggerCentral.triggerShape.findAngleIndex(&engine->triggerCentral.triggerFormDetails, 241));
|
||||||
|
|
||||||
|
|
||||||
eth.fireFall(5);
|
eth.fireFall(5);
|
||||||
ASSERT_EQ( 0, engine->executor.size()) << "queue size 4.1";
|
ASSERT_EQ( 0, engine->scheduler.size()) << "queue size 4.1";
|
||||||
|
|
||||||
|
|
||||||
eth.fireRise(5);
|
eth.fireRise(5);
|
||||||
ASSERT_EQ( 4, engine->executor.size()) << "queue size 4.2";
|
ASSERT_EQ( 4, engine->scheduler.size()) << "queue size 4.2";
|
||||||
|
|
||||||
|
|
||||||
eth.fireRise(5);
|
eth.fireRise(5);
|
||||||
ASSERT_EQ( 4, engine->executor.size()) << "queue size 4.3";
|
ASSERT_EQ( 4, engine->scheduler.size()) << "queue size 4.3";
|
||||||
|
|
||||||
assertEqualsM("dwell", 4.5, eth.engine.ignitionState.dwellAngle);
|
assertEqualsM("dwell", 4.5, eth.engine.ignitionState.dwellAngle);
|
||||||
assertEqualsM("fuel #3", 4.5450, eth.engine.engineState.injectionDuration);
|
assertEqualsM("fuel #3", 4.5450, eth.engine.engineState.injectionDuration);
|
||||||
|
@ -293,32 +293,32 @@ TEST(misc, testRpmCalculator) {
|
||||||
|
|
||||||
|
|
||||||
ASSERT_EQ( 6, eth.engine.triggerCentral.triggerState.getCurrentIndex()) << "index #4";
|
ASSERT_EQ( 6, eth.engine.triggerCentral.triggerState.getCurrentIndex()) << "index #4";
|
||||||
ASSERT_EQ( 4, engine->executor.size()) << "queue size 4";
|
ASSERT_EQ( 4, engine->scheduler.size()) << "queue size 4";
|
||||||
engine->executor.clear();
|
engine->scheduler.clear();
|
||||||
|
|
||||||
eth.fireFall(5);
|
eth.fireFall(5);
|
||||||
ASSERT_EQ( 0, engine->executor.size()) << "queue size 5";
|
ASSERT_EQ( 0, engine->scheduler.size()) << "queue size 5";
|
||||||
// todo: assert queue elements
|
// todo: assert queue elements
|
||||||
engine->executor.clear();
|
engine->scheduler.clear();
|
||||||
|
|
||||||
|
|
||||||
eth.fireRise(5);
|
eth.fireRise(5);
|
||||||
ASSERT_EQ( 4, engine->executor.size()) << "queue size 6";
|
ASSERT_EQ( 4, engine->scheduler.size()) << "queue size 6";
|
||||||
assertEqualsM("6/0", start + 40944, engine->executor.getForUnitTest(0)->momentX);
|
assertEqualsM("6/0", start + 40944, engine->scheduler.getForUnitTest(0)->momentX);
|
||||||
assertEqualsM("6/1", start + 41444, engine->executor.getForUnitTest(1)->momentX);
|
assertEqualsM("6/1", start + 41444, engine->scheduler.getForUnitTest(1)->momentX);
|
||||||
engine->executor.clear();
|
engine->scheduler.clear();
|
||||||
|
|
||||||
eth.fireFall(5);
|
eth.fireFall(5);
|
||||||
ASSERT_EQ( 0, engine->executor.size()) << "queue size 7";
|
ASSERT_EQ( 0, engine->scheduler.size()) << "queue size 7";
|
||||||
engine->executor.clear();
|
engine->scheduler.clear();
|
||||||
|
|
||||||
eth.fireRise(5 /*ms*/);
|
eth.fireRise(5 /*ms*/);
|
||||||
eth.fireFall(5);
|
eth.fireFall(5);
|
||||||
|
|
||||||
ASSERT_EQ( 4, engine->executor.size()) << "queue size 8";
|
ASSERT_EQ( 4, engine->scheduler.size()) << "queue size 8";
|
||||||
assertEqualsM("8/0", start + 53333 - 1515 + 2459, engine->executor.getForUnitTest(0)->momentX);
|
assertEqualsM("8/0", start + 53333 - 1515 + 2459, engine->scheduler.getForUnitTest(0)->momentX);
|
||||||
assertEqualsM2("8/1", start + 54277 + 2459 - 1959, engine->executor.getForUnitTest(1)->momentX, 0);
|
assertEqualsM2("8/1", start + 54277 + 2459 - 1959, engine->scheduler.getForUnitTest(1)->momentX, 0);
|
||||||
engine->executor.clear();
|
engine->scheduler.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(trigger, testAnotherTriggerDecoder) {
|
TEST(trigger, testAnotherTriggerDecoder) {
|
||||||
|
@ -440,7 +440,7 @@ static void setTestBug299(EngineTestHelper *eth) {
|
||||||
// time...|0.......|10......|20......|30......|40
|
// time...|0.......|10......|20......|30......|40
|
||||||
// inj #0 |.......#|........|.......#|........|
|
// inj #0 |.......#|........|.......#|........|
|
||||||
// inj #1 |........|.......#|........|.......#|
|
// inj #1 |........|.......#|........|.......#|
|
||||||
ASSERT_EQ( 4, engine->executor.size()) << "qs#00";
|
ASSERT_EQ( 4, engine->scheduler.size()) << "qs#00";
|
||||||
ASSERT_EQ( 3, getRevolutionCounter()) << "rev cnt#3";
|
ASSERT_EQ( 3, getRevolutionCounter()) << "rev cnt#3";
|
||||||
eth->assertInjectorUpEvent("setTestBug299: 1@0", 0, MS2US(8.5), 2);
|
eth->assertInjectorUpEvent("setTestBug299: 1@0", 0, MS2US(8.5), 2);
|
||||||
eth->assertInjectorDownEvent("@1", 1, MS2US(10), 2);
|
eth->assertInjectorDownEvent("@1", 1, MS2US(10), 2);
|
||||||
|
@ -463,7 +463,7 @@ static void setTestBug299(EngineTestHelper *eth) {
|
||||||
// time...|-20.....|-10.....|0.......|10......|20
|
// time...|-20.....|-10.....|0.......|10......|20
|
||||||
// inj #0 |.......#|........|.......#|........|
|
// inj #0 |.......#|........|.......#|........|
|
||||||
// inj #1 |........|.......#|........|.......#|
|
// inj #1 |........|.......#|........|.......#|
|
||||||
ASSERT_EQ( 8, engine->executor.size()) << "qs#0";
|
ASSERT_EQ( 8, engine->scheduler.size()) << "qs#0";
|
||||||
ASSERT_EQ( 3, getRevolutionCounter()) << "rev cnt#3";
|
ASSERT_EQ( 3, getRevolutionCounter()) << "rev cnt#3";
|
||||||
eth->assertInjectorUpEvent("02@0", 0, MS2US(-11.5), 2);
|
eth->assertInjectorUpEvent("02@0", 0, MS2US(-11.5), 2);
|
||||||
eth->assertInjectorDownEvent("@1", 1, MS2US(-10), 2);
|
eth->assertInjectorDownEvent("@1", 1, MS2US(-10), 2);
|
||||||
|
@ -487,7 +487,7 @@ static void setTestBug299(EngineTestHelper *eth) {
|
||||||
ASSERT_EQ( 4, eth->executeActions()) << "exec#20";
|
ASSERT_EQ( 4, eth->executeActions()) << "exec#20";
|
||||||
|
|
||||||
eth->firePrimaryTriggerRise();
|
eth->firePrimaryTriggerRise();
|
||||||
ASSERT_EQ( 4, engine->executor.size()) << "qs#0-2";
|
ASSERT_EQ( 4, engine->scheduler.size()) << "qs#0-2";
|
||||||
// fuel schedule - short pulses. and more realistic schedule this time
|
// fuel schedule - short pulses. and more realistic schedule this time
|
||||||
// time...|-20.....|-10.....|0.......|10......|20
|
// time...|-20.....|-10.....|0.......|10......|20
|
||||||
// inj #0 |.......#|........|.......#|........|
|
// inj #0 |.......#|........|.......#|........|
|
||||||
|
@ -506,7 +506,7 @@ static void setTestBug299(EngineTestHelper *eth) {
|
||||||
// time...|-20.....|-10.....|0.......|10......|20
|
// time...|-20.....|-10.....|0.......|10......|20
|
||||||
// inj #0 |.......#|........|........|........|
|
// inj #0 |.......#|........|........|........|
|
||||||
// inj #1 |........|.......#|........|........|
|
// inj #1 |........|.......#|........|........|
|
||||||
ASSERT_EQ( 4, engine->executor.size()) << "qs#0-2";
|
ASSERT_EQ( 4, engine->scheduler.size()) << "qs#0-2";
|
||||||
ASSERT_EQ( 4, getRevolutionCounter()) << "rev cnt#4";
|
ASSERT_EQ( 4, getRevolutionCounter()) << "rev cnt#4";
|
||||||
eth->assertInjectorUpEvent("0@0", 0, MS2US(8.5), 0);
|
eth->assertInjectorUpEvent("0@0", 0, MS2US(8.5), 0);
|
||||||
eth->assertInjectorDownEvent("0@1", 1, MS2US(10), 0);
|
eth->assertInjectorDownEvent("0@1", 1, MS2US(10), 0);
|
||||||
|
@ -561,10 +561,10 @@ void doTestFuelSchedulerBug299smallAndMedium(int startUpDelayMs) {
|
||||||
|
|
||||||
assertEqualsM("duty for maf=3", 62.5, getInjectorDutyCycle(round(Sensor::getOrZero(SensorType::Rpm))));
|
assertEqualsM("duty for maf=3", 62.5, getInjectorDutyCycle(round(Sensor::getOrZero(SensorType::Rpm))));
|
||||||
|
|
||||||
ASSERT_EQ( 4, engine->executor.size()) << "qs#1";
|
ASSERT_EQ( 4, engine->scheduler.size()) << "qs#1";
|
||||||
eth.moveTimeForwardUs(MS2US(20));
|
eth.moveTimeForwardUs(MS2US(20));
|
||||||
ASSERT_EQ( 4, eth.executeActions()) << "exec#2#0";
|
ASSERT_EQ( 4, eth.executeActions()) << "exec#2#0";
|
||||||
ASSERT_EQ( 0, engine->executor.size()) << "qs#1#2";
|
ASSERT_EQ( 0, engine->scheduler.size()) << "qs#1#2";
|
||||||
|
|
||||||
|
|
||||||
ASSERT_EQ( 4, getRevolutionCounter()) << "rev cnt#4#0";
|
ASSERT_EQ( 4, getRevolutionCounter()) << "rev cnt#4#0";
|
||||||
|
@ -573,7 +573,7 @@ void doTestFuelSchedulerBug299smallAndMedium(int startUpDelayMs) {
|
||||||
// time...|0.......|10......|20......|30......|40......|50......|60......|
|
// time...|0.......|10......|20......|30......|40......|50......|60......|
|
||||||
// inj #0 |########|##...###|########|.....###|########|........|........|
|
// inj #0 |########|##...###|########|.....###|########|........|........|
|
||||||
// inj #1 |.....###|########|....####|########|........|........|........|
|
// inj #1 |.....###|########|....####|########|........|........|........|
|
||||||
ASSERT_EQ( 6, engine->executor.size()) << "qs#4";
|
ASSERT_EQ( 6, engine->scheduler.size()) << "qs#4";
|
||||||
//todo assertInjectorUpEvent("04@0", 0, MS2US(0), 0);
|
//todo assertInjectorUpEvent("04@0", 0, MS2US(0), 0);
|
||||||
// assertInjectorUpEvent("04@1", 1, MS2US(7.5), 1);
|
// assertInjectorUpEvent("04@1", 1, MS2US(7.5), 1);
|
||||||
// assertInjectorDownEvent("04@2", 2, MS2US(12.5), 0);
|
// assertInjectorDownEvent("04@2", 2, MS2US(12.5), 0);
|
||||||
|
@ -586,7 +586,7 @@ void doTestFuelSchedulerBug299smallAndMedium(int startUpDelayMs) {
|
||||||
// assertInjectorDownEvent("04@9", 9, MS2US(50.0), 0);
|
// assertInjectorDownEvent("04@9", 9, MS2US(50.0), 0);
|
||||||
|
|
||||||
// {
|
// {
|
||||||
// scheduling_s *ev = engine->executor.getForUnitTest(9);
|
// scheduling_s *ev = engine->scheduler.getForUnitTest(9);
|
||||||
// ASSERT_EQ( 5, getRevolutionCounter()) << "rev cnt#4#2";
|
// ASSERT_EQ( 5, getRevolutionCounter()) << "rev cnt#4#2";
|
||||||
// ASSERT_TRUE(ev == &engineConfiguration->fuelActuators[2].signalPair[1].signalTimerDown) << "down 50";
|
// ASSERT_TRUE(ev == &engineConfiguration->fuelActuators[2].signalPair[1].signalTimerDown) << "down 50";
|
||||||
// }
|
// }
|
||||||
|
@ -596,7 +596,7 @@ void doTestFuelSchedulerBug299smallAndMedium(int startUpDelayMs) {
|
||||||
|
|
||||||
|
|
||||||
eth.fireFall(20);
|
eth.fireFall(20);
|
||||||
ASSERT_EQ( 8, engine->executor.size()) << "qs#2#1";
|
ASSERT_EQ( 8, engine->scheduler.size()) << "qs#2#1";
|
||||||
ASSERT_EQ( 5, getRevolutionCounter()) << "rev cnt#5";
|
ASSERT_EQ( 5, getRevolutionCounter()) << "rev cnt#5";
|
||||||
// using old fuel schedule - but already wider pulses
|
// using old fuel schedule - but already wider pulses
|
||||||
// time...|-20.....|-10.....|0.......|10......|20......|30......|40......|
|
// time...|-20.....|-10.....|0.......|10......|20......|30......|40......|
|
||||||
|
@ -626,7 +626,7 @@ void doTestFuelSchedulerBug299smallAndMedium(int startUpDelayMs) {
|
||||||
assertInjectionEventBatch("inj#3", &t->elements[3], 1, 2, 0, 333);
|
assertInjectionEventBatch("inj#3", &t->elements[3], 1, 2, 0, 333);
|
||||||
|
|
||||||
eth.moveTimeForwardUs(MS2US(20));
|
eth.moveTimeForwardUs(MS2US(20));
|
||||||
ASSERT_EQ( 5, engine->executor.size()) << "qs#02";
|
ASSERT_EQ( 5, engine->scheduler.size()) << "qs#02";
|
||||||
// assertInjectorUpEvent("6@0", 0, MS2US(-12.5), 1);
|
// assertInjectorUpEvent("6@0", 0, MS2US(-12.5), 1);
|
||||||
// assertInjectorDownEvent("6@1", 1, MS2US(-10.0), 0);
|
// assertInjectorDownEvent("6@1", 1, MS2US(-10.0), 0);
|
||||||
// assertInjectorUpEvent("6@2", 2, MS2US(-2.5), 0);
|
// assertInjectorUpEvent("6@2", 2, MS2US(-2.5), 0);
|
||||||
|
@ -635,11 +635,11 @@ void doTestFuelSchedulerBug299smallAndMedium(int startUpDelayMs) {
|
||||||
|
|
||||||
// so placing this 'executeAll' changes much?
|
// so placing this 'executeAll' changes much?
|
||||||
ASSERT_EQ( 5, eth.executeActions()) << "exec#07";
|
ASSERT_EQ( 5, eth.executeActions()) << "exec#07";
|
||||||
ASSERT_EQ( 0, engine->executor.size()) << "qs#07";
|
ASSERT_EQ( 0, engine->scheduler.size()) << "qs#07";
|
||||||
// assertInjectorDownEvent("26@0", 0, MS2US(10.0), 0);
|
// assertInjectorDownEvent("26@0", 0, MS2US(10.0), 0);
|
||||||
|
|
||||||
eth.firePrimaryTriggerRise();
|
eth.firePrimaryTriggerRise();
|
||||||
ASSERT_EQ( 4, engine->executor.size()) << "qs#2#2";
|
ASSERT_EQ( 4, engine->scheduler.size()) << "qs#2#2";
|
||||||
ASSERT_EQ( 6, getRevolutionCounter()) << "rev cnt6";
|
ASSERT_EQ( 6, getRevolutionCounter()) << "rev cnt6";
|
||||||
// time...|-20.....|-10.....|0.......|10......|20......|30......|40......|
|
// time...|-20.....|-10.....|0.......|10......|20......|30......|40......|
|
||||||
// inj #0 |########|.....###|########|....####|........|........|........|
|
// inj #0 |########|.....###|########|....####|........|........|........|
|
||||||
|
@ -657,7 +657,7 @@ void doTestFuelSchedulerBug299smallAndMedium(int startUpDelayMs) {
|
||||||
// time...|-20.....|-10.....|0.......|10......|20......|30......|40......|
|
// time...|-20.....|-10.....|0.......|10......|20......|30......|40......|
|
||||||
// inj #0 |########|.......#|........|........|........|........|........|
|
// inj #0 |########|.......#|........|........|........|........|........|
|
||||||
// inj #1 |....####|########|........|........|........|........|........|
|
// inj #1 |....####|########|........|........|........|........|........|
|
||||||
ASSERT_EQ( 4, engine->executor.size()) << "qs#022";
|
ASSERT_EQ( 4, engine->scheduler.size()) << "qs#022";
|
||||||
// assertInjectorUpEvent("7@0", 0, MS2US(-12.5), 1);
|
// assertInjectorUpEvent("7@0", 0, MS2US(-12.5), 1);
|
||||||
// assertInjectorDownEvent("7@1", 1, MS2US(-10.0), 0);
|
// assertInjectorDownEvent("7@1", 1, MS2US(-10.0), 0);
|
||||||
// assertInjectorUpEvent("7@2", 2, MS2US(-2.5), 0);
|
// assertInjectorUpEvent("7@2", 2, MS2US(-2.5), 0);
|
||||||
|
@ -670,7 +670,7 @@ void doTestFuelSchedulerBug299smallAndMedium(int startUpDelayMs) {
|
||||||
|
|
||||||
ASSERT_EQ( 3, eth.executeActions()) << "executed #06";
|
ASSERT_EQ( 3, eth.executeActions()) << "executed #06";
|
||||||
assertInjectors("#4", 1, 0);
|
assertInjectors("#4", 1, 0);
|
||||||
ASSERT_EQ( 1, engine->executor.size()) << "qs#06";
|
ASSERT_EQ( 1, engine->scheduler.size()) << "qs#06";
|
||||||
eth.assertInjectorDownEvent("17@0", 0, MS2US(10), 0);
|
eth.assertInjectorDownEvent("17@0", 0, MS2US(10), 0);
|
||||||
// assertInjectorDownEvent("17@1", 1, MS2US(10.0), 0);
|
// assertInjectorDownEvent("17@1", 1, MS2US(10.0), 0);
|
||||||
// assertInjectorUpEvent("17@2", 2, MS2US(17.5), 0);
|
// assertInjectorUpEvent("17@2", 2, MS2US(17.5), 0);
|
||||||
|
@ -679,18 +679,18 @@ void doTestFuelSchedulerBug299smallAndMedium(int startUpDelayMs) {
|
||||||
|
|
||||||
eth.firePrimaryTriggerFall();
|
eth.firePrimaryTriggerFall();
|
||||||
|
|
||||||
ASSERT_EQ( 5, engine->executor.size()) << "qs#3";
|
ASSERT_EQ( 5, engine->scheduler.size()) << "qs#3";
|
||||||
ASSERT_EQ( 6, getRevolutionCounter()) << "rev cnt6";
|
ASSERT_EQ( 6, getRevolutionCounter()) << "rev cnt6";
|
||||||
ASSERT_EQ( 0, eth.executeActions()) << "executed #6";
|
ASSERT_EQ( 0, eth.executeActions()) << "executed #6";
|
||||||
|
|
||||||
|
|
||||||
eth.moveTimeForwardUs(MS2US(20));
|
eth.moveTimeForwardUs(MS2US(20));
|
||||||
ASSERT_EQ( 4, eth.executeActions()) << "executed #06";
|
ASSERT_EQ( 4, eth.executeActions()) << "executed #06";
|
||||||
ASSERT_EQ( 1, engine->executor.size()) << "qs#06";
|
ASSERT_EQ( 1, engine->scheduler.size()) << "qs#06";
|
||||||
assertInjectors("inj#2", 1, 0);
|
assertInjectors("inj#2", 1, 0);
|
||||||
|
|
||||||
eth.firePrimaryTriggerRise();
|
eth.firePrimaryTriggerRise();
|
||||||
ASSERT_EQ( 5, engine->executor.size()) << "Queue.size#03";
|
ASSERT_EQ( 5, engine->scheduler.size()) << "Queue.size#03";
|
||||||
|
|
||||||
eth.assertInjectorUpEvent("07@0", 0, MS2US(7.5), 3);
|
eth.assertInjectorUpEvent("07@0", 0, MS2US(7.5), 3);
|
||||||
eth.assertInjectorDownEvent("07@1", 1, MS2US(10), 2);
|
eth.assertInjectorDownEvent("07@1", 1, MS2US(10), 2);
|
||||||
|
@ -728,7 +728,7 @@ void doTestFuelSchedulerBug299smallAndMedium(int startUpDelayMs) {
|
||||||
|
|
||||||
ASSERT_EQ( 1, enginePins.injectors[0].m_currentLogicValue) << "inj#0";
|
ASSERT_EQ( 1, enginePins.injectors[0].m_currentLogicValue) << "inj#0";
|
||||||
|
|
||||||
ASSERT_EQ( 1, engine->executor.size()) << "Queue.size#04";
|
ASSERT_EQ( 1, engine->scheduler.size()) << "Queue.size#04";
|
||||||
eth.assertInjectorDownEvent("08@0", 0, MS2US(10), 0);
|
eth.assertInjectorDownEvent("08@0", 0, MS2US(10), 0);
|
||||||
// assertInjectorDownEvent("08@1", 1, MS2US(10), 0);
|
// assertInjectorDownEvent("08@1", 1, MS2US(10), 0);
|
||||||
// assertInjectorUpEvent("08@2", 2, MS2US(17.5), 0);
|
// assertInjectorUpEvent("08@2", 2, MS2US(17.5), 0);
|
||||||
|
@ -740,7 +740,7 @@ void doTestFuelSchedulerBug299smallAndMedium(int startUpDelayMs) {
|
||||||
|
|
||||||
eth.executeActions();
|
eth.executeActions();
|
||||||
eth.fireRise(20);
|
eth.fireRise(20);
|
||||||
ASSERT_EQ(9, engine->executor.size()) << "Queue.size#05";
|
ASSERT_EQ(9, engine->scheduler.size()) << "Queue.size#05";
|
||||||
eth.executeActions();
|
eth.executeActions();
|
||||||
|
|
||||||
|
|
||||||
|
@ -759,7 +759,7 @@ void doTestFuelSchedulerBug299smallAndMedium(int startUpDelayMs) {
|
||||||
assertInjectionEventBatch("#30", &t->elements[3], 1, 2, 0, 45);
|
assertInjectionEventBatch("#30", &t->elements[3], 1, 2, 0, 45);
|
||||||
|
|
||||||
// todo: what's what? a mix of new something and old something?
|
// todo: what's what? a mix of new something and old something?
|
||||||
ASSERT_EQ(6, engine->executor.size()) << "qs#5";
|
ASSERT_EQ(6, engine->scheduler.size()) << "qs#5";
|
||||||
// assertInjectorDownEvent("8@0", 0, MS2US(5.0), 1);
|
// assertInjectorDownEvent("8@0", 0, MS2US(5.0), 1);
|
||||||
// assertInjectorUpEvent("8@1", 1, MS2US(7.5), 1);
|
// assertInjectorUpEvent("8@1", 1, MS2US(7.5), 1);
|
||||||
// assertInjectorDownEvent("8@2", 2, MS2US(15.0), 0);
|
// assertInjectorDownEvent("8@2", 2, MS2US(15.0), 0);
|
||||||
|
@ -901,7 +901,7 @@ TEST(big, testFuelSchedulerBug299smallAndLarge) {
|
||||||
engineConfiguration->isFasterEngineSpinUpEnabled = false;
|
engineConfiguration->isFasterEngineSpinUpEnabled = false;
|
||||||
engine->tdcMarkEnabled = false;
|
engine->tdcMarkEnabled = false;
|
||||||
setTestBug299(ð);
|
setTestBug299(ð);
|
||||||
ASSERT_EQ( 4, engine->executor.size()) << "Lqs#0";
|
ASSERT_EQ( 4, engine->scheduler.size()) << "Lqs#0";
|
||||||
|
|
||||||
engine->periodicFastCallback();
|
engine->periodicFastCallback();
|
||||||
|
|
||||||
|
@ -914,7 +914,7 @@ TEST(big, testFuelSchedulerBug299smallAndLarge) {
|
||||||
assertEqualsM("Lduty for maf=3", 87.5, getInjectorDutyCycle(round(Sensor::getOrZero(SensorType::Rpm))));
|
assertEqualsM("Lduty for maf=3", 87.5, getInjectorDutyCycle(round(Sensor::getOrZero(SensorType::Rpm))));
|
||||||
|
|
||||||
|
|
||||||
ASSERT_EQ( 4, engine->executor.size()) << "Lqs#1";
|
ASSERT_EQ( 4, engine->scheduler.size()) << "Lqs#1";
|
||||||
eth.moveTimeForwardUs(MS2US(20));
|
eth.moveTimeForwardUs(MS2US(20));
|
||||||
eth.executeActions();
|
eth.executeActions();
|
||||||
|
|
||||||
|
@ -926,7 +926,7 @@ TEST(big, testFuelSchedulerBug299smallAndLarge) {
|
||||||
// time...|0.......|10......|20......|30......|40......|50......|60......|
|
// time...|0.......|10......|20......|30......|40......|50......|60......|
|
||||||
// inj #0 |########|########|########|.....###|########|........|........|
|
// inj #0 |########|########|########|.....###|########|........|........|
|
||||||
// inj #1 |..######|########|....####|########|........|........|........|
|
// inj #1 |..######|########|....####|########|........|........|........|
|
||||||
ASSERT_EQ( 6, engine->executor.size()) << "Lqs#4";
|
ASSERT_EQ( 6, engine->scheduler.size()) << "Lqs#4";
|
||||||
eth.assertInjectorUpEvent("L04@0", 0, MS2US(8.5), 2);
|
eth.assertInjectorUpEvent("L04@0", 0, MS2US(8.5), 2);
|
||||||
eth.assertInjectorUpEvent("L04@1", 1, MS2US(12.5), 0);
|
eth.assertInjectorUpEvent("L04@1", 1, MS2US(12.5), 0);
|
||||||
// special overlapping injection is merged with one of the scheduled injections
|
// special overlapping injection is merged with one of the scheduled injections
|
||||||
|
@ -941,18 +941,18 @@ TEST(big, testFuelSchedulerBug299smallAndLarge) {
|
||||||
// assertInjectorDownEvent("L04@8", 8, MS2US(50.0), 0);
|
// assertInjectorDownEvent("L04@8", 8, MS2US(50.0), 0);
|
||||||
|
|
||||||
|
|
||||||
engine->executor.executeAll(getTimeNowUs() + 1);
|
engine->scheduler.executeAll(getTimeNowUs() + 1);
|
||||||
// injector goes high...
|
// injector goes high...
|
||||||
ASSERT_FALSE(enginePins.injectors[0].m_currentLogicValue) << "injector@1";
|
ASSERT_FALSE(enginePins.injectors[0].m_currentLogicValue) << "injector@1";
|
||||||
|
|
||||||
engine->executor.executeAll(getTimeNowUs() + MS2US(17.5) + 1);
|
engine->scheduler.executeAll(getTimeNowUs() + MS2US(17.5) + 1);
|
||||||
// injector does not go low too soon, that's a feature :)
|
// injector does not go low too soon, that's a feature :)
|
||||||
ASSERT_TRUE(enginePins.injectors[0].m_currentLogicValue) << "injector@2";
|
ASSERT_TRUE(enginePins.injectors[0].m_currentLogicValue) << "injector@2";
|
||||||
|
|
||||||
|
|
||||||
eth.fireFall(20);
|
eth.fireFall(20);
|
||||||
|
|
||||||
ASSERT_EQ( 6, engine->executor.size()) << "Lqs#04";
|
ASSERT_EQ( 6, engine->scheduler.size()) << "Lqs#04";
|
||||||
eth.assertInjectorUpEvent("L015@0", 0, MS2US(-1.5), 3);
|
eth.assertInjectorUpEvent("L015@0", 0, MS2US(-1.5), 3);
|
||||||
eth.assertInjectorUpEvent("L015@1", 1, MS2US(2.5), 1);
|
eth.assertInjectorUpEvent("L015@1", 1, MS2US(2.5), 1);
|
||||||
eth.assertInjectorDownEvent("L015@2", 2, MS2US(6), 2);
|
eth.assertInjectorDownEvent("L015@2", 2, MS2US(6), 2);
|
||||||
|
@ -961,14 +961,14 @@ TEST(big, testFuelSchedulerBug299smallAndLarge) {
|
||||||
//todo assertInjectorDownEvent("L015@5", 5, MS2US(30), 0);
|
//todo assertInjectorDownEvent("L015@5", 5, MS2US(30), 0);
|
||||||
|
|
||||||
|
|
||||||
engine->executor.executeAll(getTimeNowUs() + MS2US(10) + 1);
|
engine->scheduler.executeAll(getTimeNowUs() + MS2US(10) + 1);
|
||||||
// end of combined injection
|
// end of combined injection
|
||||||
ASSERT_FALSE(enginePins.injectors[0].m_currentLogicValue) << "injector@3";
|
ASSERT_FALSE(enginePins.injectors[0].m_currentLogicValue) << "injector@3";
|
||||||
|
|
||||||
|
|
||||||
eth.moveTimeForwardUs(MS2US(20));
|
eth.moveTimeForwardUs(MS2US(20));
|
||||||
eth.executeActions();
|
eth.executeActions();
|
||||||
ASSERT_EQ( 0, engine->executor.size()) << "Lqs#04";
|
ASSERT_EQ( 0, engine->scheduler.size()) << "Lqs#04";
|
||||||
|
|
||||||
engine->periodicFastCallback();
|
engine->periodicFastCallback();
|
||||||
|
|
||||||
|
@ -983,7 +983,7 @@ TEST(big, testFuelSchedulerBug299smallAndLarge) {
|
||||||
|
|
||||||
eth.firePrimaryTriggerRise();
|
eth.firePrimaryTriggerRise();
|
||||||
|
|
||||||
//todoASSERT_EQ( 5, engine->executor.size()) << "Lqs#05";
|
//todoASSERT_EQ( 5, engine->scheduler.size()) << "Lqs#05";
|
||||||
//todo assertInjectorUpEvent("L016@0", 0, MS2US(8), 0);
|
//todo assertInjectorUpEvent("L016@0", 0, MS2US(8), 0);
|
||||||
//todo assertInjectorDownEvent("L016@1", 1, MS2US(10), 0);
|
//todo assertInjectorDownEvent("L016@1", 1, MS2US(10), 0);
|
||||||
//todo assertInjectorDownEvent("L016@2", 2, MS2US(10), 0);
|
//todo assertInjectorDownEvent("L016@2", 2, MS2US(10), 0);
|
||||||
|
@ -998,7 +998,7 @@ TEST(big, testFuelSchedulerBug299smallAndLarge) {
|
||||||
eth.executeActions();
|
eth.executeActions();
|
||||||
eth.firePrimaryTriggerRise();
|
eth.firePrimaryTriggerRise();
|
||||||
|
|
||||||
ASSERT_EQ( 4, engine->executor.size()) << "Lqs#5";
|
ASSERT_EQ( 4, engine->scheduler.size()) << "Lqs#5";
|
||||||
eth.assertInjectorUpEvent("L05@0", 0, MS2US(8), 2);
|
eth.assertInjectorUpEvent("L05@0", 0, MS2US(8), 2);
|
||||||
eth.assertInjectorDownEvent("L05@1", 1, MS2US(10), 2);
|
eth.assertInjectorDownEvent("L05@1", 1, MS2US(10), 2);
|
||||||
eth.assertInjectorUpEvent("L05@2", 2, MS2US(18), 3);
|
eth.assertInjectorUpEvent("L05@2", 2, MS2US(18), 3);
|
||||||
|
@ -1045,7 +1045,7 @@ TEST(big, testSparkReverseOrderBug319) {
|
||||||
ASSERT_EQ( 3000, round(Sensor::getOrZero(SensorType::Rpm))) << "testSparkReverseOrderBug319: RPM";
|
ASSERT_EQ( 3000, round(Sensor::getOrZero(SensorType::Rpm))) << "testSparkReverseOrderBug319: RPM";
|
||||||
|
|
||||||
|
|
||||||
ASSERT_EQ( 8, engine->executor.size()) << "testSparkReverseOrderBug319: queue size";
|
ASSERT_EQ( 8, engine->scheduler.size()) << "testSparkReverseOrderBug319: queue size";
|
||||||
eth.executeActions();
|
eth.executeActions();
|
||||||
printf("***************************************************\r\n");
|
printf("***************************************************\r\n");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue