only:Improve toolset for default tune canned tune generation #4871

This commit is contained in:
Andrey 2023-06-16 20:18:04 -04:00
parent 73239d1616
commit 5dc3840ca7
2 changed files with 13 additions and 4 deletions

View File

@ -104,13 +104,15 @@ public class IoUtil {
log.info("AUTOTEST RPM change [" + rpm + "] executed in " + (System.currentTimeMillis() - time));
}
static void waitForFirstResponse() throws InterruptedException {
private static void waitForFirstResponse() throws InterruptedException {
log.info("Let's give it some time to start...");
final CountDownLatch startup = new CountDownLatch(1);
long waitStart = System.currentTimeMillis();
ISensorCentral.ListenerToken listener = SensorCentral.getInstance().addListener(Sensor.RPMValue, value -> startup.countDown());
startup.await(5, TimeUnit.SECONDS);
boolean haveResponse = startup.await(10, TimeUnit.SECONDS);
if (!haveResponse)
throw new IllegalStateException("No response from simulator");
listener.remove();
FileLog.MAIN.logLine("Got first signal in " + (System.currentTimeMillis() - waitStart));
}

View File

@ -19,7 +19,15 @@ public class WriteSimulatorConfiguration {
private static final String FOLDER = "generated";
public static void main(String[] args) throws IOException, InterruptedException, JAXBException {
// SimulatorExecHelper
try {
writeTune();
} finally {
// No way to set Process.exec to be a daemon, we need explicit exit
System.exit(0);
}
}
private static void writeTune() throws InterruptedException, JAXBException, IOException {
LinkManager linkManager = new LinkManager();
IoUtil.connectToSimulator(linkManager, true);
BinaryProtocol bp = Objects.requireNonNull(linkManager.getBinaryProtocol(), "getBinaryProtocol");
@ -31,6 +39,5 @@ public class WriteSimulatorConfiguration {
Msq m = MsqFactory.valueOf(configuration, ini);
new File(FOLDER).mkdirs();
m.writeXmlFile(FOLDER + File.separator + "simulator_tune.xml");
System.exit(0);
}
}