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

namespace FLY.FilmCasting.AutoDie.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 bool IsForbidUpDown { get; set; }


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

        /// <summary>
        /// 最大加热量 默认100%
        /// </summary>
        public int MaxHeat { get; set; }
        #endregion


        #region 状态

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

        /// <summary>
        /// 当前加热策略改变的时间
        /// </summary>
        public DateTime LastHeatsChangedTime { get; set; }

        /// <summary>
        /// 当前方向的加热策略，必须保证 0~100
        /// </summary>
        public int[] Heats { get; set; }


        private int Base { 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));
        }

    }
}
