using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using FLY.Thick.Base.Common;
using System.Collections.ObjectModel;
using Misc;
using FObjBase.Reflect;
using FObjBase;

namespace FLY.Thick.Base.IService
{
    public interface IScanCorrService : INotifyPropertyChanged
    {
        /// <summary>
        /// 使能修正
        /// </summary>
        bool Enable{set;get;}

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

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

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

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

        /// <summary>
        /// 平滑
        /// </summary>
        int SmoothFactor { get; }

        /// <summary>
        /// 开始机架修正
        /// </summary>
        /// <param name="groupIndex">组序号</param>
        /// <param name="scanCnt">扫描次数</param>
        /// <param name="smoothFactor">平滑</param>
        void Start(int groupIndex, int scanCnt, int smoothFactor);

        /// <summary>
        /// 清空组数据
        /// </summary>
        /// <param name="groupIndex"></param>
        void Clear(int groupIndex);

        /// <summary>
        /// 设置修正曲线
        /// </summary>
        /// <param name="groupIndex">组序号</param>
        /// <param name="corrDatas">修正数据</param>
        /// <param name="avg">均值</param>
        void SetCorrData(int groupIndex, int[][] corrDatas, int avg);


        [Call(typeof(GetScanCorrGroupResponse))]
        void GetScanCorrGroup(int groupIndex, AsyncCBHandler asyncDelegate, object asyncContext);

    }

    public class GetScanCorrGroupResponse
    {
        /// <summary>
        /// 组序号
        /// </summary>
        public int GroupIndex;
        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime UpdateTime;

        /// <summary>
        /// 机架准备好了
        /// </summary>
        public bool IsDataOK;

        /// <summary>
        /// 机架总长，脉冲
        /// </summary>
        public int PosLen;

        /// <summary>
        /// 1个grid = N个pos
        /// </summary>
        public int PosOfGrid;

        /// <summary>
        /// 原始 正反方向机架AD值数据, grid数据
        /// </summary>
        public int[][] OrgDatas;

        /// <summary>
        /// 修正用 正反方向机架AD值数据
        /// </summary>
        public int[][] CorrDatas;

        /// <summary>
        /// CorrDatas 的均值
        /// </summary>
        public int Avg;
    }
    


    

}
