|
|
@ -9,9 +9,11 @@ using Prism.Events;
|
|
|
|
using Prism.Mvvm;
|
|
|
|
using Prism.Mvvm;
|
|
|
|
using SharpDX.DirectWrite;
|
|
|
|
using SharpDX.DirectWrite;
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.Collections.Concurrent;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
using System.ComponentModel;
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
|
|
using System.ComponentModel.Design.Serialization;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using System.IO;
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
@ -19,6 +21,7 @@ using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Windows;
|
|
|
|
using System.Windows;
|
|
|
|
using System.Windows.Controls;
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
|
|
using System.Windows.Markup;
|
|
|
|
using System.Windows.Media;
|
|
|
|
using System.Windows.Media;
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
using System.Windows.Threading;
|
|
|
|
using System.Windows.Threading;
|
|
|
@ -35,8 +38,9 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
CreateChart();
|
|
|
|
CreateChart();
|
|
|
|
(Application.Current.MainWindow as System.Windows.Window).Closing += ApplicationClosingDispose;
|
|
|
|
(Application.Current.MainWindow as System.Windows.Window).Closing += ApplicationClosingDispose;
|
|
|
|
|
|
|
|
|
|
|
|
string fileName = "2023-03-31T07:43:15.464036";
|
|
|
|
string fileName = "2023-03-28T04:53:46.199584";
|
|
|
|
ShowWave(null,obj:fileName);
|
|
|
|
// fileName = "2023-03-24T04:53:46.199584";
|
|
|
|
|
|
|
|
bool multFlies = true;
|
|
|
|
string eventTimeStr = fileName;
|
|
|
|
string eventTimeStr = fileName;
|
|
|
|
string datePath = eventTimeStr.Substring(0, 4) + eventTimeStr.Substring(5, 2) + eventTimeStr.Substring(8, 2);
|
|
|
|
string datePath = eventTimeStr.Substring(0, 4) + eventTimeStr.Substring(5, 2) + eventTimeStr.Substring(8, 2);
|
|
|
|
string dataFilePath = RegionNames.MseedFilePath + "\\" + datePath + "\\";
|
|
|
|
string dataFilePath = RegionNames.MseedFilePath + "\\" + datePath + "\\";
|
|
|
@ -44,7 +48,13 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
+ eventTimeStr.Substring(8, 2) + eventTimeStr.Substring(10, 3)
|
|
|
|
+ eventTimeStr.Substring(8, 2) + eventTimeStr.Substring(10, 3)
|
|
|
|
+ eventTimeStr.Substring(14, 2) + eventTimeStr.Substring(17, 2) + ".01" + RegionNames.DataTypeString;
|
|
|
|
+ eventTimeStr.Substring(14, 2) + eventTimeStr.Substring(17, 2) + ".01" + RegionNames.DataTypeString;
|
|
|
|
string jsonStr = ".json";
|
|
|
|
string jsonStr = ".json";
|
|
|
|
_wavesModel.Json2MmEvent(dataFilePath+dataFileName+jsonStr);
|
|
|
|
string mseedStr = ".mseed";
|
|
|
|
|
|
|
|
string asciiSavePath = RegionNames.TxtFilePath + "\\" + datePath + "\\";
|
|
|
|
|
|
|
|
if (!multFlies)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_wavesModel.mseedJsonResolve(dataFilePath + dataFileName + jsonStr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ShowWave(dataFilePath + dataFileName + mseedStr, asciiSavePath + dataFileName + ".txt" , multFlies);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region 字段
|
|
|
|
#region 字段
|
|
|
@ -57,7 +67,7 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
|
|
|
|
|
|
|
WavesModel _wavesModel;
|
|
|
|
WavesModel _wavesModel;
|
|
|
|
private int _lChartCount = 1;
|
|
|
|
private int _lChartCount = 1;
|
|
|
|
public List<StationModel> smList;
|
|
|
|
public ConcurrentQueue<StationModel> smList;
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 属性
|
|
|
|
#region 属性
|
|
|
@ -159,14 +169,14 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if (openFileDialog.ShowDialog() == true)
|
|
|
|
if (openFileDialog.ShowDialog() == true)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ShowWave(openFileDialog.FileName);
|
|
|
|
//ShowWave(openFileDialog.FileName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
public void UpdateWavesFromTxt(string fn)
|
|
|
|
public List<StationModel> UpdateWavesFromTxt(string fn)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string allStr;
|
|
|
|
string allStr;
|
|
|
|
smList = new List<StationModel>();
|
|
|
|
List<StationModel> temSM = new List<StationModel>();
|
|
|
|
using (StreamReader streamReader = new StreamReader(fn))
|
|
|
|
using (StreamReader streamReader = new StreamReader(fn))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
allStr = streamReader.ReadToEnd();
|
|
|
|
allStr = streamReader.ReadToEnd();
|
|
|
@ -187,18 +197,23 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
|
|
|
|
|
|
|
int channelFlag = 0;
|
|
|
|
int channelFlag = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i < strLines.Length; i++)
|
|
|
|
for (int i = 0; i < strLines.Length; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string row = strLines[i].Trim();
|
|
|
|
string row = strLines[i].Trim();
|
|
|
|
if (strLines[i].Contains("HA"))
|
|
|
|
if (strLines[i].Contains("HA"))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string[] rowStr = strLines[i].Split(',');
|
|
|
|
string[] rowStr = strLines[i].Split(',');
|
|
|
|
string chnStr1 = rowStr[0].Substring(21, 3);
|
|
|
|
string chnStr1 = rowStr[0].Substring(21, 3);
|
|
|
|
if (chnStr1 == "SHZ")
|
|
|
|
string stationName = rowStr[0].Substring(14, 3);
|
|
|
|
|
|
|
|
if (!temSM.Any(name => name.Name == stationName))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
smList.Add(station);
|
|
|
|
|
|
|
|
station = new StationModel();
|
|
|
|
station = new StationModel();
|
|
|
|
station.Name = rowStr[0].Substring(14, 3);
|
|
|
|
station.Name = stationName;
|
|
|
|
|
|
|
|
temSM.Add(station);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (chnStr1 == "SHZ")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
channelFlag = 0;//Z
|
|
|
|
channelFlag = 0;//Z
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (chnStr1 == "SHN")
|
|
|
|
else if (chnStr1 == "SHN")
|
|
|
@ -226,9 +241,10 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
smList.Add(station);
|
|
|
|
// temSM.Add(station);
|
|
|
|
smList.Reverse();
|
|
|
|
temSM.Reverse();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return temSM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public void MSeed2Asc(string filePath, string savePath)
|
|
|
|
public void MSeed2Asc(string filePath, string savePath)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -237,6 +253,7 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
compiler.StartInfo.FileName = "mseed2ascii.exe";
|
|
|
|
compiler.StartInfo.FileName = "mseed2ascii.exe";
|
|
|
|
compiler.StartInfo.Arguments = filePath + " -o " + savePath;
|
|
|
|
compiler.StartInfo.Arguments = filePath + " -o " + savePath;
|
|
|
|
compiler.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
|
|
|
compiler.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
|
|
|
|
|
|
|
compiler.StartInfo.CreateNoWindow = true;
|
|
|
|
compiler.Start();
|
|
|
|
compiler.Start();
|
|
|
|
compiler.WaitForExit();
|
|
|
|
compiler.WaitForExit();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -274,11 +291,20 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
LChartALL.ViewXY.XAxes[0].AllowScrolling = false;
|
|
|
|
LChartALL.ViewXY.XAxes[0].AllowScrolling = false;
|
|
|
|
LChartALL.ViewXY.XAxes[0].PanningEnabled = false;
|
|
|
|
LChartALL.ViewXY.XAxes[0].PanningEnabled = false;
|
|
|
|
LChartALL.ViewXY.XAxes[0].SweepingGap = 0;
|
|
|
|
LChartALL.ViewXY.XAxes[0].SweepingGap = 0;
|
|
|
|
// LChartALL.ViewXY.XAxes[0].ValueType = AxisValueType.Number;
|
|
|
|
LChartALL.ViewXY.XAxes[0].ValueType = AxisValueType.DateTime;
|
|
|
|
LChartALL.ViewXY.XAxes[0].AutoFormatLabels = false;
|
|
|
|
LChartALL.ViewXY.XAxes[0].AutoFormatLabels = false;
|
|
|
|
// LChartALL.ViewXY.XAxes[0].LabelsNumberFormat = "N0";
|
|
|
|
// LChartALL.ViewXY.XAxes[0].LabelsNumberFormat = "N0";
|
|
|
|
// LChartALL.ViewXY.XAxes[0].MajorGrid.Pattern = LinePattern.Solid;
|
|
|
|
// LChartALL.ViewXY.XAxes[0].MajorGrid.Pattern = LinePattern.Solid;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LChartALL.ViewXY.XAxes[0].MinorGrid.Visible = false;
|
|
|
|
|
|
|
|
LChartALL.ViewXY.XAxes[0].MajorGrid.Pattern = LinePattern.Solid;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//LChartALL.ViewXY.XAxes[0].MinimumDateTime=DateTime.Now;
|
|
|
|
|
|
|
|
LChartALL.ViewXY.XAxes[0].AutoDivSpacing = false;
|
|
|
|
|
|
|
|
LChartALL.ViewXY.XAxes[0].MinorDivTickStyle.Visible = true;
|
|
|
|
|
|
|
|
LChartALL.ViewXY.XAxes[0].KeepDivCountOnRangeChange = true;
|
|
|
|
|
|
|
|
LChartALL.ViewXY.XAxes[0].MajorDivCount = 5;
|
|
|
|
|
|
|
|
LChartALL.ViewXY.XAxes[0].LabelsTimeFormat = "HH:mm.ss.ffff";
|
|
|
|
//图表背景颜色
|
|
|
|
//图表背景颜色
|
|
|
|
LChartALL.ViewXY.GraphBackground.Color = Colors.White;
|
|
|
|
LChartALL.ViewXY.GraphBackground.Color = Colors.White;
|
|
|
|
//LChartALL.ViewXY.GraphBackground.GradientFill = GradientFill.Solid;
|
|
|
|
//LChartALL.ViewXY.GraphBackground.GradientFill = GradientFill.Solid;
|
|
|
@ -292,31 +318,54 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
|
|
|
|
|
|
|
this.ChildContent = GridChart;
|
|
|
|
this.ChildContent = GridChart;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void ShowWave(string filePath, string obj = "2023-03-29T06:41:21.348")
|
|
|
|
private void ShowWave(string dataFilePath, string asciiSavePath, bool isMultFile = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string EventTimeStr = obj;
|
|
|
|
if (!Directory.Exists(Path.GetDirectoryName(dataFilePath)))
|
|
|
|
string datePath = EventTimeStr.Substring(0, 4) + EventTimeStr.Substring(5, 2) + EventTimeStr.Substring(8, 2);
|
|
|
|
|
|
|
|
string dataFilePath = RegionNames.MseedFilePath + "\\" + datePath + "\\";
|
|
|
|
|
|
|
|
string dataFileName = "HA." + EventTimeStr.Substring(0, 4) + EventTimeStr.Substring(5, 2)
|
|
|
|
|
|
|
|
+ EventTimeStr.Substring(8, 2) + EventTimeStr.Substring(10, 3)
|
|
|
|
|
|
|
|
+ EventTimeStr.Substring(14, 2) + EventTimeStr.Substring(17, 2) + ".01" + RegionNames.DataTypeString;
|
|
|
|
|
|
|
|
string mseedStr = ".mseed";
|
|
|
|
|
|
|
|
string asciiSavePath = RegionNames.TxtFilePath + "\\" + datePath + "\\" + dataFileName + ".txt";
|
|
|
|
|
|
|
|
if (filePath != null) asciiSavePath = filePath;
|
|
|
|
|
|
|
|
if (!Directory.Exists(dataFilePath))
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Directory.CreateDirectory(dataFilePath);
|
|
|
|
Directory.CreateDirectory(Path.GetDirectoryName(dataFilePath));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!Directory.Exists(Path.GetDirectoryName(asciiSavePath)))
|
|
|
|
if (!Directory.Exists(Path.GetDirectoryName(asciiSavePath)))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Directory.CreateDirectory(Path.GetDirectoryName(asciiSavePath));
|
|
|
|
Directory.CreateDirectory(Path.GetDirectoryName(asciiSavePath));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
smList = new ConcurrentQueue<StationModel>();
|
|
|
|
if (!File.Exists(asciiSavePath))
|
|
|
|
if (isMultFile)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MSeed2Asc(dataFilePath + dataFileName + mseedStr, asciiSavePath);
|
|
|
|
var filePath = new DirectoryInfo(Path.GetDirectoryName(dataFilePath));
|
|
|
|
|
|
|
|
FileInfo[] files = filePath.GetFiles();
|
|
|
|
|
|
|
|
//var dic = file.GetDirectories();
|
|
|
|
|
|
|
|
var mseedFiles = files.Where(i => i.Extension == ".mseed");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var asciiFiles = new DirectoryInfo(Path.GetDirectoryName(asciiSavePath));
|
|
|
|
|
|
|
|
var asciifile = asciiFiles.GetFiles();
|
|
|
|
|
|
|
|
if (asciifile.Count()==0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// 并行运算
|
|
|
|
|
|
|
|
Stopwatch sw = Stopwatch.StartNew();
|
|
|
|
|
|
|
|
Parallel.ForEach(mseedFiles, (item) =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MSeed2Asc(item.FullName, asciiSavePath + Path.GetFileNameWithoutExtension(item.Name));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
sw.Stop();
|
|
|
|
|
|
|
|
Debug.WriteLine("MSeed2Asc解压时间:" +sw.Elapsed.TotalSeconds);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 并行运算
|
|
|
|
|
|
|
|
Parallel.ForEach(asciiFiles.GetFiles(), (item) =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var list = UpdateWavesFromTxt(item.FullName);
|
|
|
|
|
|
|
|
list.ForEach(i => smList.Enqueue(i));
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
UpdateWavesFromTxt(asciiSavePath);
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!File.Exists(asciiSavePath))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MSeed2Asc(dataFilePath, asciiSavePath);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var list = UpdateWavesFromTxt(asciiSavePath);
|
|
|
|
|
|
|
|
list.ForEach(i => smList.Enqueue(i));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_channelCount = smList.Count * 3;
|
|
|
|
_channelCount = smList.Count * 3;
|
|
|
|
UpdateChart();
|
|
|
|
UpdateChart();
|
|
|
|
UpdateChartData();
|
|
|
|
UpdateChartData();
|
|
|
@ -329,7 +378,7 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
DisposeAllAndClear(LChartALL.ViewXY.YAxes);
|
|
|
|
DisposeAllAndClear(LChartALL.ViewXY.YAxes);
|
|
|
|
DisposeAllAndClear(LChartALL.ViewXY.SampleDataSeries);
|
|
|
|
DisposeAllAndClear(LChartALL.ViewXY.SampleDataSeries);
|
|
|
|
|
|
|
|
|
|
|
|
LChartALL.ViewXY.YAxes.AddRange(_wavesModel.CreateYAxisChart(smList, LChartALL));
|
|
|
|
LChartALL.ViewXY.YAxes.AddRange(_wavesModel.CreateYAxisChart(smList.ToList(), LChartALL));
|
|
|
|
int seriesIndex = 0;
|
|
|
|
int seriesIndex = 0;
|
|
|
|
foreach (var axisY in LChartALL.ViewXY.YAxes)
|
|
|
|
foreach (var axisY in LChartALL.ViewXY.YAxes)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -378,7 +427,7 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
LChartALL.ViewXY.XAxes[0].LabelsColor = Colors.Black;
|
|
|
|
LChartALL.ViewXY.XAxes[0].LabelsColor = Colors.Black;
|
|
|
|
|
|
|
|
|
|
|
|
LChartALL.ViewXY.SampleDataSeries.AddRange(
|
|
|
|
LChartALL.ViewXY.SampleDataSeries.AddRange(
|
|
|
|
_wavesModel.GetSampleDataSeriesPingPu(smList, LChartALL, LChartALL.ViewXY.XAxes[0],
|
|
|
|
_wavesModel.GetSampleDataSeriesPingPu(smList.ToList(), LChartALL, LChartALL.ViewXY.XAxes[0],
|
|
|
|
LChartALL.ViewXY.YAxes, _samplingFrequency));
|
|
|
|
LChartALL.ViewXY.YAxes, _samplingFrequency));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void UpdateChartData()
|
|
|
|
private void UpdateChartData()
|
|
|
@ -388,9 +437,9 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (int channelIndex = 0; channelIndex < smList.Count; channelIndex++)
|
|
|
|
for (int channelIndex = 0; channelIndex < smList.Count; channelIndex++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
multiChannelData[channelIndex * 3] = smList[channelIndex].dz.ToArray();
|
|
|
|
multiChannelData[channelIndex * 3] = smList.ElementAt(channelIndex).dz.ToArray();
|
|
|
|
multiChannelData[channelIndex * 3 + 1] = smList[channelIndex].dn.ToArray();
|
|
|
|
multiChannelData[channelIndex * 3 + 1] = smList.ElementAt(channelIndex).dn.ToArray();
|
|
|
|
multiChannelData[channelIndex * 3 + 2] = smList[channelIndex].de.ToArray();
|
|
|
|
multiChannelData[channelIndex * 3 + 2] = smList.ElementAt(channelIndex).de.ToArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Invoke FeedNewDataToChart.
|
|
|
|
// Invoke FeedNewDataToChart.
|
|
|
|
_dispatcher.Invoke(() =>
|
|
|
|
_dispatcher.Invoke(() =>
|
|
|
|