TriggerState -> TriggerDecoder (#4157)

This commit is contained in:
Matthew Kennedy 2022-05-10 01:41:39 -07:00 committed by GitHub
parent 7e0f2d8337
commit d4509cab8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 59 additions and 60 deletions

View File

@ -106,7 +106,7 @@ static operation_mode_e lookupOperationMode() {
} }
} }
static void initVvtShape(int camIndex, TriggerState &initState) { static void initVvtShape(int camIndex, TriggerDecoderBase &initState) {
vvt_mode_e vvtMode = engineConfiguration->vvtMode[camIndex]; vvt_mode_e vvtMode = engineConfiguration->vvtMode[camIndex];
if (vvtMode != VVT_INACTIVE) { if (vvtMode != VVT_INACTIVE) {
@ -126,7 +126,7 @@ static void initVvtShape(int camIndex, TriggerState &initState) {
} }
void Engine::updateTriggerWaveform() { void Engine::updateTriggerWaveform() {
static TriggerState initState; static TriggerDecoderBase initState;
// Re-read config in case it's changed // Re-read config in case it's changed
primaryTriggerConfiguration.update(); primaryTriggerConfiguration.update();
@ -165,7 +165,7 @@ void Engine::updateTriggerWaveform() {
if (!TRIGGER_WAVEFORM(shapeDefinitionError)) { if (!TRIGGER_WAVEFORM(shapeDefinitionError)) {
/** /**
* 'initState' instance of TriggerState is used only to initialize 'this' TriggerWaveform instance * 'initState' instance of TriggerDecoderBase is used only to initialize 'this' TriggerWaveform instance
* #192 BUG real hardware trigger events could be coming even while we are initializing trigger * #192 BUG real hardware trigger events could be coming even while we are initializing trigger
*/ */
calculateTriggerSynchPoint(engine->triggerCentral.triggerShape, calculateTriggerSynchPoint(engine->triggerCentral.triggerShape,

View File

@ -61,7 +61,7 @@ public:
#define TRIGGER_CHANNEL_COUNT 3 #define TRIGGER_CHANNEL_COUNT 3
class Engine; class Engine;
class TriggerState; class TriggerDecoderBase;
class TriggerFormDetails; class TriggerFormDetails;
class TriggerConfiguration; class TriggerConfiguration;
@ -264,7 +264,7 @@ public:
int triggerShapeSynchPointIndex; int triggerShapeSynchPointIndex;
void initializeSyncPoint( void initializeSyncPoint(
TriggerState& state, TriggerDecoderBase& state,
const TriggerConfiguration& triggerConfiguration, const TriggerConfiguration& triggerConfiguration,
const trigger_config_s& triggerConfig const trigger_config_s& triggerConfig
); );

View File

@ -286,9 +286,9 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index) {
} }
if (isVvtWithRealDecoder) { if (isVvtWithRealDecoder) {
TriggerState *vvtState = &tc->vvtState[bankIndex][camIndex]; TriggerDecoderBase& vvtDecoder = tc->vvtState[bankIndex][camIndex];
vvtState->decodeTriggerEvent( vvtDecoder.decodeTriggerEvent(
"vvt", "vvt",
tc->vvtShape[camIndex], tc->vvtShape[camIndex],
nullptr, nullptr,
@ -296,8 +296,8 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index) {
engine->vvtTriggerConfiguration[camIndex], engine->vvtTriggerConfiguration[camIndex],
front == TV_RISE ? SHAFT_PRIMARY_RISING : SHAFT_PRIMARY_FALLING, nowNt); front == TV_RISE ? SHAFT_PRIMARY_RISING : SHAFT_PRIMARY_FALLING, nowNt);
// yes we log data from all VVT channels into same fields for now // yes we log data from all VVT channels into same fields for now
tc->triggerState.vvtSyncGapRatio = vvtState->triggerSyncGapRatio; tc->triggerState.vvtSyncGapRatio = vvtDecoder.triggerSyncGapRatio;
tc->triggerState.vvtStateIndex = vvtState->currentCycle.current_index; tc->triggerState.vvtStateIndex = vvtDecoder.currentCycle.current_index;
} }
tc->vvtCamCounter++; tc->vvtCamCounter++;
@ -529,7 +529,7 @@ static void reportEventToWaveChart(trigger_event_e ckpSignalType, int index) {
* @return true if the signal is passed through. * @return true if the signal is passed through.
*/ */
bool TriggerNoiseFilter::noiseFilter(efitick_t nowNt, bool TriggerNoiseFilter::noiseFilter(efitick_t nowNt,
TriggerState * triggerState, TriggerDecoderBase * triggerState,
trigger_event_e signal) { trigger_event_e signal) {
// todo: find a better place for these defs // todo: find a better place for these defs
static const trigger_event_e opposite[6] = { SHAFT_PRIMARY_RISING, SHAFT_PRIMARY_FALLING, SHAFT_SECONDARY_RISING, SHAFT_SECONDARY_FALLING, static const trigger_event_e opposite[6] = { SHAFT_PRIMARY_RISING, SHAFT_PRIMARY_FALLING, SHAFT_SECONDARY_RISING, SHAFT_SECONDARY_FALLING,

View File

@ -31,7 +31,7 @@ class TriggerNoiseFilter {
public: public:
void resetAccumSignalData(); void resetAccumSignalData();
bool noiseFilter(efitick_t nowNt, bool noiseFilter(efitick_t nowNt,
TriggerState * triggerState, TriggerDecoderBase* triggerState,
trigger_event_e signal); trigger_event_e signal);
efitick_t lastSignalTimes[HW_EVENT_TYPES]; efitick_t lastSignalTimes[HW_EVENT_TYPES];
@ -108,12 +108,12 @@ public:
angle_t vvtPosition[BANKS_COUNT][CAMS_PER_BANK]; angle_t vvtPosition[BANKS_COUNT][CAMS_PER_BANK];
#if EFI_SHAFT_POSITION_INPUT #if EFI_SHAFT_POSITION_INPUT
TriggerStateWithRunningStatistics triggerState; PrimaryTriggerDecoder triggerState;
#endif //EFI_SHAFT_POSITION_INPUT #endif //EFI_SHAFT_POSITION_INPUT
TriggerWaveform triggerShape; TriggerWaveform triggerShape;
TriggerState vvtState[BANKS_COUNT][CAMS_PER_BANK]; VvtTriggerDecoder vvtState[BANKS_COUNT][CAMS_PER_BANK];
TriggerWaveform vvtShape[CAMS_PER_BANK]; TriggerWaveform vvtShape[CAMS_PER_BANK];
TriggerFormDetails triggerFormDetails; TriggerFormDetails triggerFormDetails;

View File

@ -38,15 +38,15 @@
#include "sensor_chart.h" #include "sensor_chart.h"
#endif #endif
TriggerState::TriggerState() { TriggerDecoderBase::TriggerDecoderBase() {
resetTriggerState(); resetTriggerState();
} }
bool TriggerState::getShaftSynchronized() { bool TriggerDecoderBase::getShaftSynchronized() {
return shaft_is_synchronized; return shaft_is_synchronized;
} }
void TriggerState::setShaftSynchronized(bool value) { void TriggerDecoderBase::setShaftSynchronized(bool value) {
if (value) { if (value) {
if (!shaft_is_synchronized) { if (!shaft_is_synchronized) {
// just got synchronized // just got synchronized
@ -59,7 +59,7 @@ void TriggerState::setShaftSynchronized(bool value) {
shaft_is_synchronized = value; shaft_is_synchronized = value;
} }
void TriggerState::resetTriggerState() { void TriggerDecoderBase::resetTriggerState() {
setShaftSynchronized(false); setShaftSynchronized(false);
toothed_previous_time = 0; toothed_previous_time = 0;
@ -82,12 +82,12 @@ void TriggerState::resetTriggerState() {
isFirstEvent = true; isFirstEvent = true;
} }
void TriggerState::setTriggerErrorState() { void TriggerDecoderBase::setTriggerErrorState() {
lastDecodingErrorTime = getTimeNowNt(); lastDecodingErrorTime = getTimeNowNt();
someSortOfTriggerError = true; someSortOfTriggerError = true;
} }
void TriggerState::resetCurrentCycleState() { void TriggerDecoderBase::resetCurrentCycleState() {
memset(currentCycle.eventCount, 0, sizeof(currentCycle.eventCount)); memset(currentCycle.eventCount, 0, sizeof(currentCycle.eventCount));
memset(currentCycle.timeOfPreviousEventNt, 0, sizeof(currentCycle.timeOfPreviousEventNt)); memset(currentCycle.timeOfPreviousEventNt, 0, sizeof(currentCycle.timeOfPreviousEventNt));
#if EFI_UNIT_TEST #if EFI_UNIT_TEST
@ -99,7 +99,7 @@ void TriggerState::resetCurrentCycleState() {
#if EFI_SHAFT_POSITION_INPUT #if EFI_SHAFT_POSITION_INPUT
TriggerStateWithRunningStatistics::TriggerStateWithRunningStatistics() : PrimaryTriggerDecoder::PrimaryTriggerDecoder() :
//https://en.cppreference.com/w/cpp/language/zero_initialization //https://en.cppreference.com/w/cpp/language/zero_initialization
timeOfLastEvent(), instantRpmValue() timeOfLastEvent(), instantRpmValue()
{ {
@ -111,7 +111,7 @@ bool printTriggerTrace = false;
float actualSynchGap; float actualSynchGap;
#endif /* ! EFI_PROD_CODE */ #endif /* ! EFI_PROD_CODE */
void TriggerWaveform::initializeSyncPoint(TriggerState& state, void TriggerWaveform::initializeSyncPoint(TriggerDecoderBase& state,
const TriggerConfiguration& triggerConfiguration, const TriggerConfiguration& triggerConfiguration,
const trigger_config_s& triggerConfig) { const trigger_config_s& triggerConfig) {
triggerShapeSynchPointIndex = state.findTriggerZeroEventIndex(*this, triggerShapeSynchPointIndex = state.findTriggerZeroEventIndex(*this,
@ -119,11 +119,11 @@ void TriggerWaveform::initializeSyncPoint(TriggerState& state,
} }
/** /**
* Calculate 'shape.triggerShapeSynchPointIndex' value using 'TriggerState *state' * Calculate 'shape.triggerShapeSynchPointIndex' value using 'TriggerDecoderBase *state'
*/ */
void calculateTriggerSynchPoint( void calculateTriggerSynchPoint(
TriggerWaveform& shape, TriggerWaveform& shape,
TriggerState& state) { TriggerDecoderBase& state) {
state.resetTriggerState(); state.resetTriggerState();
#if EFI_PROD_CODE #if EFI_PROD_CODE
@ -209,16 +209,16 @@ void prepareEventAngles(TriggerWaveform *shape,
} }
} }
int64_t TriggerState::getTotalEventCounter() const { int64_t TriggerDecoderBase::getTotalEventCounter() const {
return totalEventCountBase + currentCycle.current_index; return totalEventCountBase + currentCycle.current_index;
} }
int TriggerState::getTotalRevolutionCounter() const { int TriggerDecoderBase::getTotalRevolutionCounter() const {
return totalRevolutionCounter; return totalRevolutionCounter;
} }
void TriggerStateWithRunningStatistics::resetTriggerState() { void PrimaryTriggerDecoder::resetTriggerState() {
TriggerState::resetTriggerState(); TriggerDecoderBase::resetTriggerState();
memset(timeOfLastEvent, 0, sizeof(timeOfLastEvent)); memset(timeOfLastEvent, 0, sizeof(timeOfLastEvent));
memset(spinningEvents, 0, sizeof(spinningEvents)); memset(spinningEvents, 0, sizeof(spinningEvents));
@ -229,7 +229,7 @@ void TriggerStateWithRunningStatistics::resetTriggerState() {
m_hasSynchronizedPhase = false; m_hasSynchronizedPhase = false;
} }
void TriggerStateWithRunningStatistics::movePreSynchTimestamps() { void PrimaryTriggerDecoder::movePreSynchTimestamps() {
// here we take timestamps of events which happened prior to synchronization and place them // here we take timestamps of events which happened prior to synchronization and place them
// at appropriate locations // at appropriate locations
auto triggerSize = getTriggerSize(); auto triggerSize = getTriggerSize();
@ -252,13 +252,10 @@ void TriggerStateWithRunningStatistics::movePreSynchTimestamps() {
memcpy(timeOfLastEvent + firstDst, spinningEvents + firstSrc, eventsToCopy * sizeof(timeOfLastEvent[0])); memcpy(timeOfLastEvent + firstDst, spinningEvents + firstSrc, eventsToCopy * sizeof(timeOfLastEvent[0]));
} }
float TriggerStateWithRunningStatistics::calculateInstantRpm( float PrimaryTriggerDecoder::calculateInstantRpm(
TriggerWaveform const & triggerShape, TriggerFormDetails *triggerFormDetails, TriggerWaveform const & triggerShape, TriggerFormDetails *triggerFormDetails,
uint32_t current_index, efitick_t nowNt) { uint32_t current_index, efitick_t nowNt) {
/**
* todo: Martin has this fatal error while feeding external RPM and changing trigger mode from 4 stoke cam to 4 stroke symmetrical
*/
assertIsInBoundsWithResult(current_index, timeOfLastEvent, "calc timeOfLastEvent", 0); assertIsInBoundsWithResult(current_index, timeOfLastEvent, "calc timeOfLastEvent", 0);
// Record the time of this event so we can calculate RPM from it later // Record the time of this event so we can calculate RPM from it later
@ -309,7 +306,7 @@ float TriggerStateWithRunningStatistics::calculateInstantRpm(
return instantRpm; return instantRpm;
} }
void TriggerStateWithRunningStatistics::setLastEventTimeForInstantRpm(efitick_t nowNt) { void PrimaryTriggerDecoder::setLastEventTimeForInstantRpm(efitick_t nowNt) {
if (getShaftSynchronized()) { if (getShaftSynchronized()) {
return; return;
} }
@ -323,7 +320,7 @@ void TriggerStateWithRunningStatistics::setLastEventTimeForInstantRpm(efitick_t
spinningEvents[spinningEventIndex++] = nowNt; spinningEvents[spinningEventIndex++] = nowNt;
} }
void TriggerStateWithRunningStatistics::updateInstantRpm( void PrimaryTriggerDecoder::updateInstantRpm(
TriggerWaveform const & triggerShape, TriggerFormDetails *triggerFormDetails, TriggerWaveform const & triggerShape, TriggerFormDetails *triggerFormDetails,
uint32_t index, efitick_t nowNt) { uint32_t index, efitick_t nowNt) {
@ -343,7 +340,7 @@ void TriggerStateWithRunningStatistics::updateInstantRpm(
#endif /* EFI_SENSOR_CHART */ #endif /* EFI_SENSOR_CHART */
} }
bool TriggerState::isValidIndex(const TriggerWaveform& triggerShape) const { bool TriggerDecoderBase::isValidIndex(const TriggerWaveform& triggerShape) const {
return currentCycle.current_index < triggerShape.getSize(); return currentCycle.current_index < triggerShape.getSize();
} }
@ -379,7 +376,7 @@ static trigger_value_e eventType[6] = { TV_FALL, TV_RISE, TV_FALL, TV_RISE, TV_F
#define needToSkipFall(type) ((!triggerShape.gapBothDirections) && (( triggerShape.useRiseEdge) && (type != TV_RISE))) #define needToSkipFall(type) ((!triggerShape.gapBothDirections) && (( triggerShape.useRiseEdge) && (type != TV_RISE)))
#define needToSkipRise(type) ((!triggerShape.gapBothDirections) && ((!triggerShape.useRiseEdge) && (type != TV_FALL))) #define needToSkipRise(type) ((!triggerShape.gapBothDirections) && ((!triggerShape.useRiseEdge) && (type != TV_FALL)))
int TriggerState::getCurrentIndex() const { int TriggerDecoderBase::getCurrentIndex() const {
return currentCycle.current_index; return currentCycle.current_index;
} }
@ -394,7 +391,7 @@ void TriggerCentral::validateCamVvtCounters() {
} }
} }
angle_t TriggerStateWithRunningStatistics::syncEnginePhase(int divider, int remainder, angle_t engineCycle) { angle_t PrimaryTriggerDecoder::syncEnginePhase(int divider, int remainder, angle_t engineCycle) {
efiAssert(OBD_PCM_Processor_Fault, remainder < divider, "syncEnginePhase", false); efiAssert(OBD_PCM_Processor_Fault, remainder < divider, "syncEnginePhase", false);
angle_t totalShift = 0; angle_t totalShift = 0;
while (getTotalRevolutionCounter() % divider != remainder) { while (getTotalRevolutionCounter() % divider != remainder) {
@ -417,11 +414,11 @@ angle_t TriggerStateWithRunningStatistics::syncEnginePhase(int divider, int rema
return totalShift; return totalShift;
} }
void TriggerState::incrementTotalEventCounter() { void TriggerDecoderBase::incrementTotalEventCounter() {
totalRevolutionCounter++; totalRevolutionCounter++;
} }
bool TriggerState::validateEventCounters(const TriggerWaveform& triggerShape) const { bool TriggerDecoderBase::validateEventCounters(const TriggerWaveform& triggerShape) const {
bool isDecodingError = false; bool isDecodingError = false;
for (int i = 0;i < PWM_PHASE_MAX_WAVE_PER_PWM;i++) { for (int i = 0;i < PWM_PHASE_MAX_WAVE_PER_PWM;i++) {
isDecodingError |= (currentCycle.eventCount[i] != triggerShape.getExpectedEventCount(i)); isDecodingError |= (currentCycle.eventCount[i] != triggerShape.getExpectedEventCount(i));
@ -440,7 +437,7 @@ bool TriggerState::validateEventCounters(const TriggerWaveform& triggerShape) co
return isDecodingError; return isDecodingError;
} }
void TriggerState::onShaftSynchronization( void TriggerDecoderBase::onShaftSynchronization(
const TriggerStateCallback triggerCycleCallback, const TriggerStateCallback triggerCycleCallback,
bool wasSynchronized, bool wasSynchronized,
const efitick_t nowNt, const efitick_t nowNt,
@ -480,7 +477,7 @@ void TriggerState::onShaftSynchronization(
* @param signal type of event which just happened * @param signal type of event which just happened
* @param nowNt current time * @param nowNt current time
*/ */
void TriggerState::decodeTriggerEvent( void TriggerDecoderBase::decodeTriggerEvent(
const char *msg, const char *msg,
const TriggerWaveform& triggerShape, const TriggerWaveform& triggerShape,
const TriggerStateCallback triggerCycleCallback, const TriggerStateCallback triggerCycleCallback,
@ -708,7 +705,7 @@ void TriggerState::decodeTriggerEvent(
} }
} }
bool TriggerState::isSyncPoint(const TriggerWaveform& triggerShape, trigger_type_e triggerType) const { bool TriggerDecoderBase::isSyncPoint(const TriggerWaveform& triggerShape, trigger_type_e triggerType) const {
// Miata NB needs a special decoder. // Miata NB needs a special decoder.
// The problem is that the crank wheel only has 4 teeth, also symmetrical, so the pattern // The problem is that the crank wheel only has 4 teeth, also symmetrical, so the pattern
// is long-short-long-short for one crank rotation. // is long-short-long-short for one crank rotation.
@ -760,7 +757,7 @@ bool TriggerState::isSyncPoint(const TriggerWaveform& triggerShape, trigger_type
return true; return true;
} }
static void onFindIndexCallback(TriggerState *state) { static void onFindIndexCallback(TriggerDecoderBase *state) {
for (int i = 0; i < PWM_PHASE_MAX_WAVE_PER_PWM; i++) { for (int i = 0; i < PWM_PHASE_MAX_WAVE_PER_PWM; i++) {
// todo: that's not the best place for this intermediate data storage, fix it! // todo: that's not the best place for this intermediate data storage, fix it!
state->expectedTotalTime[i] = state->currentCycle.totalTimeNt[i]; state->expectedTotalTime[i] = state->currentCycle.totalTimeNt[i];
@ -773,7 +770,7 @@ static void onFindIndexCallback(TriggerState *state) {
* *
* This function finds the index of synchronization event within TriggerWaveform * This function finds the index of synchronization event within TriggerWaveform
*/ */
uint32_t TriggerState::findTriggerZeroEventIndex( uint32_t TriggerDecoderBase::findTriggerZeroEventIndex(
TriggerWaveform& shape, TriggerWaveform& shape,
const TriggerConfiguration& triggerConfiguration, const TriggerConfiguration& triggerConfiguration,
const trigger_config_s& triggerConfig) { const trigger_config_s& triggerConfig) {

View File

@ -13,7 +13,7 @@
#include "trigger_state_generated.h" #include "trigger_state_generated.h"
#include "timer.h" #include "timer.h"
class TriggerState; class TriggerDecoderBase;
struct TriggerStateListener { struct TriggerStateListener {
#if EFI_SHAFT_POSITION_INPUT #if EFI_SHAFT_POSITION_INPUT
@ -40,7 +40,7 @@ protected:
virtual trigger_type_e getType() const = 0; virtual trigger_type_e getType() const = 0;
}; };
typedef void (*TriggerStateCallback)(TriggerState *); typedef void (*TriggerStateCallback)(TriggerDecoderBase*);
typedef struct { typedef struct {
/** /**
@ -74,9 +74,9 @@ typedef struct {
/** /**
* @see TriggerWaveform for trigger wheel shape definition * @see TriggerWaveform for trigger wheel shape definition
*/ */
class TriggerState : public trigger_state_s { class TriggerDecoderBase : public trigger_state_s {
public: public:
TriggerState(); TriggerDecoderBase();
/** /**
* current trigger processing index, between zero and #size * current trigger processing index, between zero and #size
*/ */
@ -173,9 +173,9 @@ private:
/** /**
* the reason for sub-class is simply to save RAM but not having statistics in the trigger initialization instance * the reason for sub-class is simply to save RAM but not having statistics in the trigger initialization instance
*/ */
class TriggerStateWithRunningStatistics : public TriggerState { class PrimaryTriggerDecoder : public TriggerDecoderBase {
public: public:
TriggerStateWithRunningStatistics(); PrimaryTriggerDecoder();
void resetTriggerState() override; void resetTriggerState() override;
angle_t syncEnginePhase(int divider, int remainder, angle_t engineCycle); angle_t syncEnginePhase(int divider, int remainder, angle_t engineCycle);
@ -231,12 +231,14 @@ private:
bool m_hasSynchronizedPhase = false; bool m_hasSynchronizedPhase = false;
}; };
class VvtTriggerDecoder : public TriggerDecoderBase { };
angle_t getEngineCycle(operation_mode_e operationMode); angle_t getEngineCycle(operation_mode_e operationMode);
class Engine; class Engine;
void calculateTriggerSynchPoint( void calculateTriggerSynchPoint(
TriggerWaveform& shape, TriggerWaveform& shape,
TriggerState& state); TriggerDecoderBase& state);
void prepareEventAngles(TriggerWaveform *shape, TriggerFormDetails *details); void prepareEventAngles(TriggerWaveform *shape, TriggerFormDetails *details);

View File

@ -39,7 +39,7 @@ int getSimulatedEventTime(const TriggerWaveform& shape, int i) {
void TriggerStimulatorHelper::feedSimulatedEvent( void TriggerStimulatorHelper::feedSimulatedEvent(
const TriggerStateCallback triggerCycleCallback, const TriggerStateCallback triggerCycleCallback,
const TriggerConfiguration& triggerConfiguration, const TriggerConfiguration& triggerConfiguration,
TriggerState& state, TriggerDecoderBase& state,
const TriggerWaveform& shape, const TriggerWaveform& shape,
int i int i
) { ) {
@ -97,7 +97,7 @@ void TriggerStimulatorHelper::assertSyncPositionAndSetDutyCycle(
const TriggerStateCallback triggerCycleCallback, const TriggerStateCallback triggerCycleCallback,
const TriggerConfiguration& triggerConfiguration, const TriggerConfiguration& triggerConfiguration,
const uint32_t syncIndex, const uint32_t syncIndex,
TriggerState& state, TriggerDecoderBase& state,
TriggerWaveform& shape TriggerWaveform& shape
) { ) {
@ -141,7 +141,7 @@ void TriggerStimulatorHelper::assertSyncPositionAndSetDutyCycle(
uint32_t TriggerStimulatorHelper::findTriggerSyncPoint( uint32_t TriggerStimulatorHelper::findTriggerSyncPoint(
TriggerWaveform& shape, TriggerWaveform& shape,
const TriggerConfiguration& triggerConfiguration, const TriggerConfiguration& triggerConfiguration,
TriggerState& state) { TriggerDecoderBase& state) {
for (int i = 0; i < 4 * PWM_PHASE_MAX_COUNT; i++) { for (int i = 0; i < 4 * PWM_PHASE_MAX_COUNT; i++) {
feedSimulatedEvent(nullptr, feedSimulatedEvent(nullptr,
triggerConfiguration, triggerConfiguration,

View File

@ -20,20 +20,20 @@ public:
uint32_t findTriggerSyncPoint( uint32_t findTriggerSyncPoint(
TriggerWaveform& shape, TriggerWaveform& shape,
const TriggerConfiguration& triggerConfiguration, const TriggerConfiguration& triggerConfiguration,
TriggerState& state); TriggerDecoderBase& state);
void assertSyncPositionAndSetDutyCycle( void assertSyncPositionAndSetDutyCycle(
const TriggerStateCallback triggerCycleCallback, const TriggerStateCallback triggerCycleCallback,
const TriggerConfiguration& triggerConfiguration, const TriggerConfiguration& triggerConfiguration,
const uint32_t index, const uint32_t index,
TriggerState& state, TriggerDecoderBase& state,
TriggerWaveform& shape TriggerWaveform& shape
); );
// 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, void feedSimulatedEvent(const TriggerStateCallback triggerCycleCallback,
const TriggerConfiguration& triggerConfiguration, const TriggerConfiguration& triggerConfiguration,
TriggerState& state, TriggerDecoderBase& state,
const TriggerWaveform& shape, const TriggerWaveform& shape,
int i); int i);
}; };

View File

@ -65,7 +65,7 @@ static void testDodgeNeonDecoder() {
TriggerWaveform * shape = &eth.engine.triggerCentral.triggerShape; TriggerWaveform * shape = &eth.engine.triggerCentral.triggerShape;
ASSERT_EQ(8, shape->getTriggerWaveformSynchPointIndex()); ASSERT_EQ(8, shape->getTriggerWaveformSynchPointIndex());
TriggerState state; TriggerDecoderBase state;
ASSERT_FALSE(state.getShaftSynchronized()) << "1 shaft_is_synchronized"; ASSERT_FALSE(state.getShaftSynchronized()) << "1 shaft_is_synchronized";
@ -112,8 +112,8 @@ static void assertTriggerPosition(event_trigger_position_s *position, int eventI
TEST(trigger, testSomethingWeird) { TEST(trigger, testSomethingWeird) {
EngineTestHelper eth(FORD_INLINE_6_1995); EngineTestHelper eth(FORD_INLINE_6_1995);
TriggerState state_; TriggerDecoderBase state_;
TriggerState *sta = &state_; TriggerDecoderBase *sta = &state_;
const auto& triggerConfiguration = engine->primaryTriggerConfiguration; const auto& triggerConfiguration = engine->primaryTriggerConfiguration;