using FLY.FilmCasting.AutoDie.Common;
using FLY.FilmCasting.AutoDie.IService;
using FLY.FilmCasting.AutoDie.OBJ_INTERFACE;
using FLY.FilmCasting.AutoDie.Server.Model;
using FObjBase;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace FLY.FilmCasting.AutoDie.Client
{
    public class HeatBufServiceClient : FObjBase.Reflect.Reflect_SeviceClient, IHeatBufService
    {
        protected override Type InterfaceType => typeof(IHeatBufService);
        #region 属性，对外接口
        #region 参数

        /// <summary>
        /// 分区表
        /// </summary>
        public BoltMapCell[] Boltmap { get; set; }

        /// <summary>
        /// 加热生效曲线,允许为空，则不生效
        /// </summary>
        public int[] HeatEffectCurve { get; set; } 


        /// <summary>
        /// 厚度稳定范围 %， 偏差在范围内，都是稳定的 
        /// </summary>
        public int StableRange { get; set; } = 2;




        /// <summary>
        /// 对位模式, 加热与厚度相关性阀值, 相关性 >=0.7
        /// </summary>
        public double ThresholdR { get; set; } = 0.7;


        /// <summary>
        /// 对位模式 厚度%差 的极差 >= +4%-4%=8%， 单位%
        /// </summary>
        public int ThresholdMaxMin { get; set; } = 8;


        /// <summary>
        /// ％
        /// 最大sigma, 只有当前的sigma  在 最大sigma 与 最小 sigma 内，才能控制
        /// </summary>
        public int ThresholdSigmaMax { get; set; } = 20;

        
        #endregion

        #region 状态


        /// <summary>
        /// 总延时 =Delay+mRenZiJiaService.FilmLength/mRenZiJiaService.Velocity
        /// </summary>
        public TimeSpan Delay { get; set; } = TimeSpan.FromSeconds(100);


        #region 稳定性

        /// <summary>
        /// 当前检测出来的厚度数据 稳定状态
        /// </summary>
        public STABILITY Stability { get; set; } = STABILITY.IDLE;



        /// <summary>
        /// 当前检测出来的厚度数据 的稳定性 
        /// </summary>
        public double CurrR { get; set; } = -1;


        /// <summary>
        /// 当前检测出来的厚度数据 2Sigma
        /// </summary>
        public double Curr2Sigma { get; set; } = -1;


        /// <summary>
        /// 当前检测出来的厚度数据，时间
        /// </summary>
        public DateTime CurrTime { get; set; } = DateTime.MinValue;



        #endregion


        #endregion


        #endregion

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


        public void Apply()
        {
            Call(nameof(Apply));
        }




    }
}
