auto-sync
This commit is contained in:
parent
6bca6979c2
commit
6104c175f0
|
@ -79,6 +79,9 @@ void TriggerShape::clear() {
|
|||
tdcPosition = 0;
|
||||
setTriggerSynchronizationGap(2);
|
||||
useRiseEdge = true;
|
||||
|
||||
invertOnAdd = false;
|
||||
gapBothDirections = false;
|
||||
}
|
||||
|
||||
void TriggerShape::reset(operation_mode_e operationMode, bool needSecondTriggerInput) {
|
||||
|
|
|
@ -26,16 +26,28 @@ public class AutoTest {
|
|||
}
|
||||
|
||||
private static void test2003DodgeNeon() {
|
||||
// sendCommand("set_engine_type 23");
|
||||
// let's give some time to change engine type
|
||||
// nextChart();
|
||||
// nextChart();
|
||||
// WaveChart chart;
|
||||
// String msg = "2003 Neon cranking";
|
||||
// IoUtil.changeRpm(200);
|
||||
// chart = nextChart();
|
||||
// double x = 107;
|
||||
// assertWave(msg, chart, WaveChart.SPARK_1, 0.194433, x, x + 180, x + 360, x + 540);
|
||||
sendCommand("set_engine_type 23");
|
||||
WaveChart chart;
|
||||
// time to change engine type
|
||||
nextChart();
|
||||
String msg = "2003 Neon cranking";
|
||||
IoUtil.changeRpm(200);
|
||||
|
||||
chart = nextChart();
|
||||
double x = 100;
|
||||
assertWave(true, msg, chart, WaveChart.SPARK_1, 0.194433, 0.005, x + 180, x + 540);
|
||||
assertWaveNull(msg, chart, WaveChart.SPARK_2);
|
||||
assertWave(true, msg, chart, WaveChart.SPARK_3, 0.194433, 0.005, x, x + 360);
|
||||
assertWaveNull(msg, chart, WaveChart.SPARK_4);
|
||||
|
||||
msg = "2003 Neon running";
|
||||
IoUtil.changeRpm(2000);
|
||||
chart = nextChart();
|
||||
x = 120;
|
||||
assertWave(true, msg, chart, WaveChart.SPARK_1, 0.13299999999999998, 0.005, x + 180, x + 540);
|
||||
assertWaveNull(msg, chart, WaveChart.SPARK_2);
|
||||
assertWave(true, msg, chart, WaveChart.SPARK_3, 0.13299999999999998, 0.005, x, x + 360);
|
||||
assertWaveNull(msg, chart, WaveChart.SPARK_4);
|
||||
}
|
||||
|
||||
private static void testMazdaProtege() {
|
||||
|
@ -98,9 +110,9 @@ public class AutoTest {
|
|||
String msg = "Fiesta";
|
||||
double x = 312;
|
||||
assertWave("wasted spark #1 with Fiesta", chart, WaveChart.SPARK_1, 0.1333333, x, x + 360);
|
||||
assertNull(msg, chart.get(WaveChart.SPARK_2));
|
||||
assertWaveNull(chart, WaveChart.SPARK_2);
|
||||
assertWave("wasted spark #3 with Fiesta", chart, WaveChart.SPARK_3, 0.1333333, x + 180, x + 540);
|
||||
assertNull(msg, chart.get(WaveChart.SPARK_4));
|
||||
assertWaveNull(msg, chart, WaveChart.SPARK_4);
|
||||
}
|
||||
|
||||
private static void testFord6() {
|
||||
|
@ -114,11 +126,10 @@ public class AutoTest {
|
|||
int x = 7;
|
||||
assertWave(msg, chart, WaveChart.SPARK_1, 0.01666, x, x + 120, x + 240, x + 360, x + 480, x + 600);
|
||||
|
||||
assertNull(msg, chart.get(WaveChart.TRIGGER_2));
|
||||
assertWaveNull(msg, chart, WaveChart.TRIGGER_2);
|
||||
sendCommand("set_trigger_type 1"); // TT_FORD_ASPIRE
|
||||
chart = nextChart();
|
||||
assertTrue(msg, chart.get(WaveChart.TRIGGER_2) != null);
|
||||
|
||||
}
|
||||
|
||||
private static void testFordAspire() {
|
||||
|
@ -198,7 +209,7 @@ public class AutoTest {
|
|||
|
||||
x = 41;
|
||||
assertWave(chart, WaveChart.SPARK_1, 0.133, x, x + 180, x + 360, x + 540);
|
||||
assertNull("chart for " + WaveChart.SPARK_2, chart.get(WaveChart.SPARK_2));
|
||||
assertWaveNull(chart, WaveChart.SPARK_2);
|
||||
|
||||
sendCommand("set_global_trigger_offset_angle 130");
|
||||
sendCommand("set_injection_offset 369");
|
||||
|
@ -230,7 +241,15 @@ public class AutoTest {
|
|||
// above hard limit
|
||||
IoUtil.changeRpm(10000);
|
||||
chart = nextChart();
|
||||
assertNull("hard limit check", chart.get(WaveChart.INJECTOR_1));
|
||||
assertWaveNull("hard limit check", chart, WaveChart.INJECTOR_1);
|
||||
}
|
||||
|
||||
private static void assertWaveNull(WaveChart chart, String key) {
|
||||
assertWaveNull("", chart, key);
|
||||
}
|
||||
|
||||
private static void assertWaveNull(String msg, WaveChart chart, String key) {
|
||||
assertNull(msg + "chart for " + key, chart.get(key));
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.rusefi;
|
||||
|
||||
import com.rusefi.FileLog;
|
||||
import com.rusefi.waves.RevolutionLog;
|
||||
import com.rusefi.waves.WaveChart;
|
||||
import com.rusefi.waves.WaveReport;
|
||||
|
@ -20,9 +19,9 @@ public class TestingUtils {
|
|||
fail("Not true: " + msg);
|
||||
}
|
||||
|
||||
static void assertCloseEnough(String msg, double current, double... expectations) {
|
||||
static void assertCloseEnough(String msg, double current, double ratio, double... expectations) {
|
||||
for (double expected : expectations) {
|
||||
if (isCloseEnough(fixAngle(expected), current))
|
||||
if (isCloseEnough(fixAngle(expected), current, ratio))
|
||||
return;
|
||||
}
|
||||
fail(msg + ": Got " + current + " while expecting " + Arrays.toString(expectations));
|
||||
|
@ -49,7 +48,7 @@ public class TestingUtils {
|
|||
}
|
||||
|
||||
static void assertWave(String msg, WaveChart chart, String key, double width, double... expectedAngles) {
|
||||
assertWave(true, msg, chart, key, width, expectedAngles);
|
||||
assertWave(true, msg, chart, key, width, WaveReport.RATIO, expectedAngles);
|
||||
}
|
||||
|
||||
static void assertWaveFall(WaveChart chart, String key, double width, double... expectedAngles) {
|
||||
|
@ -57,10 +56,10 @@ public class TestingUtils {
|
|||
}
|
||||
|
||||
static void assertWaveFall(String msg, WaveChart chart, String key, double width, double... expectedAngles) {
|
||||
assertWave(false, msg, chart, key, width, expectedAngles);
|
||||
assertWave(false, msg, chart, key, width, WaveReport.RATIO, expectedAngles);
|
||||
}
|
||||
|
||||
static void assertWave(boolean rise, String msg, WaveChart chart, String key, double width, double... expectedAngles) {
|
||||
static void assertWave(boolean rise, String msg, WaveChart chart, String key, double width, double angleRatio, double... expectedAngles) {
|
||||
RevolutionLog revolutionLog = chart.getRevolutionsLog();
|
||||
if (revolutionLog.keySet().isEmpty())
|
||||
throw new IllegalStateException(msg + " Empty revolutions in " + chart);
|
||||
|
@ -72,9 +71,9 @@ public class TestingUtils {
|
|||
for (WaveReport.UpDown ud : wr) {
|
||||
int eventTime = rise ? ud.upTime : ud.downTime;
|
||||
double angleByTime = revolutionLog.getCrankAngleByTime(eventTime);
|
||||
assertCloseEnough(msg + " angle for " + key + "@" + eventTime, fixAngle(angleByTime), expectedAngles);
|
||||
assertCloseEnough(msg + " angle for " + key + "@" + eventTime, fixAngle(angleByTime), angleRatio, expectedAngles);
|
||||
|
||||
assertCloseEnough(msg + "width for " + key, ud.getDutyCycle(revolutionLog), width);
|
||||
assertCloseEnough(msg + "width for " + key, ud.getDutyCycle(revolutionLog), WaveReport.RATIO, width);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,4 +43,15 @@ public class WaveChart {
|
|||
public StringBuilder get(String key) {
|
||||
return map.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WaveChart{" +
|
||||
"size=" + map.size() +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Map<String, StringBuilder> getMap() {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ public class WaveReport implements TimeAxisTranslator {
|
|||
* number of ChibiOS systicks per ms
|
||||
*/
|
||||
public static final double SYS_TICKS_PER_MS = 100;
|
||||
public static final double RATIO = 0.05;
|
||||
public static final int mult = (int) (100 * SYS_TICKS_PER_MS); // 100ms
|
||||
private static final String WC_DOWN = "d";
|
||||
private static final String WC_UP = "u";
|
||||
|
@ -46,10 +47,14 @@ public class WaveReport implements TimeAxisTranslator {
|
|||
}
|
||||
|
||||
public static boolean isCloseEnough(double v1, double v2) {
|
||||
return isCloseEnough(v1, v2, RATIO);
|
||||
}
|
||||
|
||||
public static boolean isCloseEnough(double v1, double v2, double th) {
|
||||
if (v2 == 0)
|
||||
return v1 == 0;
|
||||
double ratio = v1 / v2;
|
||||
return Math.abs(1 - ratio) < 0.05;
|
||||
return Math.abs(1 - ratio) < th;
|
||||
}
|
||||
|
||||
public List<UpDown> getList() {
|
||||
|
|
|
@ -19,10 +19,10 @@ public class WaveChartParserTest {
|
|||
@Test
|
||||
public void testMultiParser() {
|
||||
WaveChart result = WaveChartParser.unpackToMap("");
|
||||
assertTrue(result.map.isEmpty());
|
||||
assertTrue(result.getMap().isEmpty());
|
||||
|
||||
result = WaveChartParser.unpackToMap("wave_chart,c1!u_154!0!c1!d_155!11!c1!u_156!24!spa5!u!36!c1!d_157!39!c1!u_158!49!c1!d_159!61!c1!u_160!74!c1!d_161!86!c1!u_162!99!c1!d_163!111!c1!u_164!124!");
|
||||
assertEquals(3, result.map.size());
|
||||
assertEquals(3, result.getMap().size());
|
||||
|
||||
String crankReport = result.get("c1").toString();
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class WaveChartParserTest {
|
|||
@Test
|
||||
public void testDutyCycle() {
|
||||
WaveChart result = WaveChartParser.unpackToMap("r!1199!64224414!crank2!u!64225149_3!Injector 2!u!64225149!Spark 1!u!64225249!Injector 2!d!64225303!Spark 1!d!64225649!crank2!d!64226105_4!crank!d!64226980_5!crank2!u!64227730_6!Injector 1!u!64227730!Spark 1!u!64227830!Injector 1!d!64227884!Spark 1!d!64228230!crank2!d!64228678_7!crank2!u!64230212_8!Injector 3!u!64230212!Spark 1!u!64230312!Injector 3!d!64230366!Spark 1!d!64230712!crank2!d!64231156_9!crank!u!64231982_0!crank2!u!64232672_1!Injector 4!u!64232672!Spark 1!u!64232772!Injector 4!d!64232826!Spark 1!d!64233172!crank2!d!64233626_2!r!1200!64234412!crank2!u!64235150_3!Injector 2!u!64235150!Spark 1!u!64235250!Injector 2!d!64235304!Spark 1!d!64235650!crank2!d!64236106_4!crank!d!64236981_5!crank2!u!64237730_6!Injector 1!u!64237730!Spark 1!u!64237830!Injector 1!d!64237884!Spark 1!d!64238230!crank2!d!64238677_7!crank2!u!64240213_8!Injector 3!u!64240213!Spark 1!u!64240313!Injector 3!d!64240367!Spark 1!d!64240713!crank2!d!64241158_9!crank!u!64241982_0!crank2!u!64242674_1!Injector 4!u!64242674!Spark 1!u!64242774!Injector 4!d!64242828!Spark 1!d!64243174!crank2!d!64243625_2!r!1200!64244412!crank2!u!64245149_3!Injector 2!u!64245149!Spark 1!u!64245249!Injector 2!d!64245303!Spark 1!d!64245649!crank2!d!64246106_4!crank!d!64246980_5!crank2!u!64247728_6!Injector 1!u!64247728!Spark 1!u!64247828!Injector 1!d!64247882!Spark 1!d!64248228!crank2!d!64248679_7!crank2!u!64250212_8!Injector 3!u!64250212!Spark 1!u!64250312!Injector 3!d!64250366!Spark 1!d!64250712!crank2!d!64251158_9!crank!u!64251982_0!crank2!u!64252674_1!Injector 4!u!64252674!Spark 1!u!64252774!Injector 4!d!64252828!Spark 1!d!64253174!crank2!d!64253625_2!r!1200!64254412!crank2!u!64255150_3!Injector 2!u!64255150!Spark 1!u!64255250!Injector 2!d!64255304!Spark 1!d!64255650!crank2!d!64256106_4!crank!d!64256982_5!crank2!u!64257728_6!Injector 1!u!64257728!Spark 1!u!64257828!Injector 1!d!64257882!Spark 1!d!64258228!crank2!d!64258678_7!crank2!u!64260214_8!Injector 3!u!64260214!Spark 1!u!64260314!Injector 3!d!64260368!Spark 1!d!64260714!,");
|
||||
assertFalse(result.map.isEmpty());
|
||||
assertFalse(result.getMap().isEmpty());
|
||||
|
||||
StringBuilder revolutions = result.get(RevolutionLog.TOP_DEAD_CENTER_MESSAGE);
|
||||
|
||||
|
|
|
@ -69,7 +69,8 @@ public class Launcher extends FrameHelper {
|
|||
|
||||
if (!LinkManager.isLogViewerMode(port)) {
|
||||
int selectedIndex = getConfig().getRoot().getIntProperty("main_tab", 2);
|
||||
tabbedPane.setSelectedIndex(selectedIndex);
|
||||
if (selectedIndex < tabbedPane.getTabCount())
|
||||
tabbedPane.setSelectedIndex(selectedIndex);
|
||||
}
|
||||
|
||||
StartupFrame.setAppIcon(frame);
|
||||
|
|
|
@ -187,7 +187,7 @@ public class EngineSnifferPanel {
|
|||
/**
|
||||
* First let's create images for new keys
|
||||
*/
|
||||
for (String imageName : map.map.keySet())
|
||||
for (String imageName : map.getMap().keySet())
|
||||
createSecondaryImage(imageName);
|
||||
|
||||
|
||||
|
@ -196,7 +196,7 @@ public class EngineSnifferPanel {
|
|||
if (image == null)
|
||||
throw new IllegalStateException("image not found for " + imageName);
|
||||
|
||||
StringBuilder sb = map.map.get(imageName);
|
||||
StringBuilder sb = map.getMap().get(imageName);
|
||||
String report = sb == null ? "" : sb.toString();
|
||||
|
||||
image.setRevolutions(revolutions);
|
||||
|
|
Loading…
Reference in New Issue