auto-sync
This commit is contained in:
parent
a61851698e
commit
6506e74f6b
|
@ -79,7 +79,7 @@ void WaveChart::resetWaveChart() {
|
||||||
static char WAVE_LOGGING_BUFFER[WAVE_LOGGING_SIZE] CCM_OPTIONAL
|
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.
|
* Say at 300rpm we should get at least four events per revolution.
|
||||||
* That's 300/60*4=20 events per second
|
* That's 300/60*4=20 events per second
|
||||||
|
@ -87,8 +87,11 @@ int WaveChart::isWaveChartFull() {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint64_t chartDurationNt = getTimeNowNt() - startTimeNt;
|
uint64_t chartDurationNt = getTimeNowNt() - startTimeNt;
|
||||||
bool startedTooLongAgo = startTimeNt!= 0 && NT2US(chartDurationNt) > engineConfiguration->digitalChartSize * 1000000 / 20;
|
return startTimeNt!= 0 && NT2US(chartDurationNt) > engineConfiguration->digitalChartSize * 1000000 / 20;
|
||||||
return startedTooLongAgo || counter >= engineConfiguration->digitalChartSize;
|
}
|
||||||
|
|
||||||
|
bool_t WaveChart::isWaveChartFull() {
|
||||||
|
return counter >= engineConfiguration->digitalChartSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printStatus(void) {
|
static void printStatus(void) {
|
||||||
|
@ -110,7 +113,7 @@ void setChartSize(int newSize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveChart::publishChartIfFull() {
|
void WaveChart::publishChartIfFull() {
|
||||||
if (isWaveChartFull()) {
|
if (isWaveChartFull() || isStartedTooLongAgo()) {
|
||||||
publishChart();
|
publishChart();
|
||||||
resetWaveChart();
|
resetWaveChart();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,8 @@ public:
|
||||||
void init();
|
void init();
|
||||||
void publishChart();
|
void publishChart();
|
||||||
void resetWaveChart();
|
void resetWaveChart();
|
||||||
int isWaveChartFull();
|
bool_t isWaveChartFull();
|
||||||
|
bool_t isStartedTooLongAgo();
|
||||||
void publishChartIfFull();
|
void publishChartIfFull();
|
||||||
void addWaveChartEvent3(const char *name, const char *msg, const char *msg2);
|
void addWaveChartEvent3(const char *name, const char *msg, const char *msg2);
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -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_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 };
|
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) {
|
#define getCurrentGapDuration(nowUs) \
|
||||||
int64_t currentDuration = isFirstEvent ? 0 : nowUs - toothed_previous_time;
|
(isFirstEvent ? 0 : (nowUs) - toothed_previous_time)
|
||||||
isFirstEvent = false;
|
|
||||||
return currentDuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Trigger decoding happens here
|
* @brief Trigger decoding happens here
|
||||||
|
@ -124,12 +122,14 @@ void TriggerState::decodeTriggerEvent(trigger_shape_s const*triggerShape, trigge
|
||||||
nextTriggerEvent(triggerWheel, nowUs);
|
nextTriggerEvent(triggerWheel, nowUs);
|
||||||
if (triggerShape->gapBothDirections) {
|
if (triggerShape->gapBothDirections) {
|
||||||
toothed_previous_duration = getCurrentGapDuration(nowUs);
|
toothed_previous_duration = getCurrentGapDuration(nowUs);
|
||||||
|
isFirstEvent = false;
|
||||||
toothed_previous_time = nowUs;
|
toothed_previous_time = nowUs;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t currentDuration = getCurrentGapDuration(nowUs);
|
int64_t currentDuration = getCurrentGapDuration(nowUs);
|
||||||
|
isFirstEvent = false;
|
||||||
efiAssertVoid(currentDuration >= 0, "decode: negative duration?");
|
efiAssertVoid(currentDuration >= 0, "decode: negative duration?");
|
||||||
|
|
||||||
// todo: skip a number of signal from the beginning
|
// todo: skip a number of signal from the beginning
|
||||||
|
|
|
@ -50,7 +50,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void clear();
|
void clear();
|
||||||
uint64_t getCurrentGapDuration(uint64_t nowUs);
|
|
||||||
/**
|
/**
|
||||||
* index within trigger revolution, from 0 to trigger event count
|
* index within trigger revolution, from 0 to trigger event count
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue