refactoring: better dependency control
This commit is contained in:
parent
54dba3887f
commit
6a4cc8b266
|
@ -93,18 +93,18 @@ public class AutoTest {
|
||||||
setEngineType(32);
|
setEngineType(32);
|
||||||
changeRpm(900);
|
changeRpm(900);
|
||||||
// first let's get to expected RPM
|
// first let's get to expected RPM
|
||||||
assertRpmDoesNotJump(20000, 15, 30, FAIL);
|
assertRpmDoesNotJump(20000, 15, 30, FAIL, linkManager.getCommandQueue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testV12() {
|
private void testV12() {
|
||||||
setEngineType(40);
|
setEngineType(40);
|
||||||
changeRpm(700);
|
changeRpm(700);
|
||||||
// first let's get to expected RPM
|
// first let's get to expected RPM
|
||||||
assertRpmDoesNotJump(15000, 15, 30, FAIL);
|
assertRpmDoesNotJump(15000, 15, 30, FAIL, linkManager.getCommandQueue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void assertRpmDoesNotJump(int rpm, int settleTime, int testDuration, Function<String, Object> callback) {
|
public static void assertRpmDoesNotJump(int rpm, int settleTime, int testDuration, Function<String, Object> callback, CommandQueue commandQueue) {
|
||||||
IoUtil.changeRpm(CommandQueue.getInstance(), rpm);
|
IoUtil.changeRpm(commandQueue, rpm);
|
||||||
sleepSeconds(settleTime);
|
sleepSeconds(settleTime);
|
||||||
AtomicReference<String> result = new AtomicReference<>();
|
AtomicReference<String> result = new AtomicReference<>();
|
||||||
SensorCentral.SensorListener listener = new SensorCentral.SensorListener() {
|
SensorCentral.SensorListener listener = new SensorCentral.SensorListener() {
|
||||||
|
@ -155,13 +155,13 @@ public class AutoTest {
|
||||||
String msg = "BMW";
|
String msg = "BMW";
|
||||||
EngineChart chart;
|
EngineChart chart;
|
||||||
changeRpm(200);
|
changeRpm(200);
|
||||||
chart = nextChart1();
|
chart = nextChart();
|
||||||
double x = 173.988;
|
double x = 173.988;
|
||||||
// something is wrong here - it's a 6 cylinder here, why 4 cylinder cycle?
|
// something is wrong here - it's a 6 cylinder here, why 4 cylinder cycle?
|
||||||
assertWave(msg, chart, EngineChart.SPARK_1, 0.0199666, x, x + 180, x + 360, x + 540);
|
assertWave(msg, chart, EngineChart.SPARK_1, 0.0199666, x, x + 180, x + 360, x + 540);
|
||||||
|
|
||||||
changeRpm(1200);
|
changeRpm(1200);
|
||||||
chart = nextChart1();
|
chart = nextChart();
|
||||||
|
|
||||||
x = 688.464;
|
x = 688.464;
|
||||||
// something is wrong here - it's a 6 cylinder here, why 4 cylinder cycle?
|
// something is wrong here - it's a 6 cylinder here, why 4 cylinder cycle?
|
||||||
|
@ -173,7 +173,7 @@ public class AutoTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
void changeRpm(final int rpm) {
|
void changeRpm(final int rpm) {
|
||||||
IoUtil.changeRpm(CommandQueue.getInstance(), rpm);
|
IoUtil.changeRpm(linkManager.getCommandQueue(), rpm);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testMitsu() {
|
private void testMitsu() {
|
||||||
|
@ -208,7 +208,7 @@ public class AutoTest {
|
||||||
String msg = "mazda 626 default cranking";
|
String msg = "mazda 626 default cranking";
|
||||||
changeRpm(200);
|
changeRpm(200);
|
||||||
EngineChart chart;
|
EngineChart chart;
|
||||||
chart = nextChart1();
|
chart = nextChart();
|
||||||
|
|
||||||
double x = 102;
|
double x = 102;
|
||||||
assertWave(msg, chart, EngineChart.SPARK_1, 0.1944, x, x + 180, x + 360, x + 540);
|
assertWave(msg, chart, EngineChart.SPARK_1, 0.1944, x, x + 180, x + 360, x + 540);
|
||||||
|
@ -274,12 +274,12 @@ public class AutoTest {
|
||||||
assertWave(true, msg, chart, EngineChart.INJECTOR_4, 0.29233, 0.1, 0.2, x);
|
assertWave(true, msg, chart, EngineChart.INJECTOR_4, 0.29233, 0.1, 0.2, x);
|
||||||
|
|
||||||
sendCommand("set_whole_timing_map 520");
|
sendCommand("set_whole_timing_map 520");
|
||||||
chart = nextChart1();
|
chart = nextChart();
|
||||||
x = 328;
|
x = 328;
|
||||||
assertWave(true, msg, chart, EngineChart.SPARK_1, 0.13299999999999998, EngineReport.RATIO, EngineReport.RATIO, x + 180, x + 540);
|
assertWave(true, msg, chart, EngineChart.SPARK_1, 0.13299999999999998, EngineReport.RATIO, EngineReport.RATIO, x + 180, x + 540);
|
||||||
|
|
||||||
sendCommand("set_whole_timing_map 0");
|
sendCommand("set_whole_timing_map 0");
|
||||||
chart = nextChart1();
|
chart = nextChart();
|
||||||
x = 128;
|
x = 128;
|
||||||
assertWave(true, msg, chart, EngineChart.SPARK_1, 0.13299999999999998, EngineReport.RATIO, EngineReport.RATIO, x + 180, x + 540);
|
assertWave(true, msg, chart, EngineChart.SPARK_1, 0.13299999999999998, EngineReport.RATIO, EngineReport.RATIO, x + 180, x + 540);
|
||||||
}
|
}
|
||||||
|
@ -292,7 +292,7 @@ public class AutoTest {
|
||||||
changeRpm(260);
|
changeRpm(260);
|
||||||
changeRpm(200);
|
changeRpm(200);
|
||||||
String msg = "ProtegeLX cranking";
|
String msg = "ProtegeLX cranking";
|
||||||
chart = nextChart1();
|
chart = nextChart();
|
||||||
assertEquals("", 12, SensorCentral.getInstance().getValue(Sensor.VBATT), 0.1);
|
assertEquals("", 12, SensorCentral.getInstance().getValue(Sensor.VBATT), 0.1);
|
||||||
double x = 107;
|
double x = 107;
|
||||||
assertWave(msg, chart, EngineChart.SPARK_3, 0.194433, x);
|
assertWave(msg, chart, EngineChart.SPARK_3, 0.194433, x);
|
||||||
|
@ -303,7 +303,7 @@ public class AutoTest {
|
||||||
|
|
||||||
msg = "ProtegeLX running";
|
msg = "ProtegeLX running";
|
||||||
changeRpm(2000);
|
changeRpm(2000);
|
||||||
chart = nextChart1();
|
chart = nextChart();
|
||||||
x = 112;
|
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;
|
||||||
|
@ -320,7 +320,7 @@ public class AutoTest {
|
||||||
* note that command order matters - RPM change resets wave chart
|
* note that command order matters - RPM change resets wave chart
|
||||||
*/
|
*/
|
||||||
changeRpm(2000);
|
changeRpm(2000);
|
||||||
chart = nextChart1();
|
chart = nextChart();
|
||||||
|
|
||||||
String msg = "1995 Neon";
|
String msg = "1995 Neon";
|
||||||
double x = -70;
|
double x = -70;
|
||||||
|
@ -340,7 +340,7 @@ public class AutoTest {
|
||||||
sendComplexCommand("set algorithm 3");
|
sendComplexCommand("set algorithm 3");
|
||||||
changeRpm(2600);
|
changeRpm(2600);
|
||||||
changeRpm(2000);
|
changeRpm(2000);
|
||||||
chart = nextChart1();
|
chart = nextChart();
|
||||||
x = -70;
|
x = -70;
|
||||||
assertWaveFall(msg, chart, EngineChart.INJECTOR_4, 0.493, x + 540);
|
assertWaveFall(msg, chart, EngineChart.INJECTOR_4, 0.493, x + 540);
|
||||||
}
|
}
|
||||||
|
@ -353,7 +353,7 @@ public class AutoTest {
|
||||||
setEngineType(4);
|
setEngineType(4);
|
||||||
EngineChart chart;
|
EngineChart chart;
|
||||||
changeRpm(2000);
|
changeRpm(2000);
|
||||||
chart = nextChart1();
|
chart = nextChart();
|
||||||
|
|
||||||
String msg = "Fiesta";
|
String msg = "Fiesta";
|
||||||
double x = 312;
|
double x = 312;
|
||||||
|
@ -367,7 +367,7 @@ public class AutoTest {
|
||||||
setEngineType(7);
|
setEngineType(7);
|
||||||
EngineChart chart;
|
EngineChart chart;
|
||||||
changeRpm(2000);
|
changeRpm(2000);
|
||||||
chart = nextChart1();
|
chart = nextChart();
|
||||||
|
|
||||||
String msg = "ford 6";
|
String msg = "ford 6";
|
||||||
|
|
||||||
|
@ -376,7 +376,7 @@ public class AutoTest {
|
||||||
|
|
||||||
assertWaveNull(msg, chart, EngineChart.TRIGGER_2);
|
assertWaveNull(msg, chart, EngineChart.TRIGGER_2);
|
||||||
sendComplexCommand("set " + "trigger_type" + " 1"); // TT_FORD_ASPIRE
|
sendComplexCommand("set " + "trigger_type" + " 1"); // TT_FORD_ASPIRE
|
||||||
chart = nextChart1();
|
chart = nextChart();
|
||||||
assertTrue(msg, chart.get(EngineChart.TRIGGER_2) != null);
|
assertTrue(msg, chart.get(EngineChart.TRIGGER_2) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,14 +392,14 @@ public class AutoTest {
|
||||||
changeRpm(200);
|
changeRpm(200);
|
||||||
|
|
||||||
double x;
|
double x;
|
||||||
chart = nextChart1();
|
chart = nextChart();
|
||||||
assertEquals(12, SensorCentral.getInstance().getValue(Sensor.VBATT));
|
assertEquals(12, SensorCentral.getInstance().getValue(Sensor.VBATT));
|
||||||
x = 55;
|
x = 55;
|
||||||
assertWave("aspire default cranking ", chart, EngineChart.SPARK_1, 0.1944, x, x + 180, x + 360, x + 540);
|
assertWave("aspire default cranking ", chart, EngineChart.SPARK_1, 0.1944, x, x + 180, x + 360, x + 540);
|
||||||
|
|
||||||
|
|
||||||
changeRpm(600);
|
changeRpm(600);
|
||||||
chart = nextChart1();
|
chart = nextChart();
|
||||||
x = 78;
|
x = 78;
|
||||||
assertWave(true, "aspire default running ", chart, EngineChart.SPARK_1, 0.04, 0.1, 0.1, x, x + 180, x + 360, x + 540);
|
assertWave(true, "aspire default running ", chart, EngineChart.SPARK_1, 0.04, 0.1, 0.1, x, x + 180, x + 360, x + 540);
|
||||||
|
|
||||||
|
@ -557,7 +557,7 @@ public class AutoTest {
|
||||||
try {
|
try {
|
||||||
LinkManager linkManager = new LinkManager();
|
LinkManager linkManager = new LinkManager();
|
||||||
IoUtil.connectToSimulator(linkManager, startSimulator);
|
IoUtil.connectToSimulator(linkManager, startSimulator);
|
||||||
new AutoTest(linkManager, CommandQueue.getInstance()).mainTestBody();
|
new AutoTest(linkManager, linkManager.getCommandQueue()).mainTestBody();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
failed = true;
|
failed = true;
|
||||||
|
|
|
@ -85,6 +85,6 @@ public class RealHwTest {
|
||||||
private static void runRealHardwareTest(String port) throws Exception {
|
private static void runRealHardwareTest(String port) throws Exception {
|
||||||
LinkManager linkManager = new LinkManager();
|
LinkManager linkManager = new LinkManager();
|
||||||
IoUtil.realHardwareConnect(linkManager, port);
|
IoUtil.realHardwareConnect(linkManager, port);
|
||||||
new AutoTest(linkManager, CommandQueue.getInstance()).mainTestBody();
|
new AutoTest(linkManager, linkManager.getCommandQueue()).mainTestBody();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,10 +112,6 @@ public class TestingUtils {
|
||||||
return chart;
|
return chart;
|
||||||
}
|
}
|
||||||
|
|
||||||
static EngineChart nextChart1() {
|
|
||||||
return nextChart();
|
|
||||||
}
|
|
||||||
|
|
||||||
static String getNextWaveChart(CommandQueue commandQueue) {
|
static String getNextWaveChart(CommandQueue commandQueue) {
|
||||||
IoUtil.sendCommand(Fields.CMD_RESET_ENGINE_SNIFFER, commandQueue);
|
IoUtil.sendCommand(Fields.CMD_RESET_ENGINE_SNIFFER, commandQueue);
|
||||||
String result = getEngineChart();
|
String result = getEngineChart();
|
||||||
|
|
|
@ -173,7 +173,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
||||||
/**
|
/**
|
||||||
* this here to make CommandQueue happy
|
* this here to make CommandQueue happy
|
||||||
*/
|
*/
|
||||||
CommandQueue.getInstance().handleConfirmationMessage(CommandQueue.CONFIRMATION_PREFIX + command);
|
linkManager.getCommandQueue().handleConfirmationMessage(CommandQueue.CONFIRMATION_PREFIX + command);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -62,6 +62,10 @@ public class LinkManager {
|
||||||
return connector.getBinaryProtocol();
|
return connector.getBinaryProtocol();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CommandQueue getCommandQueue() {
|
||||||
|
return CommandQueue.getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
public enum LogLevel {
|
public enum LogLevel {
|
||||||
INFO,
|
INFO,
|
||||||
DEBUG,
|
DEBUG,
|
||||||
|
|
|
@ -105,22 +105,22 @@ public class BenchTestPane {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component createDizzyTest() {
|
private Component createDizzyTest() {
|
||||||
CommandControl panel = new FixedCommandControl("Dizzy", "dizzy.jpg", TEST, "dizzybench");
|
CommandControl panel = new FixedCommandControl(uiContext, "Dizzy", "dizzy.jpg", TEST, "dizzybench");
|
||||||
return panel.getContent();
|
return panel.getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component createFanTest() {
|
private Component createFanTest() {
|
||||||
CommandControl panel = new FixedCommandControl("Radiator Fan", "radiator_fan.jpg", TEST, "fanbench");
|
CommandControl panel = new FixedCommandControl(uiContext, "Radiator Fan", "radiator_fan.jpg", TEST, "fanbench");
|
||||||
return panel.getContent();
|
return panel.getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component createAcRelayTest() {
|
private Component createAcRelayTest() {
|
||||||
CommandControl panel = new FixedCommandControl("A/C Compressor Relay", ".jpg", TEST, "acrelaybench");
|
CommandControl panel = new FixedCommandControl(uiContext, "A/C Compressor Relay", ".jpg", TEST, "acrelaybench");
|
||||||
return panel.getContent();
|
return panel.getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component createFuelPumpTest() {
|
private Component createFuelPumpTest() {
|
||||||
CommandControl panel = new FixedCommandControl("Fuel Pump", "fuel_pump.jpg", TEST, "fuelpumpbench");
|
CommandControl panel = new FixedCommandControl(uiContext, "Fuel Pump", "fuel_pump.jpg", TEST, "fuelpumpbench");
|
||||||
return panel.getContent();
|
return panel.getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package com.rusefi;
|
package com.rusefi;
|
||||||
|
|
||||||
|
import com.rusefi.ui.UIContext;
|
||||||
|
|
||||||
public class FixedCommandControl extends CommandControl {
|
public class FixedCommandControl extends CommandControl {
|
||||||
private final String command;
|
private final String command;
|
||||||
|
|
||||||
public FixedCommandControl(String labelText, String iconFileName, String buttonText, String command) {
|
public FixedCommandControl(UIContext uiContext, String labelText, String iconFileName, String buttonText, String command) {
|
||||||
super(labelText, iconFileName, buttonText);
|
super(uiContext, labelText, iconFileName, buttonText);
|
||||||
this.command = command;
|
this.command = command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.rusefi;
|
package com.rusefi;
|
||||||
|
|
||||||
import com.rusefi.config.generated.Fields;
|
import com.rusefi.config.generated.Fields;
|
||||||
import com.rusefi.io.CommandQueue;
|
|
||||||
import com.rusefi.ui.UIContext;
|
import com.rusefi.ui.UIContext;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@ -23,15 +22,15 @@ public class PresetsPane {
|
||||||
|
|
||||||
public PresetsPane(UIContext uiContext) {
|
public PresetsPane(UIContext uiContext) {
|
||||||
this.uiContext = uiContext;
|
this.uiContext = uiContext;
|
||||||
content.add(new SetEngineTypeCommandControl("Frankenso Miata NA6 Stage 0", "/engines/miata_na.png", Fields.ET_FRANKENSO_MIATA_NA6_VAF).getContent());
|
content.add(new SetEngineTypeCommandControl(uiContext,"Frankenso Miata NA6 Stage 0", "/engines/miata_na.png", Fields.ET_FRANKENSO_MIATA_NA6_VAF).getContent());
|
||||||
content.add(new SetEngineTypeCommandControl("Frankenso Miata NA6 Stage 1", "/engines/miata_na.png", Fields.ET_FRANKENSO_MIATA_NA6).getContent());
|
content.add(new SetEngineTypeCommandControl(uiContext, "Frankenso Miata NA6 Stage 1", "/engines/miata_na.png", Fields.ET_FRANKENSO_MIATA_NA6).getContent());
|
||||||
content.add(new SetEngineTypeCommandControl("Frankenso Miata NB2", "/engines/miata_nb.png", Fields.ET_FRANKENSO_MIATA_NB2).getContent());
|
content.add(new SetEngineTypeCommandControl(uiContext, "Frankenso Miata NB2", "/engines/miata_nb.png", Fields.ET_FRANKENSO_MIATA_NB2).getContent());
|
||||||
content.add(new SetEngineTypeCommandControl("MRE Miata NB2 MAF", "engines/miata_nb.png", Fields.ET_MRE_MIATA_NB2_MAF).getContent());
|
content.add(new SetEngineTypeCommandControl(uiContext, "MRE Miata NB2 MAF", "engines/miata_nb.png", Fields.ET_MRE_MIATA_NB2_MAF).getContent());
|
||||||
content.add(new SetEngineTypeCommandControl("Frankenso V12", "/engines/v12", TEST_V_12).getContent());
|
content.add(new SetEngineTypeCommandControl(uiContext, "Frankenso V12", "/engines/v12", TEST_V_12).getContent());
|
||||||
content.add(new SetEngineTypeCommandControl("ETB bench", "", ETB_BENCH).getContent());
|
content.add(new SetEngineTypeCommandControl(uiContext, "ETB bench", "", ETB_BENCH).getContent());
|
||||||
content.add(new SetEngineTypeCommandControl("Minimal", "", MINIMAL_PINS).getContent());
|
content.add(new SetEngineTypeCommandControl(uiContext, "Minimal", "", MINIMAL_PINS).getContent());
|
||||||
content.add(new SetEngineTypeCommandControl("MRE old test", "", Fields.ET_MRE_OLD_TEST_BOARD).getContent());
|
content.add(new SetEngineTypeCommandControl(uiContext, "MRE old test", "", Fields.ET_MRE_OLD_TEST_BOARD).getContent());
|
||||||
content.add(new SetEngineTypeCommandControl("MRE new test", "", Fields.ET_MRE_NEW_TEST_BOARD).getContent());
|
content.add(new SetEngineTypeCommandControl(uiContext, "MRE new test", "", Fields.ET_MRE_NEW_TEST_BOARD).getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public JPanel getContent() {
|
public JPanel getContent() {
|
||||||
|
@ -41,8 +40,8 @@ public class PresetsPane {
|
||||||
private class SetEngineTypeCommandControl extends FixedCommandControl {
|
private class SetEngineTypeCommandControl extends FixedCommandControl {
|
||||||
private final String labelTest;
|
private final String labelTest;
|
||||||
|
|
||||||
public SetEngineTypeCommandControl(String labelTest, String imageFileName, int engineType) {
|
public SetEngineTypeCommandControl(UIContext uiContext, String labelTest, String imageFileName, int engineType) {
|
||||||
super(labelTest, imageFileName, CommandControl.SET, "set " + Fields.CMD_ENGINE_TYPE + " " + engineType);
|
super(uiContext, labelTest, imageFileName, CommandControl.SET, "set " + Fields.CMD_ENGINE_TYPE + " " + engineType);
|
||||||
this.labelTest = labelTest;
|
this.labelTest = labelTest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.rusefi.FileLog;
|
||||||
import com.rusefi.InfixConverter;
|
import com.rusefi.InfixConverter;
|
||||||
import com.rusefi.core.MessagesCentral;
|
import com.rusefi.core.MessagesCentral;
|
||||||
import com.rusefi.io.CommandQueue;
|
import com.rusefi.io.CommandQueue;
|
||||||
|
import com.rusefi.io.LinkManager;
|
||||||
import com.rusefi.ui.RecentCommands;
|
import com.rusefi.ui.RecentCommands;
|
||||||
import com.rusefi.ui.UIContext;
|
import com.rusefi.ui.UIContext;
|
||||||
import com.rusefi.ui.storage.Node;
|
import com.rusefi.ui.storage.Node;
|
||||||
|
@ -114,7 +115,7 @@ public class AnyCommand {
|
||||||
private void sendCommand(String rawCommand) {
|
private void sendCommand(String rawCommand) {
|
||||||
if (!isValidInput(rawCommand))
|
if (!isValidInput(rawCommand))
|
||||||
return;
|
return;
|
||||||
String cmd = prepareCommand(rawCommand);
|
String cmd = prepareCommand(rawCommand, uiContext.getLinkManager());
|
||||||
if (cmd == null) {
|
if (cmd == null) {
|
||||||
/**
|
/**
|
||||||
* {@link #DECODE_RPN} for example does not send out anything
|
* {@link #DECODE_RPN} for example does not send out anything
|
||||||
|
@ -129,12 +130,12 @@ public class AnyCommand {
|
||||||
reentrant = false;
|
reentrant = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String prepareCommand(String rawCommand) {
|
public static String prepareCommand(String rawCommand, LinkManager linkManager) {
|
||||||
try {
|
try {
|
||||||
if (rawCommand.startsWith("eval" + " ")) {
|
if (rawCommand.startsWith("eval" + " ")) {
|
||||||
return prepareEvalCommand(rawCommand);
|
return prepareEvalCommand(rawCommand);
|
||||||
} else if (rawCommand.toLowerCase().startsWith("stim_check" + " ")) {
|
} else if (rawCommand.toLowerCase().startsWith("stim_check" + " ")) {
|
||||||
handleStimulationSelfCheck(rawCommand);
|
handleStimulationSelfCheck(rawCommand, linkManager);
|
||||||
return null;
|
return null;
|
||||||
} else if (rawCommand.toLowerCase().startsWith(DECODE_RPN + " ")) {
|
} else if (rawCommand.toLowerCase().startsWith(DECODE_RPN + " ")) {
|
||||||
handleDecodeRpn(rawCommand);
|
handleDecodeRpn(rawCommand);
|
||||||
|
@ -154,7 +155,7 @@ public class AnyCommand {
|
||||||
* stim_check 3000 5 30
|
* stim_check 3000 5 30
|
||||||
* would set RPM to 3000, give it 5 seconds to settle, and test for 30 seconds
|
* would set RPM to 3000, give it 5 seconds to settle, and test for 30 seconds
|
||||||
*/
|
*/
|
||||||
private static void handleStimulationSelfCheck(String rawCommand) {
|
private static void handleStimulationSelfCheck(String rawCommand, LinkManager linkManager) {
|
||||||
String[] parts = rawCommand.split(" ", 4);
|
String[] parts = rawCommand.split(" ", 4);
|
||||||
if (parts.length != 4) {
|
if (parts.length != 4) {
|
||||||
MessagesCentral.getInstance().postMessage(AnyCommand.class, "Invalid command length " + parts);
|
MessagesCentral.getInstance().postMessage(AnyCommand.class, "Invalid command length " + parts);
|
||||||
|
@ -178,7 +179,7 @@ public class AnyCommand {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
AutoTest.assertRpmDoesNotJump(rpm, settleTime, durationTime, callback);
|
AutoTest.assertRpmDoesNotJump(rpm, settleTime, durationTime, callback, linkManager.getCommandQueue());
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,10 @@ import static org.junit.Assert.assertEquals;
|
||||||
* 3/9/2017.
|
* 3/9/2017.
|
||||||
*/
|
*/
|
||||||
public class AnyCommandTest {
|
public class AnyCommandTest {
|
||||||
|
private static String prepareCommand(String rawCommand) {
|
||||||
|
return AnyCommand.prepareCommand(rawCommand, null);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnquote() {
|
public void testUnquote() {
|
||||||
assertEquals("1 2 3", AnyCommand.unquote(" \"1 2 3\" "));
|
assertEquals("1 2 3", AnyCommand.unquote(" \"1 2 3\" "));
|
||||||
|
@ -17,13 +21,13 @@ public class AnyCommandTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPrepareEvalCommand() {
|
public void testPrepareEvalCommand() {
|
||||||
assertEquals("rpn_eval \"2 3 +\"", AnyCommand.prepareCommand("eval \"2 + 3\" "));
|
assertEquals("rpn_eval \"2 3 +\"", prepareCommand("eval \"2 + 3\" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetFSIOexpression() {
|
public void testSetFSIOexpression() {
|
||||||
// todo: parameter order needs to be in postfix form
|
// todo: parameter order needs to be in postfix form
|
||||||
assertEquals("set_rpn_expression 1 \"rpm fsio_setting 0 >\"", AnyCommand.prepareCommand("set_fsio_expression 1 \"rpm > fsio_setting 0\""));
|
assertEquals("set_rpn_expression 1 \"rpm fsio_setting 0 >\"", prepareCommand("set_fsio_expression 1 \"rpm > fsio_setting 0\""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -32,6 +36,6 @@ public class AnyCommandTest {
|
||||||
assertEquals("tps > 10", AnyCommand.unquote("\u201Ctps > 10\u201D"));
|
assertEquals("tps > 10", AnyCommand.unquote("\u201Ctps > 10\u201D"));
|
||||||
|
|
||||||
|
|
||||||
assertEquals("set_rpn_expression 1 \"tps 10 >\"", AnyCommand.prepareCommand("Set_fsio_expression 1 \u201Ctps > 10\u201D"));
|
assertEquals("set_rpn_expression 1 \"tps 10 >\"", prepareCommand("Set_fsio_expression 1 \u201Ctps > 10\u201D"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue