auto-sync

This commit is contained in:
rusEfi 2014-11-24 14:06:11 -06:00
parent e12aabc11f
commit d881584824
7 changed files with 32 additions and 28 deletions

View File

@ -585,7 +585,7 @@ void applyNonPersistentConfiguration(Logging * logger, Engine *engine) {
#if EFI_PROD_CODE
scheduleMsg(logger, "applyNonPersistentConfiguration()");
#endif
initializeTriggerShape(logger, engineConfiguration, engineConfiguration2);
initializeTriggerShape(logger, engineConfiguration, engineConfiguration2, engine);
if (engineConfiguration2->triggerShape.getSize() == 0) {
firmwareError("triggerShape size is zero");
return;

View File

@ -271,16 +271,12 @@ float getSparkDwellMsT(int rpm DECLARE_ENGINE_PARAMETER_S) {
return interpolate2d(rpm, engineConfiguration->sparkDwellBins, engineConfiguration->sparkDwell, DWELL_CURVE_SIZE);
}
int getEngineCycleEventCount2(operation_mode_e mode, trigger_shape_s * s) {
return mode == FOUR_STROKE_CAM_SENSOR ? s->getSize() : 2 * s->getSize();
}
/**
* Trigger event count equals engine cycle event count if we have a cam sensor.
* Two trigger cycles make one engine cycle in case of a four stroke engine If we only have a cranksensor.
*/
int getEngineCycleEventCount(engine_configuration_s const *engineConfiguration, trigger_shape_s * s) {
return getEngineCycleEventCount2(getOperationMode(engineConfiguration), s);
int getEngineCycleEventCount2(operation_mode_e mode, trigger_shape_s * s) {
return mode == FOUR_STROKE_CAM_SENSOR ? s->getSize() : 2 * s->getSize();
}
void findTriggerPosition(trigger_shape_s * s, event_trigger_position_s *position,
@ -288,7 +284,7 @@ void findTriggerPosition(trigger_shape_s * s, event_trigger_position_s *position
angleOffset = fixAngle(angleOffset + engineConfiguration->globalTriggerAngleOffset PASS_ENGINE_PARAMETER);
int engineCycleEventCount = getEngineCycleEventCount(engineConfiguration, s);
int engineCycleEventCount = getEngineCycleEventCount2(getOperationMode(engineConfiguration), s);
efiAssertVoid(engineCycleEventCount > 0, "engineCycleEventCount");

View File

@ -220,7 +220,7 @@ void initializeSkippedToothTriggerShapeExt(trigger_shape_s *s, int totalTeethCou
* External logger is needed because at this point our logger is not yet initialized
*/
void initializeTriggerShape(Logging *logger, engine_configuration_s const *engineConfiguration,
engine_configuration2_s *engineConfiguration2) {
engine_configuration2_s *engineConfiguration2, Engine *engine) {
#if EFI_PROD_CODE
scheduleMsg(logger, "initializeTriggerShape()");
#endif

View File

@ -88,7 +88,10 @@ private:
void initializeSkippedToothTriggerShapeExt(trigger_shape_s *s, int totalTeethCount, int skippedCount, operation_mode_e operationMode);
uint32_t findTriggerZeroEventIndex(trigger_shape_s * shape, trigger_config_s const*triggerConfig);
void initializeTriggerShape(Logging *logger, engine_configuration_s const *engineConfiguration, engine_configuration2_s *engineConfiguration2);
class Engine;
void initializeTriggerShape(Logging *logger, engine_configuration_s const *engineConfiguration, engine_configuration2_s *engineConfiguration2, Engine *engine);
void initTriggerDecoder(void);
bool_t isTriggerDecoderError(void);

View File

@ -40,7 +40,7 @@ void EngineTestHelper::fireTriggerEvents() {
}
void EngineTestHelper::initTriggerShapeAndRpmCalculator() {
initializeTriggerShape(NULL, ec, &ec2);
initializeTriggerShape(NULL, ec, &ec2, &engine);
incrementGlobalConfigurationVersion();
triggerCentral.addEventListener((ShaftPositionListener) &rpmShaftPositionCallback, "rpm reporter", &engine);

View File

@ -178,14 +178,14 @@ void testAngleResolver(void) {
ae.resetEventList();
printf("*************************************************** testAngleResolver 0\r\n");
findTriggerPosition(&engineConfiguration2->triggerShape, &ae.getNextActuatorEvent()->position, 53 - 175 PASS_ENGINE_PARAMETER);
findTriggerPosition(ts, &ae.getNextActuatorEvent()->position, 53 - 175 PASS_ENGINE_PARAMETER);
assertEqualsM("size", 1, ae.size);
assertEquals(0, ae.events[0].position.eventIndex);
assertEquals(53, ae.events[0].position.angleOffset);
printf("*************************************************** testAngleResolver 2\r\n");
ae.resetEventList();
findTriggerPosition(&engineConfiguration2->triggerShape, &ae.getNextActuatorEvent()->position, 51 + 180 - 175 PASS_ENGINE_PARAMETER);
findTriggerPosition(ts, &ae.getNextActuatorEvent()->position, 51 + 180 - 175 PASS_ENGINE_PARAMETER);
assertEquals(2, ae.events[0].position.eventIndex);
assertEquals(109.1, ae.events[0].position.angleOffset);
}

View File

@ -57,9 +57,9 @@ static void testDodgeNeonDecoder(void) {
EngineTestHelper eth(DODGE_NEON_1995);
engine_configuration_s *ec = eth.ec;
assertEquals(8, eth.ec2.triggerShape.getTriggerShapeSynchPointIndex());
trigger_shape_s * shape = &eth.ec2.triggerShape;
assertEquals(8, shape->getTriggerShapeSynchPointIndex());
TriggerState state;
assertFalseM("1 shaft_is_synchronized", state.shaft_is_synchronized);
@ -116,9 +116,10 @@ static void test1995FordInline6TriggerDecoder(void) {
engine_configuration_s *engineConfiguration = eth.engine.engineConfiguration;
Engine *engine = &eth.engine;
assertEqualsM("triggerShapeSynchPointIndex", 0, eth.ec2.triggerShape.getTriggerShapeSynchPointIndex());
trigger_shape_s * shape = &eth.ec2.triggerShape;
assertEqualsM("triggerShapeSynchPointIndex", 0, shape->getTriggerShapeSynchPointIndex());
event_trigger_position_s position;
assertEqualsM("globalTriggerAngleOffset", 0, engineConfiguration->globalTriggerAngleOffset);
findTriggerPosition(shape, &position, 0 PASS_ENGINE_PARAMETER);
@ -207,10 +208,10 @@ void testMazdaMianaNbDecoder(void) {
engine_configuration_s *ec = eth.ec;
Engine *engine = &eth.engine;
engine_configuration_s *engineConfiguration = ec;
assertEquals(11, eth.ec2.triggerShape.getTriggerShapeSynchPointIndex());
trigger_shape_s * shape = &eth.ec2.triggerShape;
assertEquals(11, shape->getTriggerShapeSynchPointIndex());
TriggerState state;
trigger_shape_s * shape = &eth.ec2.triggerShape;
int a = 0;
state.decodeTriggerEvent(shape, &ec->triggerConfig, SHAFT_PRIMARY_DOWN, a + 20);
@ -293,10 +294,12 @@ static void testTriggerDecoder2(const char *msg, engine_type_e type, int synchPo
initSpeedDensity(ec);
assertEqualsM("synchPointIndex", synchPointIndex, eth.ec2.triggerShape.getTriggerShapeSynchPointIndex());
trigger_shape_s *t = &eth.ec2.triggerShape;
assertEqualsM("channel1duty", channel1duty, eth.ec2.triggerShape.dutyCycle[0]);
assertEqualsM("channel2duty", channel2duty, eth.ec2.triggerShape.dutyCycle[1]);
assertEqualsM("synchPointIndex", synchPointIndex, t->getTriggerShapeSynchPointIndex());
assertEqualsM("channel1duty", channel1duty, t->dutyCycle[0]);
assertEqualsM("channel2duty", channel2duty, t->dutyCycle[1]);
}
void testGY6_139QMB(void) {
@ -482,13 +485,15 @@ void testTriggerDecoder(void) {
printf("*************************************************** testTriggerDecoder\r\n");
engine_configuration2_s ec2;
trigger_shape_s * s = &ec2.triggerShape;
initializeSkippedToothTriggerShapeExt(&ec2.triggerShape, 2, 0, FOUR_STROKE_CAM_SENSOR);
assertEqualsM("shape size", ec2.triggerShape.getSize(), 4);
assertEquals(ec2.triggerShape.wave.switchTimes[0], 0.25);
assertEquals(ec2.triggerShape.wave.switchTimes[1], 0.5);
assertEquals(ec2.triggerShape.wave.switchTimes[2], 0.75);
assertEquals(ec2.triggerShape.wave.switchTimes[3], 1);
initializeSkippedToothTriggerShapeExt(s, 2, 0, FOUR_STROKE_CAM_SENSOR);
assertEqualsM("shape size", s->getSize(), 4);
assertEquals(s->wave.switchTimes[0], 0.25);
assertEquals(s->wave.switchTimes[1], 0.5);
assertEquals(s->wave.switchTimes[2], 0.75);
assertEquals(s->wave.switchTimes[3], 1);
testDodgeNeonDecoder();
testTriggerDecoder2("dodge neon", DODGE_NEON_1995, 8, 0.4931, 0.2070);