auto-sync

This commit is contained in:
rusEfi 2015-02-23 20:09:14 -06:00
parent 7b1a55ba93
commit 1d98728821
5 changed files with 39 additions and 4 deletions

View File

@ -22,6 +22,7 @@ public class AutoTest {
static void mainTestBody() {
sendCommand("fl 1"); // just in case it was disabled
testMitsu();
testCitroenBerlingo();
testMazda626();
test2003DodgeNeon();
@ -32,9 +33,17 @@ public class AutoTest {
testFordFiesta();
}
private static void testMitsu() {
setEngineType(16);
String msg = "Mitsubishi";
IoUtil.changeRpm(1200);
// todo: add more content
}
private static void testCitroenBerlingo() {
setEngineType(15);
String msg = "Citroen";
IoUtil.changeRpm(1200);
// todo: add more content
}

View File

@ -9,6 +9,11 @@ import static com.rusefi.AutoTest.*;
*/
public class RealHwTest {
public static void main(String[] args) {
/**
* with real hardware we have noise on all analog inputs which gives us random sensor data, we cannot really
* test exact numbers yet
*/
TestingUtils.skipWaveCheck = true;
FileLog.MAIN.start();
String port;
if (args.length == 1) {

View File

@ -19,6 +19,8 @@ import static com.rusefi.waves.WaveReport.isCloseEnough;
* 3/19/14.
*/
public class TestingUtils {
static boolean skipWaveCheck;
static void assertTrue(String msg, boolean b) {
if (!b)
fail("Not true: " + msg);
@ -35,7 +37,7 @@ public class TestingUtils {
}
private static String printRange(double current, double ratio) {
return " expected range from " + current * (1 - ratio) + " to " + current * (1 + ratio);
return " expected range from " + current * (1 - ratio) + " to " + current * (1 + ratio) + " with ratio " + ratio;
}
private static double fixAngle(double angle) {
@ -46,7 +48,9 @@ public class TestingUtils {
private static void fail(String message) {
FileLog.MAIN.logLine("FAILURE: " + message);
throw new IllegalStateException(message);
IllegalStateException exception = new IllegalStateException(message);
FileLog.MAIN.log(exception);
throw exception;
}
static void assertTrue(boolean b) {
@ -70,7 +74,9 @@ public class TestingUtils {
assertWave(false, msg, chart, key, width, WaveReport.RATIO, WaveReport.RATIO, expectedAngles);
}
static void assertWave(boolean rise, String msg, WaveChart chart, String key, double width, double angleRatio, double widthRatio, double... expectedAngles) {
static void assertWave(boolean rise, String msg, WaveChart chart, String key, double expectedWidth, double angleRatio, double widthRatio, double... expectedAngles) {
if(skipWaveCheck)
return;
RevolutionLog revolutionLog = chart.getRevolutionsLog();
if (revolutionLog.keySet().isEmpty())
throw new IllegalStateException(msg + " Empty revolutions in " + chart);
@ -84,7 +90,13 @@ public class TestingUtils {
double angleByTime = revolutionLog.getCrankAngleByTime(eventTime);
assertCloseEnough(msg + " angle for " + key + "@" + eventTime, fixAngle(angleByTime), angleRatio, expectedAngles);
assertCloseEnough(msg + "width for " + key, ud.getDutyCycle(revolutionLog), widthRatio, width);
double actualWidth = ud.getDutyCycle(revolutionLog);
if (!isCloseEnough(fixAngle(actualWidth), expectedWidth, widthRatio)) {
System.out.println("f " + revolutionLog.getCrankAngleByTime(ud.downTime));
System.out.println("t " + revolutionLog.getCrankAngleByTime(ud.upTime));
}
assertCloseEnough(msg + "width for " + key, actualWidth, widthRatio, expectedWidth);
}
}
@ -100,6 +112,7 @@ public class TestingUtils {
// we need to skip TWO because spark could have been scheduled a while ago and happen now
// todo: improve this logic, compare times
getWaveChart();
getWaveChart();
// we want to wait for the 2nd chart to see same same RPM across the whole chart
String result = getWaveChart();
FileLog.MAIN.logLine("current chart: " + result);

View File

@ -83,4 +83,11 @@ public enum FileLog {
public static void rlog(String msg) {
System.out.println("r " + msg);
}
public void log(IllegalStateException exception) {
if (fileLog == null)
throw new NullPointerException("fileLog");
OutputStreamWriter os = new OutputStreamWriter(fileLog);
exception.printStackTrace(new PrintWriter(os));
}
}

View File

@ -33,6 +33,7 @@ import static com.rusefi.ui.util.LocalizedMessages.PAUSE;
* Andrey Belomutskiy (c) 2012-2013
*
* @see EngineSnifferStatusPanel status bar
* @see com.rusefi.ui.test.WavePanelSandbox
*/
public class EngineSnifferPanel {
private static final int EFI_DEFAULT_CHART_SIZE = 180;