using FLY.Thick.Base.Common;
using FLY.Thick.Base.IService;
using FObjBase;
using FObjBase.Reflect;
using System;

namespace FLY.Thick.Base.Client
{
    public class FlyADServiceClient : FObjBase.Reflect.Reflect_SeviceClient, IFlyADService
    {
        protected override Type InterfaceType => typeof(IFlyADService);
        public FlyADServiceClient(UInt32 serviceId) : base(serviceId) { }
        public FlyADServiceClient(UInt32 serviceId, string connName) : base(serviceId, connName) { }
        #region IFlyAD接口


        public string Addr { get; set; }

        public bool HasCRC { get; set; }


        /// <summary>
        /// grid数据平滑
        /// </summary>
        public int GridSmooth { get; set; }

        public int PosLen { get; set; }

        public MOTORTYPE MotorType { get; set; }

        /// <summary>
        /// // 单位 pulse/grid
        /// </summary>
        public UInt16 PosOfGrid { get; set; }

        public UInt16 Ratio01 { get; set; }


        public UInt16 Ratio02 { get; set; }


        public Int16 PosOffset { get; set; }


        /// <summary>
        /// 脉冲平移
        /// </summary>
        public UInt32 JogVelocity { get; set; }
        public int ADLag { get; set; }
        public bool HasPosMaxMin { get; set; }
        public int PosMin { get; set; }
        public int PosMax { get; set; }

        public int Verson { get; set; }

        public int HardwareVersion { get; set; }


        /// <summary>
        /// 参数应用
        /// </summary>
        public void Apply()
        {
            Call(nameof(Apply));
        }
        /// <summary>
        /// 获取序列码
        /// </summary>
        /// <param name="asyncDelegate"></param>
        /// <param name="asyncContext"></param>
        [Call(typeof(AccessInfo))]
        public void GetAccessInfo(AsyncCBHandler asyncDelegate, object asyncContext)
        {
            Call(nameof(GetAccessInfo), null, asyncDelegate, asyncContext);
        }
        /// <summary>
        /// 设置授权码
        /// </summary>
        /// <param name="access"></param>
        /// <param name="asyncDelegate"></param>
        /// <param name="asyncContext"></param>
        [Call(typeof(AccessInfo))]
        public void SetAccess(byte[] access, AsyncCBHandler asyncDelegate, object asyncContext)
        {
            Call(nameof(SetAccess), new { access }, asyncDelegate, asyncContext);
        }

        /// <summary>
        /// 获取grid
        /// </summary>
        /// <param name="direction"></param>
        /// <param name="asyncDelegate"></param>
        /// <param name="asyncContext"></param>
        [Call(typeof(byte[]))]
        public void GetGrid(Misc.DIRECTION direction, AsyncCBHandler asyncDelegate, object asyncContext)
        {
            Call(nameof(GetGrid), new { direction }, asyncDelegate, asyncContext);
        }

        #endregion
    }
}