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

namespace FLY.Thick.Base.Client
{
    public class ScanCorrServiceClient : FObjBase.Reflect.Reflect_SeviceClient, IScanCorrService
    {
        protected override Type InterfaceType => typeof(IScanCorrService);

        public ScanCorrServiceClient(UInt32 serviceId) : base(serviceId)
        {
        }
        public ScanCorrServiceClient(UInt32 serviceId, string connName) : base(serviceId, connName)
        {

        }

        /// <summary>
        /// 使能修正
        /// </summary>
        public bool Enable { set; get; }

        /// <summary>
        /// 当前修正的组
        /// </summary>
        public int CurrGroupIndex { get; set; }
        /// <summary>
        /// 当前进度 0 - 100 
        /// </summary>
        public int Progress { get; set; }

        /// <summary>
        /// 数据更新时间
        /// </summary>
        public DateTime[] UpdateTimes { get; set; }

        /// <summary>
        /// 正在机架修正中
        /// </summary>
        public bool IsRunning { get; set; }

        /// <summary>
        /// 来回次数
        /// </summary>
        public int ScanCnt { get; set; }

        /// <summary>
        /// 平滑
        /// </summary>
        public int SmoothFactor { get; set; }
        /// <summary>
        /// 开始机架修正
        /// </summary>
        /// <param name="groupIndex">组序号</param>
        /// <param name="scanCnt">扫描次数</param>
        /// <param name="smoothFactor">平滑</param>
        public void Start(int groupIndex, int scanCnt, int smoothFactor)
        {
            Call(nameof(Start), new { groupIndex = groupIndex, scanCnt = scanCnt, smoothFactor = smoothFactor });
        }

        /// <summary>
        /// 清空组数据
        /// </summary>
        /// <param name="groupIndex"></param>
        public void Clear(int groupIndex)
        {
            Call(nameof(Clear), new { groupIndex = groupIndex });
        }

        /// <summary>
        /// 设置修正曲线
        /// </summary>
        /// <param name="groupIndex">组序号</param>
        /// <param name="corrDatas">修正数据</param>
        /// <param name="avg">均值</param>
        /// <param name="orgDatas">原始数据</param>
        public void SetCorrData(int groupIndex, int[][] corrDatas, int avg, int[][] orgDatas)
        {
            Call(nameof(SetCorrData), new { groupIndex = groupIndex, corrDatas = corrDatas, avg = avg, orgDatas = orgDatas });
        }


        [Call(typeof(GetScanCorrGroupResponse))]
        public void GetScanCorrGroup(int groupIndex, AsyncCBHandler asyncDelegate, object asyncContext)
        {
            Call(nameof(GetScanCorrGroup), new { groupIndex = groupIndex }, asyncDelegate, asyncContext);
        }

    }


}
