This commit is contained in:
rusefi 2017-05-18 16:16:55 -04:00
parent c390b63b4a
commit 8d5502ae4e
4 changed files with 25 additions and 7 deletions

View File

@ -20,7 +20,11 @@ class Engine;
#define HW_EVENT_TYPES 6
// todo: maybe merge TriggerCentral and TriggerState classes into one class?
/**
* Maybe merge TriggerCentral and TriggerState classes into one class?
* Probably not: we have an instance of TriggerState which is used for trigger initialization,
* also composition probably better than inheritance here
*/
class TriggerCentral {
public:
TriggerCentral();
@ -28,7 +32,7 @@ public:
void handleShaftSignal(trigger_event_e signal DECLARE_ENGINE_PARAMETER_SUFFIX);
int getHwEventCounter(int index);
void resetCounters();
TriggerState triggerState;
TriggerStateWithRunningStatistics triggerState;
efitick_t nowNt;
angle_t vvtPosition;
/**

View File

@ -398,6 +398,8 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no
}
}
runtimeStatistics();
if (ENGINE(sensorChartMode) == SC_RPM_ACCEL || ENGINE(sensorChartMode) == SC_DETAILED_RPM) {
angle_t currentAngle = TRIGGER_SHAPE(eventAngles[currentCycle.current_index]);
// todo: make this '90' depend on cylinder count?

View File

@ -82,11 +82,6 @@ public:
uint32_t prevTotalTime[PWM_PHASE_MAX_WAVE_PER_PWM];
int expectedTotalTime[PWM_PHASE_MAX_WAVE_PER_PWM];
// we need two instances of TriggerState
// todo: re-imiplement as a sub-class to reduce memory consumption
// uint32_t timeOfLastEvent[PWM_PHASE_MAX_COUNT];
// float instantRpmValue[PWM_PHASE_MAX_COUNT];
/**
* how many times since ECU reboot we had unexpected number of teeth in trigger cycle
*/
@ -98,6 +93,8 @@ public:
void reset();
void resetRunningCounters();
virtual void runtimeStatistics();
uint32_t runningRevolutionCounter;
/**
* this is start of real trigger cycle
@ -115,6 +112,13 @@ private:
efitime_t prevCycleDuration;
};
class TriggerStateWithRunningStatistics : public TriggerState {
public:
uint32_t timeOfLastEvent[PWM_PHASE_MAX_COUNT];
float instantRpmValue[PWM_PHASE_MAX_COUNT];
virtual void runtimeStatistics();
};
angle_t getEngineCycle(operation_mode_e operationMode);
uint32_t findTriggerZeroEventIndex(TriggerState *state, TriggerShape * shape, trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_SUFFIX);

View File

@ -205,6 +205,14 @@ void TriggerState::resetRunningCounters() {
runningOrderingErrorCounter = 0;
}
void TriggerState::runtimeStatistics() {
// empty base implementation
}
void TriggerStateWithRunningStatistics::runtimeStatistics() {
// empty base implementation
}
efitime_t TriggerState::getTotalEventCounter() {
return totalEventCountBase + currentCycle.current_index;
}