basic hw in the loop - pwm self validation #2028
This commit is contained in:
parent
f0e6c9739b
commit
86a6b3f7ad
|
@ -1,7 +1,6 @@
|
||||||
package com.rusefi;
|
package com.rusefi;
|
||||||
|
|
||||||
|
|
||||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
|
||||||
import com.rusefi.config.generated.Fields;
|
import com.rusefi.config.generated.Fields;
|
||||||
import com.rusefi.core.Sensor;
|
import com.rusefi.core.Sensor;
|
||||||
import com.rusefi.core.SensorCentral;
|
import com.rusefi.core.SensorCentral;
|
||||||
|
@ -29,24 +28,14 @@ import static com.rusefi.waves.EngineReport.isCloseEnough;
|
||||||
*/
|
*/
|
||||||
public class FunctionalTestsSuite {
|
public class FunctionalTestsSuite {
|
||||||
|
|
||||||
private final LinkManager linkManager;
|
|
||||||
private final EcuTestHelper ecu;
|
private final EcuTestHelper ecu;
|
||||||
|
|
||||||
public FunctionalTestsSuite(LinkManager linkManager, CommandQueue commandQueue) {
|
public FunctionalTestsSuite(LinkManager linkManager, CommandQueue commandQueue) {
|
||||||
ecu = new EcuTestHelper(commandQueue);
|
ecu = new EcuTestHelper(linkManager);
|
||||||
this.linkManager = linkManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mainTestBody() {
|
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();
|
testCustomEngine();
|
||||||
testVW_60_2();
|
|
||||||
testV12();
|
|
||||||
testMazdaMiata2003();
|
testMazdaMiata2003();
|
||||||
test2003DodgeNeon();
|
test2003DodgeNeon();
|
||||||
testFordAspire();
|
testFordAspire();
|
||||||
|
@ -63,33 +52,12 @@ public class FunctionalTestsSuite {
|
||||||
testFordFiesta();
|
testFordFiesta();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Function<String, Object> FAIL = errorCode -> {
|
public static final Function<String, Object> FAIL = errorCode -> {
|
||||||
if (errorCode != null)
|
if (errorCode != null)
|
||||||
throw new IllegalStateException("Failed " + errorCode);
|
throw new IllegalStateException("Failed " + errorCode);
|
||||||
return null;
|
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) {
|
public static void assertRpmDoesNotJump(int rpm, int settleTime, int testDuration, Function<String, Object> callback, CommandQueue commandQueue) {
|
||||||
IoUtil.changeRpm(commandQueue, rpm);
|
IoUtil.changeRpm(commandQueue, rpm);
|
||||||
sleepSeconds(settleTime);
|
sleepSeconds(settleTime);
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,11 +19,7 @@ import static com.rusefi.config.generated.Fields.*;
|
||||||
public class VssHardwareLoopTest {
|
public class VssHardwareLoopTest {
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
EcuTestHelper ecu = new EcuTestHelper(ControllerConnectorState.getLinkManager().getCommandQueue());
|
EcuTestHelper ecu = EcuTestHelper.createInstance(true);
|
||||||
|
|
||||||
ecu.sendCommand(getEnableCommand(Fields.CMD_TRIGGER_HW_INPUT));
|
|
||||||
ecu.enableFunctionalMode();
|
|
||||||
|
|
||||||
|
|
||||||
ecu.setEngineType(ET_FRANKENSO_MIATA_NA6);
|
ecu.setEngineType(ET_FRANKENSO_MIATA_NA6);
|
||||||
ecu.sendCommand(getDisableCommand(Fields.CMD_SELF_STIMULATION));
|
ecu.sendCommand(getDisableCommand(Fields.CMD_SELF_STIMULATION));
|
||||||
|
@ -43,4 +39,5 @@ public class VssHardwareLoopTest {
|
||||||
if (ControllerConnectorState.firmwareVersion == null)
|
if (ControllerConnectorState.firmwareVersion == null)
|
||||||
throw new IllegalStateException("firmwareVersion has not arrived");
|
throw new IllegalStateException("firmwareVersion has not arrived");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
package com.rusefi.functional_tests;
|
package com.rusefi.functional_tests;
|
||||||
|
|
||||||
import com.devexperts.logging.Logging;
|
import com.devexperts.logging.Logging;
|
||||||
|
import com.rusefi.ControllerConnectorState;
|
||||||
import com.rusefi.IoUtil;
|
import com.rusefi.IoUtil;
|
||||||
import com.rusefi.Timeouts;
|
import com.rusefi.Timeouts;
|
||||||
import com.rusefi.config.generated.Fields;
|
import com.rusefi.config.generated.Fields;
|
||||||
import com.rusefi.io.CommandQueue;
|
import com.rusefi.io.CommandQueue;
|
||||||
|
import com.rusefi.io.LinkManager;
|
||||||
import com.rusefi.waves.EngineReport;
|
import com.rusefi.waves.EngineReport;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static com.devexperts.logging.Logging.getLogging;
|
import static com.devexperts.logging.Logging.getLogging;
|
||||||
import static com.rusefi.IoUtil.*;
|
import static com.rusefi.IoUtil.*;
|
||||||
|
@ -17,9 +20,17 @@ public class EcuTestHelper {
|
||||||
public static final int COMPLEX_COMMAND_RETRY = 10000;
|
public static final int COMPLEX_COMMAND_RETRY = 10000;
|
||||||
public static int currentEngineType;
|
public static int currentEngineType;
|
||||||
public final CommandQueue commandQueue;
|
public final CommandQueue commandQueue;
|
||||||
|
@NotNull
|
||||||
|
private final LinkManager linkManager;
|
||||||
|
|
||||||
public EcuTestHelper(CommandQueue commandQueue) {
|
public EcuTestHelper(LinkManager linkManager) {
|
||||||
this.commandQueue = commandQueue;
|
this.commandQueue = linkManager.getCommandQueue();
|
||||||
|
this.linkManager = linkManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public LinkManager getLinkManager() {
|
||||||
|
return linkManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void assertEquals(double expected, double actual) {
|
public static void assertEquals(double expected, double actual) {
|
||||||
|
@ -35,6 +46,23 @@ public class EcuTestHelper {
|
||||||
throw new IllegalStateException(msg + " Expected " + expected + " but got " + actual);
|
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) {
|
public void sendCommand(String command) {
|
||||||
sendCommand(command, CommandQueue.DEFAULT_TIMEOUT, Timeouts.CMD_TIMEOUT);
|
sendCommand(command, CommandQueue.DEFAULT_TIMEOUT, Timeouts.CMD_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue