auto-sync
This commit is contained in:
parent
8a116552a3
commit
6d6f02036d
|
@ -83,9 +83,16 @@ void Engine::onTriggerEvent(efitick_t nowNt) {
|
|||
lastTriggerEventTimeNt = nowNt;
|
||||
}
|
||||
|
||||
Engine::Engine() {
|
||||
reset();
|
||||
}
|
||||
|
||||
Engine::Engine(persistent_config_s *config) {
|
||||
init(config);
|
||||
engineState.warmupAfrPid.init(&config->engineConfiguration.warmupAfrPid, 0.5, 1.5);
|
||||
setConfig(config);
|
||||
reset();
|
||||
}
|
||||
|
||||
void Engine::reset() {
|
||||
isEngineChartEnabled = false;
|
||||
sensorChartMode = SC_OFF;
|
||||
actualLastInjection = 0;
|
||||
|
@ -130,6 +137,7 @@ EngineState::EngineState() {
|
|||
warningCounter = 0;
|
||||
lastErrorCode = 0;
|
||||
crankingTime = 0;
|
||||
timeSinceCranking = 0;
|
||||
targetAFR = 0;
|
||||
tpsAccelEnrich = 0;
|
||||
tChargeK = 0;
|
||||
|
@ -232,10 +240,11 @@ void Engine::preCalculate() {
|
|||
}
|
||||
}
|
||||
|
||||
void Engine::init(persistent_config_s *config) {
|
||||
void Engine::setConfig(persistent_config_s *config) {
|
||||
this->config = config;
|
||||
engineConfiguration = &config->engineConfiguration;
|
||||
memset(config, 0, sizeof(persistent_config_s));
|
||||
engineState.warmupAfrPid.init(&config->engineConfiguration.warmupAfrPid, 0.5, 1.5);
|
||||
}
|
||||
|
||||
void Engine::printKnockState(void) {
|
||||
|
@ -297,7 +306,7 @@ void Engine::watchdog() {
|
|||
return;
|
||||
}
|
||||
isSpinning = false;
|
||||
ignitionList()->isReady = false;
|
||||
ignitionEvents.isReady = false;
|
||||
#if EFI_PROD_CODE || EFI_SIMULATOR
|
||||
scheduleMsg(&logger, "engine has STOPPED");
|
||||
scheduleMsg(&logger, "templog engine has STOPPED [%x][%x] [%x][%x] %d",
|
||||
|
@ -312,10 +321,6 @@ void Engine::watchdog() {
|
|||
#endif
|
||||
}
|
||||
|
||||
IgnitionEventList * Engine::ignitionList() {
|
||||
return &engineConfiguration2->ignitionEvents;
|
||||
}
|
||||
|
||||
injection_mode_e Engine::getCurrentInjectionMode(DECLARE_ENGINE_PARAMETER_F) {
|
||||
int rpm = rpmCalculator.rpmValue;
|
||||
return isCrankingR(rpm) ? CONFIG(crankingInjectionMode) : CONFIG(injectionMode);
|
||||
|
|
|
@ -76,11 +76,9 @@ public:
|
|||
FuelSchedule *injectionEvents;
|
||||
#endif
|
||||
|
||||
OutputSignalPair fuelActuators[INJECTION_PIN_COUNT];
|
||||
|
||||
float fsioLastValue[LE_COMMAND_COUNT];
|
||||
|
||||
IgnitionEventList ignitionEvents;
|
||||
};
|
||||
|
||||
class ThermistorMath {
|
||||
|
@ -241,10 +239,15 @@ typedef void (*configuration_callback_t)(Engine*);
|
|||
class Engine {
|
||||
public:
|
||||
Engine(persistent_config_s *config);
|
||||
void init(persistent_config_s *config);
|
||||
Engine();
|
||||
void setConfig(persistent_config_s *config);
|
||||
void reset();
|
||||
void prepareFuelSchedule(DECLARE_ENGINE_PARAMETER_F);
|
||||
injection_mode_e getCurrentInjectionMode(DECLARE_ENGINE_PARAMETER_F);
|
||||
IgnitionEventList *ignitionList(); // todo: inline/rename/refactor
|
||||
|
||||
OutputSignalPair fuelActuators[INJECTION_PIN_COUNT];
|
||||
IgnitionEventList ignitionEvents;
|
||||
|
||||
|
||||
WallFuel wallFuel;
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ typedef enum {
|
|||
FO_1_2_3 = 10,
|
||||
|
||||
// 4 cylinder
|
||||
FO_1_3_4_2 = 1,
|
||||
FO_1_3_4_2 = 1, // typical inline 4
|
||||
FO_1_2_4_3 = 2,
|
||||
FO_1_3_2_4 = 3,
|
||||
FO_1_3_2_4 = 3, // for example horizontally opposed engine
|
||||
// 8 cylinder
|
||||
FO_1_8_4_3_6_5_7_2 = 5,
|
||||
FO_1_8_7_2_6_5_4_3 = 11,
|
||||
|
|
|
@ -101,7 +101,7 @@ engine_configuration2_s * engineConfiguration2 = &ec2;
|
|||
* todo: eliminate constructor parameter so that _engine could be moved to CCM_OPTIONAL
|
||||
* todo: this should probably become 'static', i.e. private, and propagated around explicitly?
|
||||
*/
|
||||
Engine _engine(&persistentState.persistentConfiguration);
|
||||
Engine _engine CCM_OPTIONAL;
|
||||
Engine * engine = &_engine;
|
||||
#endif /* EFI_PROD_CODE */
|
||||
|
||||
|
@ -137,16 +137,6 @@ static msg_t csThread(void) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
static void updateErrorCodes(void) {
|
||||
/**
|
||||
* technically we can set error codes right inside the getMethods, but I a bit on a fence about it
|
||||
*/
|
||||
setError(!isValidIntakeAirTemperature(getIntakeAirTemperature(PASS_ENGINE_PARAMETER_F)),
|
||||
OBD_Intake_Air_Temperature_Circuit_Malfunction);
|
||||
setError(!isValidCoolantTemperature(getCoolantTemperature(PASS_ENGINE_PARAMETER_F)),
|
||||
OBD_Engine_Coolant_Temperature_Circuit_Malfunction);
|
||||
}
|
||||
|
||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||
Overflow64Counter halTime;
|
||||
|
||||
|
@ -253,8 +243,6 @@ static void periodicSlowCallback(Engine *engine) {
|
|||
runFsio();
|
||||
#endif
|
||||
|
||||
updateErrorCodes();
|
||||
|
||||
cylinderCleanupControl(engine);
|
||||
|
||||
scheduleNextSlowInvocation();
|
||||
|
|
|
@ -304,7 +304,7 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
|
|||
getRevolutionCounter());
|
||||
#endif /* EFI_DEFAILED_LOGGING */
|
||||
|
||||
OutputSignalPair *pair = &ENGINE(engineConfiguration2)->fuelActuators[injEventIndex];
|
||||
OutputSignalPair *pair = &ENGINE(fuelActuators[injEventIndex]);
|
||||
|
||||
if (event->isSimultanious) {
|
||||
/**
|
||||
|
@ -489,7 +489,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex D
|
|||
engine->fuelScheduleForThisEngineCycle->usedAtEngineCycle = ENGINE(rpmCalculator).getRevolutionCounter();
|
||||
|
||||
if (triggerVersion.isOld()) {
|
||||
engine->ignitionList()->isReady = false; // we need to rebuild ignition schedule
|
||||
engine->ignitionEvents.isReady = false; // we need to rebuild ignition schedule
|
||||
engine->fuelScheduleForThisEngineCycle->isReady = false;
|
||||
// todo: move 'triggerIndexByAngle' change into trigger initialization, why is it invoked from here if it's only about trigger shape & optimization?
|
||||
prepareOutputSignals(PASS_ENGINE_PARAMETER_F);
|
||||
|
|
|
@ -254,6 +254,12 @@ void prepareIgnitionSchedule(IgnitionEvent *event DECLARE_ENGINE_PARAMETER_S) {
|
|||
}
|
||||
|
||||
static void initializeIgnitionActions(IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S) {
|
||||
if (cisnan(ENGINE(engineState.timingAdvance))) {
|
||||
// error should already be reported
|
||||
// need to invalidate previous ignition schedule
|
||||
list->isReady = false;
|
||||
return;
|
||||
}
|
||||
efiAssertVoid(engineConfiguration->specs.cylindersCount > 0, "cylindersCount");
|
||||
|
||||
for (int cylinderIndex = 0; cylinderIndex < CONFIG(specs.cylindersCount); cylinderIndex++) {
|
||||
|
@ -291,14 +297,8 @@ static ALWAYS_INLINE void prepareIgnitionSchedule(int rpm DECLARE_ENGINE_PARAMET
|
|||
|
||||
// todo: add some check for dwell overflow? like 4 times 6 ms while engine cycle is less then that
|
||||
|
||||
IgnitionEventList *list = engine->ignitionList();
|
||||
IgnitionEventList *list = &engine->ignitionEvents;
|
||||
|
||||
if (cisnan(ENGINE(engineState.timingAdvance))) {
|
||||
// error should already be reported
|
||||
// need to invalidate previous ignition schedule
|
||||
list->isReady = false;
|
||||
return;
|
||||
}
|
||||
initializeIgnitionActions(list PASS_ENGINE_PARAMETER);
|
||||
engine->m.ignitionSchTime = GET_TIMESTAMP() - engine->m.beforeIgnitionSch;
|
||||
}
|
||||
|
@ -311,8 +311,7 @@ void handleSpark(bool limitedSpark, uint32_t trgEventIndex, int rpm
|
|||
return;
|
||||
}
|
||||
|
||||
IgnitionEventList *list = engine->ignitionList();
|
||||
if (!list->isReady) {
|
||||
if (!engine->ignitionEvents.isReady) {
|
||||
prepareIgnitionSchedule(rpm PASS_ENGINE_PARAMETER);
|
||||
}
|
||||
|
||||
|
@ -342,9 +341,9 @@ void handleSpark(bool limitedSpark, uint32_t trgEventIndex, int rpm
|
|||
}
|
||||
|
||||
// scheduleSimpleMsg(&logger, "eventId spark ", eventIndex);
|
||||
if (list->isReady) {
|
||||
if (engine->ignitionEvents.isReady) {
|
||||
for (int i = 0; i < CONFIG(specs.cylindersCount); i++) {
|
||||
IgnitionEvent *event = &list->elements[i];
|
||||
IgnitionEvent *event = &engine->ignitionEvents.elements[i];
|
||||
if (event->dwellPosition.eventIndex != trgEventIndex)
|
||||
continue;
|
||||
handleSparkEvent(limitedSpark, trgEventIndex, event, rpm PASS_ENGINE_PARAMETER);
|
||||
|
|
|
@ -200,7 +200,7 @@ void runRusEfi(void) {
|
|||
*/
|
||||
initializeConsole(&sharedLogger);
|
||||
|
||||
engine->init(config);
|
||||
engine->setConfig(config);
|
||||
|
||||
addConsoleAction("reboot", scheduleReboot);
|
||||
|
||||
|
@ -281,9 +281,9 @@ void firmwareError(obd_code_e code, const char *errorMsg, ...) {
|
|||
}
|
||||
}
|
||||
|
||||
static char UNUSED_RAM_SIZE[1100];
|
||||
static char UNUSED_RAM_SIZE[11100];
|
||||
|
||||
static char UNUSED_CCM_SIZE[26500] CCM_OPTIONAL;
|
||||
static char UNUSED_CCM_SIZE[16500] CCM_OPTIONAL;
|
||||
|
||||
int getRusEfiVersion(void) {
|
||||
if (UNUSED_RAM_SIZE[0] != 0)
|
||||
|
|
|
@ -148,7 +148,7 @@ void test1995FordInline6TriggerDecoder(void) {
|
|||
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_F);
|
||||
eth.fireTriggerEvents(48);
|
||||
|
||||
IgnitionEventList *ecl = ð.ec2.ignitionEvents;
|
||||
IgnitionEventList *ecl = ð.engine.ignitionEvents;
|
||||
assertEqualsM("ford inline ignition events size", 1, ecl->isReady);
|
||||
assertEqualsM("event index", 0, ecl->elements[0].dwellPosition.eventIndex);
|
||||
assertEqualsM("angle offset#1", 7, ecl->elements[0].dwellPosition.angleOffset);
|
||||
|
@ -300,7 +300,7 @@ void testRpmCalculator(void) {
|
|||
|
||||
EngineTestHelper eth(FORD_INLINE_6_1995);
|
||||
EXPAND_EngineTestHelper;
|
||||
IgnitionEventList *ilist = ð.engine.engineConfiguration2->ignitionEvents;
|
||||
IgnitionEventList *ilist = ð.engine.ignitionEvents;
|
||||
assertEqualsM("size #1", 0, ilist->isReady);
|
||||
|
||||
assertEqualsM("engineCycle", 720, eth.engine.engineCycle);
|
||||
|
|
Loading…
Reference in New Issue