using System;

namespace Plane.Copters
{
#if PRIVATE
    public
#else
    internal
#endif
        enum FlightMode
    {
        // 林俊清，20150608：不可将以下枚举项重命名。

        STABILIZE = 0,          // hold level position

        ACRO = 1,           // rate control // 林俊清, 20160205, 特技模式：http://copter.ardupilot.cn/wiki/acro-mode/

        ALT_HOLD = 2,       // AUTO control

        AUTO = 3,           // AUTO control

        GUIDED = 4,     // AUTO control

        LOITER = 5,     // Hold a single location

        RTL = 6,                // AUTO control

        CIRCLE = 7,

        POSITION = 8,   // 林俊清, 20160205, 位置模式：http://copter.ardupilot.cn/wiki/POSITION-mode/

        LAND = 9,               // AUTO control

        OF_LOITER = 10, // 林俊清, 20160205, 光流悬停模式：http://copter.ardupilot.cn/wiki/loiter-mode/ 底部。

        TOY = 11
    }

    internal static class FightModeExtensions
    {
        public static string GetModeString(this FlightMode flightMode)
        {
            switch (flightMode)
            {
                case FlightMode.ALT_HOLD:
                    return "ALT HOLD";

                case FlightMode.POSITION:
                    return "POS HOLD";

                default:
                    return Enum.GetName(typeof(FlightMode), flightMode);
            }
        }

        public static bool NeedGps(this FlightMode flightMode)
        {
            switch (flightMode)
            {
                case FlightMode.AUTO:
                case FlightMode.GUIDED:
                case FlightMode.LOITER:
                case FlightMode.RTL:
                case FlightMode.CIRCLE:
                case FlightMode.LAND:
                case FlightMode.POSITION:
                default:
                    return true;

                case FlightMode.STABILIZE:
                case FlightMode.ACRO:
                case FlightMode.ALT_HOLD:
                case FlightMode.OF_LOITER:
                case FlightMode.TOY:
                    return false;
            }
        }

        internal static PlaneCopter.ac2modes ToAC2Mode(this FlightMode flightMode)
        {
            return (PlaneCopter.ac2modes)flightMode;
        }
    }
}
