The Big Refactoring of 2019: scheduler should not be global #655
This commit is contained in:
parent
3a52b14502
commit
7989763ee9
|
@ -156,15 +156,6 @@ void SingleTimerExecutor::scheduleTimerCallback() {
|
||||||
hwSetTimerDuration = GET_TIMESTAMP() - beforeHwSetTimer;
|
hwSetTimerDuration = GET_TIMESTAMP() - beforeHwSetTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Schedule an event at specified timestamp
|
|
||||||
*
|
|
||||||
* @param [in] timeUs absolute time of the event, since ECU boot
|
|
||||||
*/
|
|
||||||
void scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, void *param) {
|
|
||||||
_engine.executor.scheduleByTimestamp(scheduling, time, callback, param);
|
|
||||||
}
|
|
||||||
|
|
||||||
void initSignalExecutorImpl(void) {
|
void initSignalExecutorImpl(void) {
|
||||||
globalTimerCallback = executorCallback;
|
globalTimerCallback = executorCallback;
|
||||||
initMicrosecondTimer();
|
initMicrosecondTimer();
|
||||||
|
|
|
@ -223,10 +223,10 @@ static void timerCallback(PwmConfig *state) {
|
||||||
efiAssertVoid(CUSTOM_ERR_6581, state->dbgNestingLevel < 25, "PWM nesting issue");
|
efiAssertVoid(CUSTOM_ERR_6581, state->dbgNestingLevel < 25, "PWM nesting issue");
|
||||||
|
|
||||||
efitimeus_t switchTimeUs = state->togglePwmState();
|
efitimeus_t switchTimeUs = state->togglePwmState();
|
||||||
// if (state->executor == NULL) {
|
if (state->executor == NULL) {
|
||||||
// firmwareError(CUSTOM_ERR_6695, "exec on %s", state->name);
|
firmwareError(CUSTOM_ERR_6695, "exec on %s", state->name);
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
state->executor->scheduleByTimestamp(&state->scheduling, switchTimeUs, (schfunc_t) timerCallback, state);
|
state->executor->scheduleByTimestamp(&state->scheduling, switchTimeUs, (schfunc_t) timerCallback, state);
|
||||||
state->dbgNestingLevel--;
|
state->dbgNestingLevel--;
|
||||||
|
|
|
@ -14,6 +14,10 @@ EventQueue schedulingQueue;
|
||||||
|
|
||||||
bool_t debugSignalExecutor = false;
|
bool_t debugSignalExecutor = false;
|
||||||
|
|
||||||
|
TestExecutor::TestExecutor() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void TestExecutor::scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) {
|
void TestExecutor::scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) {
|
||||||
if (debugSignalExecutor) {
|
if (debugSignalExecutor) {
|
||||||
printf("scheduleTask %d\r\n", delayUs);
|
printf("scheduleTask %d\r\n", delayUs);
|
||||||
|
@ -21,6 +25,11 @@ void TestExecutor::scheduleForLater(scheduling_s *scheduling, int delayUs, schfu
|
||||||
scheduleByTimestamp(scheduling, getTimeNowUs() + delayUs, callback, param);
|
scheduleByTimestamp(scheduling, getTimeNowUs() + delayUs, callback, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TestExecutor::clear() {
|
||||||
|
schedulingQueue.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void TestExecutor::scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param) {
|
void TestExecutor::scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param) {
|
||||||
if (debugSignalExecutor) {
|
if (debugSignalExecutor) {
|
||||||
printf("scheduleByTime %d\r\n", timeUs);
|
printf("scheduleByTime %d\r\n", timeUs);
|
||||||
|
@ -28,14 +37,6 @@ void TestExecutor::scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t tim
|
||||||
schedulingQueue.insertTask(scheduling, timeUs, callback, param);
|
schedulingQueue.insertTask(scheduling, timeUs, callback, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
void scheduleByTimestamp(scheduling_s *scheduling,
|
|
||||||
efitimeus_t timeUs, schfunc_t callback, void *param) {
|
|
||||||
if (debugSignalExecutor) {
|
|
||||||
printf("scheduleByTime %d\r\n", timeUs);
|
|
||||||
}
|
|
||||||
schedulingQueue.insertTask(scheduling, timeUs, callback, param);
|
|
||||||
}
|
|
||||||
|
|
||||||
void initSignalExecutorImpl(void) {
|
void initSignalExecutorImpl(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,10 @@
|
||||||
|
|
||||||
class TestExecutor : public ExecutorInterface {
|
class TestExecutor : public ExecutorInterface {
|
||||||
public:
|
public:
|
||||||
|
TestExecutor();
|
||||||
void scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param);
|
void scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param);
|
||||||
void scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param);
|
void scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param);
|
||||||
|
void clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* GLOBAL_EXECUTION_QUEUE_H_ */
|
#endif /* GLOBAL_EXECUTION_QUEUE_H_ */
|
||||||
|
|
|
@ -381,7 +381,7 @@ void testRpmCalculator(void) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
schedulingQueue.clear();
|
engine->executor.clear();
|
||||||
|
|
||||||
eth.fireFall(5);
|
eth.fireFall(5);
|
||||||
eth.fireRise(5);
|
eth.fireRise(5);
|
||||||
|
@ -391,7 +391,7 @@ void testRpmCalculator(void) {
|
||||||
assertEqualsM("ev 3", start + 13333 - 1515, schedulingQueue.getForUnitText(0)->momentX);
|
assertEqualsM("ev 3", start + 13333 - 1515, schedulingQueue.getForUnitText(0)->momentX);
|
||||||
assertEqualsM2("ev 5", start + 14277, schedulingQueue.getForUnitText(1)->momentX, 2);
|
assertEqualsM2("ev 5", start + 14277, schedulingQueue.getForUnitText(1)->momentX, 2);
|
||||||
assertEqualsM("3/3", start + 14777, schedulingQueue.getForUnitText(2)->momentX);
|
assertEqualsM("3/3", start + 14777, schedulingQueue.getForUnitText(2)->momentX);
|
||||||
schedulingQueue.clear();
|
engine->executor.clear();
|
||||||
|
|
||||||
assertEquals(5, TRIGGER_SHAPE(triggerIndexByAngle[240]));
|
assertEquals(5, TRIGGER_SHAPE(triggerIndexByAngle[240]));
|
||||||
assertEquals(5, TRIGGER_SHAPE(triggerIndexByAngle[241]));
|
assertEquals(5, TRIGGER_SHAPE(triggerIndexByAngle[241]));
|
||||||
|
|
Loading…
Reference in New Issue