diff --git a/java_console/io/src/main/java/com/rusefi/SimulatorExecHelper.java b/java_console/io/src/main/java/com/rusefi/SimulatorExecHelper.java index 0c9924499d..2379d0c879 100644 --- a/java_console/io/src/main/java/com/rusefi/SimulatorExecHelper.java +++ b/java_console/io/src/main/java/com/rusefi/SimulatorExecHelper.java @@ -20,12 +20,11 @@ public class SimulatorExecHelper { /** * This is currently used by auto-tests only. Todo: reuse same code for UI-launched simulator? */ - private static void runSimulator() { + private static void runSimulator(File binary) { Thread.currentThread().setName("Main simulation"); FileLog.MAIN.logLine("runSimulator..."); try { - File binary = getSimulatorBinary(SIMULATOR_BINARY_PATH); FileLog.MAIN.logLine("Binary size: " + binary.length()); FileLog.MAIN.logLine("Executing " + binary.getPath()); @@ -94,10 +93,9 @@ static void destroy() { } public static void startSimulator() { - getSimulatorBinary(SIMULATOR_BINARY_PATH); - FileLog.MAIN.logLine("startSimulator..."); - new Thread(SimulatorExecHelper::runSimulator, "simulator process").start(); + File simulatorBinary = getSimulatorBinary(SIMULATOR_BINARY_PATH); + new Thread(() -> SimulatorExecHelper.runSimulator(simulatorBinary), "simulator process").start(); } public static File getSimulatorBinary(String binaryPath) { diff --git a/java_console/ui/src/main/java/com/rusefi/SimulatorHelper.java b/java_console/ui/src/main/java/com/rusefi/SimulatorHelper.java index 8228917173..09d7b9e6ec 100644 --- a/java_console/ui/src/main/java/com/rusefi/SimulatorHelper.java +++ b/java_console/ui/src/main/java/com/rusefi/SimulatorHelper.java @@ -21,11 +21,9 @@ public class SimulatorHelper { * this code start sumulator for UI console * todo: unify with the code which starts simulator for auto tests? */ - private static void startSimulator() { + private static void startSimulator(File binary) { LinkManager.isSimulationMode = true; - File binary = SimulatorExecHelper.getSimulatorBinary(SIMULATOR_BINARY_PATH); - FileLog.MAIN.logLine("Executing " + binary.getPath()); THREAD_FACTORY.newThread(new Runnable() { @Override @@ -60,8 +58,9 @@ public void run() { } public static JComponent createSimulatorComponent(final StartupFrame portSelector) { + File simulatorBinary; try { - SimulatorExecHelper.getSimulatorBinary(SIMULATOR_BINARY_PATH); + simulatorBinary = SimulatorExecHelper.getSimulatorBinary(SIMULATOR_BINARY_PATH); } catch (IllegalStateException e) { return new JLabel(e.getMessage()); } @@ -74,7 +73,7 @@ public static JComponent createSimulatorComponent(final StartupFrame portSelecto @Override public void actionPerformed(ActionEvent event) { portSelector.disposeFrameAndProceed(); - startSimulator(); + startSimulator(simulatorBinary); } }); setToolTip(simulatorButton, "Connect to totally virtual simulator",