auto-sync
This commit is contained in:
parent
3b34c95c01
commit
f575e7bd55
|
@ -169,8 +169,8 @@ void printState(Engine *engine, int currentCkpEventCounter) {
|
||||||
|
|
||||||
// debugFloat(&logger, "table_spark", getAdvance(rpm, getMaf()), 2);
|
// debugFloat(&logger, "table_spark", getAdvance(rpm, getMaf()), 2);
|
||||||
|
|
||||||
float engineLoad = getEngineLoadT(engine);
|
float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER);
|
||||||
float baseFuel = getBaseFuel(engine, rpm);
|
float baseFuel = getBaseFuel(rpm PASS_ENGINE_PARAMETER);
|
||||||
debugFloat(&logger, "fuel_base", baseFuel, 2);
|
debugFloat(&logger, "fuel_base", baseFuel, 2);
|
||||||
// debugFloat(&logger, "fuel_iat", getIatCorrection(getIntakeAirTemperature()), 2);
|
// debugFloat(&logger, "fuel_iat", getIatCorrection(getIntakeAirTemperature()), 2);
|
||||||
// debugFloat(&logger, "fuel_clt", getCltCorrection(getCoolantTemperature()), 2);
|
// debugFloat(&logger, "fuel_clt", getCltCorrection(getCoolantTemperature()), 2);
|
||||||
|
@ -333,7 +333,7 @@ static void showFuelInfo2(float rpm, float engineLoad, Engine *engine) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void showFuelInfo(Engine *engine) {
|
static void showFuelInfo(Engine *engine) {
|
||||||
showFuelInfo2((float) getRpmE(engine), getEngineLoadT(engine), engine);
|
showFuelInfo2((float) getRpmE(engine), getEngineLoadT(PASS_ENGINE_PARAMETER), engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* EFI_PROD_CODE */
|
#endif /* EFI_PROD_CODE */
|
||||||
|
@ -420,7 +420,7 @@ void updateTunerStudioState(Engine *engine, TunerStudioOutputChannels *tsOutputC
|
||||||
float coolant = getCoolantTemperature(engine);
|
float coolant = getCoolantTemperature(engine);
|
||||||
float intake = getIntakeAirTemperature(engine);
|
float intake = getIntakeAirTemperature(engine);
|
||||||
|
|
||||||
float engineLoad = getEngineLoadT(engine);
|
float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER);
|
||||||
float baseFuelMs = getBaseTableFuel(engineConfiguration, (int) rpm, engineLoad);
|
float baseFuelMs = getBaseTableFuel(engineConfiguration, (int) rpm, engineLoad);
|
||||||
|
|
||||||
tsOutputChannels->rpm = rpm;
|
tsOutputChannels->rpm = rpm;
|
||||||
|
|
|
@ -51,7 +51,7 @@ float getAccelEnrichment(void) {
|
||||||
static msg_t DiffEnrichmentThread(int param) {
|
static msg_t DiffEnrichmentThread(int param) {
|
||||||
chRegSetThreadName("Diff Enrichment");
|
chRegSetThreadName("Diff Enrichment");
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
instance.updateDiffEnrichment(engineConfiguration, getEngineLoad());
|
instance.updateDiffEnrichment(engineConfiguration, getEngineLoadT(PASS_ENGINE_PARAMETER));
|
||||||
chThdSleepMilliseconds(100);
|
chThdSleepMilliseconds(100);
|
||||||
}
|
}
|
||||||
#if defined __GNUC__
|
#if defined __GNUC__
|
||||||
|
|
|
@ -43,11 +43,11 @@
|
||||||
|
|
||||||
EXTERN_ENGINE;
|
EXTERN_ENGINE;
|
||||||
|
|
||||||
float getBaseFuel(Engine *engine, int rpm) {
|
float getBaseFuel(int rpm DECLARE_ENGINE_PARAMETER_S) {
|
||||||
if (engine->engineConfiguration->algorithm == LM_SPEED_DENSITY) {
|
if (engine->engineConfiguration->algorithm == LM_SPEED_DENSITY) {
|
||||||
return getSpeedDensityFuel(engine, rpm);
|
return getSpeedDensityFuel(engine, rpm);
|
||||||
} else {
|
} else {
|
||||||
float engineLoad = getEngineLoadT(engine);
|
float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_F);
|
||||||
return getBaseTableFuel(engine->engineConfiguration, rpm, engineLoad);
|
return getBaseTableFuel(engine->engineConfiguration, rpm, engineLoad);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ float getFuelMs(int rpm DECLARE_ENGINE_PARAMETER_S) {
|
||||||
if (isCrankingR(rpm)) {
|
if (isCrankingR(rpm)) {
|
||||||
theoreticalInjectionLength = getCrankingFuel(engine) / getNumberOfInjections(engineConfiguration, engineConfiguration->crankingInjectionMode);
|
theoreticalInjectionLength = getCrankingFuel(engine) / getNumberOfInjections(engineConfiguration, engineConfiguration->crankingInjectionMode);
|
||||||
} else {
|
} else {
|
||||||
float baseFuel = getBaseFuel(engine, rpm);
|
float baseFuel = getBaseFuel(rpm PASS_ENGINE_PARAMETER);
|
||||||
float fuelPerCycle = getRunningFuel(baseFuel, rpm PASS_ENGINE_PARAMETER);
|
float fuelPerCycle = getRunningFuel(baseFuel, rpm PASS_ENGINE_PARAMETER);
|
||||||
theoreticalInjectionLength = fuelPerCycle / getNumberOfInjections(engineConfiguration, engine->engineConfiguration->injectionMode);
|
theoreticalInjectionLength = fuelPerCycle / getNumberOfInjections(engineConfiguration, engine->engineConfiguration->injectionMode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
void prepareFuelMap(engine_configuration_s *engineConfiguration);
|
void prepareFuelMap(engine_configuration_s *engineConfiguration);
|
||||||
|
|
||||||
float getBaseFuel(Engine *engine, int rpm);
|
float getBaseFuel(int rpm DECLARE_ENGINE_PARAMETER_S);
|
||||||
float getBaseTableFuel(engine_configuration_s *engineConfiguration, int rpm, float engineLoad);
|
float getBaseTableFuel(engine_configuration_s *engineConfiguration, int rpm, float engineLoad);
|
||||||
float getIatCorrection(float iat DECLARE_ENGINE_PARAMETER_S);
|
float getIatCorrection(float iat DECLARE_ENGINE_PARAMETER_S);
|
||||||
float getInjectorLag(float vBatt DECLARE_ENGINE_PARAMETER_S);
|
float getInjectorLag(float vBatt DECLARE_ENGINE_PARAMETER_S);
|
||||||
|
|
|
@ -29,7 +29,7 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
void initMainEventListener(Engine *engine, engine_configuration2_s *engineConfiguration2);
|
void initMainEventListener(Engine *engine, engine_configuration2_s *engineConfiguration2);
|
||||||
void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex, Engine *engine);
|
void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex DECLARE_ENGINE_PARAMETER_S);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int isIgnitionTimingError(void);
|
int isIgnitionTimingError(void);
|
||||||
|
|
|
@ -126,7 +126,7 @@ static void endAveraging(void *arg) {
|
||||||
/**
|
/**
|
||||||
* Shaft Position callback used to schedule start and end of MAP averaging
|
* Shaft Position callback used to schedule start and end of MAP averaging
|
||||||
*/
|
*/
|
||||||
static void shaftPositionCallback(trigger_event_e ckpEventType, uint32_t index, Engine *arg) {
|
static void shaftPositionCallback(trigger_event_e ckpEventType, uint32_t index DECLARE_ENGINE_PARAMETER_S) {
|
||||||
// this callback is invoked on interrupt thread
|
// this callback is invoked on interrupt thread
|
||||||
|
|
||||||
if (index != 0)
|
if (index != 0)
|
||||||
|
|
|
@ -65,7 +65,7 @@ static void maThread(int param) {
|
||||||
|
|
||||||
// ideally this should be atomic, but hopefully it's good enough
|
// ideally this should be atomic, but hopefully it's good enough
|
||||||
int rpm = getRpm();
|
int rpm = getRpm();
|
||||||
float load = getEngineLoad();
|
float load = getEngineLoadT(PASS_ENGINE_PARAMETER);
|
||||||
float afr = getAfr();
|
float afr = getAfr();
|
||||||
|
|
||||||
addAfr(rpm, load, afr);
|
addAfr(rpm, load, afr);
|
||||||
|
|
|
@ -66,9 +66,8 @@ float fixAngle(float angle DECLARE_ENGINE_PARAMETER_S) {
|
||||||
* @brief Returns engine load according to selected engine_load_mode
|
* @brief Returns engine load according to selected engine_load_mode
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
float getEngineLoadT(Engine *engine) {
|
float getEngineLoadT(DECLARE_ENGINE_PARAMETER_F) {
|
||||||
efiAssert(engine!=NULL, "engine 2NULL", NAN);
|
efiAssert(engine!=NULL, "engine 2NULL", NAN);
|
||||||
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
|
||||||
efiAssert(engineConfiguration!=NULL, "engineConfiguration 2NULL", NAN);
|
efiAssert(engineConfiguration!=NULL, "engineConfiguration 2NULL", NAN);
|
||||||
switch (engineConfiguration->algorithm) {
|
switch (engineConfiguration->algorithm) {
|
||||||
case LM_MAF:
|
case LM_MAF:
|
||||||
|
|
|
@ -50,8 +50,8 @@ float getCrankshaftRevolutionTimeMs(int rpm);
|
||||||
|
|
||||||
#define isCrankingR(rpm) ((rpm) > 0 && (rpm) < engineConfiguration->crankingSettings.crankingRpm)
|
#define isCrankingR(rpm) ((rpm) > 0 && (rpm) < engineConfiguration->crankingSettings.crankingRpm)
|
||||||
|
|
||||||
float getEngineLoadT(Engine *engine);
|
float getEngineLoadT(DECLARE_ENGINE_PARAMETER_F);
|
||||||
#define getEngineLoad() getEngineLoadT(engine)
|
|
||||||
|
|
||||||
float getSparkDwellMsT(int rpm DECLARE_ENGINE_PARAMETER_S);
|
float getSparkDwellMsT(int rpm DECLARE_ENGINE_PARAMETER_S);
|
||||||
|
|
||||||
|
|
|
@ -288,7 +288,7 @@ void showMainHistogram(void) {
|
||||||
* This is the main trigger event handler.
|
* This is the main trigger event handler.
|
||||||
* Both injection and ignition are controlled from this method.
|
* Both injection and ignition are controlled from this method.
|
||||||
*/
|
*/
|
||||||
void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex, Engine *engine) {
|
void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex DECLARE_ENGINE_PARAMETER_S) {
|
||||||
if (hasFirmwareError()) {
|
if (hasFirmwareError()) {
|
||||||
/**
|
/**
|
||||||
* In case on a major error we should not process any more events.
|
* In case on a major error we should not process any more events.
|
||||||
|
@ -301,9 +301,6 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex, Eng
|
||||||
efiAssertVoid(eventIndex < 2 * engine->triggerShape.shaftPositionEventCount, "event index");
|
efiAssertVoid(eventIndex < 2 * engine->triggerShape.shaftPositionEventCount, "event index");
|
||||||
efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "lowstck#2");
|
efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "lowstck#2");
|
||||||
|
|
||||||
// todo: remove these local variables soon?
|
|
||||||
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
|
||||||
|
|
||||||
int rpm = getRpmE(engine);
|
int rpm = getRpmE(engine);
|
||||||
if (rpm == 0) {
|
if (rpm == 0) {
|
||||||
// this happens while we just start cranking
|
// this happens while we just start cranking
|
||||||
|
@ -348,7 +345,8 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex, Eng
|
||||||
firmwareError("invalid dwell: %f at %d", dwellMs, rpm);
|
firmwareError("invalid dwell: %f at %d", dwellMs, rpm);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float advance = getAdvance(rpm, getEngineLoadT(engine) PASS_ENGINE_PARAMETER);
|
float el = getEngineLoadT(PASS_ENGINE_PARAMETER_F);
|
||||||
|
float advance = getAdvance(rpm, el PASS_ENGINE_PARAMETER);
|
||||||
|
|
||||||
if (cisnan(advance)) {
|
if (cisnan(advance)) {
|
||||||
// error should already be reported
|
// error should already be reported
|
||||||
|
@ -402,8 +400,8 @@ void MainTriggerCallback::init(Engine *engine, engine_configuration2_s *engineCo
|
||||||
|
|
||||||
static void showMainInfo(Engine *engine) {
|
static void showMainInfo(Engine *engine) {
|
||||||
int rpm = engine->rpmCalculator.rpm();
|
int rpm = engine->rpmCalculator.rpm();
|
||||||
float el = getEngineLoadT(mainTriggerCallbackInstance.engine);
|
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
|
float el = getEngineLoadT(PASS_ENGINE_PARAMETER);
|
||||||
scheduleMsg(&logger, "rpm %d engine_load %f", rpm, el);
|
scheduleMsg(&logger, "rpm %d engine_load %f", rpm, el);
|
||||||
scheduleMsg(&logger, "fuel %fms timing %f", getFuelMs(rpm PASS_ENGINE_PARAMETER),
|
scheduleMsg(&logger, "fuel %fms timing %f", getFuelMs(rpm PASS_ENGINE_PARAMETER),
|
||||||
getAdvance(rpm, el PASS_ENGINE_PARAMETER));
|
getAdvance(rpm, el PASS_ENGINE_PARAMETER));
|
||||||
|
|
|
@ -127,7 +127,7 @@ bool isCranking(void) {
|
||||||
* updated here.
|
* updated here.
|
||||||
* This callback is invoked on interrupt thread.
|
* This callback is invoked on interrupt thread.
|
||||||
*/
|
*/
|
||||||
void rpmShaftPositionCallback(trigger_event_e ckpSignalType, uint32_t index, Engine *engine) {
|
void rpmShaftPositionCallback(trigger_event_e ckpSignalType, uint32_t index DECLARE_ENGINE_PARAMETER_S) {
|
||||||
RpmCalculator *rpmState = &engine->rpmCalculator;
|
RpmCalculator *rpmState = &engine->rpmCalculator;
|
||||||
uint64_t nowNt = getTimeNowNt();
|
uint64_t nowNt = getTimeNowNt();
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
|
@ -186,7 +186,7 @@ static void onTdcCallback(void) {
|
||||||
/**
|
/**
|
||||||
* This trigger callback schedules the actual physical TDC callback in relation to trigger synchronization point.
|
* This trigger callback schedules the actual physical TDC callback in relation to trigger synchronization point.
|
||||||
*/
|
*/
|
||||||
static void tdcMarkCallback(trigger_event_e ckpSignalType, uint32_t index0, Engine *engine) {
|
static void tdcMarkCallback(trigger_event_e ckpSignalType, uint32_t index0 DECLARE_ENGINE_PARAMETER_S) {
|
||||||
(void) ckpSignalType;
|
(void) ckpSignalType;
|
||||||
bool isTriggerSynchronizationPoint = index0 == 0;
|
bool isTriggerSynchronizationPoint = index0 == 0;
|
||||||
if (isTriggerSynchronizationPoint) {
|
if (isTriggerSynchronizationPoint) {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#define RPM_REPORTER_H_
|
#define RPM_REPORTER_H_
|
||||||
|
|
||||||
#include <global.h>
|
#include <global.h>
|
||||||
|
#include "engine_configuration.h"
|
||||||
|
|
||||||
#define WC_DOWN "d"
|
#define WC_DOWN "d"
|
||||||
#define WC_UP "u"
|
#define WC_UP "u"
|
||||||
|
@ -62,7 +63,7 @@ private:
|
||||||
#define getRpmE(engine) (engine)->rpmCalculator.rpm()
|
#define getRpmE(engine) (engine)->rpmCalculator.rpm()
|
||||||
|
|
||||||
bool isCrankingE(Engine *engine);
|
bool isCrankingE(Engine *engine);
|
||||||
void rpmShaftPositionCallback(trigger_event_e ckpSignalType, uint32_t index, Engine *engine);
|
void rpmShaftPositionCallback(trigger_event_e ckpSignalType, uint32_t index DECLARE_ENGINE_PARAMETER_S);
|
||||||
/**
|
/**
|
||||||
* @brief Initialize RPM calculator
|
* @brief Initialize RPM calculator
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -70,7 +70,7 @@ void hwHandleShaftSignal(trigger_event_e signal) {
|
||||||
maxTriggerReentraint = triggerReentraint;
|
maxTriggerReentraint = triggerReentraint;
|
||||||
triggerReentraint++;
|
triggerReentraint++;
|
||||||
efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "lowstck#8");
|
efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "lowstck#8");
|
||||||
triggerCentral.handleShaftSignal(engine, signal);
|
triggerCentral.handleShaftSignal(signal, engine, engine->engineConfiguration);
|
||||||
triggerReentraint--;
|
triggerReentraint--;
|
||||||
}
|
}
|
||||||
#endif /* EFI_PROD_CODE */
|
#endif /* EFI_PROD_CODE */
|
||||||
|
@ -109,7 +109,7 @@ static ALWAYS_INLINE void reportEventToWaveChart(trigger_event_e ckpSignalType,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerCentral::handleShaftSignal(Engine *engine, trigger_event_e signal) {
|
void TriggerCentral::handleShaftSignal(trigger_event_e signal, Engine *engine, engine_configuration_s *engineConfiguration) {
|
||||||
efiAssertVoid(engine!=NULL, "configuration");
|
efiAssertVoid(engine!=NULL, "configuration");
|
||||||
|
|
||||||
nowNt = getTimeNowNt();
|
nowNt = getTimeNowNt();
|
||||||
|
@ -140,7 +140,7 @@ void TriggerCentral::handleShaftSignal(Engine *engine, trigger_event_e signal) {
|
||||||
/**
|
/**
|
||||||
* This invocation changes the state of triggerState
|
* This invocation changes the state of triggerState
|
||||||
*/
|
*/
|
||||||
triggerState.decodeTriggerEvent(triggerShape, &engine->engineConfiguration->triggerConfig, signal, nowNt);
|
triggerState.decodeTriggerEvent(triggerShape, &engineConfiguration->triggerConfig, signal, nowNt);
|
||||||
|
|
||||||
if (!triggerState.shaft_is_synchronized) {
|
if (!triggerState.shaft_is_synchronized) {
|
||||||
// we should not propagate event if we do not know where we are
|
// we should not propagate event if we do not know where we are
|
||||||
|
@ -169,7 +169,11 @@ void TriggerCentral::handleShaftSignal(Engine *engine, trigger_event_e signal) {
|
||||||
/**
|
/**
|
||||||
* Here we invoke all the listeners - the main engine control logic is inside these listeners
|
* Here we invoke all the listeners - the main engine control logic is inside these listeners
|
||||||
*/
|
*/
|
||||||
invokeIntIntVoidCallbacks(&triggerListeneres, signal, triggerIndexForListeners);
|
for (int i = 0; i < triggerListeneres.currentListenersCount; i++) {
|
||||||
|
ShaftPositionListener listener = (ShaftPositionListener)triggerListeneres.callbacks[i];
|
||||||
|
(listener)(signal, triggerIndexForListeners PASS_ENGINE_PARAMETER);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#if EFI_HISTOGRAMS && EFI_PROD_CODE
|
#if EFI_HISTOGRAMS && EFI_PROD_CODE
|
||||||
int afterCallback = hal_lld_get_counter_value();
|
int afterCallback = hal_lld_get_counter_value();
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include "trigger_decoder.h"
|
#include "trigger_decoder.h"
|
||||||
|
|
||||||
class Engine;
|
class Engine;
|
||||||
typedef void (*ShaftPositionListener)(trigger_event_e signal, uint32_t index, Engine *engine);
|
typedef void (*ShaftPositionListener)(trigger_event_e signal, uint32_t index DECLARE_ENGINE_PARAMETER_S);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#include "ec2.h"
|
#include "ec2.h"
|
||||||
|
@ -25,7 +25,7 @@ class TriggerCentral {
|
||||||
public:
|
public:
|
||||||
TriggerCentral();
|
TriggerCentral();
|
||||||
void addEventListener(ShaftPositionListener handler, const char *name, Engine *engine);
|
void addEventListener(ShaftPositionListener handler, const char *name, Engine *engine);
|
||||||
void handleShaftSignal(Engine *engine, trigger_event_e signal);
|
void handleShaftSignal(trigger_event_e signal, Engine *engine, engine_configuration_s *engineConfiguration);
|
||||||
int getHwEventCounter(int index);
|
int getHwEventCounter(int index);
|
||||||
TriggerState triggerState;
|
TriggerState triggerState;
|
||||||
uint64_t nowNt;
|
uint64_t nowNt;
|
||||||
|
|
|
@ -136,9 +136,8 @@ static void initWave(const char *name, int index) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void waTriggerEventListener(trigger_event_e ckpSignalType, uint32_t index, Engine *arg) {
|
static void waTriggerEventListener(trigger_event_e ckpSignalType, uint32_t index DECLARE_ENGINE_PARAMETER_S) {
|
||||||
(void)ckpSignalType;
|
(void)ckpSignalType;
|
||||||
(void)arg;
|
|
||||||
if (index != 0) {
|
if (index != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@ typedef Thread thread_t;
|
||||||
|
|
||||||
#define DECLARE_ENGINE_PARAMETER_F void
|
#define DECLARE_ENGINE_PARAMETER_F void
|
||||||
#define DECLARE_ENGINE_PARAMETER_S
|
#define DECLARE_ENGINE_PARAMETER_S
|
||||||
|
#define PASS_ENGINE_PARAMETER_F
|
||||||
#define PASS_ENGINE_PARAMETER
|
#define PASS_ENGINE_PARAMETER
|
||||||
|
|
||||||
#endif /* GLOBAL_H_ */
|
#endif /* GLOBAL_H_ */
|
||||||
|
|
|
@ -33,9 +33,9 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType) {
|
||||||
void EngineTestHelper::fireTriggerEvents() {
|
void EngineTestHelper::fireTriggerEvents() {
|
||||||
for (int i = 0; i < 24; i++) {
|
for (int i = 0; i < 24; i++) {
|
||||||
timeNow += 5000; // 5ms
|
timeNow += 5000; // 5ms
|
||||||
triggerCentral.handleShaftSignal(&engine, SHAFT_PRIMARY_UP);
|
triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP, &engine, engine.engineConfiguration);
|
||||||
timeNow += 5000;
|
timeNow += 5000;
|
||||||
triggerCentral.handleShaftSignal(&engine, SHAFT_PRIMARY_DOWN);
|
triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN, &engine, engine.engineConfiguration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,6 @@ void EngineTestHelper::initTriggerShapeAndRpmCalculator() {
|
||||||
initializeTriggerShape(NULL, ec, &engine);
|
initializeTriggerShape(NULL, ec, &engine);
|
||||||
incrementGlobalConfigurationVersion();
|
incrementGlobalConfigurationVersion();
|
||||||
|
|
||||||
triggerCentral.addEventListener((ShaftPositionListener) &rpmShaftPositionCallback, "rpm reporter", &engine);
|
triggerCentral.addEventListener(rpmShaftPositionCallback, "rpm reporter", &engine);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ class Engine;
|
||||||
|
|
||||||
#define DECLARE_ENGINE_PARAMETER_F Engine *engine, engine_configuration_s *engineConfiguration
|
#define DECLARE_ENGINE_PARAMETER_F Engine *engine, engine_configuration_s *engineConfiguration
|
||||||
#define DECLARE_ENGINE_PARAMETER_S , 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 PASS_ENGINE_PARAMETER , engine, engineConfiguration
|
||||||
|
|
||||||
#endif /* GLOBAL_H_ */
|
#endif /* GLOBAL_H_ */
|
||||||
|
|
|
@ -58,7 +58,7 @@ void testFuelMap(void) {
|
||||||
|
|
||||||
// because all the correction tables are zero
|
// because all the correction tables are zero
|
||||||
printf("*************************************************** getRunningFuel 1\r\n");
|
printf("*************************************************** getRunningFuel 1\r\n");
|
||||||
float baseFuel = getBaseTableFuel(eth.engine.engineConfiguration, 5, getEngineLoadT(ð.engine));
|
float baseFuel = getBaseTableFuel(eth.engine.engineConfiguration, 5, getEngineLoadT(PASS_ENGINE_PARAMETER_F));
|
||||||
assertEqualsM("base fuel", 5.0, getRunningFuel(baseFuel, 5 PASS_ENGINE_PARAMETER));
|
assertEqualsM("base fuel", 5.0, getRunningFuel(baseFuel, 5 PASS_ENGINE_PARAMETER));
|
||||||
|
|
||||||
printf("*************************************************** setting IAT table\r\n");
|
printf("*************************************************** setting IAT table\r\n");
|
||||||
|
@ -87,7 +87,7 @@ void testFuelMap(void) {
|
||||||
|
|
||||||
// 1005 * 2 for IAT correction
|
// 1005 * 2 for IAT correction
|
||||||
printf("*************************************************** getRunningFuel 2\r\n");
|
printf("*************************************************** getRunningFuel 2\r\n");
|
||||||
baseFuel = getBaseTableFuel(eth.engine.engineConfiguration, 5, getEngineLoadT(ð.engine));
|
baseFuel = getBaseTableFuel(eth.engine.engineConfiguration, 5, getEngineLoadT(PASS_ENGINE_PARAMETER_F));
|
||||||
assertEqualsM("v1", 30150, getRunningFuel(baseFuel, 5 PASS_ENGINE_PARAMETER));
|
assertEqualsM("v1", 30150, getRunningFuel(baseFuel, 5 PASS_ENGINE_PARAMETER));
|
||||||
|
|
||||||
testMafValue = 0;
|
testMafValue = 0;
|
||||||
|
|
|
@ -404,13 +404,13 @@ static void testRpmCalculator(void) {
|
||||||
|
|
||||||
static MainTriggerCallback triggerCallbackInstance;
|
static MainTriggerCallback triggerCallbackInstance;
|
||||||
triggerCallbackInstance.init(ð.engine, ec2);
|
triggerCallbackInstance.init(ð.engine, ec2);
|
||||||
eth.triggerCentral.addEventListener((ShaftPositionListener)&mainTriggerCallback, "main loop", ð.engine);
|
eth.triggerCentral.addEventListener(mainTriggerCallback, "main loop", ð.engine);
|
||||||
|
|
||||||
// engine.rpmCalculator = ð.rpmState;
|
// engine.rpmCalculator = ð.rpmState;
|
||||||
prepareTimingMap();
|
prepareTimingMap();
|
||||||
|
|
||||||
timeNow += 5000; // 5ms
|
timeNow += 5000; // 5ms
|
||||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_UP);
|
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP, ð.engine, eth.ec);
|
||||||
assertEqualsM("index #2", 0, eth.triggerCentral.triggerState.getCurrentIndex());
|
assertEqualsM("index #2", 0, eth.triggerCentral.triggerState.getCurrentIndex());
|
||||||
assertEqualsM("queue size", 6, schedulingQueue.size());
|
assertEqualsM("queue size", 6, schedulingQueue.size());
|
||||||
assertEqualsM("ev 1", 246444, schedulingQueue.getForUnitText(0)->momentX);
|
assertEqualsM("ev 1", 246444, schedulingQueue.getForUnitText(0)->momentX);
|
||||||
|
@ -418,11 +418,11 @@ static void testRpmCalculator(void) {
|
||||||
schedulingQueue.clear();
|
schedulingQueue.clear();
|
||||||
|
|
||||||
timeNow += 5000;
|
timeNow += 5000;
|
||||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_DOWN);
|
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN, ð.engine, eth.ec);
|
||||||
timeNow += 5000; // 5ms
|
timeNow += 5000; // 5ms
|
||||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_UP);
|
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP, ð.engine, eth.ec);
|
||||||
timeNow += 5000;
|
timeNow += 5000;
|
||||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_DOWN);
|
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN, ð.engine, eth.ec);
|
||||||
assertEqualsM("index #3", 3, eth.triggerCentral.triggerState.getCurrentIndex());
|
assertEqualsM("index #3", 3, eth.triggerCentral.triggerState.getCurrentIndex());
|
||||||
assertEqualsM("queue size 3", 6, schedulingQueue.size());
|
assertEqualsM("queue size 3", 6, schedulingQueue.size());
|
||||||
assertEqualsM("ev 3", 259777, schedulingQueue.getForUnitText(0)->momentX);
|
assertEqualsM("ev 3", 259777, schedulingQueue.getForUnitText(0)->momentX);
|
||||||
|
@ -432,24 +432,24 @@ static void testRpmCalculator(void) {
|
||||||
schedulingQueue.clear();
|
schedulingQueue.clear();
|
||||||
|
|
||||||
timeNow += 5000;
|
timeNow += 5000;
|
||||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_DOWN);
|
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN, ð.engine, eth.ec);
|
||||||
timeNow += 5000; // 5ms
|
timeNow += 5000; // 5ms
|
||||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_UP);
|
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP, ð.engine, eth.ec);
|
||||||
timeNow += 5000; // 5ms
|
timeNow += 5000; // 5ms
|
||||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_UP);
|
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP, ð.engine, eth.ec);
|
||||||
assertEqualsM("index #4", 6, eth.triggerCentral.triggerState.getCurrentIndex());
|
assertEqualsM("index #4", 6, eth.triggerCentral.triggerState.getCurrentIndex());
|
||||||
assertEqualsM("queue size 4", 6, schedulingQueue.size());
|
assertEqualsM("queue size 4", 6, schedulingQueue.size());
|
||||||
assertEqualsM("4/0", 273111, schedulingQueue.getForUnitText(0)->momentX);
|
assertEqualsM("4/0", 273111, schedulingQueue.getForUnitText(0)->momentX);
|
||||||
schedulingQueue.clear();
|
schedulingQueue.clear();
|
||||||
|
|
||||||
timeNow += 5000;
|
timeNow += 5000;
|
||||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_DOWN);
|
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN, ð.engine, eth.ec);
|
||||||
assertEqualsM("queue size 5", 0, schedulingQueue.size());
|
assertEqualsM("queue size 5", 0, schedulingQueue.size());
|
||||||
// assertEqualsM("5/1", 284500, schedulingQueue.getForUnitText(0)->momentUs);
|
// assertEqualsM("5/1", 284500, schedulingQueue.getForUnitText(0)->momentUs);
|
||||||
schedulingQueue.clear();
|
schedulingQueue.clear();
|
||||||
|
|
||||||
timeNow += 5000; // 5ms
|
timeNow += 5000; // 5ms
|
||||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_UP);
|
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP, ð.engine, eth.ec);
|
||||||
assertEqualsM("queue size 6", 6, schedulingQueue.size());
|
assertEqualsM("queue size 6", 6, schedulingQueue.size());
|
||||||
assertEqualsM("6/0", 286444, schedulingQueue.getForUnitText(0)->momentX);
|
assertEqualsM("6/0", 286444, schedulingQueue.getForUnitText(0)->momentX);
|
||||||
assertEqualsM("6/1", 285944, schedulingQueue.getForUnitText(1)->momentX);
|
assertEqualsM("6/1", 285944, schedulingQueue.getForUnitText(1)->momentX);
|
||||||
|
@ -457,12 +457,12 @@ static void testRpmCalculator(void) {
|
||||||
schedulingQueue.clear();
|
schedulingQueue.clear();
|
||||||
|
|
||||||
timeNow += 5000;
|
timeNow += 5000;
|
||||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_DOWN);
|
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN, ð.engine, eth.ec);
|
||||||
assertEqualsM("queue size 7", 0, schedulingQueue.size());
|
assertEqualsM("queue size 7", 0, schedulingQueue.size());
|
||||||
schedulingQueue.clear();
|
schedulingQueue.clear();
|
||||||
|
|
||||||
timeNow += 5000; // 5ms
|
timeNow += 5000; // 5ms
|
||||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_UP);
|
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP, ð.engine, eth.ec);
|
||||||
assertEqualsM("queue size 8", 6, schedulingQueue.size());
|
assertEqualsM("queue size 8", 6, schedulingQueue.size());
|
||||||
assertEqualsM("8/0", 299777, schedulingQueue.getForUnitText(0)->momentX);
|
assertEqualsM("8/0", 299777, schedulingQueue.getForUnitText(0)->momentX);
|
||||||
assertEqualsM("8/1", 299277, schedulingQueue.getForUnitText(1)->momentX);
|
assertEqualsM("8/1", 299277, schedulingQueue.getForUnitText(1)->momentX);
|
||||||
|
@ -471,12 +471,12 @@ static void testRpmCalculator(void) {
|
||||||
schedulingQueue.clear();
|
schedulingQueue.clear();
|
||||||
|
|
||||||
timeNow += 5000;
|
timeNow += 5000;
|
||||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_DOWN);
|
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN, ð.engine, eth.ec);
|
||||||
assertEqualsM("queue size 9", 0, schedulingQueue.size());
|
assertEqualsM("queue size 9", 0, schedulingQueue.size());
|
||||||
schedulingQueue.clear();
|
schedulingQueue.clear();
|
||||||
|
|
||||||
timeNow += 5000; // 5ms
|
timeNow += 5000; // 5ms
|
||||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_UP);
|
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP, ð.engine, eth.ec);
|
||||||
assertEqualsM("queue size 10", 0, schedulingQueue.size());
|
assertEqualsM("queue size 10", 0, schedulingQueue.size());
|
||||||
schedulingQueue.clear();
|
schedulingQueue.clear();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue