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

namespace FLY.FilmCasting.AutoDie.Client
{
    public class FeedbackHeatServiceClient: FObjBase.Reflect.Reflect_SeviceClient, IFeedbackHeatService
    {
        protected override Type InterfaceType => typeof(IFeedbackHeatService);
        #region IFeedbackHeat 成员
        #region 参数
        /// <summary>
        /// 自动控制使能
        /// </summary>
        public bool IsAuto { get; set; }

        /// <summary>
        /// 加热后起效延时(s)
        /// </summary>
        public int Delay { get; set; } = 10;

        /// <summary>
        /// 膜距离 m
        /// 模头到测厚仪的距离
        /// </summary>
        public double FilmLength { get; set; } = 20;

        /// <summary>
        /// 测厚仪厚度数据混合数
        /// </summary>
        public int Mix { get; set; } = 8;

        /// <summary>
        /// 检测功能使能
        /// </summary>
        public bool HasCheck { get; set; }

        /// <summary>
        /// 检测线速度 使能
        /// </summary>
        public bool HasCheckFilmVelocity { get; set; }

        /// <summary>
        /// 手动加热步进
        /// </summary>
        public int Step { get; set; } = 5;


        #endregion


        #region 动态数据
        /// <summary>
        /// 通道数， 从测厚仪获取的！！！！
        /// </summary>
        public int ChannelCnt { get; set; } = 88;

        public int NBolts { get; set; } = 88;


        /// <summary>
        /// 保存的加热策略名称
        /// </summary>
        public string HeatsProductName { get; set; } = "default";

        /// <summary>
        /// 连接到PLC?
        /// </summary>
        public bool IsConnectedWithPLC { get; set; }

        /// <summary>
        /// 上一次加热修改时间
        /// </summary>
        public DateTime LastChangedTime { get; set; }

        #endregion
        #region 异常检测

        /// <summary>
        /// 烧了的加热棒
        /// </summary>
        [PropertyChanged.DoNotCheckEquality]
        public bool[] Bads { get; set; }

        /// <summary>
        /// 当前风机启动中
        /// </summary>
        public bool HasFan { get; set; }

        /// <summary>
        /// 加热棒有电流
        /// </summary>
        public bool HasElectricity { get; set; }
        
        /// <summary>
        /// 当前正在检测的加热通道
        /// </summary>
        public int CheckNo { get; set; } = -2;
        /// <summary>
        /// 正在检测中
        /// </summary>
        public bool CheckEnable { get; set; }



        #endregion
        #endregion
        public FeedbackHeatServiceClient(UInt32 serviceId) : base(serviceId) { }
        public FeedbackHeatServiceClient(UInt32 serviceId, string connName) : base(serviceId, connName) { }
        #region IFeedbackHeat 函数
        public void Apply()
        {
            Call(nameof(Apply));
        }
        /// <summary>
        /// 保存当前加热量
        /// </summary>
        /// <param name="productname"></param>
        public void SaveHeats(string productname)
        {
            Call(nameof(SaveHeats), new { productname });
        }
        /// <summary>
        /// 获取保存的加热量文件列表 返回类型为 List&lt;string&gt;
        /// </summary>
        /// <param name="asyncDelegate"></param>
        /// <param name="asyncContext"></param>
        public void GetHeatsFileList(AsyncCBHandler asyncDelegate, object asyncContext)
        {
            Call(nameof(GetHeatsFileList),null,asyncDelegate, asyncContext);
        }

        /// <summary>
        /// 删除 加热量文件
        /// </summary>
        /// <param name="productname"></param>
        public void DelHeatsFile(string productname) 
        {
            Call(nameof(DelHeatsFile), new { productname });
        }

        /// <summary>
        /// 加载 加热量文件 
        /// </summary>
        /// <param name="filename"></param>
        public void LoadHeatsFile(string productname) 
        {
            Call(nameof(LoadHeatsFile), new { productname });  
        }

        #endregion

        #region 撤销

        /// <summary>
        /// undo 的序号
        /// </summary>
        public long UndoId { get; set; }
        /// <summary>
        /// 在撤销中
        /// </summary>
        public bool IsInUndo { get; set; }

        /// <summary>
        /// 这次撤销动作的时间
        /// </summary>
        public DateTime UndoTime { get; set; }
        //UndoIdx--
        public void Undo()
        {
            Call(nameof(Undo));
        }

        //UndoIdx++
        public void Redo()
        {
            Call(nameof(Redo));
        }

        #endregion


    }

}
