using Newtonsoft.Json;
using FreeSql.DataAnnotations;
using System;

namespace Txgy.EWS.Client.Entity
{
    [JsonObject(MemberSerialization.OptIn),Table(Name = "realtimeeventresult")]
    public class LocalRealtimeResultEntity
    {
        [JsonProperty, Column(DbType = "varchar(254)")]
        public string EventTime { get; set; }

        [JsonProperty, Column(DbType = "int")]
        public int LocSta { get; set; }

        [JsonProperty]
        public double ML { get; set; }

        [JsonProperty, Column(DbType = "int")]
        public int MLSta { get; set; }

        [JsonProperty, Column(DbType = "varchar(254)")]
        public string OriginTime { get; set; }

        [JsonProperty, Column(DbType = "int")]
        public int RTEventID { get; set; }

        [JsonProperty]
        public double RMS { get; set; }

        [JsonProperty, Column(DbType = "int")]
        public int WorkAreaID { get; set; }

        [JsonProperty]
        public double X { get; set; }

        [JsonProperty]
        public double Y { get; set; }

        [JsonProperty]
        public double Z { get; set; }
        public double Energy { get; set; }
        /// <summary>
        /// 震源性质:1：张性；2：剪切；3：走滑
        /// </summary>
        [Column(IsIgnore = true)]
        public int SourceChara { get; set; }
        /// <summary>
        /// 震源机制方向
        /// </summary>
        [Column(IsIgnore = true)]
        public double Direction { get; set; }
        /// <summary>
        /// 应力降
        /// </summary>
        [Column(IsIgnore = true)]
        public double StressDrop { get; set; }
        /// <summary>
        /// 主频
        /// </summary>
        [Column(IsIgnore = true)]
        public int DominantFreq { get; set; }
        /// <summary>
        /// 矩震级
        /// </summary>
        [Column(IsIgnore = true)]
        public double MW { get; set; }

        public void SetEnergy()
        {
            Energy = Math.Round(63000.0 * Math.Pow(10, 1.47 * ML), 2);
        }
        public LocalRealtimeResultEntity()
        {

        }
        public LocalRealtimeResultEntity(RemoteRealtimeResultEntity rrr)
        {
            this.RTEventID= rrr.RTEventID;
            this.WorkAreaID= rrr.WorkAreaID;
            this.EventTime= rrr.EventTime;
            this.OriginTime= rrr.OriginTime;
            this.X= rrr.X;
            this.Y= rrr.Y;
            this.Z = rrr.Z;
            this.ML = Math.Round(rrr.ML,2);
            this.RMS= Math.Round(rrr.RMS,3);
            this.LocSta= rrr.LocSta;
            this.MLSta= rrr.MLSta;
            this.Energy= rrr.Energy;
        }
        
    }
}
