|
|
|
@ -69,7 +69,7 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
|
|
|
|
|
Dispatcher _dispatcher;
|
|
|
|
|
public int CurPoints;
|
|
|
|
|
int _channelCount = 0;
|
|
|
|
|
int _samplingFrequency = 1000; // 采样频率 (Hz).
|
|
|
|
|
int _samplingFrequency = 500; // 采样频率 (Hz).
|
|
|
|
|
WavesModel _wavesModel;
|
|
|
|
|
private int _lChartCount = 1;
|
|
|
|
|
public ConcurrentQueue<StationModel> smList=new ConcurrentQueue<StationModel>();
|
|
|
|
@ -302,14 +302,6 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
|
|
|
|
|
YasixZENVisible(".E", SHEChannel);
|
|
|
|
|
YasixZENVisible(".N", SHNChannel);
|
|
|
|
|
_lChartAll.EndUpdate();
|
|
|
|
|
//if (index * 30 < 800)
|
|
|
|
|
//{
|
|
|
|
|
// ChartHeight = 800;
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// ChartHeight = index * 50;
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -503,15 +495,15 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
|
|
|
|
|
IsEnableStartRealtime = false;
|
|
|
|
|
IsEnableStopRealtime = true;
|
|
|
|
|
_data = new double[smList.Count * 3][];
|
|
|
|
|
beginTime = DateTime.Now.AddSeconds(-0.5);
|
|
|
|
|
beginTime = DateTime.Now.AddSeconds(-30.5);
|
|
|
|
|
currentTime = beginTime;
|
|
|
|
|
if (AxisValueType.DateTime == LChartALL.ViewXY.XAxes[0].ValueType)
|
|
|
|
|
{
|
|
|
|
|
DateTime MaxDateTime = currentTime.AddSeconds(_samplingFrequency == 1000 ? 30 : 60);
|
|
|
|
|
DateTime MaxDateTime = currentTime.AddSeconds(30);
|
|
|
|
|
LChartALL.ViewXY.XAxes[0].SetRange(LChartALL.ViewXY.XAxes[0].DateTimeToAxisValue(currentTime), LChartALL.ViewXY.XAxes[0].DateTimeToAxisValue(MaxDateTime));
|
|
|
|
|
}
|
|
|
|
|
LChartALL.ViewXY.DropOldSeriesData = true;
|
|
|
|
|
//Set real-time monitoring automatic old data destruction
|
|
|
|
|
|
|
|
|
|
_pointsAppended = LChartALL.ViewXY.XAxes[0].Minimum;
|
|
|
|
|
_lChartAll.ViewXY.XAxes[0].ScrollPosition = _pointsAppended;
|
|
|
|
|
|
|
|
|
@ -573,8 +565,8 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
|
|
|
|
|
string[] sid = asciiData.sid.Substring(5).Split('_');
|
|
|
|
|
string name = $"{sid[0]}.{sid[1]}.{sid[2]}.{sid[3]}{sid[4]}{sid[5]}";
|
|
|
|
|
var ts = DateTime.Now.Subtract(startTime);
|
|
|
|
|
//System.Diagnostics.Debug.WriteLine($"台站号:{name},总数:{asciiData.samprate},{asciiData.datasize},{asciiData.samplecnt}, {asciiData.numsamples},当前时间:{DateTime.Now.ToString("o")},接时间:{startTime.ToString("o")}********时间差:{ts.TotalSeconds}秒");
|
|
|
|
|
if ( ts.TotalSeconds > 10)
|
|
|
|
|
System.Diagnostics.Debug.WriteLine($"台站号:{name},总数:{asciiData.samprate},{asciiData.datasize},{asciiData.samplecnt}, {asciiData.numsamples},当前时间:{DateTime.Now.ToString("o")},接时间:{startTime.ToString("o")}********时间差:{ts.TotalSeconds}秒");
|
|
|
|
|
if ( ts.TotalSeconds > 20)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -612,7 +604,7 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
var flag = subNameList[name].DataOrders.TryPeek(out ChartSamples dataOrder);
|
|
|
|
|
if (flag && DateTime.Now.Subtract(dataOrder.StartTime).TotalSeconds > 35)
|
|
|
|
|
if (flag && DateTime.Now.Subtract(dataOrder.StartTime).TotalSeconds > 60)
|
|
|
|
|
{
|
|
|
|
|
//删除过期数据
|
|
|
|
|
subNameList[name].DataOrders.TryDequeue(out ChartSamples chart);
|
|
|
|
@ -722,11 +714,8 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
|
|
|
|
|
//设置X轴的开始时间
|
|
|
|
|
v.XAxes[0].AutoFormatLabels = false;
|
|
|
|
|
v.XAxes[0].LabelsTimeFormat = "HH:mm:ss.f";
|
|
|
|
|
// v.XAxes[0].DateOriginYear = beginTime.Year;
|
|
|
|
|
// v.XAxes[0].DateOriginDay = beginTime.Day;
|
|
|
|
|
// v.XAxes[0].DateOriginMonth = beginTime.Month;
|
|
|
|
|
DateTime MaxDateTime = beginTime.AddSeconds(_samplingFrequency == 1000? 30 : 60);
|
|
|
|
|
v.XAxes[0].SetRange(v.XAxes[0].DateTimeToAxisValue(beginTime), v.XAxes[0].DateTimeToAxisValue(MaxDateTime));
|
|
|
|
|
// DateTime MaxDateTime = beginTime.AddSeconds(30);
|
|
|
|
|
//v.XAxes[0].SetRange(v.XAxes[0].DateTimeToAxisValue(beginTime), v.XAxes[0].DateTimeToAxisValue(MaxDateTime));
|
|
|
|
|
}
|
|
|
|
|
double firstSampleTimeStamp = v.XAxes[0].DateTimeToAxisValue(beginTime);
|
|
|
|
|
|
|
|
|
@ -774,7 +763,7 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
|
|
|
|
|
series.SampleFormat = SampleFormat.DoubleFloat;
|
|
|
|
|
|
|
|
|
|
string subName = string.Empty;
|
|
|
|
|
string name = axisY.Title.Text.Substring(0,4);
|
|
|
|
|
string name = axisY.Title.Text.Substring(0,3);
|
|
|
|
|
if (seriesIndex % 3 == 0)
|
|
|
|
|
{
|
|
|
|
|
subName = $"{workarea.StationConfig.Network}.{name}.{workarea.StationConfig.Location}." +
|
|
|
|
@ -935,25 +924,20 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
|
|
|
|
|
; foreach (var item in subNameList)
|
|
|
|
|
{
|
|
|
|
|
List<double> temDou = new List<double>();
|
|
|
|
|
var tem = item.Value.DataOrders.Where(d => d.StartTime > currentTime.AddSeconds(-30));
|
|
|
|
|
var tem = item.Value.DataOrders.Where(d => d.StartTime > currentTime.AddSeconds(-30) && d.StartTime < currentTime.AddSeconds(0.5));
|
|
|
|
|
if (tem.Any())
|
|
|
|
|
{
|
|
|
|
|
item.Value.FirstSampleTime = tem.ElementAt(0).StartTime; //设置数据的开始时间
|
|
|
|
|
tem.ToList().ForEach(d => temDou.AddRange(d.DataArray));
|
|
|
|
|
var time = (currentTime - tem.Last().StartTime).Duration();
|
|
|
|
|
if (time.TotalSeconds > 2 && time.TotalSeconds < 30)
|
|
|
|
|
{
|
|
|
|
|
//中途未收数据填充均值
|
|
|
|
|
temDou.AddRange(Enumerable.Repeat(temDou.Average(), (int)time.TotalMilliseconds));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_data[item.Value.Index] = temDou.ToArray();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//没有收到数据的通道填充0
|
|
|
|
|
var duration = (DateTime.Now - beginTime).Duration();
|
|
|
|
|
var duration = (currentTime - beginTime.AddSeconds(-1)).Duration();
|
|
|
|
|
item.Value.FirstSampleTime = duration.TotalSeconds > 30 ? currentTime.AddSeconds(-29) : beginTime;
|
|
|
|
|
int feed = duration.TotalSeconds > 30 ? 30 * 1000 : (int)duration.TotalMilliseconds;
|
|
|
|
|
int feed = duration.TotalSeconds > 30 ? 30 * _samplingFrequency : (int)duration.TotalSeconds* _samplingFrequency;
|
|
|
|
|
_data[item.Value.Index] = new double[feed];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -988,8 +972,7 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
|
|
|
|
|
var d = _lChartAll.ViewXY.XAxes[0].DateTimeToAxisValue(item.Value.FirstSampleTime);
|
|
|
|
|
_lChartAll.ViewXY.SampleDataSeries[index].FirstSampleTimeStamp = d;// _lChartAll.ViewXY.XAxes[0].Minimum;// item.Value.FirstSampleTimeStamp;
|
|
|
|
|
}
|
|
|
|
|
//Append data to series
|
|
|
|
|
System.Threading.Tasks.Parallel.For(0, _channelCount, (seriesIndex) =>
|
|
|
|
|
Parallel.For(0, _channelCount, (seriesIndex) =>
|
|
|
|
|
{
|
|
|
|
|
double[] thisSeriesData = _data[seriesIndex];
|
|
|
|
|
|
|
|
|
@ -1004,137 +987,12 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
|
|
|
|
|
});
|
|
|
|
|
_pointsAppended += 1;
|
|
|
|
|
|
|
|
|
|
//Set X axis real-time scrolling position
|
|
|
|
|
double lastX = _pointsAppended * XInterval;
|
|
|
|
|
_lChartAll.ViewXY.XAxes[0].ScrollPosition = lastX;
|
|
|
|
|
_lChartAll.EndUpdate();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//Append data point per round count
|
|
|
|
|
private int _appendCountPerRound=30000;
|
|
|
|
|
//X axis length
|
|
|
|
|
private double _xLen;
|
|
|
|
|
//Generate this many rounds of data
|
|
|
|
|
private const int PreGenerateDataForRoundCount = 10;
|
|
|
|
|
//X data point step
|
|
|
|
|
private const double XInterval = 1;
|
|
|
|
|
//Data feeding round
|
|
|
|
|
private int _iRound = 0;
|
|
|
|
|
|
|
|
|
|
//Y axis minimum
|
|
|
|
|
private const double YMin = 0;
|
|
|
|
|
|
|
|
|
|
//Y axis maximum
|
|
|
|
|
private const double YMax = 100;
|
|
|
|
|
|
|
|
|
|
private double[][] CreateInputData(int seriesCount, int appendCountPerRound)
|
|
|
|
|
{
|
|
|
|
|
//Create input data for all series.
|
|
|
|
|
double[][] data = new double[seriesCount][];
|
|
|
|
|
// System.Threading.Tasks.Parallel.For(0, seriesCount, (seriesIndex) =>
|
|
|
|
|
for (int seriesIndex = 0; seriesIndex < seriesCount; seriesIndex++)
|
|
|
|
|
{
|
|
|
|
|
int dataPointCount = PreGenerateDataForRoundCount * appendCountPerRound;
|
|
|
|
|
double[] seriesData = new double[dataPointCount];
|
|
|
|
|
float seriesIndexPlus1 = seriesIndex + 1;
|
|
|
|
|
Random rand = new Random((int)DateTime.Now.Ticks / (seriesIndex + 1));
|
|
|
|
|
|
|
|
|
|
double y = 50;
|
|
|
|
|
for (int i = 0; i < dataPointCount; i++)
|
|
|
|
|
{
|
|
|
|
|
y = y - 0.05 + rand.NextDouble() / 10.0;
|
|
|
|
|
if (y > YMax)
|
|
|
|
|
{
|
|
|
|
|
y = YMax;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (y < YMin)
|
|
|
|
|
{
|
|
|
|
|
y = YMin;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
seriesData[i] = (float)y;
|
|
|
|
|
}
|
|
|
|
|
data[seriesIndex] = seriesData;
|
|
|
|
|
}//);
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
private void PrefillChartWithData()
|
|
|
|
|
{
|
|
|
|
|
/* test
|
|
|
|
|
_lChartAll.BeginUpdate();
|
|
|
|
|
_data = CreateInputData(smList.Count * 3, _appendCountPerRound);
|
|
|
|
|
LChartALL.ViewXY.DropOldSeriesData = true;
|
|
|
|
|
_pointsAppended = LChartALL.ViewXY.XAxes[0].Minimum;
|
|
|
|
|
time.Elapsed -= CompositionTarget_Rendering;
|
|
|
|
|
time.Elapsed += CompositionTarget_Rendering;
|
|
|
|
|
LChartALL.ViewXY.XAxes[0].ScrollMode = XAxisScrollMode.Scrolling;
|
|
|
|
|
LChartALL.ViewXY.AxisLayout.AutoShrinkSegmentsGap = true;
|
|
|
|
|
_lChartAll.EndUpdate();
|
|
|
|
|
time.Start();*/
|
|
|
|
|
//Set data almost till the end,
|
|
|
|
|
//so it will reach end and start scrolling quite soon.
|
|
|
|
|
|
|
|
|
|
//How many rounds to prefill in the series
|
|
|
|
|
int roundsToPrefill = 50;// (int)(0.9 * _xLen) / _appendCountPerRound;
|
|
|
|
|
|
|
|
|
|
//How many points to prefill in the series
|
|
|
|
|
int pointCount = roundsToPrefill * _appendCountPerRound;
|
|
|
|
|
|
|
|
|
|
System.Threading.Tasks.Parallel.For(0, _channelCount, (seriesIndex) =>
|
|
|
|
|
{
|
|
|
|
|
double[] thisSeriesData = _data[seriesIndex];
|
|
|
|
|
|
|
|
|
|
for (int round = 0; round < roundsToPrefill; round++)
|
|
|
|
|
{
|
|
|
|
|
float[] dataArray = new float[_appendCountPerRound];
|
|
|
|
|
Array.Copy(thisSeriesData, (round % PreGenerateDataForRoundCount) * _appendCountPerRound, dataArray, 0, _appendCountPerRound);
|
|
|
|
|
_lChartAll.ViewXY.SampleDataBlockSeries[seriesIndex].AddSamples(dataArray, false);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
_pointsAppended += pointCount;
|
|
|
|
|
_iRound += roundsToPrefill;
|
|
|
|
|
|
|
|
|
|
//Set X axis real-time scrolling position
|
|
|
|
|
double lastX = _pointsAppended * XInterval;
|
|
|
|
|
_lChartAll.ViewXY.XAxes[0].ScrollPosition = lastX;
|
|
|
|
|
}
|
|
|
|
|
private void FeedDataTest(/*string chartTitleText*/)
|
|
|
|
|
{
|
|
|
|
|
if (_lChartAll != null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
_lChartAll.BeginUpdate();
|
|
|
|
|
foreach (var item in _lChartAll.ViewXY.SampleDataSeries)
|
|
|
|
|
{
|
|
|
|
|
item.Clear();
|
|
|
|
|
item.FirstSampleTimeStamp = _lChartAll.ViewXY.XAxes[0].Minimum;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//Append data to series
|
|
|
|
|
System.Threading.Tasks.Parallel.For(0, _channelCount, (seriesIndex) =>
|
|
|
|
|
{
|
|
|
|
|
double[] thisSeriesData = _data[seriesIndex];
|
|
|
|
|
double[] dataToAppendNow = new double[_appendCountPerRound];
|
|
|
|
|
Array.Copy(thisSeriesData, (_iRound % PreGenerateDataForRoundCount) * _appendCountPerRound, dataToAppendNow, 0, _appendCountPerRound);
|
|
|
|
|
_lChartAll.ViewXY.YAxes[seriesIndex].SetRange(dataToAppendNow.Min(), dataToAppendNow.Max());
|
|
|
|
|
_lChartAll.ViewXY.SampleDataSeries[seriesIndex].AddSamples(dataToAppendNow, false);
|
|
|
|
|
System.Diagnostics.Debug.WriteLine("***********index:{0}, pointCount:{1}", seriesIndex,
|
|
|
|
|
_lChartAll.ViewXY.SampleDataSeries[seriesIndex].PointCount);
|
|
|
|
|
});
|
|
|
|
|
_pointsAppended += 1;//;_appendCountPerRound;
|
|
|
|
|
|
|
|
|
|
//Set X axis real-time scrolling position
|
|
|
|
|
double lastX = _pointsAppended * XInterval;
|
|
|
|
|
_lChartAll.ViewXY.XAxes[0].ScrollPosition = lastX;
|
|
|
|
|
|
|
|
|
|
_lChartAll.EndUpdate();
|
|
|
|
|
|
|
|
|
|
_iRound++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DateTime GetTime()
|
|
|
|
|
{
|
|
|
|
|