using System;

namespace MECF.Framework.Common.MultiProcess.ProcessCenter
{
    //使用加热基数作为逻辑判断条件，S栋目前最多支持4个加热基数，   一个ProcessIdle是一个加热基数，Run是两个加热基数
    public class PMProcessData : ICloneable
    {
        /// <summary>
        /// 设备名
        /// </summary>
        public string SicMachineName { get; set; }

        public bool IsOnline { get; set; }


        public int OffLineNum { get; set; }

        /// <summary>
        /// PM名称
        /// </summary>
        public string PmName { get; set; }

        private string _pmRunState = "0";

        /// <summary>
        /// PM腔体RUN基数
        /// </summary>
        public string PmRunState
        {
            get => _pmRunState;
            set
            {
                _pmRunState = value;
                int heat;
                if (int.TryParse(_pmRunState, out heat))
                    Heat = heat;
            }
        }

        /// <summary>
        /// PM腔体当前状态
        /// </summary>
        public string PmState { get; set; }

        /// <summary>
        /// 保温状态，0, 1, 2
        /// </summary>
        public int Heat { get; set; }

        public string SicMachineID { get; set; }

        public string StateChangeTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

        public DateTime HeartBeatTime { get; set; } = DateTime.Now;

        public object Clone()
        {
            return new PMProcessData()
            {
                SicMachineName = SicMachineName,
                IsOnline = IsOnline,
                OffLineNum = OffLineNum,
                PmName = PmName,
                PmState = PmState,
                PmRunState = PmRunState,
                Heat = Heat,
                SicMachineID = SicMachineID,
                StateChangeTime = StateChangeTime,
                HeartBeatTime = HeartBeatTime
            };
        }

        public void Reset()
        {
            Heat = 0;
            _pmRunState = "0";
        }
    }
}