From ac852f3971f739906048222e01ee95a0219a10b4 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Thu, 11 Sep 2014 10:03:38 -0500 Subject: [PATCH] auto-sync --- firmware/controllers/algo/wave_chart.cpp | 73 ++++++++++--------- firmware/controllers/algo/wave_chart.h | 11 ++- .../controllers/trigger/rpm_calculator.cpp | 2 +- .../controllers/trigger/trigger_central.cpp | 2 + firmware/emulation/wave_analyzer.cpp | 2 +- .../simulator/rusEfiFunctionalTest.cpp | 2 +- 6 files changed, 50 insertions(+), 42 deletions(-) diff --git a/firmware/controllers/algo/wave_chart.cpp b/firmware/controllers/algo/wave_chart.cpp index f681f0efc2..f2be46101a 100644 --- a/firmware/controllers/algo/wave_chart.cpp +++ b/firmware/controllers/algo/wave_chart.cpp @@ -62,24 +62,24 @@ static int isChartActive = TRUE; #if DEBUG_WAVE static Logging debugLogging; -#endif +#endif /* DEBUG_WAVE */ static Logging logger; -void resetWaveChart(WaveChart *chart) { +void WaveChart::resetWaveChart() { #if DEBUG_WAVE - scheduleSimpleMsg(&debugLogging, "reset while at ", chart->counter); -#endif - resetLogging(&chart->logging); - chart->counter = 0; - appendPrintf(&chart->logging, "wave_chart%s", DELIMETER); + scheduleSimpleMsg(&debugLogging, "reset while at ", counter); +#endif /* DEBUG_WAVE */ + resetLogging(&logging); + counter = 0; + appendPrintf(&logging, "wave_chart%s", DELIMETER); } static char WAVE_LOGGING_BUFFER[WAVE_LOGGING_SIZE] CCM_OPTIONAL ; -static int isWaveChartFull(WaveChart *chart) { - return chart->counter >= engineConfiguration->digitalChartSize; +int WaveChart::isWaveChartFull() { + return counter >= engineConfiguration->digitalChartSize; } static void printStatus(void) { @@ -100,23 +100,29 @@ void setChartSize(int newSize) { printStatus(); } -void publishChartIfFull(WaveChart *chart) { - if (isWaveChartFull(chart)) { - publishChart(chart); - resetWaveChart(chart); +void WaveChart::publishChartIfFull() { + if (isWaveChartFull()) { + publishChart(); + resetWaveChart(); } } -void publishChart(WaveChart *chart) { - appendPrintf(&chart->logging, DELIMETER); - waveChartUsedSize = loggingSize(&chart->logging); +WaveChart::WaveChart() { + initLoggingExt(&logging, "wave chart", WAVE_LOGGING_BUFFER, sizeof(WAVE_LOGGING_BUFFER)); + isInitialized = TRUE; + resetWaveChart(); +} + +void WaveChart::publishChart() { + appendPrintf(&logging, DELIMETER); + waveChartUsedSize = loggingSize(&logging); #if DEBUG_WAVE Logging *l = &chart->logging; scheduleSimpleMsg(&debugLogging, "IT'S TIME", strlen(l->buffer)); #endif bool isFullLog = getFullLog(); if (isChartActive && isFullLog) { - scheduleLogging(&chart->logging); + scheduleLogging(&logging); } } @@ -125,12 +131,12 @@ static char timeBuffer[10]; /** * @brief Register an event for digital sniffer */ -void addWaveChartEvent3(WaveChart *chart, const char *name, const char * msg, const char * msg2) { - efiAssertVoid(chart->isInitialized, "chart not initialized"); +void WaveChart::addWaveChartEvent3(const char *name, const char * msg, const char * msg2) { + efiAssertVoid(isInitialized, "chart not initialized"); #if DEBUG_WAVE scheduleSimpleMsg(&debugLogging, "current", chart->counter); #endif - if (isWaveChartFull(chart)) { + if (isWaveChartFull()) { return; } @@ -142,27 +148,27 @@ void addWaveChartEvent3(WaveChart *chart, const char *name, const char * msg, co bool alreadyLocked = lockOutputBuffer(); // we have multiple threads writing to the same output buffer - if (chart->counter == 0) { - chart->startTime = time100; + if (counter == 0) { + startTime = time100; } - chart->counter++; - if (remainingSize(&chart->logging) > 30) { + counter++; + if (remainingSize(&logging) > 30) { /** * printf is a heavy method, append is used here as a performance optimization */ - appendFast(&chart->logging, name); - appendFast(&chart->logging, CHART_DELIMETER); - appendFast(&chart->logging, msg); - appendFast(&chart->logging, CHART_DELIMETER); + appendFast(&logging, name); + appendFast(&logging, CHART_DELIMETER); + appendFast(&logging, msg); + appendFast(&logging, CHART_DELIMETER); /** * We want smaller times within a chart in order to reduce packet size. */ - time100 -= chart->startTime; + time100 -= startTime; itoa10(timeBuffer, time100); - appendFast(&chart->logging, timeBuffer); - appendFast(&chart->logging, msg2); - appendFast(&chart->logging, CHART_DELIMETER); + appendFast(&logging, timeBuffer); + appendFast(&logging, msg2); + appendFast(&logging, CHART_DELIMETER); } if (!alreadyLocked) { unlockOutputBuffer(); @@ -192,8 +198,6 @@ void initWaveChart(WaveChart *chart) { printStatus(); - initLoggingExt(&chart->logging, "wave chart", WAVE_LOGGING_BUFFER, sizeof(WAVE_LOGGING_BUFFER)); - chart->isInitialized = TRUE; #if DEBUG_WAVE initLoggingExt(&debugLogging, "wave chart debug", &debugLogging.DEFAULT_BUFFER, sizeof(debugLogging.DEFAULT_BUFFER)); #endif @@ -202,7 +206,6 @@ void initWaveChart(WaveChart *chart) { initHistogram(&waveChartHisto, "wave chart"); #endif /* EFI_HISTOGRAMS */ - resetWaveChart(chart); addConsoleActionI("chartsize", setChartSize); addConsoleActionI("chart", setChartActive); } diff --git a/firmware/controllers/algo/wave_chart.h b/firmware/controllers/algo/wave_chart.h index 551d54177a..79475022f0 100644 --- a/firmware/controllers/algo/wave_chart.h +++ b/firmware/controllers/algo/wave_chart.h @@ -20,6 +20,13 @@ */ class WaveChart { public: + WaveChart(); + void publishChart(); + void resetWaveChart(); + int isWaveChartFull(); + void publishChartIfFull(); + void addWaveChartEvent3(const char *name, const char *msg, const char *msg2); +private: #if EFI_WAVE_CHART Logging logging; #endif /* EFI_WAVE_CHART */ @@ -28,12 +35,8 @@ public: volatile int isInitialized; }; -void addWaveChartEvent3(WaveChart *chart, const char *name, const char *msg, const char *msg2); -void publishChart(WaveChart *chart); void initWaveChart(WaveChart *chart); void showWaveChartHistogram(void); -void resetWaveChart(WaveChart *chart); void setChartSize(int newSize); -void publishChartIfFull(WaveChart *chart); #endif /* WAVE_CHART_H_ */ diff --git a/firmware/controllers/trigger/rpm_calculator.cpp b/firmware/controllers/trigger/rpm_calculator.cpp index 965e994cea..51e3b32016 100644 --- a/firmware/controllers/trigger/rpm_calculator.cpp +++ b/firmware/controllers/trigger/rpm_calculator.cpp @@ -235,6 +235,6 @@ void scheduleByAngle(scheduling_s *timer, float angle, schfunc_t callback, void void addWaveChartEvent(const char *name, const char * msg, const char *msg2) { #if EFI_WAVE_CHART - addWaveChartEvent3(&waveChart, name, msg, msg2); + waveChart.addWaveChartEvent3(name, msg, msg2); #endif /* EFI_WAVE_CHART */ } diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index ccf4e741de..44dd94648e 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -21,7 +21,9 @@ #include "pin_repository.h" #endif +#if EFI_WAVE_CHART WaveChart waveChart; +#endif /* EFI_WAVE_CHART */ static histogram_s triggerCallback; diff --git a/firmware/emulation/wave_analyzer.cpp b/firmware/emulation/wave_analyzer.cpp index c43ccd31d5..0a41697d50 100644 --- a/firmware/emulation/wave_analyzer.cpp +++ b/firmware/emulation/wave_analyzer.cpp @@ -156,7 +156,7 @@ static msg_t waThread(void *arg) { while (TRUE) { chThdSleepSeconds(CHART_RESET_DELAY); - publishChartIfFull(&waveChart); + waveChart.publishChartIfFull(); } #endif /* EFI_WAVE_CHART */ #if defined __GNUC__ diff --git a/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp b/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp index 20f9a8b2b8..c715a02b96 100644 --- a/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp +++ b/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp @@ -106,7 +106,7 @@ void rusEfiFunctionalTest(void) { void printPendingMessages(void) { updateDevConsoleState(); - publishChartIfFull(&waveChart); + waveChart.publishChartIfFull(); } static size_t wt_writes(void *ip, const uint8_t *bp, size_t n) {