private static void RunSimulation(object simObject) { try { Stages = (simObject as Simulation).RunSimulation(null); if (Stages != null && Stages.Length > 0) { if (logOutput) { foreach (var stage in Stages) { stage.Dump(log); } } LastStage = Stages[Stages.Length - 1]; } } catch (Exception e) { BasicLogger.Exception(e, "SimManager.RunSimulation()"); Stages = null; LastStage = null; failMessage = e.ToString(); } lock (locker) { timer.Stop(); #if TIMERS log.AppendLine("Total simulation time: ", timer.ElapsedMilliseconds, "ms"); #else if (logOutput) { log.AppendLine("Total simulation time: ", timer.ElapsedMilliseconds, "ms"); } #endif delayBetweenSims = minSimTime - timer.Elapsed; if (delayBetweenSims < TimeSpan.Zero) { delayBetweenSims = TimeSpan.Zero; } timer.Reset(); timer.Start(); bRunning = false; if (OnReady != null) { OnReady.Invoke(); } } logOutput = false; }
private static void StartSimulation() { try { lock (locker) { bRunning = true; } ClearResults(); lock (locker) { timer.Start(); } if (HighLogic.LoadedSceneIsEditor) { parts = EditorLogic.fetch.ship.parts; } else { parts = FlightGlobals.ActiveVessel.Parts; Atmosphere = FlightGlobals.ActiveVessel.staticPressurekPa * PhysicsGlobals.KpaToAtmospheres; } // This call doesn't ever fail at the moment but we'll check and return a sensible error for display if (simulation.PrepareSimulation(null, parts, Gravity, Atmosphere, Mach, dumpTree, vectoredThrust)) { ThreadPool.QueueUserWorkItem(_runSim, simulation); //RunSimulation(simulation); } else { failMessage = "PrepareSimulation failed"; lock (locker) { bRunning = false; } logOutput = false; } } catch (Exception e) { BasicLogger.Exception(e, "SimManager.StartSimulation()"); failMessage = e.ToString(); lock (locker) { bRunning = false; } logOutput = false; } dumpTree = false; }
private static void StartSimulation() { try { lock (locker) { bRunning = true; } ClearResults(); lock (locker) { timer.Start(); } parts = EditorLogic.fetch.ship.parts; // This call doesn't ever fail at the moment but we'll check and return a sensible error for display if (simulation.PrepareSimulation(logOutput ? log : null, parts, Gravity, Atmosphere, Mach, dumpTree, vectoredThrust)) { ThreadPool.QueueUserWorkItem(RunSimulation, simulation); //RunSimulation(simulation); } else { failMessage = "PrepareSimulation failed"; lock (locker) { bRunning = false; } logOutput = false; } } catch (Exception e) { BasicLogger.Exception(e, "SimManager.StartSimulation()"); failMessage = e.ToString(); lock (locker) { bRunning = false; } logOutput = false; } dumpTree = false; }