mirror of https://github.com/FOME-Tech/fome-fw.git
console refactoring
This commit is contained in:
parent
4b2f01016f
commit
67ecdc24a5
|
@ -108,10 +108,10 @@ public class AnyCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendCommand(String rawCommand) {
|
private void sendCommand(String cmd) {
|
||||||
if (!isValidInput(rawCommand))
|
if (!isValidInput(cmd))
|
||||||
return;
|
return;
|
||||||
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
|
||||||
|
@ -126,53 +126,6 @@ public class AnyCommand {
|
||||||
reentrant = false;
|
reentrant = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String prepareCommand(String rawCommand, LinkManager linkManager) {
|
|
||||||
try {
|
|
||||||
if (rawCommand.toLowerCase().startsWith("stim_check" + " ")) {
|
|
||||||
handleStimulationSelfCheck(rawCommand, linkManager);
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return rawCommand;
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
FileLog.MAIN.log(e);
|
|
||||||
return rawCommand;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* stim_check 3000 5 30
|
|
||||||
* would set RPM to 3000, give it 5 seconds to settle, and test for 30 seconds
|
|
||||||
*/
|
|
||||||
private static void handleStimulationSelfCheck(String rawCommand, LinkManager linkManager) {
|
|
||||||
String[] parts = rawCommand.split(" ", 4);
|
|
||||||
if (parts.length != 4) {
|
|
||||||
MessagesCentral.getInstance().postMessage(AnyCommand.class, "Invalid command length " + parts.length);
|
|
||||||
return; // let's ignore invalid command
|
|
||||||
}
|
|
||||||
int rpm = Integer.parseInt(parts[1]);
|
|
||||||
int settleTime = Integer.parseInt(parts[2]);
|
|
||||||
int durationTime = Integer.parseInt(parts[3]);
|
|
||||||
THREAD_FACTORY.newThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MessagesCentral.getInstance().postMessage(AnyCommand.class, "Will test with RPM " + rpm + ", settle time" + settleTime + "s and duration" + durationTime + "s");
|
|
||||||
Function<String, Object> callback = new Function<String, Object>() {
|
|
||||||
@Override
|
|
||||||
public Object apply(String status) {
|
|
||||||
if (status == null) {
|
|
||||||
MessagesCentral.getInstance().postMessage(AnyCommand.class, rpm + " worked!");
|
|
||||||
} else {
|
|
||||||
MessagesCentral.getInstance().postMessage(AnyCommand.class, rpm + " failed " + status);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
EcuTestHelper.assertRpmDoesNotJump(rpm, settleTime, durationTime, callback, linkManager.getCommandQueue());
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isValidInput(String text) {
|
private static boolean isValidInput(String text) {
|
||||||
boolean isOk = true;
|
boolean isOk = true;
|
||||||
for (char c : text.toCharArray()) {
|
for (char c : text.toCharArray()) {
|
||||||
|
|
Loading…
Reference in New Issue