|
|
|
@ -31,6 +31,7 @@ using System.Windows.Markup;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
using System.Windows.Threading;
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
|
|
|
|
|
namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
{
|
|
|
|
@ -72,7 +73,7 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
public int CurPoints;
|
|
|
|
|
|
|
|
|
|
int _channelCount = 0;
|
|
|
|
|
double _samplingFrequency = 500; // 采样频率 (Hz).
|
|
|
|
|
int _samplingFrequency = 500; // 采样频率 (Hz).
|
|
|
|
|
WavesModel _wavesModel;
|
|
|
|
|
private int _lChartCount = 1;
|
|
|
|
|
public ConcurrentQueue<StationModel> smList;
|
|
|
|
@ -200,6 +201,8 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
public DelegateCommand<object> YasixZENVisibleCommand => new DelegateCommand<object>(YasixZENVisible);
|
|
|
|
|
public DelegateCommand IntervalSureCommand => new DelegateCommand(IntervalSure);
|
|
|
|
|
|
|
|
|
|
public DelegateCommand<object> RealTimeDataCommand => new DelegateCommand<object>(RealTimeData);
|
|
|
|
|
|
|
|
|
|
private void AxesYVisible(object isCheck)
|
|
|
|
|
{
|
|
|
|
|
if (_lChartAll != null)
|
|
|
|
@ -370,6 +373,33 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
_lChartAll.EndUpdate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void RealTimeData(object isCheck)
|
|
|
|
|
{
|
|
|
|
|
if (_lChartAll != null)
|
|
|
|
|
{
|
|
|
|
|
bool yAxesVisible = ((bool)isCheck == true);
|
|
|
|
|
_lChartAll.BeginUpdate();
|
|
|
|
|
if (yAxesVisible)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//Set real-time monitoring automatic old data destruction
|
|
|
|
|
LChartALL.ViewXY.DropOldSeriesData = true;
|
|
|
|
|
_pointsAppended = LChartALL.ViewXY.XAxes[0].Minimum;
|
|
|
|
|
CompositionTarget.Rendering -= CompositionTarget_Rendering;
|
|
|
|
|
CompositionTarget.Rendering += CompositionTarget_Rendering;
|
|
|
|
|
LChartALL.ViewXY.XAxes[0].ScrollMode = XAxisScrollMode.Scrolling;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
LChartALL.ViewXY.XAxes[0].ScrollMode = XAxisScrollMode.None;
|
|
|
|
|
CompositionTarget.Rendering -= CompositionTarget_Rendering;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_lChartAll.EndUpdate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
public List<StationModel> UpdateWavesFromTxt(string fn)
|
|
|
|
|
{
|
|
|
|
@ -663,6 +693,7 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
multiChannelData[channelIndex * 3 + 1] = smList.ElementAt(channelIndex).dn.ToArray();
|
|
|
|
|
multiChannelData[channelIndex * 3 + 2] = smList.ElementAt(channelIndex).de.ToArray();
|
|
|
|
|
}
|
|
|
|
|
_data = multiChannelData;
|
|
|
|
|
// Invoke FeedNewDataToChart.
|
|
|
|
|
_dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
@ -725,5 +756,91 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 实时数据
|
|
|
|
|
private void CompositionTarget_Rendering(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
RenderNextFrame();
|
|
|
|
|
}
|
|
|
|
|
private void RenderNextFrame()
|
|
|
|
|
{
|
|
|
|
|
if (_lChartAll == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
FeedData(/*chartTitleText*/);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
int _iRound = 0;
|
|
|
|
|
double _pointsAppended = 0;
|
|
|
|
|
double[][] _data;
|
|
|
|
|
int PreGenerateDataForRoundCount = 6;
|
|
|
|
|
private void FeedData(/*string chartTitleText*/)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (_lChartAll != null)
|
|
|
|
|
{
|
|
|
|
|
_lChartAll.BeginUpdate();
|
|
|
|
|
|
|
|
|
|
//Append data to series
|
|
|
|
|
System.Threading.Tasks.Parallel.For(0, _channelCount, (seriesIndex) =>
|
|
|
|
|
{
|
|
|
|
|
double[] thisSeriesData = _data[seriesIndex];
|
|
|
|
|
double[] dataToAppendNow = new double[_samplingFrequency];
|
|
|
|
|
Array.Copy(thisSeriesData, (_iRound % PreGenerateDataForRoundCount) * _samplingFrequency, dataToAppendNow, 0, _samplingFrequency);
|
|
|
|
|
_lChartAll.ViewXY.SampleDataSeries[seriesIndex].AddSamples(dataToAppendNow, false);
|
|
|
|
|
System.Diagnostics.Debug.WriteLine("***********index:{0}, pointCount:{1},time:{2}", seriesIndex,
|
|
|
|
|
_lChartAll.ViewXY.SampleDataSeries[seriesIndex].PointCount, DateTime.Now);
|
|
|
|
|
});
|
|
|
|
|
_pointsAppended += 1;
|
|
|
|
|
|
|
|
|
|
//Set X axis real-time scrolling position
|
|
|
|
|
double lastX = _pointsAppended;
|
|
|
|
|
_lChartAll.ViewXY.XAxes[0].ScrollPosition = lastX;
|
|
|
|
|
|
|
|
|
|
//Update sweep bands
|
|
|
|
|
if (_lChartAll.ViewXY.XAxes[0].ScrollMode == XAxisScrollMode.Sweeping)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//Dark band of old page fading away
|
|
|
|
|
double pageLen = _lChartAll.ViewXY.XAxes[0].Maximum - _lChartAll.ViewXY.XAxes[0].Minimum;
|
|
|
|
|
double sweepGapWidth = pageLen / 20.0;
|
|
|
|
|
_lChartAll.ViewXY.Bands[0].SetValues(lastX - pageLen, lastX - pageLen + sweepGapWidth);
|
|
|
|
|
if (_lChartAll.ViewXY.Bands[0].Visible == false)
|
|
|
|
|
{
|
|
|
|
|
_lChartAll.ViewXY.Bands[0].Visible = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Bright new page band
|
|
|
|
|
_lChartAll.ViewXY.Bands[1].SetValues(lastX - sweepGapWidth / 6, lastX);
|
|
|
|
|
if (_lChartAll.ViewXY.Bands[1].Visible == false)
|
|
|
|
|
{
|
|
|
|
|
_lChartAll.ViewXY.Bands[1].Visible = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//Hide sweeping bands if not in sweeping mode
|
|
|
|
|
//if (_lChartAll.ViewXY.Bands[0].Visible == true)
|
|
|
|
|
//{
|
|
|
|
|
// _lChartAll.ViewXY.Bands[0].Visible = false;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//if (_lChartAll.ViewXY.Bands[1].Visible == true)
|
|
|
|
|
//{
|
|
|
|
|
// _lChartAll.ViewXY.Bands[1].Visible = false;
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
_lChartAll.EndUpdate();
|
|
|
|
|
|
|
|
|
|
_iRound++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|