auto-sync

This commit is contained in:
rusEfi 2015-12-24 13:01:40 -05:00
parent 472202370d
commit 8ad500fcec
2 changed files with 48 additions and 5 deletions

View File

@ -5,7 +5,6 @@ package com.rusefi.logic;
* 12/24/2015
*/
public class IgnitionMapBuilder {
public enum ChamberStyle {
OPEN_CHAMBER(33),
CLOSED_CHAMBER(28),
@ -24,7 +23,37 @@ public class IgnitionMapBuilder {
}
public static double getTopAdvanceForBore(ChamberStyle style) {
return style.advance;
public static double getTopAdvanceForBore(ChamberStyle style, int octane, double compression, double bore) {
int octaneCorrection;
if ( octane <= 90) {
octaneCorrection = -2;
} else if (octane < 94) {
octaneCorrection = -1;
} else {
octaneCorrection = 0;
}
int compressionCorrection;
if (compression <= 9) {
compressionCorrection = 2;
} else if (compression <= 10) {
compressionCorrection = 1;
} else if (compression <= 11) {
compressionCorrection = 0;
} else {
// compression ratio above 11
compressionCorrection = -2;
}
double result = style.advance + octaneCorrection + compressionCorrection + getBoreCorrection(bore);
return round10(result);
}
public static double round10(double result) {
return ((int)(result * 10)) / 10.0;
}
public static double getBoreCorrection(double bore) {
return (bore - 4 * 25.4) / 25.4 * 6;
}
}

View File

@ -3,6 +3,10 @@ package com.rusefi.logic.test;
import com.rusefi.logic.IgnitionMapBuilder;
import org.junit.Test;
import static com.rusefi.logic.IgnitionMapBuilder.ChamberStyle.*;
import static com.rusefi.logic.IgnitionMapBuilder.getBoreCorrection;
import static com.rusefi.logic.IgnitionMapBuilder.getTopAdvanceForBore;
import static com.rusefi.logic.IgnitionMapBuilder.round10;
import static junit.framework.Assert.assertEquals;
/**
@ -10,10 +14,20 @@ import static junit.framework.Assert.assertEquals;
* 12/24/2015
*/
public class IgnitionMapBuilderTest {
private static final double EPS = 0.001;
@Test
public void testIgnitionMapBuilder() {
assertEquals(33.0, IgnitionMapBuilder.getTopAdvanceForBore(IgnitionMapBuilder.ChamberStyle.OPEN_CHAMBER));
assertEquals(1.1, round10(1.1));
assertEquals(1.1, round10(1.123));
assertEquals(22.0, IgnitionMapBuilder.getTopAdvanceForBore(IgnitionMapBuilder.ChamberStyle.SWITL_TUMBLE));
assertEquals(0.0, getBoreCorrection(4 * 25.4));
assertEquals(6.0, getBoreCorrection(5 * 25.4), EPS);
assertEquals(35.0, getTopAdvanceForBore(OPEN_CHAMBER, 98, 8, 101.6));
assertEquals(33.0, getTopAdvanceForBore(OPEN_CHAMBER, 98, 11, 101.6));
assertEquals(22.0, getTopAdvanceForBore(SWITL_TUMBLE, 89, 9, 101.6));
assertEquals(32.2, getTopAdvanceForBore(SWITL_TUMBLE, 89, 9, 145));
}
}