public static double GetBaseFailureRateForScope(Part part, String scope) { ITestFlightCore core = TestFlightInterface.GetCore(part); if (core == null) { return(TestFlightUtil.MIN_FAILURE_RATE); } return(core.GetBaseFailureRateForScope(scope)); }
internal override void DrawWindow(int id) { if (!isReady) { return; } if (SelectedPart == null) { GUILayout.BeginVertical(); GUILayout.Label("Select a part to display its details", Styles.styleEditorTitle); GUILayout.Label("MouseOver part in bin or 3D view to quickview", Styles.styleEditorText); GUILayout.Label("RightClick part in bin (not 3D) to toggle window lock on that part", Styles.styleEditorText); GUILayout.EndVertical(); if (DrawToggle(ref tfScenario.userSettings.editorWindowLocked, "Lock Window", Styles.styleToggle)) { if (tfScenario.userSettings.editorWindowLocked) { CalculateWindowBounds(); tfScenario.userSettings.editorWindowPosition = WindowRect; DragEnabled = false; } else { DragEnabled = true; } tfScenario.userSettings.Save(); } return; } ITestFlightCore core = null; GUILayout.BeginVertical(); GUILayout.Label(String.Format("Selected Part: {0}", TestFlightUtil.GetFullPartName(SelectedPart)), Styles.styleEditorTitle); tfScenario.userSettings.currentEditorScrollPosition = GUILayout.BeginScrollView(tfScenario.userSettings.currentEditorScrollPosition); PartFlightData partData = tfScenario.GetFlightDataForPartName(TestFlightUtil.GetFullPartName(SelectedPart)); if (partData != null) { string configuration; if (SelectedPart.Modules.Contains("ModuleEngineConfigs")) { configuration = (string)(SelectedPart.Modules["ModuleEngineConfigs"].GetType().GetField("configuration").GetValue(SelectedPart.Modules["ModuleEngineConfigs"])); } else { configuration = ""; } foreach (PartModule pm in SelectedPart.Modules) { core = pm as ITestFlightCore; if (core != null && core.Configuration == configuration) { break; } } if (core != null) { List <TestFlightData> flightData = partData.GetFlightData(); core.InitializeFlightData(flightData); foreach (TestFlightData data in flightData) { GUILayout.BeginHorizontal(); double failureRate = core.GetBaseFailureRateForScope(data.scope); String mtbfString = core.FailureRateToMTBFString(failureRate, TestFlightUtil.MTBFUnits.SECONDS, 999); // 10 characters for body max plus 10 characters for situation plus underscore = 21 characters needed for longest scope string GUILayout.Label(core.PrettyStringForScope(data.scope), GUILayout.Width(125)); GUILayout.Label(String.Format("{0,-7:F2}<b>du</b>", data.flightData), GUILayout.Width(75)); GUILayout.Label(String.Format("{0,-5:F2} MTBF", mtbfString), GUILayout.Width(125)); GUILayout.EndHorizontal(); } } } GUILayout.EndScrollView(); if (DrawToggle(ref tfScenario.userSettings.editorWindowLocked, "Lock Window", Styles.styleToggle)) { if (tfScenario.userSettings.editorWindowLocked) { CalculateWindowBounds(); tfScenario.userSettings.editorWindowPosition = WindowRect; DragEnabled = false; } else { DragEnabled = true; } tfScenario.userSettings.Save(); } GUILayout.EndVertical(); }