using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WjwLib.API.System;

namespace GatewayTool.Models
{
    [Serializable]
    /// <summary>
    /// DTU系统状态
    /// </summary>
    public class DTUSystemState
    {
        /// <summary>
        /// 设备编号
        /// </summary>
        [Category("\t基本信息")]
        [DisplayName("设备编号")]
        [ReadOnly(true)]
        [JsonProperty(PropertyName = "UniqueId")]
        public string DeviceID { get; set; }

        /// <summary>
        /// 设备名称
        /// </summary>
        [Category("\t基本信息")]
        [DisplayName("设备名称")]
        [ReadOnly(true)]
        [JsonProperty(PropertyName = "Equipmentname")]
        public string DeviceName { get; set; }

        /// <summary>
        /// 设备型号
        /// </summary>
        [Category("\t基本信息")]
        [DisplayName("设备型号")]
        [ReadOnly(true)]
        [JsonProperty(PropertyName = "Equipmenttype")]
        public string DeviceType { get; set; }

        /// <summary>
        /// 当前工作模式
        /// </summary>
        [Category("\t基本信息")]
        [DisplayName("当前工作模式")]
        [ReadOnly(true)]
        [JsonProperty(PropertyName = "Workmode")]
        public string CurrentWorkMode { get; set; }

        private string _OperatorType = string.Empty;
        /// <summary>
        /// 运营商类型
        /// </summary>
        [Category("SIM卡信息")]
        [DisplayName("运营商类型")]
        [ReadOnly(true)]
        [JsonProperty(PropertyName = "Operatortype")]
        public string OperatorType
        {
            get => _OperatorType;
            set
            {
                switch (value)
                {
                    case "CHN-CT":
                        _OperatorType = "中国电信";
                        break;
                    case "CHN-UNICOM":
                        _OperatorType = "中国联通";
                        break;
                    case "CHINA MOBILE":
                        _OperatorType = "中国移动";
                        break;
                    default:
                        _OperatorType = value;
                        break;
                }
            }
        }

        private string _NetworkType = string.Empty;
        /// <summary>
        /// 网络类型
        /// </summary>
        [Category("SIM卡信息")]
        [DisplayName("网络类型")]
        [ReadOnly(true)]
        [JsonProperty(PropertyName = "Networktype")]
        public string NetworkType
        {
            get => _NetworkType;
            set
            {
                switch (value)
                {
                    case "0":
                        _NetworkType = "GSM";
                        break;
                    case "2":
                        _NetworkType = "UTRAN";
                        break;
                    case "3":
                        _NetworkType = "GSM W/EGPRS";
                        break;
                    case "4":
                        _NetworkType = "UTRAN W/HSDPA";
                        break;
                    case "5":
                        _NetworkType = "UTRAN W/HSUPA";
                        break;
                    case "6":
                        _NetworkType = "UTRAN W/HSDPA and HSUPA";
                        break;
                    case "7":
                        _NetworkType = "E-UTRAN";
                        break;
                    case "8":
                        _NetworkType = "UTRAN HSPA+";
                        break;
                    default:
                        _NetworkType = value;
                        break;
                }
            }
        }

        private string _NetworkState = string.Empty;
        /// <summary>
        /// 网络状态
        /// </summary>
        [Category("SIM卡信息")]
        [DisplayName("网络状态")]
        [ReadOnly(true)]
        [JsonProperty(PropertyName = "Networkstatus")]
        public string NetworkState
        {
            get => _NetworkState;
            set
            {
                switch (value)
                {
                    case "0":
                        _NetworkState = "未注册到网络";
                        break;
                    case "1":
                        _NetworkState = "注册到网络";
                        break;
                    default:
                        _NetworkState = value;
                        break;
                }
            }
        }

        private string _SIMCardState = string.Empty;
        /// <summary>
        /// SIM卡状态
        /// </summary>
        [Category("SIM卡信息")]
        [DisplayName("SIM卡状态")]
        [ReadOnly(true)]
        [JsonProperty(PropertyName = "SIMcardstatus")]
        public string SIMCardState
        {
            get => _SIMCardState;
            set
            {
                switch (value)
                {
                    case "0":
                        _SIMCardState = "正常";
                        break;
                    case "1":
                        _SIMCardState = "异常";
                        break;
                    default:
                        _SIMCardState = value;
                        break;
                }
            }
        }

