auto-sync
This commit is contained in:
parent
f82875ec2a
commit
b27b0b0685
|
@ -58,10 +58,10 @@ void addTriggerEventListener(ShaftPositionListener listener, const char *name, v
|
|||
}
|
||||
|
||||
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
|
||||
extern configuration_s *configuration;
|
||||
extern Engine engine;
|
||||
|
||||
void hwHandleShaftSignal(trigger_event_e signal) {
|
||||
triggerCentral.handleShaftSignal(configuration, signal, getTimeNowUs());
|
||||
triggerCentral.handleShaftSignal(&engine, signal, getTimeNowUs());
|
||||
}
|
||||
#endif /* EFI_PROD_CODE */
|
||||
|
||||
|
@ -96,13 +96,13 @@ static void reportEventToWaveChart(trigger_event_e ckpSignalType, int index) {
|
|||
// todo: improve this
|
||||
extern Engine engine;
|
||||
|
||||
void TriggerCentral::handleShaftSignal(configuration_s *configuration, trigger_event_e signal, uint64_t nowUs) {
|
||||
efiAssertVoid(configuration!=NULL, "configuration");
|
||||
void TriggerCentral::handleShaftSignal(Engine *engine, trigger_event_e signal, uint64_t nowUs) {
|
||||
efiAssertVoid(engine!=NULL, "configuration");
|
||||
|
||||
efiAssertVoid(configuration->engineConfiguration!=NULL, "engineConfiguration");
|
||||
efiAssertVoid(configuration->engineConfiguration2!=NULL, "engineConfiguration2");
|
||||
efiAssertVoid(engine->engineConfiguration!=NULL, "engineConfiguration");
|
||||
efiAssertVoid(engine->engineConfiguration2!=NULL, "engineConfiguration2");
|
||||
|
||||
engine.onTriggerEvent(nowUs);
|
||||
engine->onTriggerEvent(nowUs);
|
||||
|
||||
#if EFI_HISTOGRAMS && EFI_PROD_CODE
|
||||
int beforeCallback = hal_lld_get_counter_value();
|
||||
|
@ -120,12 +120,12 @@ void TriggerCentral::handleShaftSignal(configuration_s *configuration, trigger_e
|
|||
}
|
||||
previousShaftEventTime = nowUs;
|
||||
|
||||
trigger_shape_s * triggerShape = &configuration->engineConfiguration2->triggerShape;
|
||||
trigger_shape_s * triggerShape = &engine->engineConfiguration2->triggerShape;
|
||||
|
||||
/**
|
||||
* This invocation changes the state of triggerState
|
||||
*/
|
||||
triggerState.decodeTriggerEvent(triggerShape, &configuration->engineConfiguration->triggerConfig, signal, nowUs);
|
||||
triggerState.decodeTriggerEvent(triggerShape, &engine->engineConfiguration->triggerConfig, signal, nowUs);
|
||||
|
||||
if (!triggerState.shaft_is_synchronized) {
|
||||
// we should not propagate event if we do not know where we are
|
||||
|
@ -137,7 +137,7 @@ void TriggerCentral::handleShaftSignal(configuration_s *configuration, trigger_e
|
|||
* cycle into a four stroke, 720 degrees cycle. TODO
|
||||
*/
|
||||
int triggerIndexForListeners;
|
||||
if (getOperationMode(configuration->engineConfiguration) == FOUR_STROKE_CAM_SENSOR) {
|
||||
if (getOperationMode(engine->engineConfiguration) == FOUR_STROKE_CAM_SENSOR) {
|
||||
// That's easy - trigger cycle matches engine cycle
|
||||
triggerIndexForListeners = triggerState.getCurrentIndex();
|
||||
} else {
|
||||
|
@ -147,7 +147,7 @@ void TriggerCentral::handleShaftSignal(configuration_s *configuration, trigger_e
|
|||
}
|
||||
reportEventToWaveChart(signal, triggerIndexForListeners);
|
||||
|
||||
if (triggerState.getCurrentIndex() >= configuration->engineConfiguration2->triggerShape.shaftPositionEventCount) {
|
||||
if (triggerState.getCurrentIndex() >= engine->engineConfiguration2->triggerShape.shaftPositionEventCount) {
|
||||
warning(OBD_PCM_Processor_Fault, "unexpected eventIndex=%d", triggerState.getCurrentIndex());
|
||||
} else {
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class TriggerCentral {
|
|||
public:
|
||||
TriggerCentral();
|
||||
void addEventListener(ShaftPositionListener handler, const char *name, void *arg);
|
||||
void handleShaftSignal(configuration_s *configuration, trigger_event_e signal, uint64_t nowUs);
|
||||
void handleShaftSignal(Engine *engine, trigger_event_e signal, uint64_t nowUs);
|
||||
int getHwEventCounter(int index);
|
||||
TriggerState triggerState;
|
||||
private:
|
||||
|
|
|
@ -35,9 +35,9 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType) {
|
|||
void EngineTestHelper::fireTriggerEvents() {
|
||||
for (int i = 0; i < 24; i++) {
|
||||
timeNow += 5000; // 5ms
|
||||
triggerCentral.handleShaftSignal(&configuration, SHAFT_PRIMARY_UP, timeNow);
|
||||
triggerCentral.handleShaftSignal(&engine, SHAFT_PRIMARY_UP, timeNow);
|
||||
timeNow += 5000;
|
||||
triggerCentral.handleShaftSignal(&configuration, SHAFT_PRIMARY_DOWN, timeNow);
|
||||
triggerCentral.handleShaftSignal(&engine, SHAFT_PRIMARY_DOWN, timeNow);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -426,7 +426,7 @@ static void testRpmCalculator(void) {
|
|||
prepareTimingMap();
|
||||
|
||||
timeNow += 5000; // 5ms
|
||||
eth.triggerCentral.handleShaftSignal(&configuration, SHAFT_PRIMARY_UP, timeNow);
|
||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_UP, timeNow);
|
||||
assertEqualsM("index #2", 0, eth.triggerCentral.triggerState.getCurrentIndex());
|
||||
assertEqualsM("queue size", 4, schedulingQueue.size());
|
||||
assertEqualsM("ev 1", 248000, schedulingQueue.getForUnitText(0)->momentUs);
|
||||
|
@ -434,11 +434,11 @@ static void testRpmCalculator(void) {
|
|||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000;
|
||||
eth.triggerCentral.handleShaftSignal(&configuration, SHAFT_PRIMARY_DOWN, timeNow);
|
||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_DOWN, timeNow);
|
||||
timeNow += 5000; // 5ms
|
||||
eth.triggerCentral.handleShaftSignal(&configuration, SHAFT_PRIMARY_UP, timeNow);
|
||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_UP, timeNow);
|
||||
timeNow += 5000;
|
||||
eth.triggerCentral.handleShaftSignal(&configuration, SHAFT_PRIMARY_DOWN, timeNow);
|
||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_DOWN, timeNow);
|
||||
assertEqualsM("index #3", 3, eth.triggerCentral.triggerState.getCurrentIndex());
|
||||
assertEqualsM("queue size 3", 6, schedulingQueue.size());
|
||||
assertEquals(258333, schedulingQueue.getForUnitText(0)->momentUs);
|
||||
|
@ -448,24 +448,24 @@ static void testRpmCalculator(void) {
|
|||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000;
|
||||
eth.triggerCentral.handleShaftSignal(&configuration, SHAFT_PRIMARY_DOWN, timeNow);
|
||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_DOWN, timeNow);
|
||||
timeNow += 5000; // 5ms
|
||||
eth.triggerCentral.handleShaftSignal(&configuration, SHAFT_PRIMARY_UP, timeNow);
|
||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_UP, timeNow);
|
||||
timeNow += 5000; // 5ms
|
||||
eth.triggerCentral.handleShaftSignal(&configuration, SHAFT_PRIMARY_UP, timeNow);
|
||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_UP, timeNow);
|
||||
assertEqualsM("index #4", 6, eth.triggerCentral.triggerState.getCurrentIndex());
|
||||
assertEqualsM("queue size 4", 6, schedulingQueue.size());
|
||||
assertEqualsM("4/0", 271666, schedulingQueue.getForUnitText(0)->momentUs);
|
||||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000;
|
||||
eth.triggerCentral.handleShaftSignal(&configuration, SHAFT_PRIMARY_DOWN, timeNow);
|
||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_DOWN, timeNow);
|
||||
assertEqualsM("queue size 5", 1, schedulingQueue.size());
|
||||
assertEqualsM("5/1", 284500, schedulingQueue.getForUnitText(0)->momentUs);
|
||||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000; // 5ms
|
||||
eth.triggerCentral.handleShaftSignal(&configuration, SHAFT_PRIMARY_UP, timeNow);
|
||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_UP, timeNow);
|
||||
assertEqualsM("queue size 6", 5, schedulingQueue.size());
|
||||
assertEqualsM("6/0", 285000, schedulingQueue.getForUnitText(0)->momentUs);
|
||||
assertEqualsM("6/1", 288000, schedulingQueue.getForUnitText(1)->momentUs);
|
||||
|
@ -473,12 +473,12 @@ static void testRpmCalculator(void) {
|
|||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000;
|
||||
eth.triggerCentral.handleShaftSignal(&configuration, SHAFT_PRIMARY_DOWN, timeNow);
|
||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_DOWN, timeNow);
|
||||
assertEqualsM("queue size 7", 0, schedulingQueue.size());
|
||||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000; // 5ms
|
||||
eth.triggerCentral.handleShaftSignal(&configuration, SHAFT_PRIMARY_UP, timeNow);
|
||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_UP, timeNow);
|
||||
assertEqualsM("queue size 8", 6, schedulingQueue.size());
|
||||
assertEqualsM("8/0", 298333, schedulingQueue.getForUnitText(0)->momentUs);
|
||||
assertEqualsM("8/1", 297833, schedulingQueue.getForUnitText(1)->momentUs);
|
||||
|
@ -487,12 +487,12 @@ static void testRpmCalculator(void) {
|
|||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000;
|
||||
eth.triggerCentral.handleShaftSignal(&configuration, SHAFT_PRIMARY_DOWN, timeNow);
|
||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_DOWN, timeNow);
|
||||
assertEqualsM("queue size 9", 0, schedulingQueue.size());
|
||||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000; // 5ms
|
||||
eth.triggerCentral.handleShaftSignal(&configuration, SHAFT_PRIMARY_UP, timeNow);
|
||||
eth.triggerCentral.handleShaftSignal(ð.engine, SHAFT_PRIMARY_UP, timeNow);
|
||||
assertEqualsM("queue size 10", 0, schedulingQueue.size());
|
||||
schedulingQueue.clear();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue