minor refactoring

This commit is contained in:
rusefillc 2022-02-11 08:50:42 -05:00
parent ad9cc4c219
commit 48e77b163d
5 changed files with 12 additions and 13 deletions

View File

@ -27,12 +27,12 @@ public class EnduranceTestUtility {
for (int i = 0; i < count; i++) {
EcuTestHelper.currentEngineType = engine_type_e.FORD_ASPIRE_1996.ordinal();
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 3, Timeouts.SET_ENGINE_TIMEOUT, commandQueue);
sendBlockingCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 3, Timeouts.SET_ENGINE_TIMEOUT, commandQueue);
sleepSeconds(2);
sendCommand(getEnableCommand("self_stimulation"), commandQueue);
sendBlockingCommand(getEnableCommand("self_stimulation"), commandQueue);
// IoUtil.changeRpm(1200);
EcuTestHelper.currentEngineType = engine_type_e.DEFAULT_FRANKENSO.ordinal();
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 28, Timeouts.SET_ENGINE_TIMEOUT, commandQueue);
sendBlockingCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 28, Timeouts.SET_ENGINE_TIMEOUT, commandQueue);
sleepSeconds(2);
FileLog.MAIN.logLine("++++++++++++++++++++++++++++++++++++ " + i + " +++++++++++++++");
}

View File

@ -30,8 +30,8 @@ public class IoUtil {
*
* @throws IllegalStateException if command was not confirmed
*/
static void sendCommand(String command, CommandQueue commandQueue) {
sendCommand(command, CommandQueue.DEFAULT_TIMEOUT, commandQueue);
static void sendBlockingCommand(String command, CommandQueue commandQueue) {
sendBlockingCommand(command, CommandQueue.DEFAULT_TIMEOUT, commandQueue);
}
public static String getSetCommand(String settingName) {
@ -47,9 +47,9 @@ public class IoUtil {
}
/**
* blocking method which would for confirmation from rusEfi
* blocking method which would for confirmation from rusEFI
*/
public static void sendCommand(String command, int timeoutMs, CommandQueue commandQueue) {
public static void sendBlockingCommand(String command, int timeoutMs, CommandQueue commandQueue) {
final CountDownLatch responseLatch = new CountDownLatch(1);
long time = System.currentTimeMillis();
log.info("Sending command [" + command + "]");
@ -74,7 +74,7 @@ public class IoUtil {
public static void changeRpm(CommandQueue commandQueue, final int rpm) {
log.info("AUTOTEST rpm EN " + rpm);
sendCommand(CMD_RPM + " " + rpm, commandQueue);
sendBlockingCommand(CMD_RPM + " " + rpm, commandQueue);
long time = System.currentTimeMillis();
final CountDownLatch rpmLatch = new CountDownLatch(1);
@ -91,7 +91,7 @@ public class IoUtil {
throw new IllegalStateException(e);
}
// We don't need to listen to RPM any more
// We don't need to listen to RPM anymore
listenerToken.remove();
double actualRpm = SensorCentral.getInstance().getValue(Sensor.RPM);
@ -160,7 +160,7 @@ public class IoUtil {
linkManager.getEngineState().registerStringValueAction(Fields.PROTOCOL_OUTPIN, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID);
linkManager.getEngineState().registerStringValueAction(AverageAnglesUtil.KEY, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID);
final CountDownLatch connected = linkManager.connect(port);
CountDownLatch connected = linkManager.connect(port);
if (connected.getCount() > 0)
throw new IllegalStateException("Not connected in time");
}

View File

@ -112,7 +112,7 @@ public class TestingUtils {
}
static String getNextWaveChart(CommandQueue commandQueue) {
IoUtil.sendCommand(Fields.CMD_RESET_ENGINE_SNIFFER, commandQueue);
IoUtil.sendBlockingCommand(Fields.CMD_RESET_ENGINE_SNIFFER, commandQueue);
String result = getEngineChart(commandQueue);
FileLog.MAIN.logLine("current chart: " + result);
return result;

View File

@ -102,7 +102,7 @@ public class EcuTestHelper {
public void sendCommand(String command, int timeoutMs) {
TestHelper.INSTANCE.assertNotFatal();
IoUtil.sendCommand(command, timeoutMs, commandQueue);
IoUtil.sendBlockingCommand(command, timeoutMs, commandQueue);
}
/**

View File

@ -69,7 +69,6 @@ public class CommandQueue {
* this method keeps retrying till a confirmation is received
*/
private void sendCommand(final IMethodInvocation commandRequest) throws InterruptedException {
int counter = 0;
String command = commandRequest.getCommand();
CountDownLatch cl = new CountDownLatch(1);