        /// <summary>
        /// SIM卡ICCID
        /// </summary>
        [Category("SIM卡信息")]
        [DisplayName("SIM卡ICCID")]
        [ReadOnly(true)]
        [JsonProperty(PropertyName = "SIMcardICCID")]
        public string SIMCardICCID { get; set; }

        /// <summary>
        /// IMEI
        /// </summary>
        [Category("SIM卡信息")]
        [DisplayName("IMEI号")]
        [ReadOnly(true)]
        [JsonProperty(PropertyName = "IMEInumber")]
        public string IMEI { get; set; }

        /// <summary>
        /// 信号强度
        /// </summary>
        [Category("SIM卡信息")]
        [DisplayName("信号强度(%)")]
        [ReadOnly(true)]
        [JsonProperty(PropertyName = "Signalstrength")]
        public string SignalStrength { get; set; }

        ///// <summary>
        ///// 基站定位
        ///// </summary>
        //[Category("SIM卡信息")]
        //[DisplayName("基站定位")]
        //[ReadOnly(true)]
        //[JsonProperty(PropertyName = "Basestationlocation")]
        //public string BasePosition { get; set; }

        ///// <summary>
        ///// MAC地址
        ///// </summary>
        //[Category("网络信息")]
        //[DisplayName("MAC地址")]
        //[ReadOnly(true)]
        //public string MAC { get; set; } = "5A:34:12:0C:26:08";

        ///// <summary>
        ///// 公网IP地址
        ///// </summary>
        //[Category("网络信息")]
        //[DisplayName("公网IP地址")]
        //[ReadOnly(true)]
        //public string PublicIP { get; set; } = "10.67.98.74";

        ///// <summary>
        ///// LAN口IP地址
        ///// </summary>
        //[Category("网络信息")]
        //[DisplayName("LAN口IP地址")]
        //[ReadOnly(true)]
        //public string LANIP { get; set; } = "192.168.10.1";

        ///// <summary>
        ///// LAN口子网掩码
        ///// </summary>
        //[Category("网络信息")]
        //[DisplayName("LAN口子网掩码")]
        //[ReadOnly(true)]
        //public string LANSubnetMask { get; set; } = "255.255.255.0";

        ///// <summary>
        ///// DNS地址
        ///// </summary>
        //[Category("网络信息")]
        //[DisplayName("DNS地址")]
        //[ReadOnly(true)]
        //public string DNS { get; set; } = "222.61.74.8";

        ///// <summary>
        ///// 串口号
        ///// </summary>
        //[Category("485信息")]
        //[DisplayName("串口号")]
        //[ReadOnly(true)]
        //public string PortNum { get; set; } = "COM1";

        /// <summary>
        /// 波特率
        /// </summary>
        [Category("485信息")]
        [DisplayName("波特率")]
        [ReadOnly(true)]
        [JsonProperty(PropertyName = "baudrate")]
        [TypeConverter(typeof(EnumTypeConverter))]
        public EnumBaudrate BaudRate { get; set; } = EnumBaudrate.rate_9600;

        /// <summary>
        /// 数据位
        /// </summary>
        [Category("485信息")]
        [DisplayName("数据位")]
        [ReadOnly(true)]
        [JsonProperty(PropertyName = "dataBit")]
        [TypeConverter(typeof(EnumTypeConverter))]
        public EnumDataBits DataBits { get; set; } = EnumDataBits.Bit_8;

        /// <summary>
        /// 停止位
        /// </summary>
        [Category("485信息")]
        [DisplayName("停止位")]
        [ReadOnly(true)]
        [JsonProperty(PropertyName = "stopBit")]
        [TypeConverter(typeof(EnumTypeConverter))]
        public EnumStopBits StopBits { get; set; } = EnumStopBits.Bit_1;

        /// <summary>
        /// 校验位
        /// </summary>
        [Category("485信息")]
        [DisplayName("校验位")]
        [ReadOnly(true)]
        [JsonProperty(PropertyName = "checkBit")]
        [TypeConverter(typeof(EnumTypeConverter))]
        public EnumCheckBit Parity { get; set; } = EnumCheckBit.none;
    }
}