|
|
@ -3,25 +3,20 @@ using Arction.Wpf.Charting.Axes;
|
|
|
|
using Arction.Wpf.Charting.SeriesXY;
|
|
|
|
using Arction.Wpf.Charting.SeriesXY;
|
|
|
|
using Arction.Wpf.Charting.Views.ViewXY;
|
|
|
|
using Arction.Wpf.Charting.Views.ViewXY;
|
|
|
|
using Microsoft.Win32;
|
|
|
|
using Microsoft.Win32;
|
|
|
|
using StartServerWPF.Modules.MseedChart.Models;
|
|
|
|
|
|
|
|
using Prism.Commands;
|
|
|
|
using Prism.Commands;
|
|
|
|
using Prism.Events;
|
|
|
|
|
|
|
|
using Prism.Mvvm;
|
|
|
|
using Prism.Mvvm;
|
|
|
|
using SharpDX.Direct2D1;
|
|
|
|
using Prism.Regions;
|
|
|
|
using SharpDX.DirectWrite;
|
|
|
|
using ServiceStack;
|
|
|
|
|
|
|
|
using StartServerWPF.Assets;
|
|
|
|
|
|
|
|
using StartServerWPF.Modules.MseedChart.Models;
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
|
|
|
|
using System.Collections.Concurrent;
|
|
|
|
using System.Collections.Concurrent;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
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;
|
|
|
|
using System.Net.Http.Headers;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Windows;
|
|
|
|
using System.Windows;
|
|
|
@ -29,18 +24,9 @@ using System.Windows.Controls;
|
|
|
|
using System.Windows.Documents;
|
|
|
|
using System.Windows.Documents;
|
|
|
|
using System.Windows.Markup;
|
|
|
|
using System.Windows.Markup;
|
|
|
|
using System.Windows.Media;
|
|
|
|
using System.Windows.Media;
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
|
|
|
using System.Windows.Threading;
|
|
|
|
using System.Windows.Threading;
|
|
|
|
using System.Xml.Linq;
|
|
|
|
using System.Xml.Linq;
|
|
|
|
using Prism.Regions;
|
|
|
|
|
|
|
|
using static System.Collections.Specialized.BitVector32;
|
|
|
|
|
|
|
|
using ZhaoXi.Advanced.MyRedis.Service;
|
|
|
|
using ZhaoXi.Advanced.MyRedis.Service;
|
|
|
|
using ServiceStack;
|
|
|
|
|
|
|
|
using ServiceStack.Redis;
|
|
|
|
|
|
|
|
using Arction.Licensing;
|
|
|
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
using StartServerWPF.Assets;
|
|
|
|
|
|
|
|
using ServiceStack.Text;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace StartServerWPF.Modules.MseedChart.ViewModels
|
|
|
|
namespace StartServerWPF.Modules.MseedChart.ViewModels
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -71,6 +57,9 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
|
|
|
|
public ConcurrentQueue<StationModel> smList=new ConcurrentQueue<StationModel>();
|
|
|
|
public ConcurrentQueue<StationModel> smList=new ConcurrentQueue<StationModel>();
|
|
|
|
|
|
|
|
|
|
|
|
public List<AxisY> _chartAxisY=new List<AxisY>();
|
|
|
|
public List<AxisY> _chartAxisY=new List<AxisY>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Dictionary<string, ASCiiData> cacheChartDic=new Dictionary<string, ASCiiData>();
|
|
|
|
|
|
|
|
Dictionary<string, ASCiiData> subNameList;
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 属性
|
|
|
|
#region 属性
|
|
|
@ -259,27 +248,25 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
|
|
|
|
public DelegateCommand<object> OtimeSortCommand => new DelegateCommand<object>(OtimeSort);
|
|
|
|
public DelegateCommand<object> OtimeSortCommand => new DelegateCommand<object>(OtimeSort);
|
|
|
|
public DelegateCommand IntervalSureCommand => new DelegateCommand(IntervalSure);
|
|
|
|
public DelegateCommand IntervalSureCommand => new DelegateCommand(IntervalSure);
|
|
|
|
public DelegateCommand<object> RealTimeDataCommand => new DelegateCommand<object>(RealTimeData);
|
|
|
|
public DelegateCommand<object> RealTimeDataCommand => new DelegateCommand<object>(RealTimeData);
|
|
|
|
|
|
|
|
|
|
|
|
Dictionary<string,int> subNameList;
|
|
|
|
|
|
|
|
private void Loaded()
|
|
|
|
private void Loaded()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//N08,N25,N26
|
|
|
|
//N08,N25,N26
|
|
|
|
string station = "N05,N10";
|
|
|
|
|
|
|
|
var stations = GlobalData.StationNames;// station.Split(',');
|
|
|
|
var stations = GlobalData.StationNames;// station.Split(',');
|
|
|
|
smList = _wavesModel.ReadWavesFromJson(stations);
|
|
|
|
smList = _wavesModel.ReadWavesFromJson(stations);
|
|
|
|
|
|
|
|
subNameList = new Dictionary<string, ASCiiData>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void UnLoaded()
|
|
|
|
private void UnLoaded()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
time.Stop();
|
|
|
|
time.Stop();
|
|
|
|
using (RedisListService service = new RedisListService())
|
|
|
|
if(subNameList == null) return;
|
|
|
|
|
|
|
|
foreach (var subName in subNameList)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (subNameList != null)
|
|
|
|
using (RedisListService service = new RedisListService())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
foreach (var subName in subNameList)
|
|
|
|
//停止订阅
|
|
|
|
{
|
|
|
|
service.Publish(subName.Key, "shutoff");
|
|
|
|
service.UnSubscribeFromChannels(subName.Key);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -488,14 +475,13 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
|
|
|
|
_lChartAll.EndUpdate();
|
|
|
|
_lChartAll.EndUpdate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int i = 1;
|
|
|
|
private void RealTimeData(object isCheck)
|
|
|
|
private void RealTimeData(object isCheck)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
_channelCount = smList.Count * 3;
|
|
|
|
_channelCount = smList.Count * 3;
|
|
|
|
CurrentTime = smList.First().BeginTime.ToShortDateString();
|
|
|
|
CurrentTime = smList.First().BeginTime.ToShortDateString();
|
|
|
|
StationsName = smList.Select(a => new StationAxis { Name = a.Name, IsChecked = true, SelectCommand = new DelegateCommand<object>(StationsNameVisible) }).ToList();
|
|
|
|
StationsName = smList.Select(a => new StationAxis { Name = a.Name, IsChecked = true, SelectCommand = new DelegateCommand<object>(StationsNameVisible) }).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
if (_lChartAll != null)
|
|
|
|
if (_lChartAll != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool isStartRealData = (Convert.ToBoolean(isCheck) == true);
|
|
|
|
bool isStartRealData = (Convert.ToBoolean(isCheck) == true);
|
|
|
@ -503,65 +489,70 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_lChartAll.BeginUpdate();
|
|
|
|
_lChartAll.BeginUpdate();
|
|
|
|
if (isStartRealData)
|
|
|
|
if (isStartRealData)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_data = new double[smList.Count * 3][];
|
|
|
|
_data = new double[smList.Count * 3][];
|
|
|
|
StartChart();
|
|
|
|
StartChart();
|
|
|
|
//Set real-time monitoring automatic old data destruction
|
|
|
|
//Set real-time monitoring automatic old data destruction
|
|
|
|
LChartALL.ViewXY.DropOldSeriesData = true;
|
|
|
|
LChartALL.ViewXY.DropOldSeriesData = true;
|
|
|
|
_pointsAppended = LChartALL.ViewXY.XAxes[0].Minimum;
|
|
|
|
_pointsAppended = LChartALL.ViewXY.XAxes[0].Minimum;
|
|
|
|
|
|
|
|
|
|
|
|
time.Elapsed -= CompositionTarget_Rendering;
|
|
|
|
time.Elapsed -= CompositionTarget_Rendering;
|
|
|
|
time.Elapsed += CompositionTarget_Rendering;
|
|
|
|
time.Elapsed += CompositionTarget_Rendering;
|
|
|
|
LChartALL.ViewXY.XAxes[0].ScrollMode = XAxisScrollMode.Scrolling;
|
|
|
|
LChartALL.ViewXY.XAxes[0].ScrollMode = XAxisScrollMode.Scrolling;
|
|
|
|
time.Start();
|
|
|
|
Task.Run(() =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
|
|
|
time.Start();
|
|
|
|
|
|
|
|
});
|
|
|
|
using (RedisListService service = new RedisListService())
|
|
|
|
using (RedisListService service = new RedisListService())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
foreach (var subName in subNameList)
|
|
|
|
service.FlushAll();
|
|
|
|
{
|
|
|
|
|
|
|
|
service.UnSubscribeFromChannels(subName.Key);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach (var subName in subNameList)
|
|
|
|
foreach (var subName in subNameList)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Task.Run(() =>
|
|
|
|
Task.Run(() =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Debug.WriteLine($"注册{1}:{subName.Key}");
|
|
|
|
|
|
|
|
using (RedisListService service = new RedisListService())
|
|
|
|
using (RedisListService service = new RedisListService())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
service.Subscribe(subName.Key, (c, message, iRedisSubscription) =>
|
|
|
|
Debug.WriteLine($"注册{1}:{subName.Key}");
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Mseed2asciiApi.bufferMseedData(message.Length, message);
|
|
|
|
service.Subscribe(subName.Key, (c, message, iRedisSubscription) =>
|
|
|
|
});
|
|
|
|
{
|
|
|
|
|
|
|
|
if(message.Length==7 && System.Text.Encoding.Default.GetString(message)== "shutoff")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
iRedisSubscription.UnSubscribeFromChannels(subName.Key);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Mseed2asciiApi.bufferMseedData(message.Length, message);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
time.Stop();
|
|
|
|
time.Stop();
|
|
|
|
time.Elapsed -= CompositionTarget_Rendering;
|
|
|
|
time.Elapsed -= CompositionTarget_Rendering;
|
|
|
|
LChartALL.ViewXY.XAxes[0].ScrollMode = XAxisScrollMode.None;
|
|
|
|
LChartALL.ViewXY.XAxes[0].ScrollMode = XAxisScrollMode.None;
|
|
|
|
using (RedisListService service = new RedisListService())
|
|
|
|
foreach (var subName in subNameList)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
foreach (var subName in subNameList)
|
|
|
|
using (RedisListService service = new RedisListService())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
service.UnSubscribeFromChannels(subName.Key);
|
|
|
|
service.Publish(subName.Key, "shutoff");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_lChartAll.EndUpdate();
|
|
|
|
_lChartAll.EndUpdate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Mseed2AsciiEvent(AsciiDataStruct asciiData)
|
|
|
|
private void Mseed2AsciiEvent(AsciiDataStruct asciiData)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DateTime startTime= Convert.ToDateTime(asciiData.endtime).AddHours(8);
|
|
|
|
DateTime startTime = Convert.ToDateTime(asciiData.endtime).AddHours(8);
|
|
|
|
DateTime endTime = Convert.ToDateTime(asciiData.endtime).AddHours(8);
|
|
|
|
DateTime endTime = Convert.ToDateTime(asciiData.endtime).AddHours(8);
|
|
|
|
Debug.WriteLine($"注册{asciiData.sid}:{startTime}");
|
|
|
|
|
|
|
|
var time = endTime - startTime;
|
|
|
|
|
|
|
|
byte[] bytes = new byte[asciiData.numsamples * asciiData.samplesize];
|
|
|
|
byte[] bytes = new byte[asciiData.numsamples * asciiData.samplesize];
|
|
|
|
// IntPtr bufferHandler = Marshal.AllocHGlobal((int)asciiData.datasize);
|
|
|
|
// IntPtr bufferHandler = Marshal.AllocHGlobal((int)asciiData.datasize);
|
|
|
|
Marshal.Copy(asciiData.datasamples, bytes, 0, bytes.Length);
|
|
|
|
Marshal.Copy(asciiData.datasamples, bytes, 0, bytes.Length);
|
|
|
@ -595,8 +586,8 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
|
|
|
|
lines.Add(b);
|
|
|
|
lines.Add(b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
string lineStr= String.Join(",", lines);
|
|
|
|
Debug.WriteLine($"接收:{asciiData.sid}:{startTime},count:{lines.Count}");
|
|
|
|
|
|
|
|
string lineStr = String.Join(",", lines);
|
|
|
|
using (RedisListService service = new RedisListService())
|
|
|
|
using (RedisListService service = new RedisListService())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
service.LPush(name, lineStr);
|
|
|
|
service.LPush(name, lineStr);
|
|
|
@ -660,8 +651,7 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
|
|
|
|
|
|
|
|
|
|
|
|
private void StartChart()
|
|
|
|
private void StartChart()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DisposeAllAndClear(_chartAxisY);
|
|
|
|
DisposeAllAndClear(_chartAxisY);
|
|
|
|
subNameList = new Dictionary<string, int>();
|
|
|
|
|
|
|
|
ViewXY v = LChartALL.ViewXY;
|
|
|
|
ViewXY v = LChartALL.ViewXY;
|
|
|
|
LChartALL.SizeChanged -= LChartALL_SizeChanged;
|
|
|
|
LChartALL.SizeChanged -= LChartALL_SizeChanged;
|
|
|
|
LChartALL.SizeChanged += LChartALL_SizeChanged;
|
|
|
|
LChartALL.SizeChanged += LChartALL_SizeChanged;
|
|
|
@ -702,7 +692,11 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
|
|
|
|
|
|
|
|
|
|
|
|
int count = stationModel.Dzne.Count;
|
|
|
|
int count = stationModel.Dzne.Count;
|
|
|
|
int number= smList.Count*3;
|
|
|
|
int number= smList.Count*3;
|
|
|
|
|
|
|
|
bool isAdd = false;
|
|
|
|
|
|
|
|
if (subNameList.Count == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
isAdd = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
for (int i = 0; i < number; i++)
|
|
|
|
for (int i = 0; i < number; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int seriesIndex = i;
|
|
|
|
int seriesIndex = i;
|
|
|
@ -755,7 +749,10 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
|
|
|
|
subName = $"HA.{name}.06.SHE";
|
|
|
|
subName = $"HA.{name}.06.SHE";
|
|
|
|
series.LineStyle.Color = System.Windows.Media.Colors.ForestGreen;
|
|
|
|
series.LineStyle.Color = System.Windows.Media.Colors.ForestGreen;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
subNameList.Add(subName,i);
|
|
|
|
if (isAdd)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
subNameList.Add(subName, new ASCiiData { Index = i, sid = subName });
|
|
|
|
|
|
|
|
}
|
|
|
|
series.LineStyle.Width = 0.2;
|
|
|
|
series.LineStyle.Width = 0.2;
|
|
|
|
series.ScrollModePointsKeepLevel = 1;
|
|
|
|
series.ScrollModePointsKeepLevel = 1;
|
|
|
|
//series.ScrollingStabilizing = true;
|
|
|
|
//series.ScrollingStabilizing = true;
|
|
|
@ -867,73 +864,166 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
|
|
|
|
{
|
|
|
|
{
|
|
|
|
RenderNextFrame();
|
|
|
|
RenderNextFrame();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static double currentOATime = 0;
|
|
|
|
|
|
|
|
List<string> tempData = new List<string>();
|
|
|
|
private void RenderNextFrame()
|
|
|
|
private void RenderNextFrame()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Debug.WriteLine("timeFrame:{0}", DateTime.Now);
|
|
|
|
Stopwatch stopwatch = Stopwatch.StartNew();
|
|
|
|
|
|
|
|
string minName = string.Empty;
|
|
|
|
if (_lChartAll == null)
|
|
|
|
if (_lChartAll == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
using (RedisListService service = new RedisListService())
|
|
|
|
List<double> datasStr = new List<double>();
|
|
|
|
|
|
|
|
//计算数据中最小时间
|
|
|
|
|
|
|
|
if (currentOATime == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
double minTime = DateTime.Now.AddHours(1).ToOADate();
|
|
|
|
|
|
|
|
string name = string.Empty;
|
|
|
|
foreach (var item in subNameList)
|
|
|
|
foreach (var item in subNameList)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
List<double> dataDouList = new List<double>();
|
|
|
|
List<double> dataDouList = new List<double>();
|
|
|
|
|
|
|
|
using (RedisListService service = new RedisListService())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var data = service.Get(item.Key, 0, 0).FirstOrDefault();
|
|
|
|
|
|
|
|
if (data != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
datasStr = data.Split(',').Select(a => Convert.ToDouble(a)).ToList();
|
|
|
|
|
|
|
|
double oaTime = datasStr.First();
|
|
|
|
|
|
|
|
if (oaTime < minTime)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
minTime = oaTime;
|
|
|
|
|
|
|
|
currentOATime = oaTime;
|
|
|
|
|
|
|
|
name=item.Key;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (currentOATime == 0) return;
|
|
|
|
|
|
|
|
Debug.WriteLine("currentTimeFirst:{0},now:{1},sid:{2},count:{3}", DateTime.FromOADate(currentOATime),DateTime.Now, name, datasStr.Count);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//更新图表数据时间,每秒刷新一次
|
|
|
|
|
|
|
|
currentOATime = DateTime.FromOADate(currentOATime).AddSeconds(1).ToOADate();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (var item in subNameList)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using (RedisListService service = new RedisListService())
|
|
|
|
|
|
|
|
{
|
|
|
|
var data = service.Get(item.Key, 0, 0).FirstOrDefault();
|
|
|
|
var data = service.Get(item.Key, 0, 0).FirstOrDefault();
|
|
|
|
if( data != null)
|
|
|
|
if (data != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
IEnumerable<double> datasStr = data.Split(',').Select(a => Convert.ToDouble(a));
|
|
|
|
datasStr = data.Split(',').Select(a => Convert.ToDouble(a)).ToList();
|
|
|
|
double oaTime = datasStr.First();
|
|
|
|
DateTime firstTime = DateTime.FromOADate(datasStr.First());
|
|
|
|
if (oaTime < DateTime.Now.AddSeconds(-3).ToOADate())
|
|
|
|
DateTime currentTime = DateTime.FromOADate(currentOATime);
|
|
|
|
|
|
|
|
datasStr.RemoveAt(0);
|
|
|
|
|
|
|
|
if (Math.Abs((currentTime - firstTime).TotalSeconds) < 1 && firstTime.Second == currentTime.Second)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//取出队列数据
|
|
|
|
|
|
|
|
service.RemoveStartFromList(item.Key);
|
|
|
|
service.RemoveStartFromList(item.Key);
|
|
|
|
var DouData = data.Split(',').Select(a => Convert.ToDouble(a)).ToList();
|
|
|
|
_data[item.Value.Index] = datasStr.ToArray();
|
|
|
|
DouData.RemoveAt(0);
|
|
|
|
}
|
|
|
|
dataDouList.AddRange(DouData);
|
|
|
|
else if ((currentTime - firstTime).TotalSeconds < 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_data[item.Value.Index] = new double[datasStr.Count];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if ((currentTime - firstTime).TotalSeconds > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
firstTime.AddMilliseconds(-firstTime.Millisecond);
|
|
|
|
|
|
|
|
//出更数据需要重新绘图表点
|
|
|
|
|
|
|
|
_data[item.Value.Index] = new double[datasStr.Count];
|
|
|
|
|
|
|
|
int offset = (int)(currentTime - firstTime).TotalSeconds;
|
|
|
|
|
|
|
|
while (offset > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
service.RemoveStartFromList(item.Key);
|
|
|
|
|
|
|
|
tempData.Add(item.Key+ firstTime);
|
|
|
|
|
|
|
|
if (offset < 100)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// 不能超过缓存数, 更新数据
|
|
|
|
|
|
|
|
var time = currentTime.AddSeconds(-offset);
|
|
|
|
|
|
|
|
var tem = item.Value.datas[time.ToOADate()];
|
|
|
|
|
|
|
|
item.Value.datas[time.ToOADate()] = datasStr.ToArray();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
data = service.Get(item.Key, 0, 0).FirstOrDefault();
|
|
|
|
|
|
|
|
if (data == null) break;
|
|
|
|
|
|
|
|
datasStr = data.Split(',').Select(a => Convert.ToDouble(a)).ToList();
|
|
|
|
|
|
|
|
firstTime = DateTime.FromOADate(datasStr.First());
|
|
|
|
|
|
|
|
offset = (int)(currentTime - firstTime).TotalSeconds;
|
|
|
|
|
|
|
|
datasStr.RemoveAt(0);
|
|
|
|
|
|
|
|
Debug.WriteLine("timeMinData:{0},Time1:{1},sid:{2},offset:{3}", currentTime, firstTime, item.Key, offset);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
throw new Exception($"数据解析异常:{item.Key},{currentTime},{firstTime}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//继续查看数据
|
|
|
|
}
|
|
|
|
// data = service.Get(item.Key, 0, 0).FirstOrDefault();
|
|
|
|
else
|
|
|
|
}
|
|
|
|
|
|
|
|
// data =service.BlockingDequeueItemFromList(item.Key, TimeSpan.FromMilliseconds(5));
|
|
|
|
|
|
|
|
if (dataDouList.Count!=0)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_data[item.Value] =dataDouList.ToArray();
|
|
|
|
_data[item.Value.Index] = new double[500];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
item.Value.AddData(currentOATime, _data[item.Value.Index]);
|
|
|
|
// if (_data.ToList().Any(d => d != null))
|
|
|
|
}
|
|
|
|
|
|
|
|
stopwatch.Stop();
|
|
|
|
|
|
|
|
double time1 = stopwatch.ElapsedMilliseconds;
|
|
|
|
|
|
|
|
stopwatch.Start();
|
|
|
|
|
|
|
|
bool isRefresh = false;
|
|
|
|
|
|
|
|
//有新数据开始刷新
|
|
|
|
|
|
|
|
if (tempData.Count > 5)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_dispatcher.Invoke(() =>
|
|
|
|
List<double> temDou = new List<double>();
|
|
|
|
{
|
|
|
|
foreach (var item in subNameList)
|
|
|
|
FeedData(/*chartTitleText*/);
|
|
|
|
{
|
|
|
|
});
|
|
|
|
var d = item.Value.datas.Keys.OrderBy(a => a).ToArray();
|
|
|
|
|
|
|
|
for (int i = 0; i < d.Count(); i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
temDou.AddRange(item.Value.datas[d[i]]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// _data[item.Value.Index] = temDou.ToArray();
|
|
|
|
|
|
|
|
// DateTime time1 = DateTime.Now.AddMinutes(i++);
|
|
|
|
|
|
|
|
// _lChartAll.ViewXY.XAxes[0].SetRange(_lChartAll.ViewXY.XAxes[0].DateTimeToAxisValue(time1),
|
|
|
|
|
|
|
|
// _lChartAll.ViewXY.XAxes[0].DateTimeToAxisValue(time1.AddSeconds(60)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// isRefresh = true;
|
|
|
|
|
|
|
|
tempData.Clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_dispatcher.Invoke(() =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
FeedData(isRefresh /*chartTitleText*/);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
stopwatch.Stop();
|
|
|
|
|
|
|
|
double time2 = stopwatch.ElapsedMilliseconds;
|
|
|
|
|
|
|
|
Debug.WriteLine("timeFrame:{0},time1:{1},time1:{2}", DateTime.FromOADate(currentOATime), time1, time2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int _iRound = 0;
|
|
|
|
int _iRound = 0;
|
|
|
|
double _pointsAppended = 0;
|
|
|
|
double _pointsAppended = 0;
|
|
|
|
double[][] _data;
|
|
|
|
double[][] _data;
|
|
|
|
|
|
|
|
|
|
|
|
private void FeedData()
|
|
|
|
private void FeedData(bool isRefresh)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (_lChartAll != null)
|
|
|
|
if (_lChartAll != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_lChartAll.BeginUpdate();
|
|
|
|
_lChartAll.BeginUpdate();
|
|
|
|
|
|
|
|
if(isRefresh)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for (int seriesIndex = 0; seriesIndex < _channelCount; seriesIndex++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_lChartAll.ViewXY.SampleDataSeries[seriesIndex].Clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
//Append data to series
|
|
|
|
//Append data to series
|
|
|
|
for (int seriesIndex = 0; seriesIndex < _channelCount; seriesIndex++)
|
|
|
|
for (int seriesIndex = 0; seriesIndex < _channelCount; seriesIndex++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
double[] thisSeriesData = _data[seriesIndex];
|
|
|
|
double[] thisSeriesData = _data[seriesIndex];
|
|
|
|
if (thisSeriesData == null) continue;
|
|
|
|
if(thisSeriesData==null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
_lChartAll.ViewXY.SampleDataSeries[seriesIndex].AddSamples(thisSeriesData, false);
|
|
|
|
_lChartAll.ViewXY.SampleDataSeries[seriesIndex].AddSamples(thisSeriesData, false);
|
|
|
|
_data[seriesIndex] = null;
|
|
|
|
_data[seriesIndex] = null;
|
|
|
|
System.Diagnostics.Debug.WriteLine("***********index:{0}, pointCount:{1},time:{2}", seriesIndex,
|
|
|
|
// System.Diagnostics.Debug.WriteLine("***********index:{0}, pointCount:{1},time:{2}", seriesIndex,
|
|
|
|
_lChartAll.ViewXY.SampleDataSeries[seriesIndex].PointCount, DateTime.Now);
|
|
|
|
// _lChartAll.ViewXY.SampleDataSeries[seriesIndex].PointCount, DateTime.Now);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//System.Threading.Tasks.Parallel.For(0, _channelCount, (seriesIndex) =>
|
|
|
|
//System.Threading.Tasks.Parallel.For(0, _channelCount, (seriesIndex) =>
|
|
|
|
//{
|
|
|
|
//{
|
|
|
|