auto-sync

This commit is contained in:
rusEfi 2015-02-14 21:04:03 -06:00
parent 43814539bd
commit 36598926fd
7 changed files with 75 additions and 23 deletions

View File

@ -35,7 +35,8 @@ void initDataStructures(DECLARE_ENGINE_PARAMETER_F) {
initSpeedDensity(engineConfiguration);
}
void initAlgo(engine_configuration_s *engineConfiguration) {
void initAlgo(Logging *sharedLogger, engine_configuration_s *engineConfiguration) {
initInterpolation(sharedLogger);
#if EFI_PROD_CODE || EFI_SIMULATOR
initSettings(engineConfiguration);
initSignalExecutor();

View File

@ -8,18 +8,9 @@
#ifndef ALGO_H_
#define ALGO_H_
#include "main.h"
#include "engine_configuration.h"
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
void initDataStructures(DECLARE_ENGINE_PARAMETER_F);
void initAlgo(engine_configuration_s *engineConfiguration);
#ifdef __cplusplus
}
#endif /* __cplusplus */
void initAlgo(Logging *sharedLogger, engine_configuration_s *engineConfiguration);
#endif /* ALGO_H_ */

View File

@ -4,6 +4,7 @@
*
* @date Oct 17, 2013
* @author Andrey Belomutskiy, (c) 2012-2015
* @author Dmitry Sidin, (c) 2015
*/
#if DEBUG_FUEL
@ -13,9 +14,58 @@
#include <math.h>
#include "main.h"
#include "efilib2.h"
#include "interpolation.h"
int needInterpolationLogging = TRUE;
int needInterpolationLogging = true;
#define BINARY_PERF true
Logging * logger;
#if BINARY_PERF
#define COUNT 10000
float array16[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
static void testBinary(void) {
const int size16 = 16;
uint32_t totalOld = 0;
uint32_t totalNew = 0;
for (int v = 0; v <= 16; v++) {
uint32_t timeOld;
{
uint32_t start = GET_TIMESTAMP();
int temp = 0;
for (int i = 0; i < COUNT; i++) {
temp += findIndex(array16, size16, v);
}
timeOld = GET_TIMESTAMP() - start;
}
uint32_t timeNew;
{
uint32_t start = GET_TIMESTAMP();
int temp = 0;
for (int i = 0; i < COUNT; i++) {
temp += findIndex2(array16, size16, v);
}
timeNew = GET_TIMESTAMP() - start;
}
scheduleMsg(logger, "for v=%d old=%d ticks", v, timeOld);
scheduleMsg(logger, "for v=%d new=%d ticks", v, timeNew);
totalOld += timeOld;
totalNew += timeNew;
}
scheduleMsg(logger, "totalOld=%d ticks", totalOld);
scheduleMsg(logger, "totalNew=%d ticks", totalNew);
}
#endif
FastInterpolation::FastInterpolation() {
init(0, 0, 1, 1);
@ -166,13 +216,13 @@ float interpolate3d(float x, float xBin[], int xBinSize, float y, float yBin[],
int xIndex = findIndex(xBin, xBinSize, x);
#if DEBUG_INTERPOLATION
if (needInterpolationLogging)
printf("X index=%d\r\n", xIndex);
printf("X index=%d\r\n", xIndex);
#endif
int yIndex = findIndex(yBin, yBinSize, y);
if (xIndex < 0 && yIndex < 0) {
#if DEBUG_INTERPOLATION
if (needInterpolationLogging)
printf("X and Y are smaller than smallest cell in table: %d\r\n", xIndex);
printf("X and Y are smaller than smallest cell in table: %d\r\n", xIndex);
#endif
return map[0][0];
}
@ -180,7 +230,7 @@ float interpolate3d(float x, float xBin[], int xBinSize, float y, float yBin[],
if (xIndex < 0) {
#if DEBUG_INTERPOLATION
if (needInterpolationLogging)
printf("X is smaller than smallest cell in table: %dr\n", xIndex);
printf("X is smaller than smallest cell in table: %dr\n", xIndex);
#endif
// no interpolation should be fine here.
return map[0][yIndex];
@ -189,7 +239,7 @@ float interpolate3d(float x, float xBin[], int xBinSize, float y, float yBin[],
if (yIndex < 0) {
#if DEBUG_INTERPOLATION
if (needInterpolationLogging)
printf("Y is smaller than smallest cell in table: %d\r\n", yIndex);
printf("Y is smaller than smallest cell in table: %d\r\n", yIndex);
#endif
// no interpolation should be fine here.
return map[xIndex][0];
@ -198,7 +248,7 @@ float interpolate3d(float x, float xBin[], int xBinSize, float y, float yBin[],
if (xIndex == xBinSize - 1 && yIndex == yBinSize - 1) {
#if DEBUG_INTERPOLATION
if (needInterpolationLogging)
printf("X and Y are larger than largest cell in table: %d %d\r\n", xIndex, yIndex);
printf("X and Y are larger than largest cell in table: %d %d\r\n", xIndex, yIndex);
#endif
return map[xBinSize - 1][yBinSize - 1];
}
@ -206,7 +256,7 @@ float interpolate3d(float x, float xBin[], int xBinSize, float y, float yBin[],
if (xIndex == xBinSize - 1) {
#if DEBUG_INTERPOLATION
if (needInterpolationLogging)
printf("TODO BETTER LOGGING x overflow %d\r\n", yIndex);
printf("TODO BETTER LOGGING x overflow %d\r\n", yIndex);
#endif
// todo: implement better handling - y interpolation
return map[xBinSize - 1][yIndex];
@ -215,7 +265,7 @@ float interpolate3d(float x, float xBin[], int xBinSize, float y, float yBin[],
if (yIndex == yBinSize - 1) {
#if DEBUG_INTERPOLATION
if (needInterpolationLogging)
printf("Y is larger than largest cell in table: %d\r\n", yIndex);
printf("Y is larger than largest cell in table: %d\r\n", yIndex);
#endif
// todo: implement better handling - x interpolation
return map[xIndex][yBinSize - 1];
@ -266,3 +316,10 @@ void setTableValue(float bins[], float values[], int size, float key, float valu
values[index] = value;
}
void initInterpolation(Logging *sharedLogger) {
logger = sharedLogger;
#if BINARY_PERF && ! EFI_UNIT_TEST
addConsoleAction("binarytest", testBinary);
#endif
}

View File

@ -8,6 +8,8 @@
#ifndef INTERPOLATION_3D_H_
#define INTERPOLATION_3D_H_
#include "datalogging.h"
#define INTERPOLATION_A(x1, y1, x2, y2) ((y1 - y2) / (x1 - x2))
int findIndex(const float array[], int size, float value);
@ -16,6 +18,7 @@ float interpolate(float x1, float y1, float x2, float y2, float x);
float interpolate2d(float value, float bin[], float values[], int size);
float interpolate3d(float x, float xBin[], int xBinSize, float y, float yBin[], int yBinSize, float* map[]);
void setTableValue(float bins[], float values[], int size, float key, float value);
void initInterpolation(Logging *sharedLogger);
class FastInterpolation {
public:

View File

@ -355,7 +355,7 @@ void initEngineContoller(Logging *sharedLogger, Engine *engine) {
initAnalogChart();
#endif /* EFI_ANALOG_CHART */
initAlgo(engineConfiguration);
initAlgo(sharedLogger, engineConfiguration);
#if EFI_WAVE_ANALYZER
if (engineConfiguration->isWaveAnalyzerEnabled) {

View File

@ -258,5 +258,5 @@ int getRusEfiVersion(void) {
return 1; // this is here to make the compiler happy about the unused array
if (UNUSED_CCM_SIZE == 0)
return 1; // this is here to make the compiler happy about the unused array
return 20150213;
return 20150214;
}

View File

@ -89,7 +89,7 @@ void rusEfiFunctionalTest(void) {
initSensors(PASS_ENGINE_PARAMETER_F);
initAlgo(engineConfiguration);
initAlgo(&sharedLogger, engineConfiguration);
initRpmCalculator(engine);
#if EFI_ANALOG_CHART