auto-sync

This commit is contained in:
rusEfi 2016-02-29 21:02:38 -05:00
parent 4b74ebe7e2
commit a216dcf812
6 changed files with 38 additions and 19 deletions

View File

@ -1,5 +1,5 @@
// This file was generated by Version2Header // This file was generated by Version2Header
// Wed Feb 17 22:07:02 EST 2016 // Mon Feb 29 20:31:38 EST 2016
#ifndef VCS_VERSION #ifndef VCS_VERSION
#define VCS_VERSION "9606" #define VCS_VERSION "9640"
#endif #endif

View File

@ -1,12 +1,12 @@
<component name="ProjectRunConfigurationManager"> <component name="ProjectRunConfigurationManager">
<configuration default="false" name="Launcher COM3" type="Application" factoryName="Application"> <configuration default="false" name="Launcher COM3" type="Application" factoryName="Application" folderName="x">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" /> <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" value="com.rusefi.Launcher" /> <option name="MAIN_CLASS_NAME" value="com.rusefi.Launcher" />
<option name="VM_PARAMETERS" value="" /> <option name="VM_PARAMETERS" value="" />
<option name="PROGRAM_PARAMETERS" value="COM3" /> <option name="PROGRAM_PARAMETERS" value="COM3" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" /> <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" value="" /> <option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" /> <option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" /> <option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" /> <option name="PASS_PARENT_ENVS" value="true" />

View File

@ -1,12 +1,12 @@
<component name="ProjectRunConfigurationManager"> <component name="ProjectRunConfigurationManager">
<configuration default="false" name="Launcher COM7" type="Application" factoryName="Application"> <configuration default="false" name="Launcher COM7" type="Application" factoryName="Application" folderName="x">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" /> <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" value="com.rusefi.Launcher" /> <option name="MAIN_CLASS_NAME" value="com.rusefi.Launcher" />
<option name="VM_PARAMETERS" value="" /> <option name="VM_PARAMETERS" value="" />
<option name="PROGRAM_PARAMETERS" value="COM7" /> <option name="PROGRAM_PARAMETERS" value="COM7" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" /> <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" value="" /> <option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" /> <option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" /> <option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" /> <option name="PASS_PARENT_ENVS" value="true" />

View File

@ -1,12 +1,12 @@
<component name="ProjectRunConfigurationManager"> <component name="ProjectRunConfigurationManager">
<configuration default="false" name="Launcher COM9" type="Application" factoryName="Application"> <configuration default="false" name="Launcher COM9" type="Application" factoryName="Application" folderName="x">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" /> <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" value="com.rusefi.Launcher" /> <option name="MAIN_CLASS_NAME" value="com.rusefi.Launcher" />
<option name="VM_PARAMETERS" value="" /> <option name="VM_PARAMETERS" value="" />
<option name="PROGRAM_PARAMETERS" value="COM9" /> <option name="PROGRAM_PARAMETERS" value="COM9" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" /> <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" value="" /> <option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" /> <option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" /> <option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" /> <option name="PASS_PARENT_ENVS" value="true" />

View File

@ -174,7 +174,7 @@ public class AutoTest {
msg = "ProtegeLX running"; msg = "ProtegeLX running";
IoUtil.changeRpm(2000); IoUtil.changeRpm(2000);
chart = nextChart(); chart = nextChart();
x = 127.92; x = 112;
assertWave(msg, chart, EngineChart.SPARK_1, 0.13333333333333333, x, x + 180, x + 360, x + 540); assertWave(msg, chart, EngineChart.SPARK_1, 0.13333333333333333, x, x + 180, x + 360, x + 540);
x = 0; x = 0;
assertWaveFall(msg, chart, EngineChart.INJECTOR_1, 0.04666666666666654, x + 180, x + 540); assertWaveFall(msg, chart, EngineChart.INJECTOR_1, 0.04666666666666654, x + 180, x + 540);

View File

@ -6,12 +6,14 @@ import jssc.SerialPort;
import jssc.SerialPortEvent; import jssc.SerialPortEvent;
import jssc.SerialPortEventListener; import jssc.SerialPortEventListener;
import jssc.SerialPortException; import jssc.SerialPortException;
import org.jetbrains.annotations.Nullable;
/** /**
* Date: 12/25/12 * Date: 12/25/12
* (c) Andrey Belomutskiy * (c) Andrey Belomutskiy
*/ */
public class SerialPortReader implements SerialPortEventListener { public class SerialPortReader implements SerialPortEventListener {
private static final int[] SLEEP_DURATIONS = {2, 20, 50, 100};
private final SerialPort serialPort; private final SerialPort serialPort;
private DataListener listener; private DataListener listener;
@ -23,23 +25,40 @@ public class SerialPortReader implements SerialPortEventListener {
public void run() { public void run() {
try { try {
while (serialPort.isOpened()) { while (serialPort.isOpened()) {
byte[] data = progressiveSleepRead(serialPort);
if (data != null)
listener.onDataArrived(data);
}
} catch (SerialPortException e) {
e.printStackTrace();
}
}
}, "Reader_" + serialPort).start();
}
/**
* This method starts with shorter sleeps (which we do not know to what extent Windows handle) and then we sleep
* a bit longer
* @param serialPort port to read from
* @return fresh data or null
*/
@Nullable
private static byte[] progressiveSleepRead(SerialPort serialPort) throws SerialPortException {
for (int sleepDuration : SLEEP_DURATIONS) {
byte[] data; byte[] data;
synchronized (serialPort) { synchronized (serialPort) {
data = serialPort.readBytes(); data = serialPort.readBytes();
} }
if (data != null) { if (data != null)
listener.onDataArrived(data); return data;
} else { try {
Thread.sleep(100); Thread.sleep(sleepDuration);
}
}
} catch (SerialPortException e) {
e.printStackTrace();
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }
} }
}, "Reader_" + serialPort).start();
return null;
} }
public void serialEvent(SerialPortEvent spe) { public void serialEvent(SerialPortEvent spe) {