public void Display() { GUILayout.BeginHorizontal(); simMode = (SimMode)GUILayout.SelectionGrid((int)simMode, SimMode_str, 2); GUILayout.EndHorizontal(); StabilityDerivOutput vehicleData = simManager.vehicleData; if (simMode == SimMode.LONG) { LongitudinalGUI(vehicleData); DataInput(lonConditions, vehicleData, true); } else { LateralGUI(vehicleData); DataInput(latConditions, vehicleData, false); } GUIStyle BackgroundStyle = new GUIStyle(GUI.skin.box); BackgroundStyle.hover = BackgroundStyle.active = BackgroundStyle.normal; _graph.Display(BackgroundStyle, 0, 0); //graph.Display(GUILayout.Width(540), GUILayout.Height(300)); DrawTooltip(); }
private void SimulationGUI(bool tmp) { GUIStyle TabLabelStyle = new GUIStyle(GUI.skin.label); TabLabelStyle.fontStyle = FontStyle.Bold; TabLabelStyle.alignment = TextAnchor.UpperCenter; if (tmp) { windowPos.height = 600; windowPos.width = 650; graph.Clear(); } GUILayout.BeginHorizontal(); simMode = (SimMode)GUILayout.SelectionGrid((int)simMode, SimMode_str, 2, ButtonStyle); stabDerivHelp = GUILayout.Toggle(stabDerivHelp, "?", ButtonStyle, GUILayout.Width(200)); GUILayout.EndHorizontal(); if (simMode == SimMode.LONG) { GUILayout.BeginHorizontal(); GUILayout.Label("Longitudinal Derivatives", GUILayout.Width(160)); GUILayout.EndHorizontal(); GUILayout.BeginVertical(BackgroundStyle); GUILayout.BeginHorizontal(); GUILayout.Label("Down Vel Derivatives", GUILayout.Width(160)); GUILayout.Label("Fwd Vel Derivatives", GUILayout.Width(160)); GUILayout.Label("Pitch Rate Derivatives", GUILayout.Width(160)); GUILayout.Label("Pitch Ctrl Derivatives", GUILayout.Width(160)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); StabilityLabel("Zw: ", MOI_stabDerivs[3], " s⁻¹", "Change in Z-direction acceleration with respect to Z-direction velocity; should be negative", 160, -1); StabilityLabel("Zu: ", MOI_stabDerivs[6], " s⁻¹", "Change in Z-direction acceleration with respect to X-direction velocity; should be negative", 160, -1); StabilityLabel("Zq: ", MOI_stabDerivs[9], " m/s", "Change in Z-direction acceleration with respect to pitch-up rate; sign unimportant", 160, 0); StabilityLabel("Zδe: ", MOI_stabDerivs[12], " m/s²", "Change in Z-direction acceleration with respect to pitch control input; should be negative", 160, -1); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); StabilityLabel("Xw: ", MOI_stabDerivs[4], " s⁻¹", "Change in X-direction acceleration with respect to Z-direction velocity; should be positive", 160, 1); StabilityLabel("Xu: ", MOI_stabDerivs[7], " s⁻¹", "Change in X-direction acceleration with respect to X-direction velocity; should be negative", 160, -1); StabilityLabel("Xq: ", MOI_stabDerivs[10], " m/s", "Change in X-direction acceleration with respect to pitch-up rate; sign unimportant", 160, 0); StabilityLabel("Xδe: ", MOI_stabDerivs[13], " m/s²", "Change in X-direction acceleration with respect to pitch control input; sign unimportant", 160, 0); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); StabilityLabel("Mw: ", MOI_stabDerivs[5], " (m * s)⁻¹", "Change in pitch-up angular acceleration with respect to Z-direction velocity; should be negative", 160, -1); StabilityLabel("Mu: ", MOI_stabDerivs[8], " (m * s)⁻¹", "Change in pitch-up angular acceleration acceleration with respect to X-direction velocity; sign unimportant", 160, 0); StabilityLabel("Mq: ", MOI_stabDerivs[11], " s⁻¹", "Change in pitch-up angular acceleration acceleration with respect to pitch-up rate; should be negative", 160, -1); StabilityLabel("Mδe: ", MOI_stabDerivs[14], " s⁻²", "Change in pitch-up angular acceleration acceleration with respect to pitch control input; should be positive", 160, 1); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.BeginHorizontal(); GUILayout.Label("Init u: "); u_init = GUILayout.TextField(u_init, GUILayout.ExpandWidth(true)); GUILayout.Label("Init w: "); w_init = GUILayout.TextField(w_init, GUILayout.ExpandWidth(true)); GUILayout.Label("Init q: "); q_init = GUILayout.TextField(q_init, GUILayout.ExpandWidth(true)); GUILayout.Label("Init θ: "); θ_init = GUILayout.TextField(θ_init, GUILayout.ExpandWidth(true)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("End Time: "); time_end = GUILayout.TextField(time_end, GUILayout.ExpandWidth(true)); GUILayout.Label("dT: "); dT = GUILayout.TextField(dT, GUILayout.ExpandWidth(true)); if (GUILayout.Button("Run Simulation", ButtonStyle, GUILayout.Width(150.0F), GUILayout.Height(25.0F))) { u_init = Regex.Replace(u_init, @"[^-?\d*\.?\d*]", ""); w_init = Regex.Replace(w_init, @"[^-?\d*\.?\d*]", ""); q_init = Regex.Replace(q_init, @"[^-?\d*\.?\d*]", ""); θ_init = Regex.Replace(θ_init, @"[^-?\d*\.?\d*]", ""); time_end = Regex.Replace(time_end, @"[^-?\d*\.?\d*]", ""); dT = Regex.Replace(dT, @"[^-?\d*\.?\d*]", ""); double[] InitCond = new double[4] { Convert.ToDouble(w_init), Convert.ToDouble(u_init), Convert.ToDouble(q_init) * Math.PI / 180, Convert.ToDouble(θ_init) * Math.PI / 180 }; RunTransientSimLongitudinal(Convert.ToDouble(time_end), Convert.ToDouble(dT), InitCond); } GUILayout.EndHorizontal(); } else { GUILayout.BeginHorizontal(); GUILayout.Label("Lateral Derivatives", GUILayout.Width(160)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Sideslip Derivatives", GUILayout.Width(160)); GUILayout.Label("Roll Rate Derivatives", GUILayout.Width(160)); GUILayout.Label("Yaw Rate Derivatives", GUILayout.Width(160)); GUILayout.EndHorizontal(); GUILayout.BeginVertical(BackgroundStyle); GUILayout.BeginHorizontal(); StabilityLabel("Yβ: ", MOI_stabDerivs[15], " m/s²", "Change in Y-direction acceleration with respect to sideslip angle β; should be negative", 160, -1); StabilityLabel("Yp: ", MOI_stabDerivs[18], " m/s", "Change in Y-direction acceleration with respect to roll-right rate; should be negative", 160, -1); StabilityLabel("Yr: ", MOI_stabDerivs[21], " m/s", "Change in Y-direction acceleration with respect to yaw-right rate; should be positive", 160, 1); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); StabilityLabel("Lβ: ", MOI_stabDerivs[16], " s⁻²", "Change in roll-right angular acceleration with respect to sideslip angle β; should be negative", 160, -1); StabilityLabel("Lp: ", MOI_stabDerivs[19], " s⁻¹", "Change in roll-right angular acceleration with respect to roll-right rate; should be negative", 160, -1); StabilityLabel("Lr: ", MOI_stabDerivs[22], " s⁻¹", "Change in roll-right angular acceleration with respect to yaw-right rate; should be positive", 160, 1); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); StabilityLabel("Nβ: ", MOI_stabDerivs[17], " s⁻²", "Change in yaw-right angular acceleration with respect to sideslip angle β; should be positive", 160, 1); StabilityLabel("Np: ", MOI_stabDerivs[20], " s⁻¹", "Change in yaw-right angular acceleration with respect to roll-right rate; sign unimportant", 160, 0); StabilityLabel("Nr: ", MOI_stabDerivs[23], " s⁻¹", "Change in yaw-right angular acceleration with respect to yaw-right rate; should be negative", 160, -1); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.BeginHorizontal(); GUILayout.Label("Init β: "); beta_init = GUILayout.TextField(beta_init, GUILayout.ExpandWidth(true)); GUILayout.Label("Init r: "); r_init = GUILayout.TextField(r_init, GUILayout.ExpandWidth(true)); GUILayout.Label("Init p: "); p_init = GUILayout.TextField(p_init, GUILayout.ExpandWidth(true)); GUILayout.Label("Init φ: "); φ_init = GUILayout.TextField(φ_init, GUILayout.ExpandWidth(true)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("End Time: "); time_end = GUILayout.TextField(time_end, GUILayout.ExpandWidth(true)); GUILayout.Label("dT: "); dT = GUILayout.TextField(dT, GUILayout.ExpandWidth(true)); if (GUILayout.Button("Run Simulation", ButtonStyle, GUILayout.Width(150.0F), GUILayout.Height(25.0F))) { beta_init = Regex.Replace(beta_init, @"[^-?\d*\.?\d*]", ""); r_init = Regex.Replace(r_init, @"[^-?\d*\.?\d*]", ""); p_init = Regex.Replace(p_init, @"[^-?\d*\.?\d*]", ""); φ_init = Regex.Replace(φ_init, @"[^-?\d*\.?\d*]", ""); time_end = Regex.Replace(time_end, @"[^-?\d*\.?\d*]", ""); dT = Regex.Replace(dT, @"[^-?\d*\.?\d*]", ""); double[] InitCond = new double[4] { Convert.ToDouble(beta_init) * Math.PI / 180, Convert.ToDouble(p_init) * Math.PI / 180, Convert.ToDouble(r_init) * Math.PI / 180, Convert.ToDouble(φ_init) * Math.PI / 180 }; RunTransientSimLateral(Convert.ToDouble(time_end), Convert.ToDouble(dT), InitCond); } GUILayout.EndHorizontal(); } graph.Display(BackgroundStyle, 0, 0); DrawTooltip(); }