toothed previous time #4019
This commit is contained in:
parent
e343989f5b
commit
b1de262520
|
@ -284,6 +284,7 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index) {
|
|||
TriggerState *vvtState = &tc->vvtState[bankIndex][camIndex];
|
||||
|
||||
vvtState->decodeTriggerEvent(
|
||||
"vvt",
|
||||
tc->vvtShape[camIndex],
|
||||
nullptr,
|
||||
nullptr,
|
||||
|
@ -617,7 +618,9 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
|
|||
/**
|
||||
* This invocation changes the state of triggerState
|
||||
*/
|
||||
triggerState.decodeTriggerEvent(triggerShape,
|
||||
triggerState.decodeTriggerEvent(
|
||||
"trigger",
|
||||
triggerShape,
|
||||
nullptr,
|
||||
engine,
|
||||
engine->primaryTriggerConfiguration,
|
||||
|
|
|
@ -477,6 +477,7 @@ void TriggerState::onShaftSynchronization(
|
|||
* @param nowNt current time
|
||||
*/
|
||||
void TriggerState::decodeTriggerEvent(
|
||||
const char *msg,
|
||||
const TriggerWaveform& triggerShape,
|
||||
const TriggerStateCallback triggerCycleCallback,
|
||||
TriggerStateListener* triggerStateListener,
|
||||
|
@ -513,7 +514,7 @@ void TriggerState::decodeTriggerEvent(
|
|||
currentCycle.eventCount[triggerWheel]++;
|
||||
|
||||
if (toothed_previous_time > nowNt) {
|
||||
firmwareError(CUSTOM_OBD_93, "toothed_previous_time after nowNt %d %d", toothed_previous_time, nowNt);
|
||||
firmwareError(CUSTOM_OBD_93, "[%s] toothed_previous_time after nowNt prev=%d now=%d", msg, toothed_previous_time, nowNt);
|
||||
}
|
||||
|
||||
efitick_t currentDurationLong = isFirstEvent ? 0 : nowNt - toothed_previous_time;
|
||||
|
|
|
@ -91,6 +91,7 @@ public:
|
|||
efitime_t getTotalEventCounter() const;
|
||||
|
||||
void decodeTriggerEvent(
|
||||
const char *msg,
|
||||
const TriggerWaveform& triggerShape,
|
||||
const TriggerStateCallback triggerCycleCallback,
|
||||
TriggerStateListener* triggerStateListener,
|
||||
|
|
|
@ -80,7 +80,9 @@ void TriggerStimulatorHelper::feedSimulatedEvent(
|
|||
pin_state_t currentValue = multiChannelStateSequence.getChannelState(/*phaseIndex*/i, stateIndex);
|
||||
trigger_event_e event = (currentValue ? riseEvents : fallEvents)[i];
|
||||
if (isUsefulSignal(event, triggerConfiguration)) {
|
||||
state.decodeTriggerEvent(shape,
|
||||
state.decodeTriggerEvent(
|
||||
"sim",
|
||||
shape,
|
||||
triggerCycleCallback,
|
||||
/* override */ nullptr,
|
||||
triggerConfiguration,
|
||||
|
|
|
@ -120,28 +120,28 @@ TEST(trigger, testSomethingWeird) {
|
|||
|
||||
ASSERT_FALSE(sta->shaft_is_synchronized) << "shaft_is_synchronized";
|
||||
int r = 10;
|
||||
sta->decodeTriggerEvent(engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_FALLING, r);
|
||||
sta->decodeTriggerEvent("t", engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_FALLING, r);
|
||||
ASSERT_FALSE(sta->shaft_is_synchronized) << "shaft_is_synchronized"; // still no synchronization
|
||||
sta->decodeTriggerEvent(engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_RISING, ++r);
|
||||
sta->decodeTriggerEvent("t", engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_RISING, ++r);
|
||||
ASSERT_TRUE(sta->shaft_is_synchronized); // first signal rise synchronize
|
||||
ASSERT_EQ(0, sta->getCurrentIndex());
|
||||
sta->decodeTriggerEvent(engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_FALLING, r++);
|
||||
sta->decodeTriggerEvent("t", engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_FALLING, r++);
|
||||
ASSERT_EQ(1, sta->getCurrentIndex());
|
||||
|
||||
for (int i = 2; i < 10;) {
|
||||
sta->decodeTriggerEvent(engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_RISING, r++);
|
||||
sta->decodeTriggerEvent("t", engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_RISING, r++);
|
||||
assertEqualsM("even", i++, sta->getCurrentIndex());
|
||||
sta->decodeTriggerEvent(engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_FALLING, r++);
|
||||
sta->decodeTriggerEvent("t", engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_FALLING, r++);
|
||||
assertEqualsM("odd", i++, sta->getCurrentIndex());
|
||||
}
|
||||
|
||||
sta->decodeTriggerEvent(engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_RISING, r++);
|
||||
sta->decodeTriggerEvent("test", engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_RISING, r++);
|
||||
ASSERT_EQ(10, sta->getCurrentIndex());
|
||||
|
||||
sta->decodeTriggerEvent(engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_FALLING, r++);
|
||||
sta->decodeTriggerEvent("test", engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_FALLING, r++);
|
||||
ASSERT_EQ(11, sta->getCurrentIndex());
|
||||
|
||||
sta->decodeTriggerEvent(engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_RISING, r++);
|
||||
sta->decodeTriggerEvent("test", engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_RISING, r++);
|
||||
ASSERT_EQ(0, sta->getCurrentIndex()); // new revolution
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue