auto-sync
This commit is contained in:
parent
7b046bdadd
commit
8ebb83b92a
|
@ -32,7 +32,7 @@ EXTERN_ENGINE;
|
|||
void initDataStructures(DECLARE_ENGINE_PARAMETER_F) {
|
||||
prepareFuelMap(engineConfiguration);
|
||||
prepareTimingMap(PASS_ENGINE_PARAMETER_F);
|
||||
initSpeedDensity(engineConfiguration);
|
||||
initSpeedDensity(config);
|
||||
}
|
||||
|
||||
void initAlgo(Logging *sharedLogger, engine_configuration_s *engineConfiguration) {
|
||||
|
|
|
@ -62,6 +62,7 @@ Engine::Engine(persistent_config_s *config) {
|
|||
isTestMode = false;
|
||||
isSpinning = false;
|
||||
adcToVoltageInputDividerCoefficient = NAN;
|
||||
this->config = config;
|
||||
engineConfiguration = &config->engineConfiguration;
|
||||
engineConfiguration2 = NULL;
|
||||
engineState.iat = engineState.clt = NAN;
|
||||
|
|
|
@ -121,6 +121,7 @@ public:
|
|||
Engine(persistent_config_s *config);
|
||||
void init();
|
||||
RpmCalculator rpmCalculator;
|
||||
persistent_config_s *config;
|
||||
engine_configuration_s *engineConfiguration;
|
||||
engine_configuration2_s *engineConfiguration2;
|
||||
|
||||
|
|
|
@ -66,6 +66,8 @@ extern bool hasFirmwareErrorFlag;
|
|||
|
||||
persistent_config_container_s persistentState CCM_OPTIONAL;
|
||||
|
||||
persistent_config_s *config;
|
||||
|
||||
/**
|
||||
* todo: it really looks like these fields should become 'static', i.e. private
|
||||
* the whole 'extern ...' pattern is less then perfect, I guess the 'God object' Engine
|
||||
|
|
|
@ -345,7 +345,7 @@ void prepareOutputSignals(DECLARE_ENGINE_PARAMETER_F) {
|
|||
engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2;
|
||||
|
||||
// todo: move this reset into decoder
|
||||
engine->triggerShape.calculateTriggerSynchPoint(engineConfiguration, engine);
|
||||
engine->triggerShape.calculateTriggerSynchPoint(PASS_ENGINE_PARAMETER_F);
|
||||
|
||||
for (int i = 0; i < CONFIG(specs.cylindersCount); i++) {
|
||||
ENGINE(angleExtra[i])= (float) CONFIG(engineCycle) * i / CONFIG(specs.cylindersCount);
|
||||
|
|
|
@ -106,7 +106,8 @@ void setDetaultVETable(engine_configuration_s *engineConfiguration) {
|
|||
afrMap.setAll(14.7);
|
||||
}
|
||||
|
||||
void initSpeedDensity(engine_configuration_s *e) {
|
||||
void initSpeedDensity(persistent_config_s *config) {
|
||||
engine_configuration_s *e = &config->engineConfiguration;
|
||||
veMap.init(e->veTable, e->veLoadBins, e->veRpmBins);
|
||||
ve2Map.init(e->ve2Table, e->ve2LoadBins, e->ve2RpmBins);
|
||||
afrMap.init(e->afrTable, e->afrLoadBins, e->afrRpmBins);
|
||||
|
|
|
@ -18,7 +18,7 @@ float sdMath(engine_configuration_s *engineConfiguration, float VE, float MAP, f
|
|||
#define cc_minute_to_gramm_second(ccm) ((ccm) * 0.0119997981)
|
||||
|
||||
void setDetaultVETable(engine_configuration_s *engineConfiguration);
|
||||
void initSpeedDensity(engine_configuration_s *engineConfiguration);
|
||||
void initSpeedDensity(persistent_config_s *config);
|
||||
float getSpeedDensityFuel(int rpm DECLARE_ENGINE_PARAMETER_S);
|
||||
|
||||
#endif /* SPEED_DENSITY_H_ */
|
||||
|
|
|
@ -100,8 +100,8 @@ static FastInterpolation *getDecoder(air_pressure_sensor_type_e type) {
|
|||
}
|
||||
|
||||
static void applyConfiguration(DECLARE_ENGINE_PARAMETER_F) {
|
||||
air_pressure_sensor_config_s * config = &engineConfiguration->map.sensor;
|
||||
customMap.init(0, config->valueAt0, 5, config->valueAt5);
|
||||
air_pressure_sensor_config_s * apConfig = &engineConfiguration->map.sensor;
|
||||
customMap.init(0, apConfig->valueAt0, 5, apConfig->valueAt5);
|
||||
mapDecoder = getDecoder(engineConfiguration->map.sensor.type);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ int TriggerShape::getTriggerShapeSynchPointIndex() {
|
|||
return triggerShapeSynchPointIndex;
|
||||
}
|
||||
|
||||
void TriggerShape::calculateTriggerSynchPoint(engine_configuration_s *engineConfiguration, Engine *engine) {
|
||||
void TriggerShape::calculateTriggerSynchPoint(DECLARE_ENGINE_PARAMETER_F) {
|
||||
trigger_config_s const*triggerConfig = &engineConfiguration->trigger;
|
||||
setTriggerShapeSynchPointIndex(engineConfiguration, findTriggerZeroEventIndex(this, triggerConfig PASS_ENGINE_PARAMETER), engine);
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ public:
|
|||
|
||||
int getTriggerShapeSynchPointIndex();
|
||||
|
||||
void calculateTriggerSynchPoint(engine_configuration_s *engineConfiguration, Engine *engine);
|
||||
void calculateTriggerSynchPoint(DECLARE_ENGINE_PARAMETER_F);
|
||||
|
||||
void setTriggerShapeSynchPointIndex(engine_configuration_s *engineConfiguration, int triggerShapeSynchPointIndex, Engine *engine);
|
||||
private:
|
||||
|
|
|
@ -81,6 +81,7 @@ typedef Thread thread_t;
|
|||
extern board_configuration_s *boardConfiguration; \
|
||||
extern persistent_config_container_s persistentState; \
|
||||
extern Engine _engine; \
|
||||
extern persistent_config_s *config; \
|
||||
extern engine_configuration2_s * engineConfiguration2
|
||||
|
||||
#define DECLARE_ENGINE_PARAMETER_F void
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
extern int timeNow;
|
||||
|
||||
EngineTestHelper::EngineTestHelper(engine_type_e engineType) : engine (&persistentConfig) {
|
||||
ec = &persistentConfig.engineConfiguration;
|
||||
engineConfiguration = ec = &persistentConfig.engineConfiguration;
|
||||
config = &persistentConfig;
|
||||
|
||||
engine_configuration_s *engineConfiguration = ec;
|
||||
|
||||
|
@ -38,7 +39,7 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType) : engine (&persiste
|
|||
prepareFuelMap(engine->engineConfiguration);
|
||||
|
||||
|
||||
initSpeedDensity(ec);
|
||||
initSpeedDensity(&persistentConfig);
|
||||
|
||||
resetConfigurationExt(NULL, engineType PASS_ENGINE_PARAMETER);
|
||||
prepareShapes(PASS_ENGINE_PARAMETER_F);
|
||||
|
@ -46,11 +47,12 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType) : engine (&persiste
|
|||
}
|
||||
|
||||
void EngineTestHelper::fireTriggerEvents() {
|
||||
Engine *engine = &this->engine;
|
||||
for (int i = 0; i < 24; i++) {
|
||||
timeNow += 5000; // 5ms
|
||||
triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP, &engine, engine.engineConfiguration);
|
||||
triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER);
|
||||
timeNow += 5000;
|
||||
triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN, &engine, engine.engineConfiguration);
|
||||
triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN PASS_ENGINE_PARAMETER);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,10 +18,12 @@ public:
|
|||
void fireTriggerEvents();
|
||||
|
||||
persistent_config_s persistentConfig;
|
||||
persistent_config_s *config;
|
||||
engine_configuration2_s ec2;
|
||||
Engine engine;
|
||||
|
||||
engine_configuration_s *ec;
|
||||
engine_configuration_s *engineConfiguration;
|
||||
|
||||
TriggerCentral triggerCentral;
|
||||
};
|
||||
|
|
|
@ -38,10 +38,10 @@ typedef int bool_t;
|
|||
class Engine;
|
||||
#endif
|
||||
|
||||
#define DECLARE_ENGINE_PARAMETER_F Engine *engine, engine_configuration_s *engineConfiguration
|
||||
#define DECLARE_ENGINE_PARAMETER_S , Engine *engine, engine_configuration_s *engineConfiguration
|
||||
#define PASS_ENGINE_PARAMETER_F engine, engineConfiguration
|
||||
#define PASS_ENGINE_PARAMETER , engine, engineConfiguration
|
||||
#define DECLARE_ENGINE_PARAMETER_F Engine *engine, engine_configuration_s *engineConfiguration, persistent_config_s *config
|
||||
#define DECLARE_ENGINE_PARAMETER_S , Engine *engine, engine_configuration_s *engineConfiguration, persistent_config_s *config
|
||||
#define PASS_ENGINE_PARAMETER_F engine, engineConfiguration, config
|
||||
#define PASS_ENGINE_PARAMETER , engine, engineConfiguration, config
|
||||
|
||||
#define CONFIG(x) engineConfiguration->x
|
||||
#define ENGINE(x) engine->x
|
||||
|
|
|
@ -24,6 +24,7 @@ void testMafFuelMath(void) {
|
|||
|
||||
Engine *engine = ð.engine;
|
||||
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
||||
persistent_config_s *config = engine->config;
|
||||
|
||||
engineConfiguration->algorithm = LM_REAL_MAF;
|
||||
|
||||
|
@ -58,6 +59,7 @@ void testFuelMap(void) {
|
|||
|
||||
Engine *engine = ð.engine;
|
||||
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
||||
persistent_config_s *config = engine->config;
|
||||
|
||||
initThermistors(NULL PASS_ENGINE_PARAMETER);
|
||||
|
||||
|
@ -174,6 +176,7 @@ void testAngleResolver(void) {
|
|||
Engine *engine = ð.engine;
|
||||
|
||||
engine_configuration_s *engineConfiguration = eth.engine.engineConfiguration;
|
||||
persistent_config_s *config = engine->config;
|
||||
|
||||
engineConfiguration->globalTriggerAngleOffset = 175;
|
||||
assertTrue(engine->engineConfiguration2!=NULL);
|
||||
|
@ -181,7 +184,7 @@ void testAngleResolver(void) {
|
|||
|
||||
confgiureFordAspireTriggerShape(ts);
|
||||
|
||||
ts->calculateTriggerSynchPoint(engineConfiguration, engine);
|
||||
ts->calculateTriggerSynchPoint(PASS_ENGINE_PARAMETER_F);
|
||||
|
||||
assertEqualsM("index 2", 228.0450, ts->eventAngles[3]); // this angle is relation to synch point
|
||||
assertEqualsM("time 2", 0.3233, ts->wave.getSwitchTime(2));
|
||||
|
|
|
@ -20,6 +20,7 @@ void testIdleController(void) {
|
|||
EngineTestHelper eth(FORD_INLINE_6_1995);
|
||||
Engine *engine = ð.engine;
|
||||
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
||||
persistent_config_s *config = engine->config;
|
||||
|
||||
engineConfiguration->targetIdleRpm = 1200;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ void testSpeedDensity(void) {
|
|||
EngineTestHelper eth(FORD_INLINE_6_1995);
|
||||
Engine *engine = ð.engine;
|
||||
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
||||
persistent_config_s *config = engine->config;
|
||||
|
||||
eth.ec->trigger.customTotalToothCount = 8;
|
||||
eth.initTriggerShapeAndRpmCalculator();
|
||||
|
|
|
@ -46,6 +46,8 @@ int getTheAngle(engine_type_e engineType) {
|
|||
|
||||
Engine *engine = ð.engine;
|
||||
engine_configuration_s *engineConfiguration = eth.ec;
|
||||
persistent_config_s *config = engine->config;
|
||||
|
||||
initDataStructures(PASS_ENGINE_PARAMETER_F);
|
||||
|
||||
TriggerShape * shape = ð.engine.triggerShape;
|
||||
|
@ -119,6 +121,7 @@ static void test1995FordInline6TriggerDecoder(void) {
|
|||
|
||||
engine_configuration_s *engineConfiguration = eth.engine.engineConfiguration;
|
||||
Engine *engine = ð.engine;
|
||||
persistent_config_s *config = engine->config;
|
||||
|
||||
TriggerShape * shape = ð.engine.triggerShape;
|
||||
|
||||
|
@ -184,6 +187,7 @@ void testFordAspire(void) {
|
|||
|
||||
Engine *engine = ð.engine;
|
||||
engine_configuration_s *engineConfiguration = eth.ec;
|
||||
persistent_config_s *config = eth.config;
|
||||
assertEquals(4, eth.engine.triggerShape.getTriggerShapeSynchPointIndex());
|
||||
|
||||
assertEquals(800, engineConfiguration->fuelRpmBins[0]);
|
||||
|
@ -211,6 +215,8 @@ void testMazdaMianaNbDecoder(void) {
|
|||
EngineTestHelper eth(MAZDA_MIATA_NB);
|
||||
engine_configuration_s *ec = eth.ec;
|
||||
Engine *engine = ð.engine;
|
||||
persistent_config_s *config = eth.config;
|
||||
|
||||
engine_configuration_s *engineConfiguration = ec;
|
||||
TriggerShape * shape = ð.engine.triggerShape;
|
||||
assertEquals(11, shape->getTriggerShapeSynchPointIndex());
|
||||
|
@ -295,8 +301,9 @@ static void testTriggerDecoder2(const char *msg, engine_type_e type, int synchPo
|
|||
|
||||
EngineTestHelper eth(type);
|
||||
engine_configuration_s *ec = eth.ec;
|
||||
persistent_config_s *config = eth.config;
|
||||
|
||||
initSpeedDensity(ec);
|
||||
initSpeedDensity(config);
|
||||
|
||||
TriggerShape *t = ð.engine.triggerShape;
|
||||
|
||||
|
@ -324,6 +331,7 @@ static void testStartupFuelPumping(void) {
|
|||
|
||||
Engine * engine = ð.engine;
|
||||
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
||||
persistent_config_s *config = engine->config;
|
||||
|
||||
engine->rpmCalculator.mockRpm = 0;
|
||||
|
||||
|
@ -370,6 +378,7 @@ static void testRpmCalculator(void) {
|
|||
efiAssertVoid(eth.engine.engineConfiguration!=NULL, "null config in engine");
|
||||
|
||||
Engine *engine = ð.engine;
|
||||
persistent_config_s *config = eth.config;
|
||||
engine_configuration_s *engineConfiguration = ð.persistentConfig.engineConfiguration;
|
||||
|
||||
initThermistors(NULL PASS_ENGINE_PARAMETER);
|
||||
|
@ -399,7 +408,7 @@ static void testRpmCalculator(void) {
|
|||
prepareTimingMap(PASS_ENGINE_PARAMETER_F);
|
||||
|
||||
timeNow += 5000; // 5ms
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP, ð.engine, eth.ec);
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER);
|
||||
assertEqualsM("index #2", 0, eth.triggerCentral.triggerState.getCurrentIndex());
|
||||
assertEqualsM("queue size", 6, schedulingQueue.size());
|
||||
assertEqualsM("ev 1", 246444, schedulingQueue.getForUnitText(0)->momentX);
|
||||
|
@ -407,11 +416,11 @@ static void testRpmCalculator(void) {
|
|||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000;
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN, ð.engine, eth.ec);
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN PASS_ENGINE_PARAMETER);
|
||||
timeNow += 5000; // 5ms
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP, ð.engine, eth.ec);
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER);
|
||||
timeNow += 5000;
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN, ð.engine, eth.ec);
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN PASS_ENGINE_PARAMETER);
|
||||
assertEqualsM("index #3", 3, eth.triggerCentral.triggerState.getCurrentIndex());
|
||||
assertEqualsM("queue size 3", 6, schedulingQueue.size());
|
||||
assertEqualsM("ev 3", 259777, schedulingQueue.getForUnitText(0)->momentX);
|
||||
|
@ -421,24 +430,24 @@ static void testRpmCalculator(void) {
|
|||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000;
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN, ð.engine, eth.ec);
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN PASS_ENGINE_PARAMETER);
|
||||
timeNow += 5000; // 5ms
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP, ð.engine, eth.ec);
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER);
|
||||
timeNow += 5000; // 5ms
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP, ð.engine, eth.ec);
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER);
|
||||
assertEqualsM("index #4", 6, eth.triggerCentral.triggerState.getCurrentIndex());
|
||||
assertEqualsM("queue size 4", 6, schedulingQueue.size());
|
||||
assertEqualsM("4/0", 273111, schedulingQueue.getForUnitText(0)->momentX);
|
||||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000;
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN, ð.engine, eth.ec);
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN PASS_ENGINE_PARAMETER);
|
||||
assertEqualsM("queue size 5", 0, schedulingQueue.size());
|
||||
// assertEqualsM("5/1", 284500, schedulingQueue.getForUnitText(0)->momentUs);
|
||||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000; // 5ms
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP, ð.engine, eth.ec);
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER);
|
||||
assertEqualsM("queue size 6", 6, schedulingQueue.size());
|
||||
assertEqualsM("6/0", 286444, schedulingQueue.getForUnitText(0)->momentX);
|
||||
assertEqualsM("6/1", 285944, schedulingQueue.getForUnitText(1)->momentX);
|
||||
|
@ -446,12 +455,12 @@ static void testRpmCalculator(void) {
|
|||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000;
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN, ð.engine, eth.ec);
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN PASS_ENGINE_PARAMETER);
|
||||
assertEqualsM("queue size 7", 0, schedulingQueue.size());
|
||||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000; // 5ms
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP, ð.engine, eth.ec);
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER);
|
||||
assertEqualsM("queue size 8", 6, schedulingQueue.size());
|
||||
assertEqualsM("8/0", 299777, schedulingQueue.getForUnitText(0)->momentX);
|
||||
assertEqualsM("8/1", 299277, schedulingQueue.getForUnitText(1)->momentX);
|
||||
|
@ -460,12 +469,12 @@ static void testRpmCalculator(void) {
|
|||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000;
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN, ð.engine, eth.ec);
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN PASS_ENGINE_PARAMETER);
|
||||
assertEqualsM("queue size 9", 0, schedulingQueue.size());
|
||||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000; // 5ms
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP, ð.engine, eth.ec);
|
||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER);
|
||||
assertEqualsM("queue size 10", 0, schedulingQueue.size());
|
||||
schedulingQueue.clear();
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ typedef EventListener event_listener_t;
|
|||
#define EXTERN_ENGINE extern Engine *engine; \
|
||||
extern engine_configuration_s *engineConfiguration; \
|
||||
extern board_configuration_s *boardConfiguration; \
|
||||
extern persistent_config_s *config; \
|
||||
extern persistent_config_container_s persistentState
|
||||
|
||||
#define DECLARE_ENGINE_PARAMETER_F void
|
||||
|
|
Loading…
Reference in New Issue