|
|
|
@ -27,6 +27,7 @@ using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
using System.Windows.Markup;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
@ -42,64 +43,25 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
{
|
|
|
|
|
_dispatcher = Application.Current.Dispatcher;
|
|
|
|
|
_wavesModel = new WavesModel();
|
|
|
|
|
CreateChart();
|
|
|
|
|
(Application.Current.MainWindow as System.Windows.Window).Closing += ApplicationClosingDispose;
|
|
|
|
|
|
|
|
|
|
string fileName = "2023-03-28T05:14:59.108464";
|
|
|
|
|
// fileName = "2023-03-24T04:53:46.199584";
|
|
|
|
|
bool multFlies = false;
|
|
|
|
|
string eventTimeStr = fileName;
|
|
|
|
|
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 jsonStr = ".json";
|
|
|
|
|
string mseedStr = ".mseed";
|
|
|
|
|
string asciiSavePath = RegionNames.TxtFilePath + "\\" + datePath + "\\";
|
|
|
|
|
if (!multFlies)
|
|
|
|
|
{
|
|
|
|
|
CurrentEventTime = _wavesModel.mseedJsonResolve(dataFilePath + dataFileName + jsonStr);
|
|
|
|
|
}
|
|
|
|
|
ShowWave(dataFilePath + dataFileName + mseedStr, asciiSavePath + dataFileName + ".txt" , multFlies);
|
|
|
|
|
|
|
|
|
|
YaxisItems.Add("SHZ");
|
|
|
|
|
YaxisItems.Add("SHN");
|
|
|
|
|
YaxisItems.Add("SHE");
|
|
|
|
|
CreateChart();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 字段
|
|
|
|
|
Dispatcher _dispatcher;
|
|
|
|
|
public int CurPoints;
|
|
|
|
|
|
|
|
|
|
int _channelCount = 0;
|
|
|
|
|
int _samplingFrequency = 500; // 采样频率 (Hz).
|
|
|
|
|
WavesModel _wavesModel;
|
|
|
|
|
private int _lChartCount = 1;
|
|
|
|
|
public ConcurrentQueue<StationModel> smList;
|
|
|
|
|
|
|
|
|
|
public List<AxisY> _chartAxisY=new List<AxisY>();
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 属性
|
|
|
|
|
|
|
|
|
|
private List<string> _yaxisItems=new List<string>();
|
|
|
|
|
|
|
|
|
|
public List<string> YaxisItems
|
|
|
|
|
{
|
|
|
|
|
get { return _yaxisItems; }
|
|
|
|
|
set { _yaxisItems = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int _selectIndex=1;
|
|
|
|
|
|
|
|
|
|
public int SelectIndex
|
|
|
|
|
{
|
|
|
|
|
get { return _selectIndex; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
SetProperty(ref _selectIndex, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool _isMultFiles;
|
|
|
|
|
|
|
|
|
|
public bool IsMultFiles
|
|
|
|
@ -161,82 +123,52 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
set { _currentEventTime = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<string> _stationYaxis;
|
|
|
|
|
private List<StationAxis> _stationsName;
|
|
|
|
|
|
|
|
|
|
public List<string> StationYaxis
|
|
|
|
|
public List<StationAxis> StationsName
|
|
|
|
|
{
|
|
|
|
|
get { return _stationYaxis; }
|
|
|
|
|
get { return _stationsName; }
|
|
|
|
|
set {
|
|
|
|
|
|
|
|
|
|
SetProperty(ref _stationYaxis, value);
|
|
|
|
|
SetProperty(ref _stationsName, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int _selectStationYaxisIndex;
|
|
|
|
|
private string _currentTime;
|
|
|
|
|
|
|
|
|
|
public int SelectStationYaxisIndex
|
|
|
|
|
public string CurrentTime
|
|
|
|
|
{
|
|
|
|
|
get { return _selectStationYaxisIndex; }
|
|
|
|
|
get { return _currentTime; }
|
|
|
|
|
set {
|
|
|
|
|
|
|
|
|
|
SetProperty(ref _selectStationYaxisIndex, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool _stationYaxisIsChecked;
|
|
|
|
|
|
|
|
|
|
public bool StationYaxisIsChecked
|
|
|
|
|
{
|
|
|
|
|
get { return _stationYaxisIsChecked; }
|
|
|
|
|
set {
|
|
|
|
|
StationYaxisVisible(value);
|
|
|
|
|
SetProperty(ref _stationYaxisIsChecked, value);
|
|
|
|
|
SetProperty(ref _currentTime, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 事件
|
|
|
|
|
public DelegateCommand LoadedCommand => new DelegateCommand(Loaded);
|
|
|
|
|
public DelegateCommand<object> AxesYVisibleCommand => new DelegateCommand<object>(AxesYVisible);
|
|
|
|
|
public DelegateCommand FileSelectorCommand => new DelegateCommand(FileSelector);
|
|
|
|
|
public DelegateCommand<object> OtimeSortCommand => new DelegateCommand<object>(OtimeSort);
|
|
|
|
|
public DelegateCommand<object> YasixZENVisibleCommand => new DelegateCommand<object>(YasixZENVisible);
|
|
|
|
|
public DelegateCommand IntervalSureCommand => new DelegateCommand(IntervalSure);
|
|
|
|
|
|
|
|
|
|
public DelegateCommand<object> RealTimeDataCommand => new DelegateCommand<object>(RealTimeData);
|
|
|
|
|
|
|
|
|
|
private void Loaded()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AxesYVisible(object isCheck)
|
|
|
|
|
{
|
|
|
|
|
if (_lChartAll != null)
|
|
|
|
|
{
|
|
|
|
|
bool yAxesVisible = ((bool)isCheck == true);
|
|
|
|
|
_lChartAll.BeginUpdate();
|
|
|
|
|
|
|
|
|
|
AxisY lastYAxis = _lChartAll.ViewXY.YAxes.Last();
|
|
|
|
|
|
|
|
|
|
_lChartAll.ViewXY.AxisLayout.AutoAdjustMargins = false;
|
|
|
|
|
|
|
|
|
|
foreach (AxisY yAxis in _lChartAll.ViewXY.YAxes)
|
|
|
|
|
{
|
|
|
|
|
if (yAxis != lastYAxis)
|
|
|
|
|
{
|
|
|
|
|
yAxis.Visible = yAxesVisible;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
yAxis.Visible = true;
|
|
|
|
|
yAxis.LabelsVisible = yAxesVisible;
|
|
|
|
|
//yAxis.MajorDivTickStyle.Visible = yAxesVisible;
|
|
|
|
|
//yAxis.MinorDivTickStyle.Visible = yAxesVisible;
|
|
|
|
|
yAxis.Title.Visible = yAxesVisible;
|
|
|
|
|
if (yAxesVisible)
|
|
|
|
|
{
|
|
|
|
|
yAxis.AxisThickness = 3;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
yAxis.AxisThickness = 0;
|
|
|
|
|
}
|
|
|
|
|
// lastYAxis.MiniScale.Visible = !yAxesVisible;
|
|
|
|
|
}
|
|
|
|
|
yAxis.Visible = yAxesVisible;
|
|
|
|
|
}
|
|
|
|
|
_lChartAll.EndUpdate();
|
|
|
|
|
|
|
|
|
@ -252,13 +184,21 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
};
|
|
|
|
|
if (openFileDialog.ShowDialog() == true)
|
|
|
|
|
{
|
|
|
|
|
string asciiSavePath = openFileDialog.FileName;
|
|
|
|
|
asciiSavePath = asciiSavePath.Replace("Mseed", "Txt");
|
|
|
|
|
string asciiSavePath = openFileDialog.FileName.Replace("Mseed", "Txt");
|
|
|
|
|
asciiSavePath = Path.ChangeExtension(asciiSavePath, ".txt");
|
|
|
|
|
|
|
|
|
|
ShowWave(openFileDialog.FileName, asciiSavePath, IsMultFiles);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
string JsonPath = Path.ChangeExtension(openFileDialog.FileName, "Json");
|
|
|
|
|
//读取.json文件
|
|
|
|
|
CurrentEventTime = _wavesModel.ReadChartJsonFile(JsonPath);
|
|
|
|
|
//读取.mseed文件
|
|
|
|
|
smList = _wavesModel.ReadMseedFile(openFileDialog.FileName, asciiSavePath, IsMultFiles);
|
|
|
|
|
_channelCount = smList.Count * 3;
|
|
|
|
|
CurrentTime = smList.First().BeginTime.ToShortDateString();
|
|
|
|
|
StationsName = smList.Select(a => new StationAxis{Name= a.Name,IsChecked=true,SelectCommand =new DelegateCommand<object>(StationsNameVisible)}).ToList();
|
|
|
|
|
StartChart();
|
|
|
|
|
FeedDatasToChart();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OtimeSort(object isCheck)
|
|
|
|
|
{
|
|
|
|
|
if (_lChartAll != null)
|
|
|
|
@ -275,57 +215,82 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
{
|
|
|
|
|
lines = v.LineCollections.Where(a => a.Tag != null && a.Tag.ToString().Contains("SHZ")).OrderByDescending(b => b.Lines[0].AX); ;
|
|
|
|
|
}
|
|
|
|
|
foreach (var item in lines)
|
|
|
|
|
{
|
|
|
|
|
var a = item.Tag.ToString().Contains("SHZ");
|
|
|
|
|
}
|
|
|
|
|
int number = v.YAxes.Count / (_chartAxisY.Count / 3);
|
|
|
|
|
foreach (var item in lines.Reverse())
|
|
|
|
|
{
|
|
|
|
|
int index = item.AssignYAxisIndex;
|
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
|
for (int i = 0; i < number; i++)
|
|
|
|
|
{
|
|
|
|
|
if (index == -1) continue; //隐藏轴不需要处理
|
|
|
|
|
AxisY axisY = v.YAxes[index + i];
|
|
|
|
|
v.YAxes.RemoveAt(index + i);
|
|
|
|
|
v.YAxes.Insert(i, axisY);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
LChartALL.EndUpdate();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void YasixZENVisible(object isCheck)
|
|
|
|
|
|
|
|
|
|
private void YasixZENVisible(object cBox)
|
|
|
|
|
{
|
|
|
|
|
var checkBox= cBox as CheckBox;
|
|
|
|
|
if (_lChartAll != null)
|
|
|
|
|
{
|
|
|
|
|
_lChartAll.BeginUpdate();
|
|
|
|
|
bool yAxesVisible = ((bool)isCheck == true);
|
|
|
|
|
bool yAxesVisible = (checkBox.IsChecked == false);
|
|
|
|
|
ViewXY v = _lChartAll.ViewXY;
|
|
|
|
|
List<bool> indexs = new List<bool>();
|
|
|
|
|
switch (SelectIndex)
|
|
|
|
|
string content = checkBox.Content.ToString();
|
|
|
|
|
string conStr = (content == "SHZ") ? ".Z" : (content == "SHN") ? ".N" : ".E";
|
|
|
|
|
for (int i = 0; i <_chartAxisY.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
indexs = v.YAxes.Select(a => a.Title.Text.Contains(".Z")).ToList();
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
indexs = v.YAxes.Select(a => a.Title.Text.Contains(".N")).ToList();
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
indexs = v.YAxes.Select(a => a.Title.Text.Contains(".E")).ToList();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < indexs.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (indexs[i] == true)
|
|
|
|
|
AxisY axisY = _chartAxisY[i];
|
|
|
|
|
if (axisY.Title.Text.Contains(conStr))
|
|
|
|
|
{
|
|
|
|
|
AxisY axisY = v.YAxes[i];
|
|
|
|
|
axisY.Visible = !yAxesVisible;
|
|
|
|
|
v.SampleDataSeries[i].Visible = !yAxesVisible;
|
|
|
|
|
int index = v.LineCollections.FindIndex(a => a.AssignYAxisIndex == i);
|
|
|
|
|
if (index != -1)
|
|
|
|
|
if (yAxesVisible)
|
|
|
|
|
{
|
|
|
|
|
v.LineCollections[index].Visible = !yAxesVisible;
|
|
|
|
|
v.YAxes.Remove(axisY);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string str = axisY.Title.Text.Replace(conStr, "");
|
|
|
|
|
int yIndex = 0;
|
|
|
|
|
if (content == "SHZ")
|
|
|
|
|
{
|
|
|
|
|
yIndex = v.YAxes.FindIndex(y => y.Title.Text.Contains(str));
|
|
|
|
|
}
|
|
|
|
|
else if (content == "SHE")
|
|
|
|
|
{
|
|
|
|
|
yIndex = v.YAxes.FindLastIndex(y => y.Title.Text.Contains(str));
|
|
|
|
|
if (yIndex != -1) yIndex += 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
yIndex = v.YAxes.FindIndex(y => y.Title.Text.Contains(str));
|
|
|
|
|
if (yIndex != -1)
|
|
|
|
|
{
|
|
|
|
|
if (v.YAxes[yIndex].Title.Text.Contains(".Z"))
|
|
|
|
|
{
|
|
|
|
|
yIndex = yIndex + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//如果没有查到,直接添加到前面,如果为容器最大索引,只能添加到后面
|
|
|
|
|
if (yIndex == -1 || (yIndex == v.YAxes.Count))
|
|
|
|
|
{
|
|
|
|
|
yIndex = v.YAxes.Count;
|
|
|
|
|
v.YAxes.Add(axisY);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
v.YAxes.Insert(yIndex, axisY);
|
|
|
|
|
}
|
|
|
|
|
int sampleIndex = v.SampleDataSeries.FindIndex(y => y.Title.Text == _chartAxisY[i].Title.Text);
|
|
|
|
|
v.SampleDataSeries[sampleIndex].AssignYAxisIndex = yIndex;
|
|
|
|
|
int lineIndex = v.LineCollections.FindIndex(a => a.Title.Text.Contains(_chartAxisY[i].Title.Text));
|
|
|
|
|
if (lineIndex != -1)
|
|
|
|
|
{
|
|
|
|
|
v.LineCollections[lineIndex].AssignYAxisIndex = yIndex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -348,33 +313,39 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void StationYaxisVisible(bool visible)
|
|
|
|
|
private void StationsNameVisible(object obj)
|
|
|
|
|
{
|
|
|
|
|
var station = obj as StationAxis;
|
|
|
|
|
if (_lChartAll != null)
|
|
|
|
|
{
|
|
|
|
|
_lChartAll.BeginUpdate();
|
|
|
|
|
bool yAxesVisible = ((bool)visible == true);
|
|
|
|
|
bool yAxesVisible = (station.IsChecked == false);
|
|
|
|
|
ViewXY v = _lChartAll.ViewXY;
|
|
|
|
|
for (int i = 0; i < v.YAxes.Count; i++)
|
|
|
|
|
var yAxisList= _chartAxisY.Where(y => y.Title.Text.Contains(station.Name));
|
|
|
|
|
foreach (var item in yAxisList)
|
|
|
|
|
{
|
|
|
|
|
AxisY axisY = v.YAxes[i];
|
|
|
|
|
if (axisY.Title.Text.Contains(StationYaxis[SelectStationYaxisIndex]))
|
|
|
|
|
if (yAxesVisible)
|
|
|
|
|
{
|
|
|
|
|
axisY.Visible = !yAxesVisible;
|
|
|
|
|
v.SampleDataSeries[i].Visible = !yAxesVisible;
|
|
|
|
|
int index = v.LineCollections.FindIndex(a => a.AssignYAxisIndex == i);
|
|
|
|
|
if (index != -1)
|
|
|
|
|
v.YAxes.Remove(item);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
v.YAxes.Add(item);
|
|
|
|
|
//SampleDataSeries查找数据对应的Y轴索引, 重新分配到对应的轴
|
|
|
|
|
int sampleIndex = v.SampleDataSeries.FindIndex(s => s.Title.Text == item.Title.Text);
|
|
|
|
|
v.SampleDataSeries[sampleIndex].AssignYAxisIndex = v.YAxes.Count()-1;
|
|
|
|
|
//LineCollections查找数据对应的Y轴索引, 重新分配到对应的轴
|
|
|
|
|
int lineIndex = v.LineCollections.FindIndex(s => s.Title.Text.Contains(item.Title.Text));
|
|
|
|
|
if (lineIndex != -1)
|
|
|
|
|
{
|
|
|
|
|
v.LineCollections[index].Visible = !yAxesVisible;
|
|
|
|
|
v.LineCollections[lineIndex].AssignYAxisIndex = v.YAxes.Count() - 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
_lChartAll.EndUpdate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void RealTimeData(object isCheck)
|
|
|
|
|
{
|
|
|
|
|
if (_lChartAll != null)
|
|
|
|
@ -400,93 +371,7 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
_lChartAll.EndUpdate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
public List<StationModel> UpdateWavesFromTxt(string fn)
|
|
|
|
|
{
|
|
|
|
|
string allStr;
|
|
|
|
|
List<StationModel> temSM = new List<StationModel>();
|
|
|
|
|
using (StreamReader streamReader = new StreamReader(fn))
|
|
|
|
|
{
|
|
|
|
|
allStr = streamReader.ReadToEnd();
|
|
|
|
|
}
|
|
|
|
|
if (allStr.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
string[] strLines = allStr.Trim().Split(new char[] { '\n' });
|
|
|
|
|
List<string> strList = strLines.ToList();
|
|
|
|
|
int cnt = strList.Count;
|
|
|
|
|
string[] snStr = strLines[0].Trim().Split(',');
|
|
|
|
|
string tmpName = snStr[0].Substring(14, 3);
|
|
|
|
|
CurPoints = int.Parse(snStr[1].Trim().Split(' ')[0]);
|
|
|
|
|
StationModel station = new StationModel();
|
|
|
|
|
station.Name = tmpName;
|
|
|
|
|
|
|
|
|
|
int channelFlag = 0;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < strLines.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
string row = strLines[i].Trim();
|
|
|
|
|
if (strLines[i].Contains("HA"))
|
|
|
|
|
{
|
|
|
|
|
string[] rowStr = strLines[i].Split(',');
|
|
|
|
|
string chnStr1 = rowStr[0].Substring(21, 3);
|
|
|
|
|
string stationName = rowStr[0].Substring(14, 3);
|
|
|
|
|
if (!temSM.Any(name => name.Name == stationName))
|
|
|
|
|
{
|
|
|
|
|
station = new StationModel();
|
|
|
|
|
station.Name = stationName;
|
|
|
|
|
station.BeginTime = Convert.ToDateTime(rowStr[3]);
|
|
|
|
|
station.PointCount = int.Parse(rowStr[1].Trim().Split(' ')[0]);
|
|
|
|
|
station.SamplingFrequency = int.Parse(rowStr[2].Trim().Split(' ')[0]);
|
|
|
|
|
temSM.Add(station);
|
|
|
|
|
}
|
|
|
|
|
if (chnStr1 == "SHZ")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
channelFlag = 0;//Z
|
|
|
|
|
}
|
|
|
|
|
else if (chnStr1 == "SHN")
|
|
|
|
|
{
|
|
|
|
|
channelFlag = 1;//N
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
channelFlag = 2;//E
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch (channelFlag)
|
|
|
|
|
{
|
|
|
|
|
case 0://Z
|
|
|
|
|
station.dz.Add(double.Parse(row));
|
|
|
|
|
break;
|
|
|
|
|
case 1://N
|
|
|
|
|
station.dn.Add(double.Parse(row));
|
|
|
|
|
break;
|
|
|
|
|
case 2://E
|
|
|
|
|
station.de.Add(double.Parse(row));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// temSM.Add(station);
|
|
|
|
|
temSM.Reverse();
|
|
|
|
|
}
|
|
|
|
|
return temSM;
|
|
|
|
|
}
|
|
|
|
|
public void MSeed2Asc(string filePath, string savePath)
|
|
|
|
|
{
|
|
|
|
|
using (Process compiler = new Process())
|
|
|
|
|
{
|
|
|
|
|
compiler.StartInfo.FileName = "mseed2ascii.exe";
|
|
|
|
|
compiler.StartInfo.Arguments = filePath + " -o " + savePath;
|
|
|
|
|
compiler.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
|
|
|
|
compiler.StartInfo.CreateNoWindow = true;
|
|
|
|
|
compiler.Start();
|
|
|
|
|
compiler.WaitForExit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
private void CreateChart()
|
|
|
|
|
{
|
|
|
|
|
if (LChartALL != null)
|
|
|
|
@ -507,7 +392,7 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
LChartALL.ViewXY.ZoomPanOptions.PanDirection = PanDirection.Horizontal;
|
|
|
|
|
LChartALL.ViewXY.ZoomPanOptions.WheelZooming = WheelZooming.Horizontal;
|
|
|
|
|
LChartALL.ViewXY.AxisLayout.YAxisAutoPlacement = YAxisAutoPlacement.AllLeft;
|
|
|
|
|
LChartALL.ViewXY.AxisLayout.YAxisTitleAutoPlacement = true;
|
|
|
|
|
LChartALL.ViewXY.AxisLayout.YAxisTitleAutoPlacement = false;
|
|
|
|
|
LChartALL.ViewXY.AxisLayout.AutoAdjustMargins = false;
|
|
|
|
|
|
|
|
|
|
LChartALL.ViewXY.ZoomPanOptions.DevicePrimaryButtonAction = UserInteractiveDeviceButtonAction.None;
|
|
|
|
@ -539,61 +424,10 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
|
|
|
|
|
this.ChildContent = GridChart;
|
|
|
|
|
}
|
|
|
|
|
private void ShowWave(string dataFilePath, string asciiSavePath, bool isMultFile = false)
|
|
|
|
|
{
|
|
|
|
|
if (!Directory.Exists(Path.GetDirectoryName(dataFilePath)))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(Path.GetDirectoryName(dataFilePath));
|
|
|
|
|
}
|
|
|
|
|
if (!Directory.Exists(Path.GetDirectoryName(asciiSavePath)))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(Path.GetDirectoryName(asciiSavePath));
|
|
|
|
|
}
|
|
|
|
|
smList = new ConcurrentQueue<StationModel>();
|
|
|
|
|
if (isMultFile)
|
|
|
|
|
{
|
|
|
|
|
var filePath = new DirectoryInfo(Path.GetDirectoryName(dataFilePath));
|
|
|
|
|
FileInfo[] files = filePath.GetFiles();
|
|
|
|
|
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, Path.Combine(Path.GetDirectoryName(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));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!File.Exists(asciiSavePath))
|
|
|
|
|
{
|
|
|
|
|
MSeed2Asc(dataFilePath, asciiSavePath);
|
|
|
|
|
}
|
|
|
|
|
var list = UpdateWavesFromTxt(asciiSavePath);
|
|
|
|
|
list.ForEach(i => smList.Enqueue(i));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_channelCount = smList.Count * 3;
|
|
|
|
|
StationYaxis = smList.Select(a => a.Name).ToList();
|
|
|
|
|
UpdateChart();
|
|
|
|
|
UpdateChartData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateChart()
|
|
|
|
|
private void StartChart()
|
|
|
|
|
{
|
|
|
|
|
DisposeAllAndClear(_chartAxisY);
|
|
|
|
|
ViewXY v = LChartALL.ViewXY;
|
|
|
|
|
DisposeAllAndClear(v.YAxes);
|
|
|
|
|
DisposeAllAndClear(v.SampleDataSeries);
|
|
|
|
@ -604,28 +438,32 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
v.LegendBoxes[0].Offset.SetValues(-10, 180);
|
|
|
|
|
v.LegendBoxes[0].Layout = LegendBoxLayout.Vertical;
|
|
|
|
|
v.LegendBoxes[0].Visible = false;
|
|
|
|
|
v.LegendBoxes[0].Shadow.Color = Colors.Transparent;
|
|
|
|
|
v.LegendBoxes[0].BorderColor = Colors.Transparent;
|
|
|
|
|
v.AutoSpaceLegendBoxes = true;
|
|
|
|
|
v.AxisLayout.SegmentsGap = 3;
|
|
|
|
|
v.LegendBoxes[0].Shadow.Visible = false;
|
|
|
|
|
|
|
|
|
|
StationModel stationModel = smList.ElementAt(0);
|
|
|
|
|
StationModel stationModel = smList.First();
|
|
|
|
|
var beginTime= stationModel.BeginTime;
|
|
|
|
|
if (AxisValueType.DateTime == v.XAxes[0].ValueType)
|
|
|
|
|
{
|
|
|
|
|
//设置X轴的开始时间
|
|
|
|
|
v.XAxes[0].AutoFormatLabels = false;
|
|
|
|
|
v.XAxes[0].LabelsTimeFormat = "HH:mm:ss.ff";
|
|
|
|
|
v.XAxes[0].DateOriginYear = CurrentEventTime.otime.Year;
|
|
|
|
|
v.XAxes[0].DateOriginDay = CurrentEventTime.otime.Day;
|
|
|
|
|
v.XAxes[0].DateOriginMonth = CurrentEventTime.otime.Month;
|
|
|
|
|
|
|
|
|
|
DateTime MaxDateTime = CurrentEventTime.otime.AddSeconds(_samplingFrequency == 500 ? 30 : 60);
|
|
|
|
|
v.XAxes[0].SetRange(v.XAxes[0].DateTimeToAxisValue(CurrentEventTime.otime), v.XAxes[0].DateTimeToAxisValue(MaxDateTime));
|
|
|
|
|
v.XAxes[0].DateOriginYear = beginTime.Year;
|
|
|
|
|
v.XAxes[0].DateOriginDay = beginTime.Day;
|
|
|
|
|
v.XAxes[0].DateOriginMonth = beginTime.Month;
|
|
|
|
|
DateTime MaxDateTime = beginTime.AddSeconds(_samplingFrequency == 500 ? 30 : 60);
|
|
|
|
|
v.XAxes[0].SetRange(v.XAxes[0].DateTimeToAxisValue(beginTime), v.XAxes[0].DateTimeToAxisValue(MaxDateTime));
|
|
|
|
|
}
|
|
|
|
|
double firstSampleTimeStamp = v.XAxes[0].DateTimeToAxisValue(beginTime);
|
|
|
|
|
|
|
|
|
|
double firstSampleTimeStamp = v.XAxes[0].DateTimeToAxisValue(CurrentEventTime.otime);
|
|
|
|
|
for (int i = 0; i < smList.Count; i++)
|
|
|
|
|
int count = stationModel.Dzne.Count;
|
|
|
|
|
int number= smList.Count;
|
|
|
|
|
for (int i = 0; i < number; i++)
|
|
|
|
|
{
|
|
|
|
|
for (int k = 0; k < smList.ElementAt(i).Dzne.Count; k++)
|
|
|
|
|
for (int k = 0; k <count; k++)
|
|
|
|
|
{
|
|
|
|
|
int seriesIndex = i * 3 + k;
|
|
|
|
|
AxisY axisY = v.YAxes[seriesIndex];
|
|
|
|
@ -637,12 +475,11 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
axisY.LabelsAngle = 0;
|
|
|
|
|
axisY.LabelsFont.Size = 8;
|
|
|
|
|
axisY.Title.Angle = 0;
|
|
|
|
|
axisY.MajorGrid.Visible = true;
|
|
|
|
|
// axisY.MajorGrid.Visible = true;
|
|
|
|
|
axisY.MinorGrid.Visible = false;
|
|
|
|
|
axisY.MajorGrid.Pattern = LinePattern.Solid;
|
|
|
|
|
axisY.AutoDivSpacing = false;
|
|
|
|
|
// axisY.AutoDivSeparationPercent = 100;
|
|
|
|
|
axisY.Visible = true;
|
|
|
|
|
|
|
|
|
|
axisY.MajorDivCount = 2;
|
|
|
|
|
axisY.MajorDivTickStyle.Visible = true;
|
|
|
|
|
axisY.MinorDivTickStyle.Visible = false;
|
|
|
|
@ -679,25 +516,32 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
series.ScrollingStabilizing = true;
|
|
|
|
|
series.AllowUserInteraction = false;
|
|
|
|
|
v.SampleDataSeries.Add(series);
|
|
|
|
|
_chartAxisY.Add(axisY);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void UpdateChartData()
|
|
|
|
|
|
|
|
|
|
private void FeedDatasToChart()
|
|
|
|
|
{
|
|
|
|
|
double[][] multiChannelData = new double[smList.Count * 3][];
|
|
|
|
|
_data = new double[smList.Count * 3][];
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
for (int channelIndex = 0; channelIndex < smList.Count; channelIndex++)
|
|
|
|
|
{
|
|
|
|
|
multiChannelData[channelIndex * 3] = smList.ElementAt(channelIndex).dz.ToArray();
|
|
|
|
|
multiChannelData[channelIndex * 3 + 1] = smList.ElementAt(channelIndex).dn.ToArray();
|
|
|
|
|
multiChannelData[channelIndex * 3 + 2] = smList.ElementAt(channelIndex).de.ToArray();
|
|
|
|
|
_data[channelIndex * 3] = smList.ElementAt(channelIndex).dz.ToArray();
|
|
|
|
|
_data[channelIndex * 3 + 1] = smList.ElementAt(channelIndex).dn.ToArray();
|
|
|
|
|
_data[channelIndex * 3 + 2] = smList.ElementAt(channelIndex).de.ToArray();
|
|
|
|
|
}
|
|
|
|
|
_data = multiChannelData;
|
|
|
|
|
// Invoke FeedNewDataToChart.
|
|
|
|
|
_dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
FeedNewDataToChar(multiChannelData);
|
|
|
|
|
LChartALL.BeginUpdate();
|
|
|
|
|
_wavesModel.CreateAxisYEventTime(CurrentEventTime, LChartALL.ViewXY, smList.ToList());
|
|
|
|
|
for (int channelIndex = 0; channelIndex < _channelCount; channelIndex++)
|
|
|
|
|
{
|
|
|
|
|
LChartALL.ViewXY.SampleDataSeries[channelIndex].AddSamples(_data[channelIndex], true);
|
|
|
|
|
}
|
|
|
|
|
LChartALL.EndUpdate();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
@ -744,19 +588,6 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FeedNewDataToChar(double[][] data)
|
|
|
|
|
{
|
|
|
|
|
LChartALL.BeginUpdate();
|
|
|
|
|
_wavesModel.CreateAxisYEventTime(CurrentEventTime, LChartALL.ViewXY, smList.ToList());
|
|
|
|
|
for (int channelIndex = 0; channelIndex < _channelCount; channelIndex++)
|
|
|
|
|
{
|
|
|
|
|
LChartALL.ViewXY.SampleDataSeries[channelIndex].AddSamples(data[channelIndex], true);
|
|
|
|
|
}
|
|
|
|
|
LChartALL.EndUpdate();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 实时数据
|
|
|
|
|
private void CompositionTarget_Rendering(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
@ -780,7 +611,6 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
int PreGenerateDataForRoundCount = 6;
|
|
|
|
|
private void FeedData(/*string chartTitleText*/)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (_lChartAll != null)
|
|
|
|
|
{
|
|
|
|
|
_lChartAll.BeginUpdate();
|
|
|
|
|