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

View File

@ -20,7 +20,11 @@ class Engine;
#define HW_EVENT_TYPES 6 #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 { class TriggerCentral {
public: public:
TriggerCentral(); TriggerCentral();
@ -28,7 +32,7 @@ public:
void handleShaftSignal(trigger_event_e signal DECLARE_ENGINE_PARAMETER_SUFFIX); void handleShaftSignal(trigger_event_e signal DECLARE_ENGINE_PARAMETER_SUFFIX);
int getHwEventCounter(int index); int getHwEventCounter(int index);
void resetCounters(); void resetCounters();
TriggerState triggerState; TriggerStateWithRunningStatistics triggerState;
efitick_t nowNt; efitick_t nowNt;
angle_t vvtPosition; 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) { if (ENGINE(sensorChartMode) == SC_RPM_ACCEL || ENGINE(sensorChartMode) == SC_DETAILED_RPM) {
angle_t currentAngle = TRIGGER_SHAPE(eventAngles[currentCycle.current_index]); angle_t currentAngle = TRIGGER_SHAPE(eventAngles[currentCycle.current_index]);
// todo: make this '90' depend on cylinder count? // todo: make this '90' depend on cylinder count?

View File

@ -82,11 +82,6 @@ public:
uint32_t prevTotalTime[PWM_PHASE_MAX_WAVE_PER_PWM]; uint32_t prevTotalTime[PWM_PHASE_MAX_WAVE_PER_PWM];
int expectedTotalTime[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 * how many times since ECU reboot we had unexpected number of teeth in trigger cycle
*/ */
@ -98,6 +93,8 @@ public:
void reset(); void reset();
void resetRunningCounters(); void resetRunningCounters();
virtual void runtimeStatistics();
uint32_t runningRevolutionCounter; uint32_t runningRevolutionCounter;
/** /**
* this is start of real trigger cycle * this is start of real trigger cycle
@ -115,6 +112,13 @@ private:
efitime_t prevCycleDuration; 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); angle_t getEngineCycle(operation_mode_e operationMode);
uint32_t findTriggerZeroEventIndex(TriggerState *state, TriggerShape * shape, trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_SUFFIX); 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; runningOrderingErrorCounter = 0;
} }
void TriggerState::runtimeStatistics() {
// empty base implementation
}
void TriggerStateWithRunningStatistics::runtimeStatistics() {
// empty base implementation
}
efitime_t TriggerState::getTotalEventCounter() { efitime_t TriggerState::getTotalEventCounter() {
return totalEventCountBase + currentCycle.current_index; return totalEventCountBase + currentCycle.current_index;
} }