This commit is contained in:
rusefi 2017-05-18 16:39:04 -04:00
parent 7fe5edf5e2
commit 907a23cda6
3 changed files with 36 additions and 33 deletions

View File

@ -398,35 +398,8 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no
}
}
runtimeStatistics();
runtimeStatistics(signal, nowNt PASS_ENGINE_PARAMETER_SUFFIX);
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?
angle_t prevAngle = currentAngle - 90;
fixAngle(prevAngle, "prevAngle");
// todo: prevIndex should be pre-calculated
int prevIndex = TRIGGER_SHAPE(triggerIndexByAngle[(int)prevAngle]);
// now let's get precise angle for that event
prevAngle = TRIGGER_SHAPE(eventAngles[prevIndex]);
// todo: re-implement this as a subclass. we need two instances of
// uint32_t time = nowNt - timeOfLastEvent[prevIndex];
angle_t angleDiff = currentAngle - prevAngle;
// todo: angle diff should be pre-calculated
fixAngle(angleDiff, "angleDiff");
// float r = (60000000.0 / 360 * US_TO_NT_MULTIPLIER) * angleDiff / time;
#if EFI_SENSOR_CHART || defined(__DOXYGEN__)
if (boardConfiguration->sensorChartMode == SC_DETAILED_RPM) {
// scAddData(currentAngle, r);
} else {
// scAddData(currentAngle, r / instantRpmValue[prevIndex]);
}
#endif
// instantRpmValue[currentCycle.current_index] = r;
// timeOfLastEvent[currentCycle.current_index] = nowNt;
}
}
void configure3_1_cam(TriggerShape *s, operation_mode_e operationMode DECLARE_ENGINE_PARAMETER_SUFFIX) {

View File

@ -93,7 +93,7 @@ public:
void reset();
void resetRunningCounters();
virtual void runtimeStatistics();
virtual void runtimeStatistics(trigger_event_e const signal, efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX);
uint32_t runningRevolutionCounter;
/**
@ -112,11 +112,15 @@ private:
efitime_t prevCycleDuration;
};
/**
* the reason for sub-class is simply to save RAM but not having statisics in the trigger initialization instance
*/
class TriggerStateWithRunningStatistics : public TriggerState {
public:
uint32_t timeOfLastEvent[PWM_PHASE_MAX_COUNT];
float instantRpmValue[PWM_PHASE_MAX_COUNT];
virtual void runtimeStatistics();
virtual void runtimeStatistics(trigger_event_e const signal, efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX);
};
angle_t getEngineCycle(operation_mode_e operationMode);

View File

@ -24,6 +24,7 @@
#include "trigger_decoder.h"
#include "engine_math.h"
#include "trigger_universal.h"
#include "sensor_chart.h"
EXTERN_ENGINE;
@ -205,12 +206,37 @@ void TriggerState::resetRunningCounters() {
runningOrderingErrorCounter = 0;
}
void TriggerState::runtimeStatistics() {
void TriggerState::runtimeStatistics(trigger_event_e const signal, efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) {
// empty base implementation
}
void TriggerStateWithRunningStatistics::runtimeStatistics() {
// empty base implementation
void TriggerStateWithRunningStatistics::runtimeStatistics(trigger_event_e const signal, efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) {
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?
angle_t prevAngle = currentAngle - 90;
fixAngle(prevAngle, "prevAngle");
// todo: prevIndex should be pre-calculated
int prevIndex = TRIGGER_SHAPE(triggerIndexByAngle[(int)prevAngle]);
// now let's get precise angle for that event
prevAngle = TRIGGER_SHAPE(eventAngles[prevIndex]);
uint32_t time = nowNt - timeOfLastEvent[prevIndex];
angle_t angleDiff = currentAngle - prevAngle;
// todo: angle diff should be pre-calculated
fixAngle(angleDiff, "angleDiff");
float r = (60000000.0 / 360 * US_TO_NT_MULTIPLIER) * angleDiff / time;
#if EFI_SENSOR_CHART || defined(__DOXYGEN__)
if (boardConfiguration->sensorChartMode == SC_DETAILED_RPM) {
scAddData(currentAngle, r);
} else {
scAddData(currentAngle, r / instantRpmValue[prevIndex]);
}
#endif
instantRpmValue[currentCycle.current_index] = r;
timeOfLastEvent[currentCycle.current_index] = nowNt;
}
}
efitime_t TriggerState::getTotalEventCounter() {