mirror of https://github.com/rusefi/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
|
||||
if (isRunning) {
|
||||
engine->executor.scheduleByTimestampNt("trigger scope", &restartTimer, getTimeNowNt() + MS2NT(10), startSampling);
|
||||
engine->scheduler.schedule("trigger scope", &restartTimer, getTimeNowNt() + MS2NT(10), startSampling);
|
||||
}
|
||||
|
||||
return buffer;
|
||||
|
|
|
@ -88,7 +88,7 @@ void initAlternatorCtrl() {
|
|||
|
||||
startSimplePwm(&alternatorControl,
|
||||
"Alternator control",
|
||||
&engine->executor,
|
||||
&engine->scheduler,
|
||||
&enginePins.alternatorPin,
|
||||
engineConfiguration->alternatorPwmFrequency, 0);
|
||||
}
|
||||
|
|
|
@ -229,7 +229,7 @@ void startBoostPin() {
|
|||
startSimplePwm(
|
||||
&boostPwmControl,
|
||||
"Boost",
|
||||
&engine->executor,
|
||||
&engine->scheduler,
|
||||
&enginePins.boostPin,
|
||||
engineConfiguration->boostPwmFrequency,
|
||||
0
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
brain_pin_e pinDir2,
|
||||
brain_pin_e pinDisable,
|
||||
bool isInverted,
|
||||
ExecutorInterface* executor,
|
||||
Scheduler* executor,
|
||||
int frequency) {
|
||||
|
||||
if (isStarted) {
|
||||
|
@ -99,7 +99,7 @@ DcMotor* initDcMotor(const dc_io& io, size_t index, bool useTwoWires) {
|
|||
io.disablePin,
|
||||
// todo You would not believe how you invert TLE9201 #4579
|
||||
engineConfiguration->stepperDcInvertedPins,
|
||||
&engine->executor,
|
||||
&engine->scheduler,
|
||||
engineConfiguration->etbFreq
|
||||
);
|
||||
|
||||
|
@ -116,7 +116,7 @@ DcMotor* initDcMotor(brain_pin_e coil_p, brain_pin_e coil_m, size_t index) {
|
|||
coil_m,
|
||||
Gpio::Unassigned, /* pinDisable */
|
||||
engineConfiguration->stepperDcInvertedPins,
|
||||
&engine->executor,
|
||||
&engine->scheduler,
|
||||
engineConfiguration->etbFreq /* same in case of stepper? */
|
||||
);
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
brain_pin_e pinDir2,
|
||||
brain_pin_e pinDisable,
|
||||
bool isInverted,
|
||||
ExecutorInterface* executor,
|
||||
Scheduler* executor,
|
||||
int frequency);
|
||||
|
||||
TwoPinDcMotor dcMotor;
|
||||
|
|
|
@ -44,7 +44,7 @@ void initGpPwm() {
|
|||
// Setup pin & pwm
|
||||
pins[i].initPin("gp pwm", cfg.pin);
|
||||
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
|
||||
|
|
|
@ -148,7 +148,7 @@ void initIdleHardware() {
|
|||
*/
|
||||
// todo: even for double-solenoid mode we can probably use same single SimplePWM
|
||||
startSimplePwm(&idleSolenoidOpen, "Idle Valve Open",
|
||||
&engine->executor,
|
||||
&engine->scheduler,
|
||||
&enginePins.idleSolenoidPin,
|
||||
engineConfiguration->idle.solenoidFrequency, PERCENT_TO_DUTY(engineConfiguration->manIdlePosition));
|
||||
|
||||
|
@ -159,7 +159,7 @@ void initIdleHardware() {
|
|||
}
|
||||
|
||||
startSimplePwm(&idleSolenoidClose, "Idle Valve Close",
|
||||
&engine->executor,
|
||||
&engine->scheduler,
|
||||
&enginePins.secondIdleSolenoidPin,
|
||||
engineConfiguration->idle.solenoidFrequency, PERCENT_TO_DUTY(engineConfiguration->manIdlePosition));
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ static void turnVvtPidOn(int index) {
|
|||
}
|
||||
|
||||
startSimplePwmExt(&vvtPwms[index], vvtOutputNames[index],
|
||||
&engine->executor,
|
||||
&engine->scheduler,
|
||||
engineConfiguration->vvtPins[index],
|
||||
&vvtPins[index],
|
||||
engineConfiguration->vvtOutputFrequency, 0);
|
||||
|
|
|
@ -492,8 +492,8 @@ TunerStudioOutputChannels *getTunerStudioOutputChannels() {
|
|||
return &engine->outputChannels;
|
||||
}
|
||||
|
||||
ExecutorInterface *getExecutorInterface() {
|
||||
return &engine->executor;
|
||||
Scheduler *getScheduler() {
|
||||
return &engine->scheduler;
|
||||
}
|
||||
|
||||
#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
|
||||
// cost to resolve pointer, we use instances as a micro optimization
|
||||
#if EFI_SIGNAL_EXECUTOR_ONE_TIMER
|
||||
SingleTimerExecutor executor;
|
||||
SingleTimerExecutor scheduler;
|
||||
#endif
|
||||
#if EFI_SIGNAL_EXECUTOR_SLEEP
|
||||
SleepExecutor executor;
|
||||
SleepExecutor scheduler;
|
||||
#endif
|
||||
#if EFI_UNIT_TEST
|
||||
TestExecutor executor;
|
||||
TestExecutor scheduler;
|
||||
|
||||
std::function<void(IgnitionEvent*, bool)> onIgnitionEvent;
|
||||
#endif // EFI_UNIT_TEST
|
||||
|
|
|
@ -101,8 +101,8 @@ static void runBench(BenchParams& params) {
|
|||
efitick_t endTime = startTime + US2NT(onTimeUs);
|
||||
|
||||
// Schedule both events
|
||||
engine->executor.scheduleByTimestampNt("bstart", nullptr, startTime, {benchOn, params.Pin});
|
||||
engine->executor.scheduleByTimestampNt("bend", nullptr, endTime, {benchOff, params.Pin});
|
||||
engine->scheduler.schedule("bstart", nullptr, startTime, {benchOn, params.Pin});
|
||||
engine->scheduler.schedule("bend", nullptr, endTime, {benchOff, params.Pin});
|
||||
|
||||
// Wait one full cycle time for the event + delay to happen
|
||||
chThdSleepMicroseconds(onTimeUs + offTimeUs);
|
||||
|
|
|
@ -39,8 +39,8 @@ void turnInjectionPinLow(uintptr_t arg) {
|
|||
efitick_t openTime = getTimeNowNt() + MS2NT(2);
|
||||
efitick_t closeTime = openTime + nextSplitDuration;
|
||||
|
||||
getExecutorInterface()->scheduleByTimestampNt("inj", nullptr, openTime, { &turnInjectionPinHigh, arg });
|
||||
getExecutorInterface()->scheduleByTimestampNt("inj", nullptr, closeTime, { turnInjectionPinLow, arg });
|
||||
getScheduler()->schedule("inj", nullptr, openTime, { &turnInjectionPinHigh, arg });
|
||||
getScheduler()->schedule("inj", nullptr, closeTime, { turnInjectionPinLow, arg });
|
||||
} else {
|
||||
event->update();
|
||||
}
|
||||
|
@ -214,12 +214,12 @@ void InjectionEvent::onTriggerTooth(efitick_t nowNt, float currentPhase, float n
|
|||
this->splitInjectionDuration = {};
|
||||
}
|
||||
|
||||
getExecutorInterface()->scheduleByTimestampNt("inj", nullptr, turnOffTimeStage1, endActionStage1);
|
||||
getScheduler()->schedule("inj", nullptr, turnOffTimeStage1, endActionStage1);
|
||||
|
||||
// Schedule closing stage 2 (if applicable)
|
||||
if (hasStage2Injection && endActionStage2) {
|
||||
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
|
||||
|
|
|
@ -64,7 +64,7 @@ void PrimeController::onIgnitionStateChanged(bool ignitionOn) {
|
|||
uint32_t primeDelayNt = MSF2NT(engineConfiguration->primingDelay * 1000 + minimumPrimeDelayMs);
|
||||
|
||||
auto startTime = getTimeNowNt() + primeDelayNt;
|
||||
getExecutorInterface()->scheduleByTimestampNt("prime start", nullptr, startTime, { PrimeController::onPrimeStartAdapter, this });
|
||||
getScheduler()->schedule("prime start", nullptr, startTime, { PrimeController::onPrimeStartAdapter, this });
|
||||
} else {
|
||||
efiPrintf("Skipped priming pulse since ignSwitchCounter = %lu", ignSwitchCounter);
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ void PrimeController::onPrimeStart() {
|
|||
// Open all injectors, schedule closing later
|
||||
m_isPriming = true;
|
||||
startSimultaneousInjection();
|
||||
getExecutorInterface()->scheduleByTimestampNt("prime end", nullptr, endTime, { onPrimeEndAdapter, this });
|
||||
getScheduler()->schedule("prime end", nullptr, endTime, { onPrimeEndAdapter, this });
|
||||
}
|
||||
|
||||
void PrimeController::onPrimeEnd() {
|
||||
|
|
|
@ -393,7 +393,7 @@ efitick_t scheduleByAngle(scheduling_s *timer, efitick_t edgeTimestamp, angle_t
|
|||
int32_t delayNt = USF2NT(delayUs);
|
||||
efitick_t delayedTime = edgeTimestamp + efidur_t{delayNt};
|
||||
|
||||
engine->executor.scheduleByTimestampNt("angle", timer, delayedTime, action);
|
||||
engine->scheduler.schedule("angle", timer, delayedTime, action);
|
||||
|
||||
return delayedTime;
|
||||
}
|
||||
|
|
|
@ -224,8 +224,8 @@ if (engineConfiguration->debugMode == DBG_DWELL_METRIC) {
|
|||
#endif /* SPARK_EXTREME_LOGGING */
|
||||
|
||||
// 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->executor.scheduleByTimestampNt("firing", &event->sparkEvent.scheduling, nextFiring, { fireSparkAndPrepareNextSchedule, event });
|
||||
engine->scheduler.schedule("dwell", &event->dwellStartTimer, nextDwellStart, { &turnSparkPinHigh, event });
|
||||
engine->scheduler.schedule("firing", &event->sparkEvent.scheduling, nextFiring, { fireSparkAndPrepareNextSchedule, event });
|
||||
} else {
|
||||
if (engineConfiguration->enableTrailingSparks) {
|
||||
#if SPARK_EXTREME_LOGGING
|
||||
|
@ -382,7 +382,7 @@ static void scheduleSparkEvent(bool limitedSpark, IgnitionEvent *event,
|
|||
if (!limitedSpark && engine->enableOverdwellProtection) {
|
||||
// auto fire spark at 1.5x nominal dwell
|
||||
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,
|
||||
"Speedometer",
|
||||
&engine->executor,
|
||||
&engine->scheduler,
|
||||
&enginePins.speedoOut,
|
||||
NAN, 0.5f);
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ void initTachometer() {
|
|||
|
||||
startSimplePwm(&tachControl,
|
||||
"Tachometer",
|
||||
&engine->executor,
|
||||
&engine->scheduler,
|
||||
&enginePins.tachOut,
|
||||
NAN, 0.1f);
|
||||
|
||||
|
|
|
@ -250,7 +250,7 @@ static int lua_startPwm(lua_State* l) {
|
|||
freq = clampF(1, freq, 1000);
|
||||
|
||||
startSimplePwmExt(
|
||||
&p.pwm, "lua", &engine->executor,
|
||||
&p.pwm, "lua", &engine->scheduler,
|
||||
engineConfiguration->luaOutputPins[p.idx], &enginePins.luaOutputPins[p.idx],
|
||||
freq, duty
|
||||
);
|
||||
|
|
|
@ -45,7 +45,7 @@ void initVrPwm() {
|
|||
}
|
||||
|
||||
startSimplePwmHard(&pwms[i], "VR PWM",
|
||||
&engine->executor,
|
||||
&engine->scheduler,
|
||||
cfg.pin,
|
||||
&pins[i],
|
||||
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;
|
||||
}
|
||||
|
||||
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--;
|
||||
}
|
||||
|
||||
|
@ -285,7 +285,7 @@ void copyPwmParameters(PwmConfig *state, MultiChannelStateSequence const * seq)
|
|||
* this method also starts the timer cycle
|
||||
* See also startSimplePwm
|
||||
*/
|
||||
void PwmConfig::weComplexInit(ExecutorInterface *executor,
|
||||
void PwmConfig::weComplexInit(Scheduler *executor,
|
||||
MultiChannelStateSequence const * seq,
|
||||
pwm_cycle_callback *pwmCycleCallback, pwm_gen_callback *stateChangeCallback) {
|
||||
m_executor = executor;
|
||||
|
@ -315,7 +315,7 @@ void PwmConfig::weComplexInit(ExecutorInterface *executor,
|
|||
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) {
|
||||
efiAssertVoid(ObdCode::CUSTOM_ERR_PWM_STATE_ASSERT, state != NULL, "state");
|
||||
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,
|
||||
ExecutorInterface *executor,
|
||||
Scheduler *executor,
|
||||
brain_pin_e brainPin, OutputPin *output, float frequency,
|
||||
float dutyCycle) {
|
||||
|
||||
|
@ -350,7 +350,7 @@ void startSimplePwmExt(SimplePwm *state, const char *msg,
|
|||
* @param dutyCycle value between 0 and 1
|
||||
*/
|
||||
void startSimplePwmHard(SimplePwm *state, const char *msg,
|
||||
ExecutorInterface *executor,
|
||||
Scheduler *executor,
|
||||
brain_pin_e brainPin, OutputPin *output, float frequency,
|
||||
float dutyCycle) {
|
||||
#if EFI_PROD_CODE && HAL_USE_PWM
|
||||
|
|
|
@ -52,12 +52,12 @@ public:
|
|||
PwmConfig();
|
||||
|
||||
void weComplexInit(
|
||||
ExecutorInterface *executor,
|
||||
Scheduler *executor,
|
||||
MultiChannelStateSequence const * seq,
|
||||
pwm_cycle_callback *pwmCycleCallback,
|
||||
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
|
||||
|
@ -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()
|
||||
*/
|
||||
void startSimplePwm(SimplePwm *state, const char *msg,
|
||||
ExecutorInterface *executor,
|
||||
Scheduler *executor,
|
||||
OutputPin *output,
|
||||
float frequency, float dutyCycle);
|
||||
|
||||
|
@ -143,12 +143,12 @@ void startSimplePwm(SimplePwm *state, const char *msg,
|
|||
*/
|
||||
void startSimplePwmExt(SimplePwm *state,
|
||||
const char *msg,
|
||||
ExecutorInterface *executor,
|
||||
Scheduler *executor,
|
||||
brain_pin_e brainPin, OutputPin *output,
|
||||
float frequency, float dutyCycle);
|
||||
|
||||
void startSimplePwmHard(SimplePwm *state, const char *msg,
|
||||
ExecutorInterface *executor,
|
||||
Scheduler *executor,
|
||||
brain_pin_e brainPin, OutputPin *output, float frequency,
|
||||
float dutyCycle);
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ struct scheduling_s {
|
|||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
struct ExecutorInterface {
|
||||
struct Scheduler {
|
||||
/**
|
||||
* @brief Schedule an action to be executed in the future.
|
||||
*
|
||||
|
@ -87,7 +87,7 @@ struct ExecutorInterface {
|
|||
* very near future, it may execute immediately.
|
||||
* @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.
|
||||
|
@ -97,5 +97,5 @@ struct ExecutorInterface {
|
|||
virtual void cancel(scheduling_s* scheduling) = 0;
|
||||
};
|
||||
|
||||
ExecutorInterface *getExecutorInterface();
|
||||
Scheduler *getScheduler();
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ uint32_t hwSetTimerDuration;
|
|||
void globalTimerCallback() {
|
||||
efiAssertVoid(ObdCode::CUSTOM_ERR_6624, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstck#2y");
|
||||
|
||||
___engine.executor.onTimerCallback();
|
||||
___engine.scheduler.onTimerCallback();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
#if EFI_ENABLE_ASSERTS
|
||||
|
@ -54,7 +54,7 @@ void SingleTimerExecutor::scheduleByTimestampNt(const char *msg, scheduling_s* s
|
|||
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
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
@ -161,11 +161,11 @@ void initSingleTimerExecutorHardware(void) {
|
|||
void executorStatistics() {
|
||||
if (engineConfiguration->debugMode == DBG_EXECUTOR) {
|
||||
#if EFI_TUNER_STUDIO
|
||||
engine->outputChannels.debugIntField1 = ___engine.executor.timerCallbackCounter;
|
||||
engine->outputChannels.debugIntField2 = ___engine.executor.executeAllPendingActionsInvocationCounter;
|
||||
engine->outputChannels.debugIntField3 = ___engine.executor.scheduleCounter;
|
||||
engine->outputChannels.debugIntField4 = ___engine.executor.executeCounter;
|
||||
engine->outputChannels.debugIntField5 = ___engine.executor.maxExecuteCounter;
|
||||
engine->outputChannels.debugIntField1 = ___engine.scheduler.timerCallbackCounter;
|
||||
engine->outputChannels.debugIntField2 = ___engine.scheduler.executeAllPendingActionsInvocationCounter;
|
||||
engine->outputChannels.debugIntField3 = ___engine.scheduler.scheduleCounter;
|
||||
engine->outputChannels.debugIntField4 = ___engine.scheduler.executeCounter;
|
||||
engine->outputChannels.debugIntField5 = ___engine.scheduler.maxExecuteCounter;
|
||||
#endif /* EFI_TUNER_STUDIO */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
#include "scheduler.h"
|
||||
#include "event_queue.h"
|
||||
|
||||
class SingleTimerExecutor final : public ExecutorInterface {
|
||||
class SingleTimerExecutor final : public Scheduler {
|
||||
public:
|
||||
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 onTimerCallback();
|
||||
|
|
|
@ -121,7 +121,7 @@ void TriggerScheduler::scheduleEventsUntilNextTriggerTooth(int rpm,
|
|||
|
||||
// In case this event was scheduled by overdwell protection, cancel it so
|
||||
// we can re-schedule at the correct time
|
||||
engine->executor.cancel(sDown);
|
||||
engine->scheduler.cancel(sDown);
|
||||
|
||||
scheduleByAngle(
|
||||
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);
|
||||
startSimplePwm(&tccPwm,
|
||||
"TCC",
|
||||
&engine->executor,
|
||||
&engine->scheduler,
|
||||
&enginePins.tcuTccPwmSolenoid,
|
||||
engineConfiguration->tcu_tcc_pwm_solenoid_freq,
|
||||
0);
|
||||
enginePins.tcuPcSolenoid.initPin("Pressure Control Solenoid", engineConfiguration->tcu_pc_solenoid_pin, engineConfiguration->tcu_pc_solenoid_pin_mode);
|
||||
startSimplePwm(&pcPwm,
|
||||
"Line Pressure",
|
||||
&engine->executor,
|
||||
&engine->scheduler,
|
||||
&enginePins.tcuPcSolenoid,
|
||||
engineConfiguration->tcu_pc_solenoid_freq,
|
||||
0);
|
||||
enginePins.tcu32Solenoid.initPin("3-2 Shift Solenoid", engineConfiguration->tcu_32_solenoid_pin, engineConfiguration->tcu_32_solenoid_pin_mode);
|
||||
startSimplePwm(&shift32Pwm,
|
||||
"3-2 Solenoid",
|
||||
&engine->executor,
|
||||
&engine->scheduler,
|
||||
&enginePins.tcu32Solenoid,
|
||||
engineConfiguration->tcu_32_solenoid_freq,
|
||||
0);
|
||||
|
|
|
@ -214,7 +214,7 @@ static void logVvtFront(bool isImportantFront, bool isRising, efitick_t nowNt, i
|
|||
#if EFI_PROD_CODE
|
||||
writePad("cam debug", engineConfiguration->camInputsDebug[index], 1);
|
||||
#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
|
||||
|
@ -434,7 +434,7 @@ void handleShaftSignal(int signalIndex, bool isRising, efitick_t timestamp) {
|
|||
#if EFI_PROD_CODE
|
||||
writePad("trigger debug", engineConfiguration->triggerInputDebugPins[signalIndex], 1);
|
||||
#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();
|
||||
|
|
|
@ -147,7 +147,7 @@ static void startSimulatedTriggerSignal() {
|
|||
TriggerWaveform *s = &engine->triggerCentral.triggerShape;
|
||||
setTriggerEmulatorRPM(engineConfiguration->triggerSimulatorRpm);
|
||||
triggerSignal.weComplexInit(
|
||||
&engine->executor,
|
||||
&engine->scheduler,
|
||||
&s->wave,
|
||||
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
|
||||
* 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;
|
||||
|
@ -156,7 +156,7 @@ static void validateHardwareTimer() {
|
|||
testScheduling.reset();
|
||||
|
||||
// to save RAM let's use 'watchDogBuddy' here once before we enable watchdog
|
||||
engine->executor.scheduleByTimestampNt(
|
||||
engine->scheduler.schedule(
|
||||
"hw-validate",
|
||||
&watchDogBuddy,
|
||||
getTimeNowNt() + MS2NT(TEST_CALLBACK_DELAY),
|
||||
|
|
|
@ -37,7 +37,7 @@ struct CallbackContext
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
#include "scheduler.h"
|
||||
|
||||
class SleepExecutor : public ExecutorInterface {
|
||||
class SleepExecutor : public Scheduler {
|
||||
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;
|
||||
};
|
||||
|
|
|
@ -35,9 +35,9 @@ scheduling_s* TestExecutor::getForUnitTest(int 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) {
|
||||
m_mockExecutor->scheduleByTimestampNt(msg, scheduling, timeNt, action);
|
||||
m_mockExecutor->schedule(msg, scheduling, timeNt, action);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,6 @@ void TestExecutor::cancel(scheduling_s* s) {
|
|||
schedulingQueue.remove(s);
|
||||
}
|
||||
|
||||
void TestExecutor::setMockExecutor(ExecutorInterface* exec) {
|
||||
void TestExecutor::setMockExecutor(Scheduler* exec) {
|
||||
m_mockExecutor = exec;
|
||||
}
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
#include "scheduler.h"
|
||||
#include "event_queue.h"
|
||||
|
||||
class TestExecutor : public ExecutorInterface {
|
||||
class TestExecutor : public Scheduler {
|
||||
public:
|
||||
~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 clear();
|
||||
|
@ -23,8 +23,8 @@ public:
|
|||
scheduling_s * getHead();
|
||||
scheduling_s * getForUnitTest(int index);
|
||||
|
||||
void setMockExecutor(ExecutorInterface* exec);
|
||||
void setMockExecutor(Scheduler* exec);
|
||||
private:
|
||||
EventQueue schedulingQueue;
|
||||
ExecutorInterface* m_mockExecutor = nullptr;
|
||||
Scheduler* m_mockExecutor = nullptr;
|
||||
};
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
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));
|
||||
};
|
||||
|
||||
|
|
|
@ -64,14 +64,14 @@ TEST(fuelControl, transitionIssue1592) {
|
|||
// Injector 2 should be scheduled to open then close
|
||||
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
|
||||
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.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
|
||||
ASSERT_EQ(sched_close->action.getArgument(), inj2);
|
||||
ASSERT_EQ(sched_close->action.getCallback(), (void(*)(void*))turnInjectionPinLow);
|
||||
|
|
|
@ -84,7 +84,7 @@ TEST(ignition, trailingSpark) {
|
|||
EXPECT_EQ(enginePins.trailingCoils[0].getLogicValue(), false);
|
||||
|
||||
// Should be a TDC callback + spark firing
|
||||
EXPECT_EQ(engine->executor.size(), 2);
|
||||
EXPECT_EQ(engine->scheduler.size(), 2);
|
||||
|
||||
// execute all actions
|
||||
eth.executeActions();
|
||||
|
|
|
@ -41,7 +41,7 @@ TEST(OddFireRunningMode, hd) {
|
|||
|
||||
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));
|
||||
|
||||
angle_t expectedAngle7 = -180 + cylinderOne - timing;
|
||||
|
|
|
@ -18,19 +18,19 @@ TEST(issues, issueOneCylinderSpecialCase968) {
|
|||
|
||||
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 */);
|
||||
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 */);
|
||||
|
||||
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 down#0", 1, (void*)fireSparkAndPrepareNextSchedule, -39167);
|
||||
|
||||
|
||||
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);
|
||||
ASSERT_EQ( 300, Sensor::getOrZero(SensorType::Rpm)) << "RPM#2";
|
||||
// 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);
|
||||
// -1 because ugh floating point math
|
||||
|
@ -41,7 +41,7 @@ TEST(priming, startScheduling) {
|
|||
// Turn on the ignition switch!
|
||||
engine->module<PrimeController>()->onIgnitionStateChanged(true);
|
||||
|
||||
ASSERT_EQ(1, engine->executor.size()) << "prime fuel";
|
||||
ASSERT_EQ(1, engine->scheduler.size()) << "prime fuel";
|
||||
}
|
||||
|
||||
TEST(priming, duration) {
|
||||
|
|
|
@ -236,7 +236,7 @@ TEST(HPFP, Schedule) {
|
|||
auto & hpfp = *engine->module<HpfpController>();
|
||||
|
||||
StrictMock<MockExecutor> mockExec;
|
||||
engine->executor.setMockExecutor(&mockExec);
|
||||
engine->scheduler.setMockExecutor(&mockExec);
|
||||
engineConfiguration->hpfpActivationAngle = 30;
|
||||
|
||||
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.
|
||||
// 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.
|
||||
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
|
||||
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);
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ TEST(cranking, testFasterEngineSpinningUp) {
|
|||
// check RPM
|
||||
ASSERT_EQ( 0, round(Sensor::getOrZero(SensorType::Rpm))) << "RPM=0";
|
||||
// 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
|
||||
// advance 1 revolution
|
||||
|
@ -47,7 +47,7 @@ TEST(cranking, testFasterEngineSpinningUp) {
|
|||
// due to isFasterEngineSpinUp=true, we should have already detected RPM!
|
||||
ASSERT_EQ( 300, round(Sensor::getOrZero(SensorType::Rpm))) << "spinning-RPM#1";
|
||||
// two simultaneous injections
|
||||
ASSERT_EQ(4, engine->executor.size()) << "plain#2";
|
||||
ASSERT_EQ(4, engine->scheduler.size()) << "plain#2";
|
||||
// test if they are simultaneous
|
||||
ASSERT_EQ(IM_SIMULTANEOUS, getCurrentInjectionMode());
|
||||
// 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
|
||||
ASSERT_EQ(IM_WASTED_SPARK, getCurrentIgnitionMode());
|
||||
// two simultaneous injections
|
||||
ASSERT_EQ( 4, engine->executor.size()) << "plain#2";
|
||||
ASSERT_EQ( 4, engine->scheduler.size()) << "plain#2";
|
||||
// check real events
|
||||
eth.assertEvent5("inj start#2", 0, (void*)startSimultaneousInjection, 148375);
|
||||
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
|
||||
ASSERT_EQ(IM_SEQUENTIAL, getCurrentInjectionMode());
|
||||
// 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
|
||||
// Note: See addFuelEvents() fix inside setRpmValue()!
|
||||
|
|
|
@ -19,7 +19,7 @@ TEST(injectionScheduling, InjectionIsScheduled) {
|
|||
StrictMock<MockExecutor> mockExec;
|
||||
|
||||
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
||||
engine->executor.setMockExecutor(&mockExec);
|
||||
engine->scheduler.setMockExecutor(&mockExec);
|
||||
|
||||
efitick_t nowNt = 1000000;
|
||||
|
||||
|
@ -42,10 +42,10 @@ 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(), _, startTime, Not(Truly(ActionArgumentHasLowBitSet))));
|
||||
EXPECT_CALL(mockExec, schedule(testing::NotNull(), _, startTime, Not(Truly(ActionArgumentHasLowBitSet))));
|
||||
// falling edge 20ms later
|
||||
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
|
||||
|
@ -60,7 +60,7 @@ TEST(injectionScheduling, InjectionIsScheduledDualStage) {
|
|||
StrictMock<MockInjectorModel2> im;
|
||||
|
||||
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
||||
engine->executor.setMockExecutor(&mockExec);
|
||||
engine->scheduler.setMockExecutor(&mockExec);
|
||||
engine->module<InjectorModelPrimary>().set(&im);
|
||||
engine->module<InjectorModelSecondary>().set(&im);
|
||||
|
||||
|
@ -92,13 +92,13 @@ TEST(injectionScheduling, InjectionIsScheduledDualStage) {
|
|||
// rising edge 5 degrees from now
|
||||
float nt5deg = USF2NT(engine->rpmCalculator.oneDegreeUs * 5);
|
||||
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
|
||||
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
|
||||
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
|
||||
|
@ -112,7 +112,7 @@ TEST(injectionScheduling, InjectionIsScheduledBeforeWraparound) {
|
|||
StrictMock<MockExecutor> mockExec;
|
||||
|
||||
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
||||
engine->executor.setMockExecutor(&mockExec);
|
||||
engine->scheduler.setMockExecutor(&mockExec);
|
||||
|
||||
efitick_t nowNt = 1000000;
|
||||
|
||||
|
@ -135,10 +135,10 @@ 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(), _, startTime, Not(Truly(ActionArgumentHasLowBitSet))));
|
||||
EXPECT_CALL(mockExec, schedule(testing::NotNull(), _, startTime, Not(Truly(ActionArgumentHasLowBitSet))));
|
||||
// falling edge 20ms later
|
||||
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
|
||||
|
@ -152,7 +152,7 @@ TEST(injectionScheduling, InjectionIsScheduledAfterWraparound) {
|
|||
StrictMock<MockExecutor> mockExec;
|
||||
|
||||
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
||||
engine->executor.setMockExecutor(&mockExec);
|
||||
engine->scheduler.setMockExecutor(&mockExec);
|
||||
|
||||
efitick_t nowNt = 1000000;
|
||||
|
||||
|
@ -175,10 +175,10 @@ 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(), _, startTime, Not(Truly(ActionArgumentHasLowBitSet))));
|
||||
EXPECT_CALL(mockExec, schedule(testing::NotNull(), _, startTime, Not(Truly(ActionArgumentHasLowBitSet))));
|
||||
// falling edge 20ms later
|
||||
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
|
||||
|
@ -193,7 +193,7 @@ TEST(injectionScheduling, InjectionNotScheduled) {
|
|||
StrictMock<MockExecutor> mockExec;
|
||||
|
||||
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
||||
engine->executor.setMockExecutor(&mockExec);
|
||||
engine->scheduler.setMockExecutor(&mockExec);
|
||||
|
||||
efitick_t nowNt = 1000000;
|
||||
|
||||
|
@ -226,7 +226,7 @@ TEST(injectionScheduling, SplitInjectionScheduled) {
|
|||
StrictMock<MockExecutor> mockExec;
|
||||
|
||||
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
||||
engine->executor.setMockExecutor(&mockExec);
|
||||
engine->scheduler.setMockExecutor(&mockExec);
|
||||
|
||||
InjectionEvent event;
|
||||
uintptr_t arg = reinterpret_cast<uintptr_t>(&event);
|
||||
|
@ -243,9 +243,9 @@ TEST(injectionScheduling, SplitInjectionScheduled) {
|
|||
// - duration 10ms (ends 12ms from now)
|
||||
efitick_t nowNt = getTimeNowNt();
|
||||
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);
|
||||
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
|
||||
|
|
|
@ -28,8 +28,8 @@ TEST(trigger, map_cam_by_magic_point) {
|
|||
ASSERT_EQ(0, engine->triggerCentral.triggerState.camResyncCounter);
|
||||
|
||||
// Nothing should have been scheduled yet
|
||||
ASSERT_EQ(1, engine->executor.size());
|
||||
scheduling_s* next = engine->executor.getForUnitTest(0);
|
||||
ASSERT_EQ(1, engine->scheduler.size());
|
||||
scheduling_s* next = engine->scheduler.getForUnitTest(0);
|
||||
eth.assertEvent5("spark down#0", 0, (void*)fireSparkAndPrepareNextSchedule, 188333);
|
||||
|
||||
engine->outputChannels.instantMAPValue = 120;
|
||||
|
@ -43,7 +43,7 @@ TEST(trigger, map_cam_by_magic_point) {
|
|||
ASSERT_EQ(ClearReason::None, getLimpManager()->allowInjection().reason);
|
||||
|
||||
// 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#1", 1, (void*)fireSparkAndPrepareNextSchedule, 188333);
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ static void scheduleTriggerEvents(TriggerWaveform *shape,
|
|||
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ TEST(nissan, vq_vvt) {
|
|||
scheduling_s *head;
|
||||
|
||||
int queueIndex = 0;
|
||||
while ((head = engine->executor.getHead()) != nullptr) {
|
||||
while ((head = engine->scheduler.getHead()) != nullptr) {
|
||||
eth.setTimeAndInvokeEventsUs(head->momentX);
|
||||
|
||||
ASSERT_TRUE(tc->vvtState[0][0].getShaftSynchronized());
|
||||
|
|
|
@ -245,47 +245,47 @@ TEST(misc, testRpmCalculator) {
|
|||
EXPECT_NEAR(ilist->elements[0].sparkAngle, 13.0f, 1e-3);
|
||||
|
||||
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);
|
||||
assertEqualsM("ev 0", start + 944, ev0->momentX);
|
||||
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);
|
||||
assertEqualsM("ev 1", start + 1444, ev1->momentX);
|
||||
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.fireRise(5);
|
||||
eth.fireFall(5);
|
||||
ASSERT_EQ( 2, eth.engine.triggerCentral.triggerState.getCurrentIndex()) << "index #3";
|
||||
ASSERT_EQ( 4, engine->executor.size()) << "queue size 3";
|
||||
assertEqualsM("ev 3", start + 13333 - 1515 + 2459, engine->executor.getForUnitTest(0)->momentX);
|
||||
assertEqualsM2("ev 5", start + 14277 + 500, engine->executor.getForUnitTest(1)->momentX, 2);
|
||||
assertEqualsM("3/3", start + 14777 + 677, engine->executor.getForUnitTest(2)->momentX);
|
||||
engine->executor.clear();
|
||||
ASSERT_EQ( 4, engine->scheduler.size()) << "queue size 3";
|
||||
assertEqualsM("ev 3", start + 13333 - 1515 + 2459, engine->scheduler.getForUnitTest(0)->momentX);
|
||||
assertEqualsM2("ev 5", start + 14277 + 500, engine->scheduler.getForUnitTest(1)->momentX, 2);
|
||||
assertEqualsM("3/3", start + 14777 + 677, engine->scheduler.getForUnitTest(2)->momentX);
|
||||
engine->scheduler.clear();
|
||||
|
||||
ASSERT_EQ(4, engine->triggerCentral.triggerShape.findAngleIndex(&engine->triggerCentral.triggerFormDetails, 240));
|
||||
ASSERT_EQ(4, engine->triggerCentral.triggerShape.findAngleIndex(&engine->triggerCentral.triggerFormDetails, 241));
|
||||
|
||||
|
||||
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);
|
||||
ASSERT_EQ( 4, engine->executor.size()) << "queue size 4.2";
|
||||
ASSERT_EQ( 4, engine->scheduler.size()) << "queue size 4.2";
|
||||
|
||||
|
||||
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("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( 4, engine->executor.size()) << "queue size 4";
|
||||
engine->executor.clear();
|
||||
ASSERT_EQ( 4, engine->scheduler.size()) << "queue size 4";
|
||||
engine->scheduler.clear();
|
||||
|
||||
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
|
||||
engine->executor.clear();
|
||||
engine->scheduler.clear();
|
||||
|
||||