trigger refactoring
This commit is contained in:
parent
241d491625
commit
a53d9c587a
|
@ -708,7 +708,7 @@ uint32_t TriggerState::findTriggerZeroEventIndex(TriggerWaveform * shape,
|
||||||
* todo: add a comment why are we doing '2 * shape->getSize()' here?
|
* todo: add a comment why are we doing '2 * shape->getSize()' here?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
helper.assertSyncPositionAndSetDutyCycle(onFindIndexCallback, syncIndex, this, shape PASS_ENGINE_PARAMETER_SUFFIX);
|
helper.assertSyncPositionAndSetDutyCycle(onFindIndexCallback, syncIndex, this, shape PASS_CONFIG_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
return syncIndex % shape->getSize();
|
return syncIndex % shape->getSize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ extern bool printTriggerDebug;
|
||||||
|
|
||||||
void TriggerStimulatorHelper::feedSimulatedEvent(const TriggerStateCallback triggerCycleCallback,
|
void TriggerStimulatorHelper::feedSimulatedEvent(const TriggerStateCallback triggerCycleCallback,
|
||||||
TriggerState *state, TriggerWaveform * shape, int i
|
TriggerState *state, TriggerWaveform * shape, int i
|
||||||
DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
DECLARE_CONFIG_PARAMETER_SUFFIX) {
|
||||||
efiAssertVoid(CUSTOM_ERR_6593, shape->getSize() > 0, "size not zero");
|
efiAssertVoid(CUSTOM_ERR_6593, shape->getSize() > 0, "size not zero");
|
||||||
int stateIndex = i % shape->getSize();
|
int stateIndex = i % shape->getSize();
|
||||||
int size = shape->getSize();
|
int size = shape->getSize();
|
||||||
|
@ -64,7 +64,7 @@ void TriggerStimulatorHelper::feedSimulatedEvent(const TriggerStateCallback trig
|
||||||
pin_state_t currentValue = multiChannelStateSequence->getChannelState(/*phaseIndex*/0, stateIndex);
|
pin_state_t currentValue = multiChannelStateSequence->getChannelState(/*phaseIndex*/0, stateIndex);
|
||||||
trigger_event_e s = currentValue ? SHAFT_PRIMARY_RISING : SHAFT_PRIMARY_FALLING;
|
trigger_event_e s = currentValue ? SHAFT_PRIMARY_RISING : SHAFT_PRIMARY_FALLING;
|
||||||
if (isUsefulSignal(s PASS_CONFIG_PARAMETER_SUFFIX)) {
|
if (isUsefulSignal(s PASS_CONFIG_PARAMETER_SUFFIX)) {
|
||||||
state->decodeTriggerEvent(&ENGINE(triggerCentral.triggerShape),
|
state->decodeTriggerEvent(shape,
|
||||||
triggerCycleCallback,
|
triggerCycleCallback,
|
||||||
/* override */ nullptr,
|
/* override */ nullptr,
|
||||||
s, time PASS_CONFIG_PARAMETER_SUFFIX);
|
s, time PASS_CONFIG_PARAMETER_SUFFIX);
|
||||||
|
@ -75,7 +75,7 @@ void TriggerStimulatorHelper::feedSimulatedEvent(const TriggerStateCallback trig
|
||||||
pin_state_t currentValue = multiChannelStateSequence->getChannelState(/*phaseIndex*/1, stateIndex);
|
pin_state_t currentValue = multiChannelStateSequence->getChannelState(/*phaseIndex*/1, stateIndex);
|
||||||
trigger_event_e s = currentValue ? SHAFT_SECONDARY_RISING : SHAFT_SECONDARY_FALLING;
|
trigger_event_e s = currentValue ? SHAFT_SECONDARY_RISING : SHAFT_SECONDARY_FALLING;
|
||||||
if (isUsefulSignal(s PASS_CONFIG_PARAMETER_SUFFIX)) {
|
if (isUsefulSignal(s PASS_CONFIG_PARAMETER_SUFFIX)) {
|
||||||
state->decodeTriggerEvent(&ENGINE(triggerCentral.triggerShape),
|
state->decodeTriggerEvent(shape,
|
||||||
triggerCycleCallback,
|
triggerCycleCallback,
|
||||||
/* override */ nullptr,
|
/* override */ nullptr,
|
||||||
s, time PASS_CONFIG_PARAMETER_SUFFIX);
|
s, time PASS_CONFIG_PARAMETER_SUFFIX);
|
||||||
|
@ -86,7 +86,7 @@ void TriggerStimulatorHelper::feedSimulatedEvent(const TriggerStateCallback trig
|
||||||
pin_state_t currentValue = multiChannelStateSequence->getChannelState(/*phaseIndex*/2, stateIndex);
|
pin_state_t currentValue = multiChannelStateSequence->getChannelState(/*phaseIndex*/2, stateIndex);
|
||||||
trigger_event_e s = currentValue ? SHAFT_3RD_RISING : SHAFT_3RD_FALLING;
|
trigger_event_e s = currentValue ? SHAFT_3RD_RISING : SHAFT_3RD_FALLING;
|
||||||
if (isUsefulSignal(s PASS_CONFIG_PARAMETER_SUFFIX)) {
|
if (isUsefulSignal(s PASS_CONFIG_PARAMETER_SUFFIX)) {
|
||||||
state->decodeTriggerEvent(&ENGINE(triggerCentral.triggerShape),
|
state->decodeTriggerEvent(shape,
|
||||||
triggerCycleCallback,
|
triggerCycleCallback,
|
||||||
/* override */ nullptr,
|
/* override */ nullptr,
|
||||||
s, time PASS_CONFIG_PARAMETER_SUFFIX);
|
s, time PASS_CONFIG_PARAMETER_SUFFIX);
|
||||||
|
@ -96,13 +96,13 @@ void TriggerStimulatorHelper::feedSimulatedEvent(const TriggerStateCallback trig
|
||||||
|
|
||||||
void TriggerStimulatorHelper::assertSyncPositionAndSetDutyCycle(const TriggerStateCallback triggerCycleCallback,
|
void TriggerStimulatorHelper::assertSyncPositionAndSetDutyCycle(const TriggerStateCallback triggerCycleCallback,
|
||||||
const uint32_t syncIndex, TriggerState *state, TriggerWaveform * shape
|
const uint32_t syncIndex, TriggerState *state, TriggerWaveform * shape
|
||||||
DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
DECLARE_CONFIG_PARAMETER_SUFFIX) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* let's feed two more cycles to validate shape definition
|
* let's feed two more cycles to validate shape definition
|
||||||
*/
|
*/
|
||||||
for (uint32_t i = syncIndex + 1; i <= syncIndex + GAP_TRACKING_LENGTH * shape->getSize(); i++) {
|
for (uint32_t i = syncIndex + 1; i <= syncIndex + GAP_TRACKING_LENGTH * shape->getSize(); i++) {
|
||||||
feedSimulatedEvent(triggerCycleCallback, state, shape, i PASS_ENGINE_PARAMETER_SUFFIX);
|
feedSimulatedEvent(triggerCycleCallback, state, shape, i PASS_CONFIG_PARAMETER_SUFFIX);
|
||||||
}
|
}
|
||||||
int revolutionCounter = state->getTotalRevolutionCounter();
|
int revolutionCounter = state->getTotalRevolutionCounter();
|
||||||
if (revolutionCounter != GAP_TRACKING_LENGTH + 1) {
|
if (revolutionCounter != GAP_TRACKING_LENGTH + 1) {
|
||||||
|
@ -123,7 +123,7 @@ void TriggerStimulatorHelper::assertSyncPositionAndSetDutyCycle(const TriggerSta
|
||||||
uint32_t TriggerStimulatorHelper::findTriggerSyncPoint(TriggerWaveform * shape,
|
uint32_t TriggerStimulatorHelper::findTriggerSyncPoint(TriggerWaveform * shape,
|
||||||
TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
for (int i = 0; i < 4 * PWM_PHASE_MAX_COUNT; i++) {
|
for (int i = 0; i < 4 * PWM_PHASE_MAX_COUNT; i++) {
|
||||||
feedSimulatedEvent(nullptr, state, shape, i PASS_ENGINE_PARAMETER_SUFFIX);
|
feedSimulatedEvent(nullptr, state, shape, i PASS_CONFIG_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
if (state->shaft_is_synchronized)
|
if (state->shaft_is_synchronized)
|
||||||
return i;
|
return i;
|
||||||
|
|
|
@ -18,11 +18,12 @@ public:
|
||||||
|
|
||||||
void assertSyncPositionAndSetDutyCycle(const TriggerStateCallback triggerCycleCallback,
|
void assertSyncPositionAndSetDutyCycle(const TriggerStateCallback triggerCycleCallback,
|
||||||
const uint32_t index, TriggerState *state, TriggerWaveform * shape
|
const uint32_t index, TriggerState *state, TriggerWaveform * shape
|
||||||
DECLARE_ENGINE_PARAMETER_SUFFIX);
|
DECLARE_CONFIG_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// send next event so that we can see how state reacts
|
// send next event so that we can see how state reacts
|
||||||
void feedSimulatedEvent(const TriggerStateCallback triggerCycleCallback, TriggerState *state, TriggerWaveform * shape, int i DECLARE_ENGINE_PARAMETER_SUFFIX);
|
void feedSimulatedEvent(const TriggerStateCallback triggerCycleCallback, TriggerState *state,
|
||||||
|
TriggerWaveform * shape, int i DECLARE_CONFIG_PARAMETER_SUFFIX);
|
||||||
};
|
};
|
||||||
|
|
||||||
bool isUsefulSignal(trigger_event_e signal DECLARE_CONFIG_PARAMETER_SUFFIX);
|
bool isUsefulSignal(trigger_event_e signal DECLARE_CONFIG_PARAMETER_SUFFIX);
|
||||||
|
|
Loading…
Reference in New Issue