/// <summary> /// Remove a specific state-control pair from the current configuration /// </summary> /// <param name="state">the state to remove</param> /// <returns>true if removal is successful</returns> public bool RemoveState(StateType state) { bool result = false; mode = TrimMode.Custom; foreach (TrimAxis iAxes in TrimAxes) { if (iAxes.GetStateType() == state) { TrimAxes.Remove(iAxes); result = true; continue; } } if (result) { sub_iterations = new double[TrimAxes.Count]; successful = new double[TrimAxes.Count]; solution = new bool[TrimAxes.Count]; } return(result); }
/// <summary> /// Add a state-control pair to the current configuration. See the enums /// State and Control in TrimAxis.h for the available options. /// Will fail if the given state is already configured. /// </summary> /// <param name="state">the accel or other condition to zero</param> /// <param name="control">the control used to zero the state</param> /// <returns>true if add is successful</returns> public bool AddState(StateType state, ControlType control) { bool result = true; mode = TrimMode.Custom; //vector <TrimAxis*>::iterator iAxes = TrimAxes.begin(); foreach (TrimAxis iAxes in TrimAxes) { if (iAxes.GetStateType() == state) { result = false; } } if (result) { TrimAxes.Add(new TrimAxis(fdmex, fgic, state, control)); sub_iterations = new double[TrimAxes.Count]; successful = new double[TrimAxes.Count]; solution = new bool[TrimAxes.Count]; } return(result); }
/// <summary> /// Clear all state-control pairs from the current configuration. /// The trimming routine must have at least one state-control pair /// configured to be useful /// </summary> public void ClearStates() { mode = TrimMode.Custom; TrimAxes.Clear(); }
/// <summary> /// Clear all state-control pairs and set a predefined trim mode /// </summary> /// <param name="tm">the set of axes to trim. Can be: /// tLongitudinal, tFull, tGround, tCustom, or tNone</param> public void SetMode(TrimMode tm) { ClearStates(); mode = tm; switch (tm) { case TrimMode.Full: if (log.IsDebugEnabled) { log.Debug(" Full Trim"); } TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Wdot, ControlType.Alpha)); TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Udot, ControlType.Throttle)); TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Qdot, ControlType.PitchTrim)); TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Hmgt, ControlType.Beta)); TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Vdot, ControlType.Phi)); TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Pdot, ControlType.Aileron)); TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Rdot, ControlType.Rudder)); break; case TrimMode.Longitudinal: if (log.IsDebugEnabled) { log.Debug(" Longitudinal Trim"); } TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Wdot, ControlType.Alpha)); TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Udot, ControlType.Throttle)); TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Qdot, ControlType.PitchTrim)); break; case TrimMode.Ground: if (log.IsDebugEnabled) { log.Debug(" Ground Trim"); } TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Wdot, ControlType.AltAGL)); TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Qdot, ControlType.Theta)); //TrimAxes.push_back(new TrimAxis(fdmex,fgic,tPdot,tPhi )); break; case TrimMode.Pullup: TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Nlf, ControlType.Alpha)); TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Udot, ControlType.Throttle)); TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Qdot, ControlType.PitchTrim)); TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Hmgt, ControlType.Beta)); TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Vdot, ControlType.Phi)); TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Pdot, ControlType.Aileron)); TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Rdot, ControlType.Rudder)); break; case TrimMode.Turn: TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Wdot, ControlType.Alpha)); TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Udot, ControlType.Throttle)); TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Qdot, ControlType.PitchTrim)); TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Vdot, ControlType.Beta)); TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Pdot, ControlType.Aileron)); TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Rdot, ControlType.Rudder)); break; case TrimMode.Custom: case TrimMode.None: break; } //cout + "TrimAxes.size(): " + TrimAxes.size() + endl; sub_iterations = new double[TrimAxes.Count]; successful = new double[TrimAxes.Count]; solution = new bool[TrimAxes.Count]; current_axis = 0; }