This commit is contained in:
rusefi 2017-03-01 22:18:25 -05:00
parent da53234ca4
commit b01b053595
13 changed files with 40 additions and 40 deletions

View File

@ -340,7 +340,6 @@ public:
*/
bool isTestMode;
TriggerShape triggerShape;
/**
* pre-calculated offset for given sequence index within engine cycle

View File

@ -1039,10 +1039,10 @@ void resetConfigurationExt(Logging * logger, engine_type_e engineType DECLARE_EN
}
applyNonPersistentConfiguration(logger PASS_ENGINE_PARAMETER);
// todo: eliminate triggerShape.operationMode?
if (engineConfiguration->operationMode != engine->triggerShape.getOperationMode())
if (engineConfiguration->operationMode != TRIGGER_SHAPE(getOperationMode()))
firmwareError(CUSTOM_ERR_OP_MODE, "operationMode %d/trigger mismatch %d",
engineConfiguration->operationMode,
engine->triggerShape.getOperationMode());
TRIGGER_SHAPE(getOperationMode()));
#if EFI_TUNER_STUDIO
syncTunerStudioCopy();
@ -1056,13 +1056,13 @@ void applyNonPersistentConfiguration(Logging * logger DECLARE_ENGINE_PARAMETER_S
#endif
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
engine->triggerShape.initializeTriggerShape(logger PASS_ENGINE_PARAMETER);
engine->triggerCentral.triggerShape.initializeTriggerShape(logger PASS_ENGINE_PARAMETER);
#endif
if (engine->triggerShape.getSize() == 0) {
if (engine->triggerCentral.triggerShape.getSize() == 0) {
firmwareError(CUSTOM_ERR_TRIGGER_ZERO, "triggerShape size is zero");
return;
}
engine->engineCycleEventCount = engine->triggerShape.getLength();
engine->engineCycleEventCount = engine->triggerCentral.triggerShape.getLength();
#if EFI_FSIO || defined(__DOXYGEN__)
applyFsioConfiguration(PASS_ENGINE_PARAMETER_F);
#endif

View File

@ -78,6 +78,6 @@ void setTimingLoadBin(float from, float to DECLARE_ENGINE_PARAMETER_S);
void setSingleCoilDwell(engine_configuration_s *engineConfiguration);
#define tdcPosition() \
(ENGINE(triggerShape.tdcPosition) + CONFIG(globalTriggerAngleOffset))
(ENGINE(triggerCentral.triggerShape.tdcPosition) + CONFIG(globalTriggerAngleOffset))
#endif /* ENGINE_MATH_H_ */

View File

@ -527,7 +527,7 @@ static void setToothedWheel(int total, int skipped DECLARE_ENGINE_PARAMETER_S) {
engineConfiguration->trigger.customSkippedToothCount = skipped;
scheduleMsg(&logger, "toothed: total=%d/skipped=%d", total, skipped);
setToothedWheelConfiguration(&engine->triggerShape, total, skipped, engineConfiguration->operationMode);
setToothedWheelConfiguration(&engine->triggerCentral.triggerShape, total, skipped, engineConfiguration->operationMode);
// initializeTriggerShape(&logger, engineConfiguration, engineConfiguration2);
incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_F);
doPrintConfiguration(engine);

View File

