You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.8 KiB
C#

using EWS.Models;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Txgy.Microseismic.BaseLib
{
public class WaveHeader
{
/// <summary>
/// HA
/// </summary>
public string Flag { get; set; }
/// <summary>
/// 台站名称
/// </summary>
public string StationName { get; set; }
/// <summary>
/// 通道
/// </summary>
public string Channel { get; set; }
/// <summary>
/// 点数
/// </summary>
public int Samples { get; set; }
/// <summary>
/// 采样率
/// </summary>
public int Sps { get; set; }
/// <summary>
/// 文件开始时间
/// </summary>
public DateTime StartTime { get; set; }
/// <summary>
/// 最大值
/// </summary>
public int MaxValue { get; set; }
/// <summary>
/// 最大值位置
/// </summary>
public int MaxValueIndex { get; set; }
/// <summary>
/// 最大振幅
/// </summary>
public double MaxAmp { get; set; }
/// <summary>
/// 到事件的距离
/// </summary>
public double ToEventDist { get; set; }
/// <summary>
/// 相对于事件的角度
/// </summary>
public int ToEventAngle { get; set; }
public WaveHeader()
{
}
public WaveHeader(string header)
{
string[] heads=header.Split(',');
Flag= heads[0].Substring(11,2);
StationName= heads[0].Substring(14,3);
Channel= heads[0].Substring(23,1);
string[] tmp = heads[1].Trim().Split(' ');
Samples = int.Parse(tmp[0]);
tmp = heads[2].Trim().Split(' ');
Sps = int.Parse(tmp[0]);
StartTime = DateTime.Parse(heads[3]).AddHours(8);
}
public static double CalAmp(int Value,int sens)
{
return Value / (PublicConfig.KW / (Math.Pow(2, sens)));
}
public static double CalDist(MmEvent mm,string stationName)
{
var sdr = PublicConfig.ProjectConfig.StationDic.Where(sd => sd.Key == stationName);
if (sdr.Count() == 0) return 0;
StationModel sm = sdr.First().Value;
double dist = Math.Sqrt(Math.Pow(sm.E - mm.X, 2) + Math.Pow(sm.N - mm.Y, 2));
return dist;
}
public static double PointsAngleTool(PointF p1, PointF p2)
{
double angleOfLine = Math.Atan2((p2.Y - p1.Y), (p2.X - p1.X)) * 180 / Math.PI;//计算两点的正切值并获取角度
return angleOfLine;
}
}
}