auto-sync
This commit is contained in:
parent
bf9266b90c
commit
e92472d299
|
@ -28,6 +28,7 @@
|
||||||
EXTERN_ENGINE;
|
EXTERN_ENGINE;
|
||||||
|
|
||||||
static ign_Map3D_t advanceMap;
|
static ign_Map3D_t advanceMap;
|
||||||
|
static ign_Map3D_t iatAdvanceCorrectionMap;
|
||||||
|
|
||||||
static const float iatTimingRpmBins[IGN_LOAD_COUNT] = {880, 1260, 1640, 2020, 2400, 2780, 3000, 3380, 3760, 4140, 4520, 5000, 5700, 6500, 7200, 8000};
|
static const float iatTimingRpmBins[IGN_LOAD_COUNT] = {880, 1260, 1640, 2020, 2400, 2780, 3000, 3380, 3760, 4140, 4520, 5000, 5700, 6500, 7200, 8000};
|
||||||
|
|
||||||
|
@ -42,8 +43,8 @@ static const ignition_table_t defaultIatTiming = {
|
||||||
{ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0},
|
{ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0},
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
{ 0, 0, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9},
|
{ 0, 0, -0.9, -0.9, -0.9, -0.9, -0.9, -0.9, -0.9, -0.9, -0.9, -0.9, -0.9, -0.9, -0.9, -0.9},
|
||||||
{ -3.3, -3.4, -4.9, -4.9, -4.9, -4.9, -4.4, -4.4, -4.4, -4.4, -4.4, -9, -9, -9, -9, -9},
|
{ -3.3, -3.4, -4.9, -4.9, -4.9, -4.9, -4.4, -4.4, -4.4, -4.4, -4.4, -0.9, -0.9, -0.9, -0.9, -0.9},
|
||||||
{ -4.4, -4.9, -5.9, -5.9, -5.9, -5.9, -4.9, -4.9, -4.9, -4.9, -4.9, -2.4, -2.4, -2.4, -2.4, -2.4},
|
{ -4.4, -4.9, -5.9, -5.9, -5.9, -5.9, -4.9, -4.9, -4.9, -4.9, -4.9, -2.4, -2.4, -2.4, -2.4, -2.4},
|
||||||
{ -4.4, -4.9, -5.9, -5.9, -5.9, -5.9, -4.9, -4.9, -4.9, -4.9, -4.9, -2.9, -2.9, -2.9, -2.9, -2.9},
|
{ -4.4, -4.9, -5.9, -5.9, -5.9, -5.9, -4.9, -4.9, -4.9, -4.9, -4.9, -2.9, -2.9, -2.9, -2.9, -2.9},
|
||||||
{-4.4, -4.9, -5.9, -5.9, -5.9, -5.9, -4.9, -4.9, -4.9, -4.9, -4.9, -3.9, -3.9, -3.9, -3.9, -3.9},
|
{-4.4, -4.9, -5.9, -5.9, -5.9, -5.9, -4.9, -4.9, -4.9, -4.9, -4.9, -3.9, -3.9, -3.9, -3.9, -3.9},
|
||||||
|
@ -61,8 +62,10 @@ float getBaseAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAMETER_S) {
|
||||||
engine->m.beforeZeroTest = GET_TIMESTAMP();
|
engine->m.beforeZeroTest = GET_TIMESTAMP();
|
||||||
engine->m.zeroTestTime = GET_TIMESTAMP() - engine->m.beforeZeroTest;
|
engine->m.zeroTestTime = GET_TIMESTAMP() - engine->m.beforeZeroTest;
|
||||||
|
|
||||||
|
float iatCorrection = iatAdvanceCorrectionMap.getValue(engine->engineState.clt, (float) rpm);
|
||||||
|
|
||||||
engine->m.beforeAdvance = GET_TIMESTAMP();
|
engine->m.beforeAdvance = GET_TIMESTAMP();
|
||||||
float result = advanceMap.getValue(engineLoad, (float) rpm);
|
float result = advanceMap.getValue(engineLoad, (float) rpm) + iatCorrection;
|
||||||
engine->m.advanceTime = GET_TIMESTAMP() - engine->m.beforeAdvance;
|
engine->m.advanceTime = GET_TIMESTAMP() - engine->m.beforeAdvance;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -88,4 +91,6 @@ void setDefaultIatTimingCorrection(DECLARE_ENGINE_PARAMETER_F) {
|
||||||
void prepareTimingMap(DECLARE_ENGINE_PARAMETER_F) {
|
void prepareTimingMap(DECLARE_ENGINE_PARAMETER_F) {
|
||||||
advanceMap.init(config->ignitionTable, config->ignitionLoadBins,
|
advanceMap.init(config->ignitionTable, config->ignitionLoadBins,
|
||||||
config->ignitionRpmBins);
|
config->ignitionRpmBins);
|
||||||
|
iatAdvanceCorrectionMap.init(config->ignitionIatCorrTable, config->ignitionIatCorrLoadBins,
|
||||||
|
config->ignitionIatCorrRpmBins);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// todo: rename this file
|
// todo: rename this file
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
|
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
|
||||||
|
@ -47,7 +46,8 @@ extern engine_pins_s enginePins;
|
||||||
void initIgnitionCentral(void) {
|
void initIgnitionCentral(void) {
|
||||||
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
|
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
|
||||||
NamedOutputPin *output = &enginePins.coils[i];
|
NamedOutputPin *output = &enginePins.coils[i];
|
||||||
outputPinRegisterExt2(output->name, output, boardConfiguration->ignitionPins[i], &boardConfiguration->ignitionPinMode);
|
outputPinRegisterExt2(output->name, output, boardConfiguration->ignitionPins[i],
|
||||||
|
&boardConfiguration->ignitionPinMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,24 +85,34 @@ static void setInjectorEnabled(int id, int value) {
|
||||||
printStatus();
|
printStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void runBench(brain_pin_e brainPin, OutputPin *output, float delayMs, float onTimeMs, float offTimeMs, int count) {
|
static void runBench(brain_pin_e brainPin, OutputPin *output, float delayMs, float onTimeMs, float offTimeMs,
|
||||||
|
int count) {
|
||||||
|
int delaySt = (int) (delayMs * CH_FREQUENCY / 1000);
|
||||||
|
int onTimeSt = (int) (onTimeMs * CH_FREQUENCY / 1000);
|
||||||
|
int offTimeSt = (int) (offTimeMs * CH_FREQUENCY / 1000);
|
||||||
|
if (delaySt <=0) {
|
||||||
|
scheduleMsg(&logger, "Invalid delay %f", delayMs);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (onTimeSt <=0) {
|
||||||
|
scheduleMsg(&logger, "Invalid onTime %f", onTimeMs);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (offTimeSt <=0) {
|
||||||
|
scheduleMsg(&logger, "Invalid offTime %f", offTimeMs);
|
||||||
|
return;
|
||||||
|
}
|
||||||
scheduleMsg(&logger, "Running bench: ON_TIME=%f ms OFF_TIME=%fms Counter=%d", onTimeMs, offTimeMs, count);
|
scheduleMsg(&logger, "Running bench: ON_TIME=%f ms OFF_TIME=%fms Counter=%d", onTimeMs, offTimeMs, count);
|
||||||
scheduleMsg(&logger, "output on %s", hwPortname(brainPin));
|
scheduleMsg(&logger, "output on %s", hwPortname(brainPin));
|
||||||
|
|
||||||
int delaySt = (int) (delayMs * CH_FREQUENCY / 1000);
|
chThdSleep(delaySt);
|
||||||
if (delaySt != 0) {
|
|
||||||
chThdSleep(delaySt);
|
|
||||||
}
|
|
||||||
|
|
||||||
isRunningBench = true;
|
isRunningBench = true;
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
output->setValue(true);
|
output->setValue(true);
|
||||||
chThdSleep((int) (onTimeMs * CH_FREQUENCY / 1000));
|
chThdSleep(onTimeSt);
|
||||||
output->setValue(false);
|
output->setValue(false);
|
||||||
int offTimeSt = (int) (offTimeMs * CH_FREQUENCY / 1000);
|
chThdSleep(offTimeSt);
|
||||||
if (offTimeSt > 0) {
|
|
||||||
chThdSleep(offTimeSt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
scheduleMsg(&logger, "Done!");
|
scheduleMsg(&logger, "Done!");
|
||||||
isRunningBench = false;
|
isRunningBench = false;
|
||||||
|
@ -117,7 +127,7 @@ static brain_pin_e brainPin;
|
||||||
static OutputPin* pinX;
|
static OutputPin* pinX;
|
||||||
|
|
||||||
static void pinbench(const char *delayStr, const char *onTimeStr, const char *offTimeStr, const char *countStr,
|
static void pinbench(const char *delayStr, const char *onTimeStr, const char *offTimeStr, const char *countStr,
|
||||||
OutputPin* pinParam, brain_pin_e brainPinParam) {
|
OutputPin* pinParam, brain_pin_e brainPinParam) {
|
||||||
delayMs = atoff(delayStr);
|
delayMs = atoff(delayStr);
|
||||||
onTime = atoff(onTimeStr);
|
onTime = atoff(onTimeStr);
|
||||||
offTime = atoff(offTimeStr);
|
offTime = atoff(offTimeStr);
|
||||||
|
@ -190,7 +200,7 @@ static msg_t benchThread(int param) {
|
||||||
(void) param;
|
(void) param;
|
||||||
chRegSetThreadName("BenchThread");
|
chRegSetThreadName("BenchThread");
|
||||||
|
|
||||||
while (TRUE) {
|
while (true) {
|
||||||
while (!needToRunBench) {
|
while (!needToRunBench) {
|
||||||
chThdSleepMilliseconds(200);
|
chThdSleepMilliseconds(200);
|
||||||
}
|
}
|
||||||
|
@ -216,7 +226,7 @@ void initInjectorCentral(Engine *engine) {
|
||||||
outputPinRegisterExt2(output->name, output, boardConfiguration->injectionPins[i],
|
outputPinRegisterExt2(output->name, output, boardConfiguration->injectionPins[i],
|
||||||
&boardConfiguration->injectionPinMode);
|
&boardConfiguration->injectionPinMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
printStatus();
|
printStatus();
|
||||||
addConsoleActionII("injector", setInjectorEnabled);
|
addConsoleActionII("injector", setInjectorEnabled);
|
||||||
|
|
||||||
|
|
|
@ -152,8 +152,7 @@ static void scheduleReboot(void) {
|
||||||
unlockAnyContext();
|
unlockAnyContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
void swo_init()
|
void swo_init() {
|
||||||
{
|
|
||||||
// todo: make SWO work
|
// todo: make SWO work
|
||||||
// uint32_t SWOSpeed = 2000000; //2000kbps, default for ST-LINK
|
// uint32_t SWOSpeed = 2000000; //2000kbps, default for ST-LINK
|
||||||
// // todo: use a macro to access clock speed
|
// // todo: use a macro to access clock speed
|
||||||
|
@ -247,7 +246,8 @@ extern engine_pins_s enginePins;
|
||||||
void firmwareError(const char *errorMsg, ...) {
|
void firmwareError(const char *errorMsg, ...) {
|
||||||
if (hasFirmwareErrorFlag)
|
if (hasFirmwareErrorFlag)
|
||||||
return;
|
return;
|
||||||
ON_FATAL_ERROR();
|
ON_FATAL_ERROR()
|
||||||
|
;
|
||||||
hasFirmwareErrorFlag = true;
|
hasFirmwareErrorFlag = true;
|
||||||
if (indexOf(errorMsg, '%') == -1) {
|
if (indexOf(errorMsg, '%') == -1) {
|
||||||
/**
|
/**
|
||||||
|
@ -272,9 +272,9 @@ static char UNUSED_RAM_SIZE[2999];
|
||||||
static char UNUSED_CCM_SIZE[3600] CCM_OPTIONAL;
|
static char UNUSED_CCM_SIZE[3600] CCM_OPTIONAL;
|
||||||
|
|
||||||
int getRusEfiVersion(void) {
|
int getRusEfiVersion(void) {
|
||||||
if (UNUSED_RAM_SIZE[0]== 0)
|
if (UNUSED_RAM_SIZE[0] != 0)
|
||||||
return 1; // this is here to make the compiler happy about the unused array
|
return 123; // this is here to make the compiler happy about the unused array
|
||||||
if (UNUSED_CCM_SIZE[0] == 0)
|
if (UNUSED_CCM_SIZE[0] * 0 != 0)
|
||||||
return 1; // this is here to make the compiler happy about the unused array
|
return 3211; // this is here to make the compiler happy about the unused array
|
||||||
return 20150406;
|
return 20150406;
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class AutoTest {
|
||||||
msg = "2003 Neon running";
|
msg = "2003 Neon running";
|
||||||
IoUtil.changeRpm(2000);
|
IoUtil.changeRpm(2000);
|
||||||
chart = nextChart();
|
chart = nextChart();
|
||||||
x = 107;
|
x = 113.28;
|
||||||
assertWave(true, msg, chart, WaveChart.SPARK_1, 0.13299999999999998, 0.005, WaveReport.RATIO, x + 180, x + 540);
|
assertWave(true, msg, chart, WaveChart.SPARK_1, 0.13299999999999998, 0.005, WaveReport.RATIO, x + 180, x + 540);
|
||||||
assertWaveNull(msg, chart, WaveChart.SPARK_2);
|
assertWaveNull(msg, chart, WaveChart.SPARK_2);
|
||||||
assertWave(true, msg, chart, WaveChart.SPARK_3, 0.13299999999999998, 0.005, WaveReport.RATIO, x, x + 360);
|
assertWave(true, msg, chart, WaveChart.SPARK_3, 0.13299999999999998, 0.005, WaveReport.RATIO, x, x + 360);
|
||||||
|
@ -149,7 +149,7 @@ public class AutoTest {
|
||||||
msg = "ProtegeLX running";
|
msg = "ProtegeLX running";
|
||||||
IoUtil.changeRpm(2000);
|
IoUtil.changeRpm(2000);
|
||||||
chart = nextChart();
|
chart = nextChart();
|
||||||
x = 121;
|
x = 127.92;
|
||||||
assertWave(msg, chart, WaveChart.SPARK_1, 0.13333333333333333, x, x + 180, x + 360, x + 540);
|
assertWave(msg, chart, WaveChart.SPARK_1, 0.13333333333333333, x, x + 180, x + 360, x + 540);
|
||||||
x = 0;
|
x = 0;
|
||||||
assertWaveFall(msg, chart, WaveChart.INJECTOR_1, 0.09766666666666689, x + 180, x + 540);
|
assertWaveFall(msg, chart, WaveChart.INJECTOR_1, 0.09766666666666689, x + 180, x + 540);
|
||||||
|
@ -168,13 +168,13 @@ public class AutoTest {
|
||||||
chart = nextChart();
|
chart = nextChart();
|
||||||
|
|
||||||
String msg = "1995 Neon";
|
String msg = "1995 Neon";
|
||||||
float x = -70;
|
double x = -70;
|
||||||
assertWaveFall(msg, chart, WaveChart.INJECTOR_4, 0.133, x + 540);
|
assertWaveFall(msg, chart, WaveChart.INJECTOR_4, 0.133, x + 540);
|
||||||
assertWaveFall(msg, chart, WaveChart.INJECTOR_2, 0.133, x + 720);
|
assertWaveFall(msg, chart, WaveChart.INJECTOR_2, 0.133, x + 720);
|
||||||
assertWaveFall(msg, chart, WaveChart.INJECTOR_1, 0.133, x + 180);
|
assertWaveFall(msg, chart, WaveChart.INJECTOR_1, 0.133, x + 180);
|
||||||
assertWaveFall(msg, chart, WaveChart.INJECTOR_3, 0.133, x + 360);
|
assertWaveFall(msg, chart, WaveChart.INJECTOR_3, 0.133, x + 360);
|
||||||
|
|
||||||
x = 106;
|
x = 115.92;
|
||||||
assertWave(msg, chart, WaveChart.SPARK_4, 0.13333, x + 540);
|
assertWave(msg, chart, WaveChart.SPARK_4, 0.13333, x + 540);
|
||||||
assertWave(msg, chart, WaveChart.SPARK_2, 0.13333, x);
|
assertWave(msg, chart, WaveChart.SPARK_2, 0.13333, x);
|
||||||
assertWave(msg, chart, WaveChart.SPARK_1, 0.13333, x + 180);
|
assertWave(msg, chart, WaveChart.SPARK_1, 0.13333, x + 180);
|
||||||
|
@ -211,7 +211,7 @@ public class AutoTest {
|
||||||
|
|
||||||
String msg = "ford 6";
|
String msg = "ford 6";
|
||||||
|
|
||||||
int x = 7;
|
double x = 12.84;
|
||||||
assertWave(msg, chart, WaveChart.SPARK_1, 0.01666, x, x + 120, x + 240, x + 360, x + 480, x + 600);
|
assertWave(msg, chart, WaveChart.SPARK_1, 0.01666, x, x + 120, x + 240, x + 360, x + 480, x + 600);
|
||||||
|
|
||||||
assertWaveNull(msg, chart, WaveChart.TRIGGER_2);
|
assertWaveNull(msg, chart, WaveChart.TRIGGER_2);
|
||||||
|
@ -278,7 +278,7 @@ public class AutoTest {
|
||||||
assertWaveFall(msg, chart, WaveChart.INJECTOR_3, 0.086, 417.04);
|
assertWaveFall(msg, chart, WaveChart.INJECTOR_3, 0.086, 417.04);
|
||||||
assertWaveFall(msg, chart, WaveChart.INJECTOR_4, 0.086, 594.04);
|
assertWaveFall(msg, chart, WaveChart.INJECTOR_4, 0.086, 594.04);
|
||||||
|
|
||||||
x = 16.32;
|
x = 22.32;
|
||||||
assertWave(chart, WaveChart.SPARK_1, 0.133, x, x + 180, x + 360, x + 540);
|
assertWave(chart, WaveChart.SPARK_1, 0.133, x, x + 180, x + 360, x + 540);
|
||||||
|
|
||||||
sendCommand("set_fuel_map 2200 4 15.66");
|
sendCommand("set_fuel_map 2200 4 15.66");
|
||||||
|
@ -296,14 +296,14 @@ public class AutoTest {
|
||||||
assertWaveFall(msg + " fuel", chart, WaveChart.INJECTOR_3, 0.555, 417.04);
|
assertWaveFall(msg + " fuel", chart, WaveChart.INJECTOR_3, 0.555, 417.04);
|
||||||
assertWaveFall(msg + " fuel", chart, WaveChart.INJECTOR_4, 0.555, 594.04);
|
assertWaveFall(msg + " fuel", chart, WaveChart.INJECTOR_4, 0.555, 594.04);
|
||||||
|
|
||||||
x = 41;
|
x = 45;
|
||||||
assertWave(chart, WaveChart.SPARK_1, 0.133, x, x + 180, x + 360, x + 540);
|
assertWave(chart, WaveChart.SPARK_1, 0.133, x, x + 180, x + 360, x + 540);
|
||||||
assertWaveNull(chart, WaveChart.SPARK_2);
|
assertWaveNull(chart, WaveChart.SPARK_2);
|
||||||
|
|
||||||
sendComplexCommand("set_global_trigger_offset_angle 130");
|
sendComplexCommand("set_global_trigger_offset_angle 130");
|
||||||
sendComplexCommand("set_injection_offset 369");
|
sendComplexCommand("set_injection_offset 369");
|
||||||
chart = nextChart();
|
chart = nextChart();
|
||||||
x = 580;
|
x = 585;
|
||||||
assertWave(chart, WaveChart.SPARK_1, 0.133, x, x + 180, x + 360, x + 540);
|
assertWave(chart, WaveChart.SPARK_1, 0.133, x, x + 180, x + 360, x + 540);
|
||||||
|
|
||||||
// let's enable more channels dynamically
|
// let's enable more channels dynamically
|
||||||
|
@ -314,7 +314,7 @@ public class AutoTest {
|
||||||
|
|
||||||
sendCommand("set_whole_timing_map 520");
|
sendCommand("set_whole_timing_map 520");
|
||||||
chart = nextChart();
|
chart = nextChart();
|
||||||
x = 59;
|
x = 64.8;
|
||||||
assertWave(chart, WaveChart.SPARK_2, 0.133, x);
|
assertWave(chart, WaveChart.SPARK_2, 0.133, x);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,7 @@ import com.rusefi.core.EngineState;
|
||||||
import com.rusefi.core.MessagesCentral;
|
import com.rusefi.core.MessagesCentral;
|
||||||
import com.rusefi.io.LinkManager;
|
import com.rusefi.io.LinkManager;
|
||||||
import com.rusefi.maintenance.VersionChecker;
|
import com.rusefi.maintenance.VersionChecker;
|
||||||
import com.rusefi.ui.GaugesPanel;
|
import com.rusefi.ui.*;
|
||||||
import com.rusefi.ui.MessagesPane;
|
|
||||||
import com.rusefi.ui.RpmPanel;
|
|
||||||
import com.rusefi.ui.Wizard;
|
|
||||||
import com.rusefi.ui.engine.EngineSnifferPanel;
|
import com.rusefi.ui.engine.EngineSnifferPanel;
|
||||||
import com.rusefi.ui.fsio.FlexibleControls;
|
import com.rusefi.ui.fsio.FlexibleControls;
|
||||||
import com.rusefi.ui.logview.LogViewer;
|
import com.rusefi.ui.logview.LogViewer;
|
||||||
|
@ -19,6 +16,7 @@ import jssc.SerialPortList;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||||
|
|
||||||
|
@ -40,6 +38,7 @@ public class Launcher {
|
||||||
protected static final String PORT_KEY = "port";
|
protected static final String PORT_KEY = "port";
|
||||||
private final String port;
|
private final String port;
|
||||||
private final JTabbedPane tabbedPane = new JTabbedPane();
|
private final JTabbedPane tabbedPane = new JTabbedPane();
|
||||||
|
private static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||||
|
|
||||||
public static int defaultFontSize;
|
public static int defaultFontSize;
|
||||||
|
|
||||||
|
@ -115,7 +114,13 @@ public class Launcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void windowOpenedHandler() {
|
private void windowOpenedHandler() {
|
||||||
setTitle("N/A");
|
setTitle();
|
||||||
|
ConnectionStatus.INSTANCE.addListener(new ConnectionStatus.Listener() {
|
||||||
|
@Override
|
||||||
|
public void onConnectionStatus(boolean isConnected) {
|
||||||
|
setTitle();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
LinkManager.open(new LinkManager.LinkStateListener() {
|
LinkManager.open(new LinkManager.LinkStateListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -129,16 +134,19 @@ public class Launcher {
|
||||||
});
|
});
|
||||||
|
|
||||||
LinkManager.engineState.registerStringValueAction(EngineState.RUS_EFI_VERSION_TAG, new EngineState.ValueCallback<String>() {
|
LinkManager.engineState.registerStringValueAction(EngineState.RUS_EFI_VERSION_TAG, new EngineState.ValueCallback<String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate(String firmwareVersion) {
|
public void onUpdate(String firmwareVersion) {
|
||||||
setTitle(firmwareVersion);
|
Launcher.firmwareVersion.set(firmwareVersion);
|
||||||
|
setTitle();
|
||||||
VersionChecker.getInstance().onFirmwareVersion(firmwareVersion);
|
VersionChecker.getInstance().onFirmwareVersion(firmwareVersion);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTitle(String value) {
|
private void setTitle() {
|
||||||
frame.getFrame().setTitle("Console " + CONSOLE_VERSION + "; firmware=" + value + "@" + port);
|
String disconnected = ConnectionStatus.INSTANCE.isConnected() ? "" : "DISCONNECTED ";
|
||||||
|
frame.getFrame().setTitle(disconnected + "Console " + CONSOLE_VERSION + "; firmware=" + Launcher.firmwareVersion.get() + "@" + port);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void windowClosedHandler() {
|
private void windowClosedHandler() {
|
||||||
|
|
|
@ -11,12 +11,16 @@ import java.awt.event.ActionListener;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This UI element displays an array of buttons, each for one of the recently used commands
|
* This UI element displays an array of buttons, each for one of the recently used commands
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class RecentCommands {
|
public class RecentCommands {
|
||||||
private final static int NUMBER_OF_COMMANDS = 20;
|
private final static int NUMBER_OF_COMMANDS = 20;
|
||||||
|
private static final String KEY = "recent_commands";
|
||||||
|
private static final String DELIMETER = "|";
|
||||||
|
|
||||||
private final JPanel content = new JPanel(new GridLayout(NUMBER_OF_COMMANDS, 1));
|
private final JPanel content = new JPanel(new GridLayout(NUMBER_OF_COMMANDS, 1));
|
||||||
|
|
||||||
|
@ -32,7 +36,6 @@ public class RecentCommands {
|
||||||
private final JScrollPane messagesScroll = new JScrollPane(content, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
private final JScrollPane messagesScroll = new JScrollPane(content, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||||
|
|
||||||
public RecentCommands() {
|
public RecentCommands() {
|
||||||
|
|
||||||
CommandQueue.getInstance().addListener(new CommandQueue.CommandQueueListener() {
|
CommandQueue.getInstance().addListener(new CommandQueue.CommandQueueListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(String command) {
|
public void onCommand(String command) {
|
||||||
|
@ -41,6 +44,22 @@ public class RecentCommands {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
String value = getConfig().getRoot().getProperty(KEY, null);
|
||||||
|
|
||||||
|
if (value != null && value.trim().length() > 5) {
|
||||||
|
unpack(value);
|
||||||
|
} else {
|
||||||
|
addDefaults();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unpack(String value) {
|
||||||
|
entries.clear();
|
||||||
|
for (String command : value.split("\\" + DELIMETER))
|
||||||
|
add(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addDefaults() {
|
||||||
add("help");
|
add("help");
|
||||||
add("showconfig");
|
add("showconfig");
|
||||||
add("analoginfo");
|
add("analoginfo");
|
||||||
|
@ -60,7 +79,6 @@ public class RecentCommands {
|
||||||
add("fuelpumpbench");
|
add("fuelpumpbench");
|
||||||
add("fanbench");
|
add("fanbench");
|
||||||
add("milbench");
|
add("milbench");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(String command) {
|
public void add(String command) {
|
||||||
|
@ -81,7 +99,7 @@ public class RecentCommands {
|
||||||
UiUtils.trueLayout(content.getParent());
|
UiUtils.trueLayout(content.getParent());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
getConfig().getRoot().setProperty(KEY, pack());
|
||||||
}
|
}
|
||||||
|
|
||||||
private JComponent createButton(final Entry entry) {
|
private JComponent createButton(final Entry entry) {
|
||||||
|
@ -105,6 +123,16 @@ public class RecentCommands {
|
||||||
return messagesScroll;
|
return messagesScroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String pack() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (Entry command : entries.keySet()) {
|
||||||
|
if (sb.length() != 0)
|
||||||
|
sb.append(DELIMETER);
|
||||||
|
sb.append(command.command);
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
static class Entry {
|
static class Entry {
|
||||||
private final String command;
|
private final String command;
|
||||||
|
|
||||||
|
|
|
@ -412,7 +412,7 @@ static void testRpmCalculator(void) {
|
||||||
assertEqualsM("one degree", 111.1111, eth.engine.rpmCalculator.oneDegreeUs);
|
assertEqualsM("one degree", 111.1111, eth.engine.rpmCalculator.oneDegreeUs);
|
||||||
assertEqualsM("size", 6, ilist->size);
|
assertEqualsM("size", 6, ilist->size);
|
||||||
assertEqualsM("dwell angle", 0, ilist->elements[0].dwellPosition.eventAngle);
|
assertEqualsM("dwell angle", 0, ilist->elements[0].dwellPosition.eventAngle);
|
||||||
assertEqualsM("dwell offset", 8.5, ilist->elements[0].dwellPosition.angleOffset);
|
assertEqualsM("dwell offset", 14.0316, ilist->elements[0].dwellPosition.angleOffset);
|
||||||
|
|
||||||
assertEqualsM("index #2", 0, eth.triggerCentral.triggerState.getCurrentIndex());
|
assertEqualsM("index #2", 0, eth.triggerCentral.triggerState.getCurrentIndex());
|
||||||
assertEqualsM("queue size", 6, schedulingQueue.size());
|
assertEqualsM("queue size", 6, schedulingQueue.size());
|
||||||
|
@ -420,8 +420,8 @@ static void testRpmCalculator(void) {
|
||||||
assertREquals((void*)ev1->callback, (void*)turnPinLow);
|
assertREquals((void*)ev1->callback, (void*)turnPinLow);
|
||||||
assertREquals((void*)&enginePins.coils[0], ev1->param);
|
assertREquals((void*)&enginePins.coils[0], ev1->param);
|
||||||
|
|
||||||
assertEqualsM("ev 1", 246444, ev1->momentX);
|
assertEqualsM("ev 1", 247059, ev1->momentX);
|
||||||
assertEqualsM("ev 2", 245944, schedulingQueue.getForUnitText(1)->momentX);
|
assertEqualsM("ev 2", 246559, schedulingQueue.getForUnitText(1)->momentX);
|
||||||
schedulingQueue.clear();
|
schedulingQueue.clear();
|
||||||
|
|
||||||
timeNow += 5000;
|
timeNow += 5000;
|
||||||
|
@ -432,8 +432,8 @@ static void testRpmCalculator(void) {
|
||||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN PASS_ENGINE_PARAMETER);
|
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN PASS_ENGINE_PARAMETER);
|
||||||
assertEqualsM("index #3", 3, eth.triggerCentral.triggerState.getCurrentIndex());
|
assertEqualsM("index #3", 3, eth.triggerCentral.triggerState.getCurrentIndex());
|
||||||
assertEqualsM("queue size 3", 6, schedulingQueue.size());
|
assertEqualsM("queue size 3", 6, schedulingQueue.size());
|
||||||
assertEqualsM("ev 3", 259777, schedulingQueue.getForUnitText(0)->momentX);
|
assertEqualsM("ev 3", 260392, schedulingQueue.getForUnitText(0)->momentX);
|
||||||
assertEquals(259277, schedulingQueue.getForUnitText(1)->momentX);
|
assertEquals(259892, schedulingQueue.getForUnitText(1)->momentX);
|
||||||
assertEqualsM2("ev 5", 261362, schedulingQueue.getForUnitText(2)->momentX, 2);
|
assertEqualsM2("ev 5", 261362, schedulingQueue.getForUnitText(2)->momentX, 2);
|
||||||
assertEqualsM("3/3", 258333, schedulingQueue.getForUnitText(3)->momentX);
|
assertEqualsM("3/3", 258333, schedulingQueue.getForUnitText(3)->momentX);
|
||||||
schedulingQueue.clear();
|
schedulingQueue.clear();
|
||||||
|
@ -446,7 +446,7 @@ static void testRpmCalculator(void) {
|
||||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER);
|
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER);
|
||||||
assertEqualsM("index #4", 6, eth.triggerCentral.triggerState.getCurrentIndex());
|
assertEqualsM("index #4", 6, eth.triggerCentral.triggerState.getCurrentIndex());
|
||||||
assertEqualsM("queue size 4", 6, schedulingQueue.size());
|
assertEqualsM("queue size 4", 6, schedulingQueue.size());
|
||||||
assertEqualsM("4/0", 273111, schedulingQueue.getForUnitText(0)->momentX);
|
assertEqualsM("4/0", 273725, schedulingQueue.getForUnitText(0)->momentX);
|
||||||
schedulingQueue.clear();
|
schedulingQueue.clear();
|
||||||
|
|
||||||
timeNow += 5000;
|
timeNow += 5000;
|
||||||
|
@ -458,8 +458,8 @@ static void testRpmCalculator(void) {
|
||||||
timeNow += 5000; // 5ms
|
timeNow += 5000; // 5ms
|
||||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER);
|
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER);
|
||||||
assertEqualsM("queue size 6", 6, schedulingQueue.size());
|
assertEqualsM("queue size 6", 6, schedulingQueue.size());
|
||||||
assertEqualsM("6/0", 286444, schedulingQueue.getForUnitText(0)->momentX);
|
assertEqualsM("6/0", 287059, schedulingQueue.getForUnitText(0)->momentX);
|
||||||
assertEqualsM("6/1", 285944, schedulingQueue.getForUnitText(1)->momentX);
|
assertEqualsM("6/1", 286559, schedulingQueue.getForUnitText(1)->momentX);
|
||||||
assertEqualsM2("6/2", 288029, schedulingQueue.getForUnitText(2)->momentX, 1);
|
assertEqualsM2("6/2", 288029, schedulingQueue.getForUnitText(2)->momentX, 1);
|
||||||
schedulingQueue.clear();
|
schedulingQueue.clear();
|
||||||
|
|
||||||
|
@ -470,16 +470,16 @@ static void testRpmCalculator(void) {
|
||||||
|
|
||||||
timeNow += 5000; // 5ms
|
timeNow += 5000; // 5ms
|
||||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER);
|
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER);
|
||||||
assertEqualsM("queue size 8", 6, schedulingQueue.size());
|
assertEqualsM("queue size 8", 5, schedulingQueue.size());
|
||||||
assertEqualsM("8/0", 299777, schedulingQueue.getForUnitText(0)->momentX);
|
assertEqualsM("8/0", 299892, schedulingQueue.getForUnitText(0)->momentX);
|
||||||
assertEqualsM("8/1", 299277, schedulingQueue.getForUnitText(1)->momentX);
|
assertEqualsM("8/1", 301363, schedulingQueue.getForUnitText(1)->momentX);
|
||||||
assertEqualsM2("8/2", 301362, schedulingQueue.getForUnitText(2)->momentX, 1);
|
assertEqualsM2("8/2", 298333, schedulingQueue.getForUnitText(2)->momentX, 1);
|
||||||
assertEqualsM("8/3", 298333, schedulingQueue.getForUnitText(3)->momentX);
|
assertEqualsM("8/3", 301363, schedulingQueue.getForUnitText(3)->momentX);
|
||||||
schedulingQueue.clear();
|
schedulingQueue.clear();
|
||||||
|
|
||||||
timeNow += 5000;
|
timeNow += 5000;
|
||||||
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN PASS_ENGINE_PARAMETER);
|
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN PASS_ENGINE_PARAMETER);
|
||||||
assertEqualsM("queue size 9", 0, schedulingQueue.size());
|
assertEqualsM("queue size 9", 1, schedulingQueue.size());
|
||||||
schedulingQueue.clear();
|
schedulingQueue.clear();
|
||||||
|
|
||||||
timeNow += 5000; // 5ms
|
timeNow += 5000; // 5ms
|
||||||
|
|
Loading…
Reference in New Issue