using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections.ObjectModel;

namespace FLY.FilmCasting.AutoDie.IService
{
    public interface IHeatCellService : INotifyPropertyChanged
    {
        #region 参数
        /// <summary>
        /// HeatOffset = ThickPercent * Kp
        /// </summary>
        double Kp { get; set; }

        /// <summary>
        /// 输出平滑的阀值，只有超出阀值，才平滑
        /// </summary>
        double ThresholdHeatSigma { get; set; }

        /// <summary>
        /// 自控时，不能调整总体上升下降
        /// </summary>
        bool IsForbidUpDown { get; set; }

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

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

        #endregion

        #region 状态
        /// <summary>
        /// 对应的100% 数据，单位是% 数量是 ChannelCnt
        /// </summary>
        double[] ThickPercents { get; }

        /// <summary>
        /// 当前加热策略改变的时间
        /// </summary>
        DateTime LastHeatsChangedTime { get; }
        /// <summary>
        /// 当前加热策略，必须保证 0~100
        /// </summary>
        int[] Heats { get; }

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

        /// <summary>
        /// Heats+Offsets+Base, 必须保证0~100
        /// </summary>
        int[] PreHeats { get; }
                
        /// <summary>
        /// PreHeat 每3个计算的sigma, 最大值
        /// </summary>
        double MaxHeatSigma { get; }

        #endregion

        #region 功能
        /// <summary>
        /// 参数应用
        /// </summary>
        void Apply();
        /// <summary>
        /// 手动调整加热增量
        /// </summary>
        /// <param name="idx"></param>
        /// <param name="change"></param>
        void ModifyOffset(int idx, int change);

        /// <summary>
        /// 参数是 baseheatoffset 的增量
        /// </summary>
        /// <param name="change"></param>
        void ModifyBase(int change);
        
        /// <summary>
        /// 清空HeatOffset
        /// </summary>
        void ClearOffsets();
        
        /// <summary>
        /// 清空PreHeats
        /// </summary>
        void ClearPreHeats();

        /// <summary>
        /// 执行 HeatOffset = ThickPercent * Factor
        /// </summary>
        void Cal();

        /// <summary>
        /// 平滑 PreHeats
        /// </summary>
        void Smooth();

        /// <summary>
        /// 加热输出应用
        /// Heats = PreHeats, Offsets = 0, Base = 0
        /// </summary>
        void HeatApply();
        #endregion
    }
}
