using FLY.KSL.IService;
using FLY.KSL.OBJ_INTERFACE;
using FObjBase;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace FLY.KSL.Client
{
    public class HeatCellServiceClient : FObjBase.Reflect.Reflect_SeviceClient, IHeatCellService
    {
        protected override Type InterfaceType => typeof(IHeatCellService);

        #region IHeatCell 接口 成员变量

        #region 参数
        /// <summary>
        /// HeatOffset = ThickPercent * Kp
        /// </summary>
        public double Kp { get; set; } = 3;

        /// <summary>
        /// 平滑的阀值,只有超出阀值,才平滑
        /// </summary>
        public double ThresholdHeatSigma { get; set; } = 10;

        /// <summary>
        /// 厚度控制线 , 厚度% 大于 厚度控制线 自动才会加热控制  
        /// </summary>
        public int CtrlLine { get; set; }

        /// <summary>
        /// 最大加热量 默认100%
        /// </summary>
        public int MaxHeat { get; set; }
        #endregion
        #region 对位
        /// <summary>
        /// 自动对位
        /// </summary>
        public bool IsAutoONo { get; set; }


        /// <summary>
        /// 当前正在自动对位模式
        /// </summary>
        public AutoONoStatusEnum AutoONoStatus { get; set; }
        /// <summary>
        /// 自动对位模式 信息
        /// </summary>
        public string AutoONoMsg { get; set; }
        /// <summary>
        /// 自动对位 那幅空的图
        /// </summary>
        public long AutoONoId0 { get; set; }
        /// <summary>
        /// 自动对位 加热后生效的图
        /// </summary>
        public long AutoONoId1 { get; set; }

        #endregion

        #region 状态

        /// <summary>
        /// 对应的100% 数据,单位是% 数量是BoltCnt, 数据肯定是完整的!!!!!
        /// </summary>
        public double[] ThickPercents { get; set; }


        /// <summary>
        /// 当前方向的加热策略,必须保证 0~100
        /// </summary>
        public int[] Heats { get; set; }
        /// <summary>
        /// 加热时间
        /// </summary>
        public DateTime HTime { get; set; }
        /// <summary>
        /// 温度当前值
        /// </summary>
        public int[] Currs { get; set; }


        /// <summary>
        /// 加热偏移量
        /// </summary>
        public int[] Offsets { get; set; }


        /// <summary>
        /// Heats+Offsets+Base
        /// </summary>
        public int[] PreHeats { get; set; }


        /// <summary>
        /// 加热量 每3个计算的sigma,最大值
        /// </summary>
        public double MaxHeatSigma { get; set; }


        #endregion
        #endregion

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




        #region IHeatCell 函数
        public void ModifyOffset(int idx, int change)
        {
            Call(nameof(ModifyOffset), new { idx, change });
        }

        public void ModifyBase(int change)
        {
            Call(nameof(ModifyBase), new { change });
        }


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

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

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

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

        public void HeatApply()
        {
            Call(nameof(HeatApply));
        }
        #endregion





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

    }
}