auto-sync

This commit is contained in:
rusEfi 2014-11-11 10:04:06 -06:00
parent 703fd24d18
commit 0079636f4c
4 changed files with 14 additions and 11 deletions

View File

@ -79,7 +79,7 @@ void WaveChart::resetWaveChart() {
static char WAVE_LOGGING_BUFFER[WAVE_LOGGING_SIZE] CCM_OPTIONAL
;
int WaveChart::isWaveChartFull() {
bool_t WaveChart::isStartedTooLongAgo() {
/**
* Say at 300rpm we should get at least four events per revolution.
* That's 300/60*4=20 events per second
@ -87,8 +87,11 @@ int WaveChart::isWaveChartFull() {
*
*/
uint64_t chartDurationNt = getTimeNowNt() - startTimeNt;
bool startedTooLongAgo = startTimeNt!= 0 && NT2US(chartDurationNt) > engineConfiguration->digitalChartSize * 1000000 / 20;
return startedTooLongAgo || counter >= engineConfiguration->digitalChartSize;
return startTimeNt!= 0 && NT2US(chartDurationNt) > engineConfiguration->digitalChartSize * 1000000 / 20;
}
bool_t WaveChart::isWaveChartFull() {
return counter >= engineConfiguration->digitalChartSize;
}
static void printStatus(void) {
@ -110,7 +113,7 @@ void setChartSize(int newSize) {
}
void WaveChart::publishChartIfFull() {
if (isWaveChartFull()) {
if (isWaveChartFull() || isStartedTooLongAgo()) {
publishChart();
resetWaveChart();
}

View File

@ -23,7 +23,8 @@ public:
void init();
void publishChart();
void resetWaveChart();
int isWaveChartFull();
bool_t isWaveChartFull();
bool_t isStartedTooLongAgo();
void publishChartIfFull();
void addWaveChartEvent3(const char *name, const char *msg, const char *msg2);
private:

View File

@ -95,11 +95,9 @@ float TriggerState::getTriggerDutyCycle(int index) {
static trigger_wheel_e eventIndex[6] = { T_PRIMARY, T_PRIMARY, T_SECONDARY, T_SECONDARY, T_CHANNEL_3, T_CHANNEL_3 };
static trigger_value_e eventType[6] = { TV_LOW, TV_HIGH, TV_LOW, TV_HIGH, TV_LOW, TV_HIGH };
uint64_t TriggerState::getCurrentGapDuration(uint64_t nowUs) {
int64_t currentDuration = isFirstEvent ? 0 : nowUs - toothed_previous_time;
isFirstEvent = false;
return currentDuration;
}
#define getCurrentGapDuration(nowUs) \
(isFirstEvent ? 0 : (nowUs) - toothed_previous_time)
/**
* @brief Trigger decoding happens here
@ -124,12 +122,14 @@ void TriggerState::decodeTriggerEvent(trigger_shape_s const*triggerShape, trigge
nextTriggerEvent(triggerWheel, nowUs);
if (triggerShape->gapBothDirections) {
toothed_previous_duration = getCurrentGapDuration(nowUs);
isFirstEvent = false;
toothed_previous_time = nowUs;
}
return;
}
int64_t currentDuration = getCurrentGapDuration(nowUs);
isFirstEvent = false;
efiAssertVoid(currentDuration >= 0, "decode: negative duration?");
// todo: skip a number of signal from the beginning

View File

@ -50,7 +50,6 @@ public:
private:
void clear();
uint64_t getCurrentGapDuration(uint64_t nowUs);
/**
* index within trigger revolution, from 0 to trigger event count
*/