using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NEIntelligentControl2.Models.Windturbine
{
    /// <summary>
    /// 风机信息
    /// </summary>
    public class WindturbineInfo
    {
        /// <summary>
        /// 风机编号
        /// </summary>
        public string WindturbineId { set; get; }
        /// <summary>
        /// 风机型号
        /// </summary>
        public string ModelId { set; get; }
        /// <summary>
        /// 风场编号
        /// </summary>
        public string StationId { set; get; }
        private int id = -1;
        /// <summary>
        /// 风机序号
        /// </summary>
        public int ID
        {
            get
            {
                if (id < 0)
                {
                    if (WindturbineId == null) return id;
                    var vs = WindturbineId.Substring(2);
                    int.TryParse(vs, out id);
                }
                return id;
            }
        }
        private string name;
        public string Name
        {
            get
            {
                if (name != null) return name;
                var vs = WindturbineId.Split('_');
                name = $"{vs[0].Substring(0, vs[0].Length - 2)}{vs[1]}";
                return name;
            }
            set => name = value;
        }
        public string Code { get; set; }
        /// <summary>
        /// 项目编号
        /// </summary>
        public string ProjectId { get; set; }

        /// <summary>
        /// 风速统一编码 
        /// </summary>
        public string WindSpeedCode { set; get; }

        /// <summary>
        /// 功率统一编码 
        /// </summary>
        public string PowerCode { set; get; }

        /// <summary>
        /// 转速统一编码 
        /// </summary>
        public string RollSpeedCode { set; get; }

        /// <summary>
        /// 状态统一编码
        /// </summary>
        public string StatusCode { set; get; }

        /// <summary>
        /// 挂牌统一编码
        /// </summary>
        public string LockCode { set; get; }

        /// <summary>
        /// 风速值
        /// </summary>
        public double WindSpeed { set; get; }


        /// <summary>
        /// 功率值
        /// </summary>
        public double Power { set; get; }

        /// <summary>
        /// 转速值
        /// </summary>
        public double RollSpeed { set; get; }

        /// <summary>
        /// 状态值
        /// </summary>
        public double Status { set; get; }
        /// <summary>
        /// 风机状态
        /// </summary>
        public WindturbineState State { get => (WindturbineState)Status; }
        /// <summary>
        /// 挂牌状态
        /// </summary>
        public double LockValue { set; get; }
        /// <summary>
        /// 是否挂牌
        /// </summary>
        public bool IsLocked { get => LockValue > 0; }
        /// <summary>
        /// 状态持续时长
        /// </summary>
        public long Ts { set; get; }
        /// <summary>
        /// 挂牌类型
        /// </summary>
        public HungType LockType { get; set; }
        /// <summary>
        /// 控制类型
        /// </summary>
        public OperateStyle OperateStyle { get; set; }
    }
}
