better method names

This commit is contained in:
rusefi 2018-01-28 11:27:33 -05:00
parent c34a9419ca
commit d9acdd6a70
12 changed files with 36 additions and 31 deletions

View File

@ -73,7 +73,7 @@ static void testCallback(void *arg) {
/**
* this would re-schedule another callback in 2ms from now
*/
scheduleTask("test", &ioTest, MS2US(2), testCallback, NULL);
scheduleForLater("test", &ioTest, MS2US(2), testCallback, NULL);
}
void initPwmTester(void) {
@ -97,7 +97,7 @@ void initPwmTester(void) {
/**
* this would schedule a callback in 2ms from now
*/
scheduleTask("test", &ioTest, MS2US(2), testCallback, NULL);
scheduleForLater("test", &ioTest, MS2US(2), testCallback, NULL);
}
#endif

View File

@ -60,7 +60,7 @@ Executor::Executor() {
queue.setLateDelay(US2NT(100));
}
void Executor::scheduleByTime(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback,
void Executor::scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback,
void *param) {
scheduleCounter++;
// if (delayUs < 0) {
@ -149,7 +149,7 @@ void Executor::scheduleTimerCallback() {
}
/**
* @brief Schedule an event
* @brief Schedule an event at specific delay after now
*
* Invokes event callback after the specified amount of time.
*
@ -157,12 +157,17 @@ void Executor::scheduleTimerCallback() {
* @param [in] delayUs the number of microseconds before the output signal immediate output if delay is zero.
* @param [in] dwell the number of ticks of output duration.
*/
void scheduleTask(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) {
instance.scheduleByTime(scheduling, getTimeNowUs() + delayUs, callback, param);
void scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) {
instance.scheduleByTimestamp(scheduling, getTimeNowUs() + delayUs, callback, param);
}
void scheduleByTime(scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, void *param) {
instance.scheduleByTime(scheduling, time, callback, param);
/**
* @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) {
instance.scheduleByTimestamp(scheduling, time, callback, param);
}
void initSignalExecutorImpl(void) {

View File

@ -14,7 +14,7 @@
class Executor {
public:
Executor();
void scheduleByTime(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 onTimerCallback();
int timerCallbackCounter;
int scheduleCounter;

View File

@ -294,7 +294,7 @@ bool OutputPin::isInitialized() {
#endif /* EFI_GPIO_HARDWARE */
}
void OutputPin::oggle() {
void OutputPin::toggle() {
setValue(!getLogicValue());
}

View File

@ -171,7 +171,7 @@ static void timerCallback(PwmConfig *state) {
efiAssertVoid(state->dbgNestingLevel < 25, "PWM nesting issue");
efitimeus_t switchTimeUs = state->togglePwmState();
scheduleByTime(&state->scheduling, switchTimeUs, (schfunc_t) timerCallback, state);
scheduleByTimestamp(&state->scheduling, switchTimeUs, (schfunc_t) timerCallback, state);
state->dbgNestingLevel--;
}

View File

@ -29,7 +29,7 @@ public:
/**
* see also scheduleByAngle
*/
void scheduleTask(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param);
void scheduleByTime(scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, void *param);
void scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param);
void scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, void *param);
#endif /* SCHEDULER_H_ */

View File

@ -34,8 +34,8 @@
#if EFI_SIGNAL_EXECUTOR_SLEEP || defined(__DOXYGEN__)
void scheduleByTime(scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, void *param) {
scheduleTask(scheduling, time - getTimeNowUs(), callback, param);
void scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, void *param) {
scheduleForLater(scheduling, time - getTimeNowUs(), callback, param);
}
static void timerCallback(scheduling_s *scheduling) {
@ -52,7 +52,7 @@ static void timerCallback(scheduling_s *scheduling) {
}
void scheduleTask(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) {
void scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) {
int delaySt = MY_US2ST(delayUs);
if (delaySt <= 0) {
/**

View File

@ -34,7 +34,7 @@ static void tachSignalCallback(trigger_event_e ckpSignalType,
} else {
durationMs = engineConfiguration->tachPulseDuractionMs;
}
scheduleTask(&tachTurnSignalOff, (int)MS2US(durationMs), (schfunc_t) &turnTachPinLow, NULL);
scheduleForLater(&tachTurnSignalOff, (int)MS2US(durationMs), (schfunc_t) &turnTachPinLow, NULL);
}
void initTachometer(void) {

View File

@ -195,7 +195,7 @@ void seTurnPinLow(InjectionSignalPair *pair) {
ENGINE(injectionEvents.addFuelEventsForCylinder(pair->event->ownIndex PASS_ENGINE_PARAMETER_SUFFIX));
}
static void seScheduleByTime(scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, InjectionSignalPair *pair) {
static void sescheduleByTimestamp(scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, InjectionSignalPair *pair) {
#if FUEL_MATH_EXTREME_LOGGING || defined(__DOXYGEN__)
InjectorOutputPin *param = pair->outputs[0];
// scheduleMsg(&sharedLogger, "schX %s %x %d", prefix, scheduling, time);
@ -205,7 +205,7 @@ static void seScheduleByTime(scheduling_s *scheduling, efitimeus_t time, schfunc
printf("seScheduleByTime %s %s %d sch=%d\r\n", direction, param->name, (int)time, (int)scheduling);
#endif /* FUEL_MATH_EXTREME_LOGGING || EFI_UNIT_TEST */
scheduleByTime(scheduling, time, callback, pair);
scheduleByTimestamp(scheduling, time, callback, pair);
}
static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionEvent *event,
@ -276,8 +276,8 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
// todo: sequential need this logic as well, just do not forget to clear flag pair->isScheduled = true;
scheduling_s * sDown = &pair->signalTimerDown;
scheduleTask(sUp, (int) injectionStartDelayUs, (schfunc_t) &startSimultaniousInjection, engine);
scheduleTask(sDown, (int) injectionStartDelayUs + durationUs,
scheduleForLater(sUp, (int) injectionStartDelayUs, (schfunc_t) &startSimultaniousInjection, engine);
scheduleForLater(sDown, (int) injectionStartDelayUs + durationUs,
(schfunc_t) &endSimultaniousInjection, event);
} else {
@ -328,10 +328,10 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
printf("please cancel %s %d %d\r\n", output->name, (int)getTimeNowUs(), output->overlappingCounter);
#endif /* EFI_UNIT_TEST || EFI_SIMULATOR */
} else {
seScheduleByTime(sUp, turnOnTime, (schfunc_t) &seTurnPinHigh, pair);
sescheduleByTimestamp(sUp, turnOnTime, (schfunc_t) &seTurnPinHigh, pair);
}
efitimeus_t turnOffTime = nowUs + (int) (injectionStartDelayUs + durationUs);
seScheduleByTime(sDown, turnOffTime, (schfunc_t) &seTurnPinLow, pair);
sescheduleByTimestamp(sDown, turnOffTime, (schfunc_t) &seTurnPinLow, pair);
}
}
@ -545,7 +545,7 @@ static void startPrimeInjectionPulse(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (pulseLength > 0) {
startSimultaniousInjection(engine);
efitimeus_t turnOffDelayUs = (efitimeus_t)efiRound(MS2US(pulseLength), 1.0f);
scheduleTask(sDown, turnOffDelayUs, (schfunc_t) &endSimultaniousInjectionOnlyTogglePins, engine);
scheduleForLater(sDown, turnOffDelayUs, (schfunc_t) &endSimultaniousInjectionOnlyTogglePins, engine);
}
}
// we'll reset it later when the engine starts

View File

@ -318,7 +318,7 @@ void scheduleByAngle(int rpm, scheduling_s *timer, angle_t angle,
efiAssertVoid(isValidRpm(rpm), "RPM check expected");
float delayUs = calc->oneDegreeUs * angle;
efiAssertVoid(!cisnan(delayUs), "NaN delay?");
scheduleTask(timer, (int) delayUs, callback, param);
scheduleForLater(timer, (int) delayUs, callback, param);
}
#endif

View File

@ -166,7 +166,7 @@ static ALWAYS_INLINE void handleSparkEvent(bool limitedSpark, uint32_t trgEventI
* This way we make sure that coil dwell started while spark was enabled would fire and not burn
* the coil.
*/
scheduleTask(sUp, chargeDelayUs, (schfunc_t) &turnSparkPinHigh, iEvent);
scheduleForLater(sUp, chargeDelayUs, (schfunc_t) &turnSparkPinHigh, iEvent);
}
/**
* Spark event is often happening during a later trigger event timeframe
@ -192,7 +192,7 @@ static ALWAYS_INLINE void handleSparkEvent(bool limitedSpark, uint32_t trgEventI
scheduleMsg(logger, "scheduling sparkDown ind=%d %d %s now=%d %d later id=%d", trgEventIndex, getRevolutionCounter(), iEvent->getOutputForLoggins()->name, (int)getTimeNowUs(), (int)timeTillIgnitionUs, iEvent->sparkId);
#endif /* FUEL_MATH_EXTREME_LOGGING */
scheduleTask(sDown, (int) timeTillIgnitionUs, (schfunc_t) &turnSparkPinLow, iEvent);
scheduleForLater(sDown, (int) timeTillIgnitionUs, (schfunc_t) &turnSparkPinLow, iEvent);
} else {
#if SPARK_EXTREME_LOGGING || defined(__DOXYGEN__)
scheduleMsg(logger, "to queue sparkDown ind=%d %d %s %d for %d", trgEventIndex, getRevolutionCounter(), iEvent->getOutputForLoggins()->name, (int)getTimeNowUs(), iEvent->sparkPosition.eventIndex);
@ -340,7 +340,7 @@ void handleSpark(bool limitedSpark, uint32_t trgEventIndex, int rpm
float timeTillIgnitionUs = ENGINE(rpmCalculator.oneDegreeUs) * current->sparkPosition.angleOffset;
scheduleTask(sDown, (int) timeTillIgnitionUs, (schfunc_t) &turnSparkPinLow, current);
scheduleForLater(sDown, (int) timeTillIgnitionUs, (schfunc_t) &turnSparkPinLow, current);
}
}

View File

@ -18,15 +18,15 @@ EventQueue schedulingQueue;
bool_t debugSignalExecutor = false;
void scheduleTask(scheduling_s *scheduling, int delayUs,
void scheduleForLater(scheduling_s *scheduling, int delayUs,
schfunc_t callback, void *param) {
if (debugSignalExecutor) {
printf("scheduleTask %d\r\n", delayUs);
}
scheduleByTime(scheduling, getTimeNowUs() + delayUs, callback, param);
scheduleByTimestamp(scheduling, getTimeNowUs() + delayUs, callback, param);
}
void scheduleByTime(scheduling_s *scheduling,
void scheduleByTimestamp(scheduling_s *scheduling,
efitimeus_t time, schfunc_t callback, void *param) {
if (debugSignalExecutor) {
printf("scheduleByTime %d\r\n", time);