using System;
using System.ComponentModel;

namespace FLY.Thick.Base.Common
{
    /// <summary>
    /// 动态数据，推送当前所有状态
    /// </summary>
    public class DynArea : INotifyPropertyChanged
    {
        public DynArea()
        {

        }

        /// <summary>
        /// 通过 Fody.PropertyChanged 自动调用
        /// OnXXXChanged
        /// </summary>
        /// <param name="before"></param>
        /// <param name="after"></param>
        void OnHrsChanged(object before, object after)
        {
            SecuteLock = Hrs <= 0;
        }

        #region BASE

        /// <summary>
        /// AD 值经过 曲线转换的 测量值
        /// </summary>
        public double Thk { get; set; } = 100.23;

        /// <summary>
        /// 编码器1 位置 脉冲
        /// </summary>
        public int Position { get; set; }
        /// <summary>
        /// 测厚仪位置mm
        /// </summary>
        public double PosMm { get; set; }
        /// <summary>
        /// AD值
        /// </summary>
        public int AD { get; set; } = 12345;

        /// <summary>
        /// 最大AD值
        /// </summary>
        public int ADMax { get; set; } = 65535;
        #endregion

        #region POSITION2

        /// <summary>
        /// 编码器2 位置 脉冲
        /// </summary>
        public int Position2 { get; set; }
        #endregion

        #region 扫描

        /// <summary>
        /// 数据是否有效， 当膜没有动时，为无效。 通过PLC获取，或编码器判断
        /// </summary>
        public bool DataValid { get; set; }

        /// <summary>
        /// 膜宽 mm
        /// </summary>
        public double Width { get; set; }
        /// <summary>
        /// 生产速度 m/min
        /// </summary>
        public double FilmVelocity { get; set; }
        /// <summary>
        /// 膜生产位置 m
        /// </summary>
        public double FilmPosition { get; set; }
        /// <summary>
        /// 测厚仪速度 m/min
        /// </summary>
        public double Velocity { get; set; }
        #endregion

        #region 运行状态
        /// <summary>
        /// 运行状态
        /// </summary>
        public CTRL_STATE ControllerState { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public int AutoScanCounter { get; set; } = 5;

        /// <summary>
        /// 测试模式
        /// </summary>
        public bool IsTest { get; set; }

        #endregion

        #region IO

        public UInt16 IStatus { get; set; } = 0xffff;

        public UInt16 OStatus { get; set; } = 0xffff;

        #endregion

        #region 系统
        /// <summary>
        /// 系统剩余小时数
        /// </summary>
        public int Hrs { get; set; } = 3;

        /// <summary>
        /// FLYAD 连接状态
        /// </summary>
        public bool FLYADIsConnect { get; set; }

        /// <summary>
        /// 过期， 锁ing
        /// </summary>
        public bool SecuteLock { get; set; }

        #endregion

        #region INotifyPropertyChanged 成员

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}
