auto-sync

This commit is contained in:
rusEfi 2014-09-11 10:03:38 -05:00
parent 0ca94f4a10
commit ac852f3971
6 changed files with 50 additions and 42 deletions

View File

@ -62,24 +62,24 @@ static int isChartActive = TRUE;
#if DEBUG_WAVE #if DEBUG_WAVE
static Logging debugLogging; static Logging debugLogging;
#endif #endif /* DEBUG_WAVE */
static Logging logger; static Logging logger;
void resetWaveChart(WaveChart *chart) { void WaveChart::resetWaveChart() {
#if DEBUG_WAVE #if DEBUG_WAVE
scheduleSimpleMsg(&debugLogging, "reset while at ", chart->counter); scheduleSimpleMsg(&debugLogging, "reset while at ", counter);
#endif #endif /* DEBUG_WAVE */
resetLogging(&chart->logging); resetLogging(&logging);
chart->counter = 0; counter = 0;
appendPrintf(&chart->logging, "wave_chart%s", DELIMETER); appendPrintf(&logging, "wave_chart%s", DELIMETER);
} }
static char WAVE_LOGGING_BUFFER[WAVE_LOGGING_SIZE] CCM_OPTIONAL static char WAVE_LOGGING_BUFFER[WAVE_LOGGING_SIZE] CCM_OPTIONAL
; ;
static int isWaveChartFull(WaveChart *chart) { int WaveChart::isWaveChartFull() {
return chart->counter >= engineConfiguration->digitalChartSize; return counter >= engineConfiguration->digitalChartSize;
} }
static void printStatus(void) { static void printStatus(void) {
@ -100,23 +100,29 @@ void setChartSize(int newSize) {
printStatus(); printStatus();
} }
void publishChartIfFull(WaveChart *chart) { void WaveChart::publishChartIfFull() {
if (isWaveChartFull(chart)) { if (isWaveChartFull()) {
publishChart(chart); publishChart();
resetWaveChart(chart); resetWaveChart();
} }
} }
void publishChart(WaveChart *chart) { WaveChart::WaveChart() {
appendPrintf(&chart->logging, DELIMETER); initLoggingExt(&logging, "wave chart", WAVE_LOGGING_BUFFER, sizeof(WAVE_LOGGING_BUFFER));
waveChartUsedSize = loggingSize(&chart->logging); isInitialized = TRUE;
resetWaveChart();
}
void WaveChart::publishChart() {
appendPrintf(&logging, DELIMETER);
waveChartUsedSize = loggingSize(&logging);
#if DEBUG_WAVE #if DEBUG_WAVE
Logging *l = &chart->logging; Logging *l = &chart->logging;
scheduleSimpleMsg(&debugLogging, "IT'S TIME", strlen(l->buffer)); scheduleSimpleMsg(&debugLogging, "IT'S TIME", strlen(l->buffer));
#endif #endif
bool isFullLog = getFullLog(); bool isFullLog = getFullLog();
if (isChartActive && isFullLog) { if (isChartActive && isFullLog) {
scheduleLogging(&chart->logging); scheduleLogging(&logging);
} }
} }
@ -125,12 +131,12 @@ static char timeBuffer[10];
/** /**
* @brief Register an event for digital sniffer * @brief Register an event for digital sniffer
*/ */
void addWaveChartEvent3(WaveChart *chart, const char *name, const char * msg, const char * msg2) { void WaveChart::addWaveChartEvent3(const char *name, const char * msg, const char * msg2) {
efiAssertVoid(chart->isInitialized, "chart not initialized"); efiAssertVoid(isInitialized, "chart not initialized");
#if DEBUG_WAVE #if DEBUG_WAVE
scheduleSimpleMsg(&debugLogging, "current", chart->counter); scheduleSimpleMsg(&debugLogging, "current", chart->counter);
#endif #endif
if (isWaveChartFull(chart)) { if (isWaveChartFull()) {
return; 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 bool alreadyLocked = lockOutputBuffer(); // we have multiple threads writing to the same output buffer
if (chart->counter == 0) { if (counter == 0) {
chart->startTime = time100; startTime = time100;
} }
chart->counter++; counter++;
if (remainingSize(&chart->logging) > 30) { if (remainingSize(&logging) > 30) {
/** /**
* printf is a heavy method, append is used here as a performance optimization * printf is a heavy method, append is used here as a performance optimization
*/ */
appendFast(&chart->logging, name); appendFast(&logging, name);
appendFast(&chart->logging, CHART_DELIMETER); appendFast(&logging, CHART_DELIMETER);
appendFast(&chart->logging, msg); appendFast(&logging, msg);
appendFast(&chart->logging, CHART_DELIMETER); appendFast(&logging, CHART_DELIMETER);
/** /**
* We want smaller times within a chart in order to reduce packet size. * We want smaller times within a chart in order to reduce packet size.
*/ */
time100 -= chart->startTime; time100 -= startTime;
itoa10(timeBuffer, time100); itoa10(timeBuffer, time100);
appendFast(&chart->logging, timeBuffer); appendFast(&logging, timeBuffer);
appendFast(&chart->logging, msg2); appendFast(&logging, msg2);
appendFast(&chart->logging, CHART_DELIMETER); appendFast(&logging, CHART_DELIMETER);
} }
if (!alreadyLocked) { if (!alreadyLocked) {
unlockOutputBuffer(); unlockOutputBuffer();
@ -192,8 +198,6 @@ void initWaveChart(WaveChart *chart) {
printStatus(); printStatus();
initLoggingExt(&chart->logging, "wave chart", WAVE_LOGGING_BUFFER, sizeof(WAVE_LOGGING_BUFFER));
chart->isInitialized = TRUE;
#if DEBUG_WAVE #if DEBUG_WAVE
initLoggingExt(&debugLogging, "wave chart debug", &debugLogging.DEFAULT_BUFFER, sizeof(debugLogging.DEFAULT_BUFFER)); initLoggingExt(&debugLogging, "wave chart debug", &debugLogging.DEFAULT_BUFFER, sizeof(debugLogging.DEFAULT_BUFFER));
#endif #endif
@ -202,7 +206,6 @@ void initWaveChart(WaveChart *chart) {
initHistogram(&waveChartHisto, "wave chart"); initHistogram(&waveChartHisto, "wave chart");
#endif /* EFI_HISTOGRAMS */ #endif /* EFI_HISTOGRAMS */
resetWaveChart(chart);
addConsoleActionI("chartsize", setChartSize); addConsoleActionI("chartsize", setChartSize);
addConsoleActionI("chart", setChartActive); addConsoleActionI("chart", setChartActive);
} }

View File

@ -20,6 +20,13 @@
*/ */
class WaveChart { class WaveChart {
public: 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 #if EFI_WAVE_CHART
Logging logging; Logging logging;
#endif /* EFI_WAVE_CHART */ #endif /* EFI_WAVE_CHART */
@ -28,12 +35,8 @@ public:
volatile int isInitialized; 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 initWaveChart(WaveChart *chart);
void showWaveChartHistogram(void); void showWaveChartHistogram(void);
void resetWaveChart(WaveChart *chart);
void setChartSize(int newSize); void setChartSize(int newSize);
void publishChartIfFull(WaveChart *chart);
#endif /* WAVE_CHART_H_ */ #endif /* WAVE_CHART_H_ */

View File

@ -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) { void addWaveChartEvent(const char *name, const char * msg, const char *msg2) {
#if EFI_WAVE_CHART #if EFI_WAVE_CHART
addWaveChartEvent3(&waveChart, name, msg, msg2); waveChart.addWaveChartEvent3(name, msg, msg2);
#endif /* EFI_WAVE_CHART */ #endif /* EFI_WAVE_CHART */
} }

View File

@ -21,7 +21,9 @@
#include "pin_repository.h" #include "pin_repository.h"
#endif #endif
#if EFI_WAVE_CHART
WaveChart waveChart; WaveChart waveChart;
#endif /* EFI_WAVE_CHART */
static histogram_s triggerCallback; static histogram_s triggerCallback;

View File

@ -156,7 +156,7 @@ static msg_t waThread(void *arg) {
while (TRUE) { while (TRUE) {
chThdSleepSeconds(CHART_RESET_DELAY); chThdSleepSeconds(CHART_RESET_DELAY);
publishChartIfFull(&waveChart); waveChart.publishChartIfFull();
} }
#endif /* EFI_WAVE_CHART */ #endif /* EFI_WAVE_CHART */
#if defined __GNUC__ #if defined __GNUC__

View File

@ -106,7 +106,7 @@ void rusEfiFunctionalTest(void) {
void printPendingMessages(void) { void printPendingMessages(void) {
updateDevConsoleState(); updateDevConsoleState();
publishChartIfFull(&waveChart); waveChart.publishChartIfFull();
} }
static size_t wt_writes(void *ip, const uint8_t *bp, size_t n) { static size_t wt_writes(void *ip, const uint8_t *bp, size_t n) {