auto-sync

This commit is contained in:
rusEfi 2016-01-26 23:01:44 -05:00
parent bb62a7ce98
commit 0374941139
4 changed files with 24 additions and 18 deletions

View File

@ -109,6 +109,8 @@ Engine::Engine(persistent_config_s *config) {
knockCount = 0;
knockDebug = false;
knockVolts = 0;
iHead = NULL;
timeOfLastKnockEvent = 0;
injectorLagMs = fuelMs = 0;

View File

@ -219,6 +219,12 @@ public:
void init(persistent_config_s *config);
void prepareFuelSchedule(DECLARE_ENGINE_PARAMETER_F);
/**
* That's the list of pending spark firing events
*/
IgnitionEvent *iHead;
RpmCalculator rpmCalculator;
persistent_config_s *config;
engine_configuration_s *engineConfiguration;

View File

@ -66,11 +66,6 @@ static LocalVersionHolder triggerVersion;
extern engine_pins_s enginePins;
static MainTriggerCallback mainTriggerCallbackInstance;
/**
* That's the list of pending spark firing events
*/
static IgnitionEvent *iHead = NULL;
/**
* In order to archive higher event precision, we are using a hybrid approach
* where we are scheduling events based on the closest trigger event with a time offset.
@ -251,11 +246,11 @@ static ALWAYS_INLINE void handleSparkEvent(bool limitedSpark, uint32_t eventInde
/**
* Spark should be scheduled in relation to some future trigger event, this way we get better firing precision
*/
bool isPending = assertNotInList<IgnitionEvent>(iHead, iEvent);
bool isPending = assertNotInList<IgnitionEvent>(ENGINE(iHead), iEvent);
if (isPending)
return;
LL_APPEND(iHead, iEvent);
LL_APPEND(ENGINE(iHead), iEvent);
}
}
@ -271,11 +266,11 @@ static ALWAYS_INLINE void handleSpark(bool limitedSpark, uint32_t eventIndex, in
IgnitionEvent *current, *tmp;
LL_FOREACH_SAFE(iHead, current, tmp)
LL_FOREACH_SAFE(ENGINE(iHead), current, tmp)
{
if (current->sparkPosition.eventIndex == eventIndex) {
// time to fire a spark which was scheduled previously
LL_DELETE(iHead, current);
LL_DELETE(ENGINE(iHead), current);
scheduling_s * sDown = &current->signalTimerDown;

View File

@ -140,18 +140,18 @@ void test1995FordInline6TriggerDecoder(void) {
eth.engine.triggerCentral.addEventListener(mainTriggerCallback, "main loop", &eth.engine);
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_F);
// eth.fireTriggerEvents(48);
// assertEquals(2000, eth.engine.rpmCalculator.rpmValue);
// eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_F);
// eth.fireTriggerEvents(48);
eth.fireTriggerEvents(48);
assertEquals(2000, eth.engine.rpmCalculator.rpmValue);
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_F);
eth.fireTriggerEvents(48);
IgnitionEventList *ecl = &eth.ec2.ignitionEvents[0];
assertEqualsM("ignition events size", 6, ecl->size);
assertEqualsM("ford inline ignition events size", 6, ecl->size);
assertEqualsM("event index", 0, ecl->elements[0].dwellPosition.eventIndex);
assertEqualsM("angle offset#1", 0, ecl->elements[0].dwellPosition.angleOffset);
assertEqualsM("angle offset#1", 7, ecl->elements[0].dwellPosition.angleOffset);
assertEqualsM("event index", 10, ecl->elements[5].dwellPosition.eventIndex);
assertEqualsM("angle offset#2", 0, ecl->elements[5].dwellPosition.angleOffset);
assertEqualsM("angle offset#2", 7, ecl->elements[5].dwellPosition.angleOffset);
TriggerState state;
@ -291,6 +291,7 @@ extern engine_pins_s enginePins;
void testRpmCalculator(void) {
printf("*************************************************** testRpmCalculator\r\n");
timeNow = 0;
schedulingQueue.clear();
EngineTestHelper eth(FORD_INLINE_6_1995);
EXPAND_EngineTestHelper;
@ -301,6 +302,7 @@ void testRpmCalculator(void) {
efiAssertVoid(eth.engine.engineConfiguration!=NULL, "null config in engine");
// this is needed to have valid CLT and IAT. todo: extract method
initThermistors(NULL PASS_ENGINE_PARAMETER);
engine->updateSlowSensors(PASS_ENGINE_PARAMETER_F);
@ -341,7 +343,8 @@ void testRpmCalculator(void) {
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_F);
assertEquals(0, eth.engine.engineConfiguration2->injectionEvents->injectionEvents.elements[0].injectionStart.angleOffset);
InjectionEvent *ie0 = &eth.engine.engineConfiguration2->injectionEvents->injectionEvents.elements[0];
assertEquals(0, ie0->injectionStart.angleOffset);
eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER);
assertEquals(1500, eth.engine.rpmCalculator.rpmValue);
@ -349,7 +352,7 @@ void testRpmCalculator(void) {
assertEqualsM("dwell", 4.5, eth.engine.engineState.dwellAngle);
assertEqualsM("fuel", 3.03, eth.engine.fuelMs);
assertEqualsM("one degree", 111.1111, eth.engine.rpmCalculator.oneDegreeUs);
assertEqualsM("size", 6, ilist->size);
assertEqualsM("size #2", 6, ilist->size);
assertEqualsM("dwell angle", 0, ilist->elements[0].dwellPosition.eventAngle);
assertEqualsM("dwell offset", 0, ilist->elements[0].dwellPosition.angleOffset);