better name & dead parameter

This commit is contained in:
rusefi 2018-02-06 01:41:05 +03:00
parent 69697833a8
commit f02258538a
4 changed files with 19 additions and 15 deletions

View File

@ -669,7 +669,7 @@ uint32_t findTriggerZeroEventIndex(TriggerState *state, TriggerShape * shape,
// todo: should this variable be declared 'static' to reduce stack usage?
TriggerStimulatorHelper helper;
uint32_t syncIndex = helper.doFindTrigger(shape, triggerConfig, state PASS_ENGINE_PARAMETER_SUFFIX);
uint32_t syncIndex = helper.findTriggerSyncPoint(shape, state PASS_ENGINE_PARAMETER_SUFFIX);
if (syncIndex == EFI_ERROR_CODE) {
isInitializingTrigger = false;
return syncIndex;

View File

@ -45,7 +45,7 @@ void TriggerEmulatorHelper::handleEmulatorCallback(PwmConfig *state, int stateIn
bool thirdWheelState = state->multiWave.waves[2].pinStates[prevIndex];
int new3rdWheelState = state->multiWave.waves[2].pinStates[stateIndex];
// todo: code duplication with TriggerStimulatorHelper::nextStep?
// todo: code duplication with TriggerStimulatorHelper::feedSimulatedEvent?
if (primaryWheelState != newPrimaryWheelState) {
primaryWheelState = newPrimaryWheelState;

View File

@ -29,8 +29,8 @@ bool isUsefulSignal(trigger_event_e signal, engine_configuration_s *engineConfig
extern bool printTriggerDebug;
#endif /* ! EFI_UNIT_TEST */
void TriggerStimulatorHelper::nextStep(TriggerState *state, TriggerShape * shape, int i,
trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_SUFFIX) {
void TriggerStimulatorHelper::feedSimulatedEvent(TriggerState *state, TriggerShape * shape, int i
DECLARE_ENGINE_PARAMETER_SUFFIX) {
int stateIndex = i % shape->getSize();
int prevIndex = (stateIndex + shape->getSize() - 1 ) % shape->getSize();
@ -50,7 +50,7 @@ void TriggerStimulatorHelper::nextStep(TriggerState *state, TriggerShape * shape
#if EFI_UNIT_TEST || defined(__DOXYGEN__)
if (printTriggerDebug) {
printf("nextStep: %d>%d primary %d>%d secondary %d>%d\r\n", prevIndex, stateIndex, primaryWheelState, newPrimaryWheelState,
printf("feedSimulatedEvent: %d>%d primary %d>%d secondary %d>%d\r\n", prevIndex, stateIndex, primaryWheelState, newPrimaryWheelState,
secondaryWheelState, newSecondaryWheelState );
}
#endif /* EFI_UNIT_TEST */
@ -82,10 +82,12 @@ void TriggerStimulatorHelper::nextStep(TriggerState *state, TriggerShape * shape
void TriggerStimulatorHelper::assertSyncPositionAndSetDutyCycle(const uint32_t syncIndex, TriggerState *state, TriggerShape * shape,
trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_SUFFIX) {
int startIndex = syncIndex + 1;
for (uint32_t i = startIndex; i <= syncIndex + 2 * shape->getSize(); i++) {
nextStep(state, shape, i, triggerConfig PASS_ENGINE_PARAMETER_SUFFIX);
/**
* let's feed two more cycles to validate shape definition
*/
for (uint32_t i = syncIndex + 1; i <= syncIndex + 2 * shape->getSize(); i++) {
feedSimulatedEvent(state, shape, i PASS_ENGINE_PARAMETER_SUFFIX);
}
int revolutionCounter = state->getTotalRevolutionCounter();
if (revolutionCounter != 3) {
@ -103,10 +105,10 @@ void TriggerStimulatorHelper::assertSyncPositionAndSetDutyCycle(const uint32_t s
/**
* @return trigger synchronization point index, or error code if not found
*/
uint32_t TriggerStimulatorHelper::doFindTrigger(TriggerShape * shape,
trigger_config_s const*triggerConfig, TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX) {
uint32_t TriggerStimulatorHelper::findTriggerSyncPoint(TriggerShape * shape,
TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX) {
for (int i = 0; i < 4 * PWM_PHASE_MAX_COUNT; i++) {
nextStep(state, shape, i, triggerConfig PASS_ENGINE_PARAMETER_SUFFIX);
feedSimulatedEvent(state, shape, i PASS_ENGINE_PARAMETER_SUFFIX);
if (state->shaft_is_synchronized)
return i;

View File

@ -15,13 +15,15 @@ class TriggerStimulatorHelper {
public:
TriggerStimulatorHelper();
uint32_t doFindTrigger(TriggerShape * shape,
trigger_config_s const*triggerConfig, TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX);
void nextStep(TriggerState *state, TriggerShape * shape, int i, trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_SUFFIX);
uint32_t findTriggerSyncPoint(TriggerShape * shape,
TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX);
void assertSyncPositionAndSetDutyCycle(const uint32_t index, TriggerState *state, TriggerShape * shape,
trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_SUFFIX);
private:
// send next event so that we can see how state reacts
void feedSimulatedEvent(TriggerState *state, TriggerShape * shape, int i DECLARE_ENGINE_PARAMETER_SUFFIX);
};
bool isUsefulSignal(trigger_event_e signal, engine_configuration_s *engineConfiguration);