using FLY.Thick.Base.Common;
using FObjBase.Reflect;
using System;
using System.ComponentModel;

namespace FLY.Thick.Base.IService
{
    /// <summary>
    /// 膜位置检测;
    /// 通过辊接近开关，或者编码器2;
    /// 支持同步;
    /// </summary>
    public interface IFilmPositionDetectService : INotifyPropertyChanged
    {
        #region 状态

        /// <summary>
        /// 线速度 m/min
        /// </summary>
        double FilmVelocity { get; }

        /// <summary>
        /// 膜位置， m
        /// </summary>
        double FilmPosition { get; }

        /// <summary>
        /// 复位标识，从同步服务器发送过来的
        /// </summary>
        int ResetMark { get; }
        #endregion

        #region 参数
        /// <summary>
        /// 线速度阀值，低于阀值，速度直接变为0
        /// </summary>
        double FilmVThreshold { get; set; }

        /// <summary>
        /// 线速度来源
        /// </summary>
        FilmVSRC FilmVSrc { get; set; }

        /// <summary>
        /// 线速度:编码器2 mm/pulse
        /// </summary>
        double Encoder2_mmpp { get; set; }

        /// <summary>
        /// 线速度:1圈多少mm
        /// </summary>
        double MmOfR { get; set; }


        #endregion


        /// <summary>
        /// 设置膜位置为某值
        /// </summary>
        /// <param name="filmPos">极片位置m</param>
        void Reset(double filmPos);


        /// <summary>
        /// 让同步信号输出 1->0
        /// </summary>
        void SyncSysTime();

        /// <summary>
        /// 纵向光纤传感器检测到 0到1 变化 事件 
        /// 或
        /// sysTime同步信号触发 0到1 变化 事件 
        /// </summary>
        [Push(typeof(SysTimeFilmPosEventArgs))]
        event EventHandler SysTimeFilmPosEvent;

        /// <summary>
        /// 设置膜位置为某值; 同步服务器调用的
        /// </summary>
        /// <param name="filmPos">极片位置m</param>
        /// <param name="sysTime">AD盒sysTime</param>
        /// <param name="resetMark">复位标识</param>
        void Reset(double filmPos, DateTime sysTime, int resetMark);

    }

    /// <summary>
    /// 从 0 到 1 时极片位置事件
    /// </summary>
    public class SysTimeFilmPosEventArgs : EventArgs
    {
        /// <summary>
        /// sysTime 的同步信号触发
        /// </summary>
        public bool IsSysTimeSync;

        /// <summary>
        /// AD盒的SysTime
        /// </summary>
        public DateTime SysTime;

        /// <summary>
        /// 极片位置单位m, 精度0.000m
        /// </summary>
        public double FilmPos;
    }


    /// <summary>
    /// 
    /// </summary>
    /// <param name="s"></param>
    /// <param name="e"></param>
    public delegate void SysTimeFilmPosEventHandler(object s, SysTimeFilmPosEventArgs e);


}
