public override ManeuverParameters MakeNodeImpl(Orbit o, double UT, MechJebModuleTargetController target) { // Check preconditions string message = CheckPreconditions(o, target); if (message != null) throw new OperationException(message); // Check if computation is finished if (worker != null && !worker.Finished) throw new OperationException("Computation not finished"); if (worker == null) { ComputeStuff(o, UT, target); throw new OperationException("Started computation"); } if (worker.result == null) { throw new OperationException("Computation failed"); } if (selectionMode == Mode.Porkchop) { if (plot == null || plot.selectedPoint == null) throw new OperationException("Invalid point selected."); return TransferCalculator.OptimizeEjection( worker.computed[plot.selectedPoint[0], plot.selectedPoint[1]], o, worker.destinationOrbit, worker.DateFromIndex(plot.selectedPoint[0]) + worker.DurationFromIndex(plot.selectedPoint[1]), UT); } return worker.OptimizedResult; }
public override void DoParametersGUI(Orbit o, double universalTime, MechJebModuleTargetController target) { _draggable = true; if (worker != null && !target.NormalTargetExists && Event.current.type == EventType.Layout) { worker.stop = true; worker = null; plot = null; } selectionMode = (Mode) GuiUtils.ComboBox.Box((int) selectionMode, modeNames, this); if (Event.current.type == EventType.Repaint) windowWidth = (int)GUILayoutUtility.GetLastRect().width; switch (selectionMode) { case Mode.LimitedTime: GuiUtils.SimpleTextBox("Max arrival time", maxArrivalTime); if (worker != null && !worker.Finished) GuiUtils.SimpleLabel("Computing: " + worker.Progress + "%"); break; case Mode.Porkchop: DoPorkchopGui(o, universalTime, target); break; } if (worker == null || worker.destinationOrbit != target.TargetOrbit || worker.originOrbit != o) ComputeTimes(o, target.TargetOrbit, universalTime); if (GUI.changed || worker == null || worker.destinationOrbit != target.TargetOrbit || worker.originOrbit != o) ComputeStuff(o, universalTime, target); }
void ComputeStuff(Orbit o, double universalTime, MechJebModuleTargetController target) { errorMessage = CheckPreconditions(o, target); if (errorMessage == null) { errorMessage = ""; } else { return; } if (worker != null) { worker.stop = true; } plot = null; switch (selectionMode) { case Mode.LimitedTime: worker = new TransferCalculator(o, target.TargetOrbit, universalTime, maxArrivalTime, minSamplingStep, includeCaptureBurn); break; case Mode.Porkchop: worker = new AllGraphTransferCalculator(o, target.TargetOrbit, minDepartureTime, maxDepartureTime, minTransferTime, maxTransferTime, windowWidth, porkchop_Height, includeCaptureBurn); break; } }
void ComputeStuff(Orbit o, double universalTime, MechJebModuleTargetController target) { errorMessage = ""; try { CheckPreconditions(o, target); } catch (Exception e) { errorMessage = e.Message; return; } if (worker != null) { worker.stop = true; } plot = null; switch (selectionMode) { case Mode.LimitedTime: // We could end up asking for parameters in the past, take a safe 10 min margin worker = new TransferCalculator(o, target.TargetOrbit, SafeDepartureTime(o, universalTime), maxArrivalTime, minSamplingStep); break; case Mode.Porkchop: worker = new AllGraphTransferCalculator(o, target.TargetOrbit, minDepartureTime, maxDepartureTime, minTransferTime, maxTransferTime, windowWidth, porkchop_Height); break; } }
void ComputeStuff(Orbit o, double universalTime, MechJebModuleTargetController target) { errorMessage = CheckPreconditions(o, target); if (errorMessage == null) errorMessage = ""; else return; if (worker != null) worker.stop = true; plot = null; switch (selectionMode) { case Mode.LimitedTime: worker = new TransferCalculator (o, target.TargetOrbit, universalTime, maxArrivalTime, minSamplingStep); break; case Mode.Porkchop: worker = new AllGraphTransferCalculator(o, target.TargetOrbit, minDepartureTime, maxDepartureTime, minTransferTime, maxTransferTime, windowWidth, porkchop_Height); break; } }