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

namespace NEIntelligentControl2.Models.PV
{
    /// <summary>
    /// 光伏信息
    /// </summary>
    public class PVInfo
    {
        /// <summary>
        /// 场站ID
        /// </summary>
        public string Station { get; set; }
        /// <summary>
        /// 期次
        /// </summary>
        public string Project { get; set; }
        /// <summary>
        /// 线路
        /// </summary>
        public string Line { get; set; }
        /// <summary>
        /// 机型
        /// </summary>
        public string Model { get; set; }
        /// <summary>
        /// 光伏设备ID
        /// </summary>
        public string Id { get; set; }
        /// <summary>
        /// 设备名称
        /// </summary>
        public string Code { get; set; }
        /// <summary>
        /// 光伏电流
        /// </summary>
        public double I { get; set; }
        /// <summary>
        /// 光伏电压
        /// </summary>
        public double U { get; set; }
        /// <summary>
        /// 光伏功率
        /// </summary>
        public double P { get; set; }
        /// <summary>
        /// 时间戳
        /// </summary>
        public long Ts { get; set; }
        /// <summary>
        /// 状态
        /// </summary>
        public double Status { get; set; }
        /// <summary>
        /// 状态
        /// </summary>
        public PVState State { get => (PVState)Status; }
        private int index = -1;
        /// <summary>
        /// 设备序号
        /// </summary>
        public int Index
        {
            get
            {
                if (index < 0)
                {
                    if (Id == null) return index;
                    var vs = Id.Split('_');
                    if (vs.Length < 2) return index;
                    int.TryParse(vs[1], out index);
                }
                return index;
            }
        }
    }
}