@ -96,7 +96,6 @@ void hwHandleVvtCamSignal(trigger_value_e front) {
efitick_t nowNt = getTimeNowNt();
if (engineConfiguration->vvtMode == MIATA_NB2) {
uint32_t currentDuration = nowNt - previousVvtCamTime;
float ratio = ((float) currentDuration) / previousVvtCamDuration;
@ -315,7 +314,7 @@ EXTERN_ENGINE
static void triggerShapeInfo(void) {
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
TriggerShape *s = &engine->triggerShape;
TriggerShape *s = &engine->triggerCentral.triggerShape;
scheduleMsg(logger, "useRise=%s", boolToString(s->useRiseEdge));
scheduleMsg(logger, "gap from %f to %f", s->syncRatioFrom, s->syncRatioTo);
@ -360,7 +359,7 @@ void printAllTriggers() {
engineConfiguration->trigger.type = tt;
engineConfiguration->operationMode = FOUR_STROKE_CAM_SENSOR;
TriggerShape *s = &engine->triggerShape;
TriggerShape *s = &engine->triggerCentral.triggerShape;
s->initializeTriggerShape(NULL PASS_ENGINE_PARAMETER);
fprintf(fp, "TRIGGERTYPE %d %d %s %f\r\n", triggerId, s->getLength(), getTrigger_type_e(tt), s->tdcPosition);
@ -401,14 +400,14 @@ extern int vvtEventFallCounter;
void triggerInfo(void) {
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
TriggerShape *ts = &engine->triggerShape;
TriggerShape *ts = &engine->triggerCentral.triggerShape;
scheduleMsg(logger, "Template %s (%d) trigger %s (%d) useRiseEdge=%s onlyFront=%s gapBothDirections=%s useOnlyFirstChannel=%s tdcOffset=%d",
getConfigurationName(engineConfiguration->engineType), engineConfiguration->engineType,
getTrigger_type_e(engineConfiguration->trigger.type), engineConfiguration->trigger.type,
boolToString(TRIGGER_SHAPE(useRiseEdge)), boolToString(engineConfiguration->useOnlyRisingEdgeForTrigger),
boolToString(TRIGGER_SHAPE(gapBothDirections)),
boolToString(engineConfiguration->trigger.useOnlyFirstChannel), ENGINE(triggerShape.tdcPosition));
boolToString(engineConfiguration->trigger.useOnlyFirstChannel), TRIGGER_SHAPE(tdcPosition));
if (engineConfiguration->trigger.type == TT_TOOTHED_WHEEL) {
scheduleMsg(logger, "total %d/skipped %d", engineConfiguration->trigger.customTotalToothCount,
@ -418,16 +417,16 @@ void triggerInfo(void) {
scheduleMsg(logger, "trigger#1 event counters up=%d/down=%d", engine->triggerCentral.getHwEventCounter(0),
engine->triggerCentral.getHwEventCounter(1));
if (engine->triggerShape.needSecondTriggerInput) {
if (ts->needSecondTriggerInput) {
scheduleMsg(logger, "trigger#2 event counters up=%d/down=%d", engine->triggerCentral.getHwEventCounter(2),
engine->triggerCentral.getHwEventCounter(3));
}
scheduleMsg(logger, "expected cycle events %d/%d/%d", ts->expectedEventCount[0],
engine->triggerShape.expectedEventCount[1], ts->expectedEventCount[2]);
scheduleMsg(logger, "expected cycle events %d/%d/%d", TRIGGER_SHAPE(expectedEventCount[0]),
TRIGGER_SHAPE(expectedEventCount[1]), TRIGGER_SHAPE(expectedEventCount[2]));
scheduleMsg(logger, "trigger type=%d/need2ndChannel=%s", engineConfiguration->trigger.type,
boolToString(engine->triggerShape.needSecondTriggerInput));
scheduleMsg(logger, "expected duty #0=%f/#1=%f", ts->dutyCycle[0], ts->dutyCycle[1]);
boolToString(TRIGGER_SHAPE(needSecondTriggerInput)));
scheduleMsg(logger, "expected duty #0=%f/#1=%f", TRIGGER_SHAPE(dutyCycle[0]), TRIGGER_SHAPE(dutyCycle[1]));
scheduleMsg(logger, "synchronizationNeeded=%s/isError=%s/total errors=%d ord_err=%d/total revolutions=%d/self=%s",
boolToString(ts->isSynchronizationNeeded),
@ -435,7 +434,7 @@ void triggerInfo(void) {
engine->triggerCentral.triggerState.orderingErrorCounter, engine->triggerCentral.triggerState.getTotalRevolutionCounter(),
boolToString(engineConfiguration->directSelfStimulation));
if (ts->isSynchronizationNeeded) {
if (TRIGGER_SHAPE(isSynchronizationNeeded)) {
scheduleMsg(logger, "gap from %f to %f", ts->syncRatioFrom, ts->syncRatioTo);
}
@ -455,7 +454,7 @@ void triggerInfo(void) {
getPin_output_mode_e(boardConfiguration->triggerSimulatorPinModes[0]),
boardConfiguration->triggerSimulatorFrequency);
if (engine->triggerShape.needSecondTriggerInput) {
if (ts->needSecondTriggerInput) {
scheduleMsg(logger, "secondary trigger input: %s", hwPortname(boardConfiguration->triggerInputPins[1]));
#if EFI_EMULATE_POSITION_SENSORS || defined(__DOXYGEN__)
scheduleMsg(logger, "secondary trigger simulator: %s %s phase=%d",

View File

@ -36,6 +36,8 @@ public:
*/
efitick_t timeAtVirtualZeroNt;
TriggerShape triggerShape;
volatile efitime_t previousShaftEventTimeNt;
private:
IntListenerArray<15> triggerListeneres;

View File

@ -129,7 +129,7 @@ static void updateTriggerShapeIfNeeded(PwmConfig *state) {
applyNonPersistentConfiguration(logger PASS_ENGINE_PARAMETER);
TriggerShape *s = &engine->triggerShape;
TriggerShape *s = &engine->triggerCentral.triggerShape;
pin_state_t *pinStates[PWM_PHASE_MAX_WAVE_PER_PWM] = { s->wave.waves[0].pinStates, s->wave.waves[1].pinStates,
s->wave.waves[2].pinStates };
copyPwmParameters(state, s->getSize(), s->wave.switchTimes, PWM_PHASE_MAX_WAVE_PER_PWM, pinStates);
@ -169,7 +169,7 @@ static void resumeStimulator(Engine *engine) {
void initTriggerEmulatorLogic(Logging *sharedLogger, Engine *engine) {
logger = sharedLogger;
TriggerShape *s = &engine->triggerShape;
TriggerShape *s = &engine->triggerCentral.triggerShape;
setTriggerEmulatorRPM(engineConfiguration->bc.triggerSimulatorFrequency, engine);
pin_state_t *pinStates[PWM_PHASE_MAX_WAVE_PER_PWM] = { s->wave.waves[0].pinStates, s->wave.waves[1].pinStates,
s->wave.waves[2].pinStates };

View File

@ -106,7 +106,7 @@ typedef VirtualTimer virtual_timer_t;
*/
#define CONFIG(x) persistentState.persistentConfiguration.engineConfiguration.x
#define ENGINE(x) _engine.x
#define TRIGGER_SHAPE(x) _engine.triggerShape.x
#define TRIGGER_SHAPE(x) _engine.triggerCentral.triggerShape.x
#else
#define EXTERN_ENGINE

View File

@ -50,7 +50,7 @@ static void shaft_icu_width_callback(ICUDriver *icup) {
if (hasFirmwareErrorFlag)
return;
int isPrimary = icup == primaryCrankDriver;
if (!isPrimary && !engine->triggerShape.needSecondTriggerInput) {
if (!isPrimary && !engine->triggerCentral.triggerShape.needSecondTriggerInput) {
return;
}
// icucnt_t last_width = icuGetWidth(icup); so far we are fine with system time
@ -64,7 +64,7 @@ static void shaft_icu_period_callback(ICUDriver *icup) {
if (hasFirmwareErrorFlag)
return;
int isPrimary = icup == primaryCrankDriver;
if (!isPrimary && !engine->triggerShape.needSecondTriggerInput) {
if (!isPrimary && !engine->triggerCentral.triggerShape.needSecondTriggerInput) {
return;
}

View File

@ -62,7 +62,7 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType) : engine (&persiste
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
engine->triggerShape.initializeTriggerShape(NULL PASS_ENGINE_PARAMETER);
engine->triggerCentral.triggerShape.initializeTriggerShape(NULL PASS_ENGINE_PARAMETER);
engine->triggerCentral.addEventListener(rpmShaftPositionCallback, "rpm reporter", engine);
engine->triggerCentral.addEventListener(mainTriggerCallback, "main loop", engine);
}
@ -96,7 +96,7 @@ void EngineTestHelper::applyTriggerShape() {
persistent_config_s *config = engine->config;
board_configuration_s *boardConfiguration = &engineConfiguration->bc;
engine->triggerShape.initializeTriggerShape(NULL PASS_ENGINE_PARAMETER);
engine->triggerCentral.triggerShape.initializeTriggerShape(NULL PASS_ENGINE_PARAMETER);
incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_F);
}

View File

@ -56,6 +56,6 @@ class Engine;
#define CONFIG(x) engineConfiguration->x
#define ENGINE(x) engine->x
#define TRIGGER_SHAPE(x) engine->triggerShape.x
#define TRIGGER_SHAPE(x) engine->triggerCentral.triggerShape.x
#endif /* GLOBAL_H_ */

View File

@ -167,7 +167,7 @@ void testAngleResolver(void) {
engineConfiguration->globalTriggerAngleOffset = 175;
TriggerShape * ts = &engine->triggerShape;
TriggerShape * ts = &engine->triggerCentral.triggerShape;
ts->initializeTriggerShape(NULL PASS_ENGINE_PARAMETER);
assertEqualsM("index 2", 52.76, ts->eventAngles[3]); // this angle is relation to synch point

View File

@ -53,7 +53,7 @@ int getTheAngle(engine_type_e engineType) {
initDataStructures(PASS_ENGINE_PARAMETER_F);
TriggerShape * shape = &eth.engine.triggerShape;
TriggerShape * shape = &eth.engine.triggerCentral.triggerShape;
return findTriggerZeroEventIndex(&eth.engine.triggerCentral.triggerState, shape, &engineConfiguration->trigger PASS_ENGINE_PARAMETER);
}
@ -66,7 +66,7 @@ static void testDodgeNeonDecoder(void) {
EngineTestHelper eth(DODGE_NEON_1995);
EXPAND_EngineTestHelper;
TriggerShape * shape = &eth.engine.triggerShape;
TriggerShape * shape = &eth.engine.triggerCentral.triggerShape;
assertEquals(8, shape->getTriggerShapeSynchPointIndex());
TriggerState state;
@ -123,7 +123,7 @@ void test1995FordInline6TriggerDecoder(void) {
EngineTestHelper eth(FORD_INLINE_6_1995);
EXPAND_EngineTestHelper;
TriggerShape * shape = &eth.engine.triggerShape;
TriggerShape * shape = &eth.engine.triggerCentral.triggerShape;
assertEqualsM("triggerShapeSynchPointIndex", 0, shape->getTriggerShapeSynchPointIndex());
@ -196,7 +196,7 @@ void testFordAspire(void) {
EngineTestHelper eth(FORD_ASPIRE_1996);
EXPAND_EngineTestHelper;
assertEquals(4, eth.engine.triggerShape.getTriggerShapeSynchPointIndex());
assertEquals(4, TRIGGER_SHAPE(getTriggerShapeSynchPointIndex()));
assertEquals(800, config->fuelRpmBins[0]);
assertEquals(7000, config->fuelRpmBins[15]);
@ -218,7 +218,7 @@ static void testTriggerDecoder2(const char *msg, engine_type_e type, int synchPo
initSpeedDensity(PASS_ENGINE_PARAMETER_F);
TriggerShape *t = &eth.engine.triggerShape;
TriggerShape *t = &eth.engine.triggerCentral.triggerShape;
assertEqualsM("synchPointIndex", synchPointIndex, t->getTriggerShapeSynchPointIndex());
@ -318,8 +318,8 @@ void testRpmCalculator(void) {
timeNow = 0;
assertEquals(0, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_F));
assertEquals(4, engine->triggerShape.triggerIndexByAngle[240]);
assertEquals(4, engine->triggerShape.triggerIndexByAngle[241]);
assertEquals(4, TRIGGER_SHAPE(triggerIndexByAngle[240]));
assertEquals(4, TRIGGER_SHAPE(triggerIndexByAngle[241]));
eth.fireTriggerEvents(48);
@ -390,8 +390,8 @@ void testRpmCalculator(void) {
assertEqualsM("3/3", st + 14777, schedulingQueue.getForUnitText(2)->momentX);
schedulingQueue.clear();
assertEquals(5, engine->triggerShape.triggerIndexByAngle[240]);
assertEquals(5, engine->triggerShape.triggerIndexByAngle[241]);
assertEquals(5, TRIGGER_SHAPE(triggerIndexByAngle[240]));
assertEquals(5, TRIGGER_SHAPE(triggerIndexByAngle[241]));
timeNow += 5000;
eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING PASS_ENGINE_PARAMETER);
@ -459,7 +459,7 @@ void testTriggerDecoder(void) {
persistent_config_s c;
Engine e(&c);
TriggerShape * s = &e.triggerShape;
TriggerShape * s = &e.triggerCentral.triggerShape;
persistent_config_s *config = &c;
@ -516,7 +516,7 @@ void testTriggerDecoder(void) {
initSpeedDensity(PASS_ENGINE_PARAMETER_F);
TriggerShape *t = &eth.engine.triggerShape;
// TriggerShape *t = &eth.engine.triggerShape;
// assertEquals(1, t->eventAngles[1]);
// assertEqualsM("index at 0", 0, t->triggerIndexByAngle[56]);
// assertEqualsM("index at 1", 1, t->triggerIndexByAngle[57]);