refactoring - explicit read method

This commit is contained in:
Andrey 2021-06-26 22:17:07 -04:00
parent 1822426d0c
commit eaff083377
4 changed files with 11 additions and 9 deletions

View File

@ -183,7 +183,7 @@ operation_mode_e TriggerWaveform::getOperationMode() const {
extern bool printTriggerDebug;
#endif
int TriggerWaveform::getExpectedEventCount(int channelIndex) {
int TriggerWaveform::getExpectedEventCount(int channelIndex) const {
return expectedEventCount[channelIndex];
}
@ -191,12 +191,12 @@ void TriggerWaveform::calculateExpectedEventCounts(bool useOnlyRisingEdgeForTrig
if (!useOnlyRisingEdgeForTrigger) {
for (size_t i = 0; i < efi::size(expectedEventCount); i++) {
if (getExpectedEventCount(i) % 2 != 0) {
firmwareError(ERROR_TRIGGER_DRAMA, "Trigger: should be even %d %d", i, expectedEventCount[i]);
firmwareError(ERROR_TRIGGER_DRAMA, "Trigger: should be even %d %d", i, getExpectedEventCount(i));
}
}
}
bool isSingleToothOnPrimaryChannel = useOnlyRisingEdgeForTrigger ? expectedEventCount[0] == 1 : expectedEventCount[0] == 2;
bool isSingleToothOnPrimaryChannel = useOnlyRisingEdgeForTrigger ? getExpectedEventCount(0) == 1 : getExpectedEventCount(0) == 2;
// todo: next step would be to set 'isSynchronizationNeeded' automatically based on the logic we have here
if (!shapeWithoutTdc && isSingleToothOnPrimaryChannel != !isSynchronizationNeeded) {
firmwareError(ERROR_TRIGGER_DRAMA, "trigger sync constraint violation");

View File

@ -178,7 +178,7 @@ public:
void calculateExpectedEventCounts(bool useOnlyRisingEdgeForTrigger);
int getExpectedEventCount(int channelIndex);
int getExpectedEventCount(int channelIndex) const;
/**
* This is used for signal validation

View File

@ -446,7 +446,7 @@ bool TriggerNoiseFilter::noiseFilter(efitick_t nowNt,
// but first check if we're expecting a gap
bool isGapExpected = TRIGGER_WAVEFORM(isSynchronizationNeeded) && triggerState->shaft_is_synchronized &&
(triggerState->currentCycle.eventCount[ti] + 1) == TRIGGER_WAVEFORM(expectedEventCount[ti]);
(triggerState->currentCycle.eventCount[ti] + 1) == TRIGGER_WAVEFORM(getExpectedEventCount(ti));
if (isGapExpected) {
// usually we need to extend the period for gaps, based on the trigger info
@ -623,8 +623,10 @@ void triggerInfo(void) {
efiPrintf("trigger#2 event counters up=%d/down=%d", engine->triggerCentral.getHwEventCounter(2),
engine->triggerCentral.getHwEventCounter(3));
}
efiPrintf("expected cycle events %d/%d/%d", TRIGGER_WAVEFORM(expectedEventCount[0]),
TRIGGER_WAVEFORM(expectedEventCount[1]), TRIGGER_WAVEFORM(expectedEventCount[2]));
efiPrintf("expected cycle events %d/%d/%d",
TRIGGER_WAVEFORM(getExpectedEventCount(0)),
TRIGGER_WAVEFORM(getExpectedEventCount(1)),
TRIGGER_WAVEFORM(getExpectedEventCount(2)));
efiPrintf("trigger type=%d/need2ndChannel=%s", engineConfiguration->trigger.type,
boolToString(TRIGGER_WAVEFORM(needSecondTriggerInput)));

View File

@ -352,7 +352,7 @@ bool TriggerState::isEvenRevolution() const {
bool TriggerState::validateEventCounters(const TriggerWaveform& triggerShape) const {
bool isDecodingError = false;
for (int i = 0;i < PWM_PHASE_MAX_WAVE_PER_PWM;i++) {
isDecodingError |= (currentCycle.eventCount[i] != triggerShape.expectedEventCount[i]);
isDecodingError |= (currentCycle.eventCount[i] != triggerShape.getExpectedEventCount(i));
}
@ -360,7 +360,7 @@ bool TriggerState::validateEventCounters(const TriggerWaveform& triggerShape) co
printf("sync point: isDecodingError=%d\r\n", isDecodingError);
if (isDecodingError) {
for (int i = 0;i < PWM_PHASE_MAX_WAVE_PER_PWM;i++) {
printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[i], triggerShape.expectedEventCount[i]);
printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[i], triggerShape.getExpectedEventCount(i));
}
}
#endif /* EFI_UNIT_TEST */