using Plane.Communication;
using System.Threading;
using System.Threading.Tasks;

namespace Plane.Copters
{
    /// <summary>
    /// <see cref="ICopter"/> 的空白实现。
    /// </summary>
    public partial class EmptyCopter : CopterImplSharedPart, ICopter
    {
        private EmptyCopter(SynchronizationContext uiSyncContext) : base(uiSyncContext)
        {
        }

        public static EmptyCopter Instance { get; } = new EmptyCopter(SynchronizationContext.Current);

        public IConnection Connection { get; set; } = EmptyConnection.Instance;

        public string Id { get; } = "EmptyCopter";

        public Task ConnectAsync()
        {
            return TaskUtils.CompletedTask;
        }

        public Task DisconnectAsync()
        {
            return TaskUtils.CompletedTask;
        }

        public Task GetCopterDataAsync()
        {
            return TaskUtils.CompletedTask;
        }

        public Task<float> GetParamAsync(string paramName, int millisecondsTimeout = -1)
        {
            return Task.FromResult(0f);
        }

        public Task LockAsync()
        {
            return TaskUtils.CompletedTask;
        }

        public override Task SetChannelsAsync()
        {
            return TaskUtils.CompletedTask;
        }

        public override Task SetMobileControlAsync()
        {
            return TaskUtils.CompletedTask;
        }

        public Task SetParamAsync(string paramName, float value, int millisecondsTimeout = -1)
        {
            return TaskUtils.CompletedTask;
        }
        public  Task SetShowLEDFlashAsync(int Flashtype, int millisecondsTime)
        {
            return TaskUtils.CompletedTask;
        }

        public bool GetShowLEDAsync()
        {
            return false;
        }
        public Task SetShowLEDAsync(bool Ledon)
        {
            return TaskUtils.CompletedTask;
        }

        public Task StartPairingAsync()
        {
            return TaskUtils.CompletedTask;
        }

        public Task StopPairingAsync()
        {
            return TaskUtils.CompletedTask;
        }

        public Task TakeOffAsync(float alt)
        {
            return TaskUtils.CompletedTask;
        }

        public Task UnlockAsync()
        {
            return TaskUtils.CompletedTask;
        }

        internal override Task<bool> SetModeCoreAsync(FlightMode mode, int millisecondsTimeout = 5000)
        {
            return Task.FromResult(true);
        }

        protected override Task FlyToCoreAsync(double lat, double lng, float alt)
        {
            return TaskUtils.CompletedTask;
        }
    }

#if PRIVATE

    public partial class EmptyCopter : CopterImplSharedPart, ICopter
    {
        public Task RebootAsync(bool bootloaderMode = false)
        {
            return TaskUtils.CompletedTask;
        }
    }

#endif
}
