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.
230 lines
8.6 KiB
C#
230 lines
8.6 KiB
C#
using FreeSql.Internal.Model;
|
|
using MaterialDesignThemes.Wpf;
|
|
using Newtonsoft.Json.Linq;
|
|
using Newtonsoft.Json;
|
|
using Prism.Mvvm;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Configuration;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Media;
|
|
using Txgy.EWS.Client.Entity;
|
|
using Txgy.EWS.Client.Models;
|
|
using Txgy.Microseismic.BaseLib.Models;
|
|
|
|
namespace Txgy.EWS.Client.Common
|
|
{
|
|
public class GlobalData : BindableBase
|
|
{
|
|
//public static bool IsDesign = true;
|
|
|
|
public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
|
|
public static UserInfoEntity CurrentUserInfo { get; set; }
|
|
public static List<Task> TaskList = new List<Task>();
|
|
|
|
private static ObservableCollection<ReportEventLevel> reportEventLevelList=new ObservableCollection<ReportEventLevel>();
|
|
/// <summary>
|
|
/// 报表事件等级列表
|
|
/// </summary>
|
|
public static ObservableCollection<ReportEventLevel> ReportEventLevelList
|
|
{
|
|
get { return reportEventLevelList; }
|
|
set
|
|
{
|
|
reportEventLevelList = value;
|
|
StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs("EportEventLevelList"));
|
|
}
|
|
}
|
|
private static ObservableCollection<GridItemEventResult> gridEvents=new ObservableCollection<GridItemEventResult>();
|
|
|
|
public static ObservableCollection<GridItemEventResult> GridEvents
|
|
{
|
|
get { return gridEvents; }
|
|
set
|
|
{
|
|
gridEvents = value;
|
|
StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs("GridEvents"));
|
|
}
|
|
}
|
|
public static List<RemoteRealtimeResultEntity> SearchEvents { get; set; } = new List<RemoteRealtimeResultEntity>();
|
|
public static List<MmEvent> StatEvents { get; set; } = new List<MmEvent>();
|
|
public static MmEvent LastEvent { get; set; }= new MmEvent();
|
|
public static List<int> ListAlarmEventId = new List<int>();
|
|
|
|
public static List<RemoteRealtimeResultEntity> ReceivedEvents { get; set; }=new List<RemoteRealtimeResultEntity>();
|
|
public static List<RemoteRealtimeResultEntity> AlarmEvents { get; set; } = new List<RemoteRealtimeResultEntity>();
|
|
|
|
private static bool isRunning = false;
|
|
public static bool IsRunning
|
|
{
|
|
get { return isRunning; }
|
|
set
|
|
{
|
|
isRunning = value;
|
|
StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs("SystemLoadingEvent"));
|
|
}
|
|
}
|
|
private static bool appendEvent = false;
|
|
public static bool AppendEvent
|
|
{
|
|
get { return appendEvent; }
|
|
set
|
|
{
|
|
appendEvent = value;
|
|
StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs("AppendEvent"));
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 深拷贝
|
|
/// </summary>
|
|
/// <typeparam name="T"></typeparam>
|
|
/// <param name="obj"></param>
|
|
/// <returns></returns>
|
|
public static T DeepCopyByReflection<T>(T obj)
|
|
{
|
|
if (obj is string || obj.GetType().IsValueType)
|
|
return obj;
|
|
|
|
object retval = Activator.CreateInstance(obj.GetType());
|
|
FieldInfo[] fields = obj.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
|
|
foreach (var field in fields)
|
|
{
|
|
try
|
|
{
|
|
field.SetValue(retval, DeepCopyByReflection(field.GetValue(obj)));
|
|
}
|
|
catch { }
|
|
}
|
|
|
|
return (T)retval;
|
|
}
|
|
public static List<MmEvent> FillEvents(List<MmEvent> sourceEvents)
|
|
{
|
|
List<MmEvent> result = new List<MmEvent>();
|
|
foreach (var item in sourceEvents)
|
|
{
|
|
result.Add(new MmEvent
|
|
{
|
|
X = item.X,
|
|
Y = item.Y,
|
|
Z = item.Z,
|
|
EventID = item.EventID,
|
|
ML = item.ML,
|
|
LocSta = item.LocSta,
|
|
MLSta = item.MLSta,
|
|
EventTime = item.EventTime,
|
|
RMS = item.RMS,
|
|
WorkAreaID = item.WorkAreaID,
|
|
});
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取主频
|
|
/// </summary>
|
|
/// <param name="mmEvent"></param>
|
|
/// <returns></returns>
|
|
public static int GetDominFreq(string eventTime)
|
|
{
|
|
string downLoadStr = eventTime;
|
|
string datePath = downLoadStr.Substring(0, 4) + downLoadStr.Substring(5, 2) + downLoadStr.Substring(8, 2);
|
|
string jsonStr = "HA." + downLoadStr.Substring(0, 4) + downLoadStr.Substring(5, 2)
|
|
+ downLoadStr.Substring(8, 2) + downLoadStr.Substring(10, 3)
|
|
+ downLoadStr.Substring(14, 2) + downLoadStr.Substring(17, 2) + ".01" + GlobalConfig.DataTypeString + ".json";
|
|
string jsonFilePath = GlobalConfig.ProjectConfig.MseedFilePath + "\\" + datePath + "\\" + jsonStr;
|
|
int dominantFreq = 0;
|
|
if (File.Exists(jsonFilePath))
|
|
{
|
|
if (new FileInfo(jsonFilePath).Length < 100)
|
|
{
|
|
return dominantFreq;
|
|
}
|
|
try
|
|
{
|
|
using (StreamReader sr = System.IO.File.OpenText(jsonFilePath))
|
|
{
|
|
JsonTextReader reader = new JsonTextReader(sr);
|
|
JArray jArray = (JArray)JToken.ReadFrom(reader);
|
|
//解析普通属性和数组混合的Json文件
|
|
//数组0是普通属性集合
|
|
JObject jobj = (JObject)jArray[0];
|
|
|
|
List<double> DominantFreqlist = new List<double>();
|
|
JArray phaseArr = JArray.FromObject(jobj["phases"]);
|
|
//List<double> DominantFreqList = new List<double>();
|
|
for (int i = 0; i < phaseArr.Count; i++)
|
|
{
|
|
if (phaseArr[i]["fmd_semi_period"] != null)
|
|
{
|
|
DominantFreqlist.Add(double.Parse(phaseArr[i]["fmd_semi_period"].ToString()));
|
|
}
|
|
}
|
|
if (DominantFreqlist.Count > 0)
|
|
{
|
|
if (DominantFreqlist.Count > 3)
|
|
{
|
|
double min = DominantFreqlist.Min();
|
|
double max = DominantFreqlist.Max();
|
|
DominantFreqlist.Remove(min);
|
|
DominantFreqlist.Remove(max);
|
|
dominantFreq = (int)((DominantFreqlist.Sum() / (double)DominantFreqlist.Count) * 1000);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//return 0;
|
|
throw ex;
|
|
}
|
|
}
|
|
return dominantFreq;
|
|
}
|
|
public static string FocalMechanismType2String(FocalMechanismType fmt)
|
|
{
|
|
string focalStr = "张性";
|
|
switch (fmt)
|
|
{
|
|
case FocalMechanismType.strikeSlip:
|
|
focalStr = "走滑";
|
|
break;
|
|
case FocalMechanismType.dipSlip:
|
|
focalStr = "倾滑";
|
|
break;
|
|
case FocalMechanismType.unknown:
|
|
focalStr = "未识别";
|
|
break;
|
|
|
|
}
|
|
return focalStr;
|
|
}
|
|
public static string FocalMechanismIndex2String(int fmt)
|
|
{
|
|
string focalStr = "张性";
|
|
switch (fmt)
|
|
{
|
|
case 0:
|
|
focalStr = "走滑";
|
|
break;
|
|
case 1:
|
|
focalStr = "倾滑";
|
|
break;
|
|
case 2:
|
|
focalStr = "张性";
|
|
break;
|
|
case 3:
|
|
focalStr = "未识别";
|
|
break;
|
|
}
|
|
return focalStr;
|
|
}
|
|
}
|
|
}
|