basic hw in the loop - pwm self validation #2028

This commit is contained in:
rusefi 2020-12-12 23:00:18 -05:00
parent f0e6c9739b
commit 86a6b3f7ad
5 changed files with 85 additions and 41 deletions

View File

@ -1,7 +1,6 @@
package com.rusefi;
import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.config.generated.Fields;
import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral;
@ -29,24 +28,14 @@ import static com.rusefi.waves.EngineReport.isCloseEnough;
*/
public class FunctionalTestsSuite {
private final LinkManager linkManager;
private final EcuTestHelper ecu;
public FunctionalTestsSuite(LinkManager linkManager, CommandQueue commandQueue) {
ecu = new EcuTestHelper(commandQueue);
this.linkManager = linkManager;
ecu = new EcuTestHelper(linkManager);
}
void mainTestBody() {
BinaryProtocol bp = linkManager.getCurrentStreamState();
// let's make sure 'burn' command works since sometimes it does not
bp.burn();
ecu.sendCommand(getDisableCommand(Fields.CMD_TRIGGER_HW_INPUT));
ecu.enableFunctionalMode();
testCustomEngine();
testVW_60_2();
testV12();
testMazdaMiata2003();
test2003DodgeNeon();
testFordAspire();
@ -63,33 +52,12 @@ public class FunctionalTestsSuite {
testFordFiesta();
}
private static final Function<String, Object> FAIL = errorCode -> {
public static final Function<String, Object> FAIL = errorCode -> {
if (errorCode != null)
throw new IllegalStateException("Failed " + errorCode);
return null;
};
private void testVW_60_2() {
ecu.setEngineType(ET_VW_ABA);
// trying to disable engine sniffer to help https://github.com/rusefi/rusefi/issues/1849
ecu.sendCommand("set " + CMD_ENGINESNIFFERRPMTHRESHOLD + " 100");
ecu.changeRpm(900);
// first let's get to expected RPM
assertRpmDoesNotJump(16000, 5, 40, FAIL, ecu.commandQueue);
}
private void testV12() {
ecu.setEngineType(ET_BMW_M73_F);
ecu.changeRpm(700);
// first let's get to expected RPM
assertRpmDoesNotJump(16000, 5, 40, FAIL, ecu.commandQueue);
testCaseBug1873();
}
private void testCaseBug1873() {
assertRpmDoesNotJump(60, 5, 110, FAIL, ecu.commandQueue);
}
public static void assertRpmDoesNotJump(int rpm, int settleTime, int testDuration, Function<String, Object> callback, CommandQueue commandQueue) {
IoUtil.changeRpm(commandQueue, rpm);
sleepSeconds(settleTime);

View File

@ -0,0 +1,35 @@
package com.rusefi;
import com.rusefi.functional_tests.EcuTestHelper;
import org.junit.Test;
import static com.rusefi.FunctionalTestsSuite.FAIL;
import static com.rusefi.config.generated.Fields.*;
public class HighRevTest {
@Test
public void testVW() {
EcuTestHelper ecu = EcuTestHelper.createInstance();
ecu.setEngineType(ET_VW_ABA);
// trying to disable engine sniffer to help https://github.com/rusefi/rusefi/issues/1849
ecu.sendCommand("set " + CMD_ENGINESNIFFERRPMTHRESHOLD + " 100");
ecu.changeRpm(900);
// first let's get to expected RPM
FunctionalTestsSuite.assertRpmDoesNotJump(16000, 5, 40, FAIL, ecu.commandQueue);
}
@Test
public void testV12() {
EcuTestHelper ecu = EcuTestHelper.createInstance();
ecu.setEngineType(ET_BMW_M73_F);
ecu.changeRpm(700);
// first let's get to expected RPM
FunctionalTestsSuite.assertRpmDoesNotJump(16000, 5, 40, FAIL, ecu.commandQueue);
testCaseBug1873(ecu);
}
private void testCaseBug1873(EcuTestHelper ecu) {
FunctionalTestsSuite.assertRpmDoesNotJump(60, 5, 110, FAIL, ecu.commandQueue);
}
}

View File

@ -0,0 +1,16 @@
package com.rusefi;
import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.functional_tests.EcuTestHelper;
import org.junit.Test;
public class MiscTest {
@Test
public void burn() {
EcuTestHelper ecu = EcuTestHelper.createInstance();
BinaryProtocol bp = ecu.getLinkManager().getCurrentStreamState();
// let's make sure 'burn' command works since sometimes it does not
bp.burn();
}
}

View File

@ -19,11 +19,7 @@ import static com.rusefi.config.generated.Fields.*;
public class VssHardwareLoopTest {
@Test
public void test() {
EcuTestHelper ecu = new EcuTestHelper(ControllerConnectorState.getLinkManager().getCommandQueue());
ecu.sendCommand(getEnableCommand(Fields.CMD_TRIGGER_HW_INPUT));
ecu.enableFunctionalMode();
EcuTestHelper ecu = EcuTestHelper.createInstance(true);
ecu.setEngineType(ET_FRANKENSO_MIATA_NA6);
ecu.sendCommand(getDisableCommand(Fields.CMD_SELF_STIMULATION));
@ -43,4 +39,5 @@ public class VssHardwareLoopTest {
if (ControllerConnectorState.firmwareVersion == null)
throw new IllegalStateException("firmwareVersion has not arrived");
}
}

View File

@ -1,11 +1,14 @@
package com.rusefi.functional_tests;
import com.devexperts.logging.Logging;
import com.rusefi.ControllerConnectorState;
import com.rusefi.IoUtil;
import com.rusefi.Timeouts;
import com.rusefi.config.generated.Fields;
import com.rusefi.io.CommandQueue;
import com.rusefi.io.LinkManager;
import com.rusefi.waves.EngineReport;
import org.jetbrains.annotations.NotNull;
import static com.devexperts.logging.Logging.getLogging;
import static com.rusefi.IoUtil.*;
@ -17,9 +20,17 @@ public class EcuTestHelper {
public static final int COMPLEX_COMMAND_RETRY = 10000;
public static int currentEngineType;
public final CommandQueue commandQueue;
@NotNull
private final LinkManager linkManager;
public EcuTestHelper(CommandQueue commandQueue) {
this.commandQueue = commandQueue;
public EcuTestHelper(LinkManager linkManager) {
this.commandQueue = linkManager.getCommandQueue();
this.linkManager = linkManager;
}
@NotNull
public LinkManager getLinkManager() {
return linkManager;
}
public static void assertEquals(double expected, double actual) {
@ -35,6 +46,23 @@ public class EcuTestHelper {
throw new IllegalStateException(msg + " Expected " + expected + " but got " + actual);
}
@NotNull
public static EcuTestHelper createInstance() {
return createInstance(false);
}
@NotNull
public static EcuTestHelper createInstance(boolean allowHardwareTriggerInput) {
EcuTestHelper ecu = new EcuTestHelper(ControllerConnectorState.getLinkManager());
if (allowHardwareTriggerInput) {
ecu.sendCommand(getEnableCommand(Fields.CMD_TRIGGER_HW_INPUT));
} else {
ecu.sendCommand(getDisableCommand(Fields.CMD_TRIGGER_HW_INPUT));
}
ecu.enableFunctionalMode();
return ecu;
}
public void sendCommand(String command) {
sendCommand(command, CommandQueue.DEFAULT_TIMEOUT, Timeouts.CMD_TIMEOUT);
}