mirror of https://github.com/rusefi/rusefi-1.git
refactoring
This commit is contained in:
parent
745f7ae5cf
commit
cdb235cd82
|
@ -70,6 +70,12 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType) : engine (&persiste
|
||||||
resetTriggerConfigChangedForUnitTest();
|
resetTriggerConfigChangedForUnitTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EngineTestHelper::fireRise(int delayMs) {
|
||||||
|
timeNowUs += MS2US(delayMs);
|
||||||
|
firePrimaryTriggerRise();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void EngineTestHelper::firePrimaryTriggerRise() {
|
void EngineTestHelper::firePrimaryTriggerRise() {
|
||||||
board_configuration_s * boardConfiguration = &engine.engineConfiguration->bc;
|
board_configuration_s * boardConfiguration = &engine.engineConfiguration->bc;
|
||||||
engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_RISING, &engine, engine.engineConfiguration, &persistentConfig, boardConfiguration);
|
engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_RISING, &engine, engine.engineConfiguration, &persistentConfig, boardConfiguration);
|
||||||
|
@ -92,8 +98,8 @@ void EngineTestHelper::fireTriggerEventsWithDuration(int durationMs) {
|
||||||
void EngineTestHelper::fireTriggerEvents2(int count, int durationMs) {
|
void EngineTestHelper::fireTriggerEvents2(int count, int durationMs) {
|
||||||
int durationUs = MS2US(durationMs);
|
int durationUs = MS2US(durationMs);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
timeNowUs += durationUs;
|
|
||||||
firePrimaryTriggerRise();
|
fireRise(durationMs);
|
||||||
timeNowUs += durationUs;
|
timeNowUs += durationUs;
|
||||||
firePrimaryTriggerFall();
|
firePrimaryTriggerFall();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,11 +20,14 @@ class EngineTestHelper {
|
||||||
public:
|
public:
|
||||||
EngineTestHelper(engine_type_e engineType);
|
EngineTestHelper(engine_type_e engineType);
|
||||||
void applyTriggerShape();
|
void applyTriggerShape();
|
||||||
|
void fireRise(int delayMs);
|
||||||
|
void fireFall(int delayMs);
|
||||||
|
|
||||||
void firePrimaryTriggerRise();
|
void firePrimaryTriggerRise();
|
||||||
void firePrimaryTriggerFall();
|
void firePrimaryTriggerFall();
|
||||||
void fireTriggerEvents(int count);
|
void fireTriggerEvents(int count);
|
||||||
void fireTriggerEventsWithDuration(int durationMs);
|
void fireTriggerEventsWithDuration(int delayMs);
|
||||||
void fireTriggerEvents2(int count, int durationMs);
|
void fireTriggerEvents2(int count, int delayMs);
|
||||||
void clearQueue();
|
void clearQueue();
|
||||||
|
|
||||||
Engine engine;
|
Engine engine;
|
||||||
|
|
|
@ -43,8 +43,7 @@ void testFasterEngineSpinningUp() {
|
||||||
// check all events starting from now
|
// check all events starting from now
|
||||||
int timeStartUs = timeNowUs;
|
int timeStartUs = timeNowUs;
|
||||||
// advance 1 revolution
|
// advance 1 revolution
|
||||||
timeNowUs += MS2US(200);
|
eth.fireRise(200);
|
||||||
eth.firePrimaryTriggerRise();
|
|
||||||
|
|
||||||
// check if the mode is changed
|
// check if the mode is changed
|
||||||
assertEquals(SPINNING_UP, engine->rpmCalculator.getState());
|
assertEquals(SPINNING_UP, engine->rpmCalculator.getState());
|
||||||
|
@ -66,8 +65,8 @@ void testFasterEngineSpinningUp() {
|
||||||
|
|
||||||
// now clear and advance more
|
// now clear and advance more
|
||||||
eth.clearQueue();
|
eth.clearQueue();
|
||||||
timeNowUs += MS2US(200);
|
|
||||||
eth.firePrimaryTriggerRise();
|
eth.fireRise(200);
|
||||||
|
|
||||||
// check if the mode is changed when fully synched
|
// check if the mode is changed when fully synched
|
||||||
assertEquals(CRANKING, engine->rpmCalculator.getState());
|
assertEquals(CRANKING, engine->rpmCalculator.getState());
|
||||||
|
|
|
@ -28,8 +28,8 @@ void testPlainCrankingWithoutAdvancedFeatures() {
|
||||||
// still no RPM since need to cycles measure cycle duration
|
// still no RPM since need to cycles measure cycle duration
|
||||||
assertEqualsM("RPM#1", 0, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
|
assertEqualsM("RPM#1", 0, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
|
||||||
|
|
||||||
timeNowUs += MS2US(200);
|
|
||||||
eth.firePrimaryTriggerRise();
|
eth.fireRise(200);
|
||||||
assertEqualsM("RPM#2", 300, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
|
assertEqualsM("RPM#2", 300, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
|
||||||
// two simultaneous injections
|
// two simultaneous injections
|
||||||
assertEqualsM("plain#2", 4, schedulingQueue.size());
|
assertEqualsM("plain#2", 4, schedulingQueue.size());
|
||||||
|
|
|
@ -677,8 +677,7 @@ static void setTestBug299(EngineTestHelper *eth) {
|
||||||
/**
|
/**
|
||||||
* Trigger up - scheduling fuel for full engine cycle
|
* Trigger up - scheduling fuel for full engine cycle
|
||||||
*/
|
*/
|
||||||
timeNowUs += MS2US(20);
|
eth->fireRise(20);
|
||||||
eth->firePrimaryTriggerRise();
|
|
||||||
// fuel schedule - short pulses.
|
// fuel schedule - short pulses.
|
||||||
// time...|0.......|10......|20......|30......|40
|
// time...|0.......|10......|20......|30......|40
|
||||||
// inj #0 |.......#|........|.......#|........|
|
// inj #0 |.......#|........|.......#|........|
|
||||||
|
@ -984,8 +983,8 @@ void testFuelSchedulerBug299smallAndMedium(void) {
|
||||||
schedulingQueue.executeAll(timeNowUs);
|
schedulingQueue.executeAll(timeNowUs);
|
||||||
engine->periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
engine->periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
||||||
timeNowUs += MS2US(20);
|
|
||||||
eth.firePrimaryTriggerRise();
|
eth.fireRise(20);
|
||||||
assertEqualsM("Queue.size#05", 7, schedulingQueue.size());
|
assertEqualsM("Queue.size#05", 7, schedulingQueue.size());
|
||||||
schedulingQueue.executeAll(timeNowUs);
|
schedulingQueue.executeAll(timeNowUs);
|
||||||
|
|
||||||
|
@ -1200,16 +1199,15 @@ void testSparkReverseOrderBug319(void) {
|
||||||
timeNowUs = 0;
|
timeNowUs = 0;
|
||||||
setWholeTimingTable(0 PASS_ENGINE_PARAMETER_SUFFIX);
|
setWholeTimingTable(0 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
timeNowUs += MS2US(20);
|
|
||||||
eth.firePrimaryTriggerRise();
|
eth.fireRise(20);
|
||||||
|
|
||||||
timeNowUs += MS2US(20);
|
timeNowUs += MS2US(20);
|
||||||
eth.firePrimaryTriggerFall();
|
eth.firePrimaryTriggerFall();
|
||||||
|
|
||||||
schedulingQueue.executeAll(timeNowUs);
|
schedulingQueue.executeAll(timeNowUs);
|
||||||
|
|
||||||
timeNowUs += MS2US(20);
|
eth.fireRise(20);
|
||||||
eth.firePrimaryTriggerRise();
|
|
||||||
|
|
||||||
timeNowUs += MS2US(20);
|
timeNowUs += MS2US(20);
|
||||||
eth.firePrimaryTriggerFall();
|
eth.firePrimaryTriggerFall();
|
||||||
|
@ -1221,8 +1219,8 @@ void testSparkReverseOrderBug319(void) {
|
||||||
schedulingQueue.executeAll(timeNowUs);
|
schedulingQueue.executeAll(timeNowUs);
|
||||||
printf("***************************************************\r\n");
|
printf("***************************************************\r\n");
|
||||||
|
|
||||||
timeNowUs += MS2US(20);
|
|
||||||
eth.firePrimaryTriggerRise();
|
eth.fireRise(20);
|
||||||
schedulingQueue.executeAll(timeNowUs);
|
schedulingQueue.executeAll(timeNowUs);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1240,8 +1238,8 @@ void testSparkReverseOrderBug319(void) {
|
||||||
|
|
||||||
printf("*************************************************** now let's have a good engine cycle and confirm things work\r\n");
|
printf("*************************************************** now let's have a good engine cycle and confirm things work\r\n");
|
||||||
|
|
||||||
timeNowUs += MS2US(20);
|
|
||||||
eth.firePrimaryTriggerRise();
|
eth.fireRise(20);
|
||||||
schedulingQueue.executeAll(timeNowUs);
|
schedulingQueue.executeAll(timeNowUs);
|
||||||
|
|
||||||
assertEqualsM("RPM#2", 545, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
|
assertEqualsM("RPM#2", 545, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
|
||||||
|
@ -1255,8 +1253,7 @@ void testSparkReverseOrderBug319(void) {
|
||||||
|
|
||||||
printf("*************************************************** (rpm is back) now let's have a good engine cycle and confirm things work\r\n");
|
printf("*************************************************** (rpm is back) now let's have a good engine cycle and confirm things work\r\n");
|
||||||
|
|
||||||
timeNowUs += MS2US(20);
|
eth.fireRise(20);
|
||||||
eth.firePrimaryTriggerRise();
|
|
||||||
schedulingQueue.executeAll(timeNowUs);
|
schedulingQueue.executeAll(timeNowUs);
|
||||||
|
|
||||||
assertEqualsM("RPM#3", 3000, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
|
assertEqualsM("RPM#3", 3000, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
|
||||||
|
@ -1270,8 +1267,7 @@ void testSparkReverseOrderBug319(void) {
|
||||||
|
|
||||||
printf("*************************************************** (rpm is back 2) now let's have a good engine cycle and confirm things work\r\n");
|
printf("*************************************************** (rpm is back 2) now let's have a good engine cycle and confirm things work\r\n");
|
||||||
|
|
||||||
timeNowUs += MS2US(20);
|
eth.fireRise(20);
|
||||||
eth.firePrimaryTriggerRise();
|
|
||||||
schedulingQueue.executeAll(timeNowUs);
|
schedulingQueue.executeAll(timeNowUs);
|
||||||
|
|
||||||
assertEqualsM("RPM#4", 3000, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
|
assertEqualsM("RPM#4", 3000, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
|
||||||
|
@ -1317,8 +1313,8 @@ void testMissedSpark299(void) {
|
||||||
schedulingQueue.executeAll(timeNowUs);
|
schedulingQueue.executeAll(timeNowUs);
|
||||||
assertEqualsM("ci#3", 1, eth.engine.triggerCentral.triggerState.currentCycle.current_index);
|
assertEqualsM("ci#3", 1, eth.engine.triggerCentral.triggerState.currentCycle.current_index);
|
||||||
|
|
||||||
timeNowUs += MS2US(20);
|
|
||||||
eth.firePrimaryTriggerRise();
|
eth.fireRise(20);
|
||||||
schedulingQueue.executeAll(timeNowUs);
|
schedulingQueue.executeAll(timeNowUs);
|
||||||
|
|
||||||
timeNowUs += MS2US(20);
|
timeNowUs += MS2US(20);
|
||||||
|
@ -1352,15 +1348,15 @@ void testMissedSpark299(void) {
|
||||||
setWholeTimingTable(-5 PASS_ENGINE_PARAMETER_SUFFIX);
|
setWholeTimingTable(-5 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
||||||
timeNowUs += MS2US(20);
|
|
||||||
eth.firePrimaryTriggerRise();
|
eth.fireRise(20);
|
||||||
schedulingQueue.executeAll(timeNowUs);
|
schedulingQueue.executeAll(timeNowUs);
|
||||||
timeNowUs += MS2US(20);
|
timeNowUs += MS2US(20);
|
||||||
eth.firePrimaryTriggerFall();
|
eth.firePrimaryTriggerFall();
|
||||||
schedulingQueue.executeAll(timeNowUs);
|
schedulingQueue.executeAll(timeNowUs);
|
||||||
|
|
||||||
timeNowUs += MS2US(20);
|
|
||||||
eth.firePrimaryTriggerRise();
|
eth.fireRise(20);
|
||||||
schedulingQueue.executeAll(timeNowUs);
|
schedulingQueue.executeAll(timeNowUs);
|
||||||
timeNowUs += MS2US(20);
|
timeNowUs += MS2US(20);
|
||||||
eth.firePrimaryTriggerFall();
|
eth.firePrimaryTriggerFall();
|
||||||
|
|
Loading…
Reference in New Issue