using Arction.Wpf.ChartingMVVM.Axes;
using Arction.Wpf.ChartingMVVM.Views.ViewXY;
using Arction.Wpf.ChartingMVVM;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Threading;
using System.Windows;
using Txgy.EWS.Client.PageModule.Models;
using Txgy.Microseismic.BaseLib.Models;
using Prism.Mvvm;
using Prism.Events;
using Txgy.EWS.Client.IBLL;
using System.Windows.Input;
using Txgy.EWS.Client.Common;
using System.Windows.Media;
using Unity;
using Txgy.EWS.Client.Common.MessageEvents;
using Txgy.EWS.Client.PageModule.Services;
using Newtonsoft.Json.Linq;
namespace Txgy.EWS.Client.PageModule.ViewModels
{
public class WaveformViewModel : BindableBase
{
#region variable
Dispatcher _dispatcher;
//private IRemoteDownloadDataBLL remoteDownloadDataBLL;
private delegate void HandleDataGeneratedDelegate(string eventTime);
///
/// Delegate for data generation.
///
private HandleDataGeneratedDelegate _handleDataGenerated;
///
/// 当前采样数
///
public int CurPoints;
private DispatcherTimer _fitYTimer;
private readonly IEventAggregator _ea;
private readonly ISearchMsEventBLL _searchMsEventBLL;
private int _selectResult = 0;
public int SelectResult
{
get { return _selectResult; }
set
{
SetProperty(ref _selectResult, value);
}
}
int _channelCount = 60; // Channel count.
double _samplingFrequency = 500; // Sampling frequency (Hz).
double _xLength = 10; // X axis length.
double _previousX = 0; // Latest X value on axis.
long _now; // Latest time stamp.
long _startTicks; // Controls timing.
long _samplesOutput; // Generated samples quantity.
// Constants
const double YMin = 30000; // Minimal y-value.
const double YMax = 33000; // Maximal y-value.
private volatile bool _stop; // Stops thread work.
internal bool IsRunning
{
get
{
return _thread != null;
}
}
WavesModel _wavesModel;
#endregion
///
/// Thread.
///
private Thread _thread;
private Thread _threadWrite;
private delegate void ChartUpdateFromThreadHandler(double[][] samples);
private ChartUpdateFromThreadHandler _chartUpdate;
private Random _rand = new Random((int)DateTime.Now.Ticks);
#region "属性"
private int _lChartCount = 1;
///
/// 波形控件数量
///
public int LChartCount
{
get { return _lChartCount; }
set { _lChartCount = value; }
}
public List WaveComList { get; set; }
private ShareProperty _wavesCombination;
///
/// 波形组合
///
public ShareProperty WavesCombination
{
get { return _wavesCombination; }
set
{
_wavesCombination = value;
SetWavesCombination();
//Console.WriteLine(_wavesCombination.Name);
}
}
private DataSourcesEnum _dataSources;
///
/// 数据来源
///
public DataSourcesEnum DataSources
{
get { return _dataSources; }
set { _dataSources = value; }
}
private DataTypeEnum _wavesType;
///
/// 波形类型
///
public DataTypeEnum WavesType
{
get { return _wavesType; }
set { _wavesType = value; }
}
private DisplayModeEnum _displayMode;
///
/// 显示模式
///
public DisplayModeEnum DisplayMode
{
get { return _displayMode; }
set { _displayMode = value; }
}
private ScollModeEnum _scollMode;
///
/// 滚动方式
///
public ScollModeEnum ScollMode
{
get { return _scollMode; }
set { _scollMode = value; }
}
private DateTime _startTime;
///
/// 开始时间
///
public DateTime StartTime
{
get { return _startTime; }
set { _startTime = value; }
}
private DateTime _endTime;
///
/// 开始时间
///
public DateTime EndTime
{
get { return _endTime; }
set { _endTime = value; }
}
private int _sampling = 500;
///
/// 采样频率
///
public int Sampling
{
get { return _sampling; }
set { _sampling = value; }
}
///
/// 延时(min)
///
public int DelayMin { get; set; } = 10;
///
/// 文件数据位置
///
public string FileDataPath { get; set; } = @"D:\TaySystemPath\Downloads";
private string _cachePath;
private int _cacheSize;
///
/// 缓存大小
///
public int CacheSize
{
get { return _cacheSize; }
set { _cacheSize = value; }
}
private ObservableCollection _stationList;
///
/// 台站列表
///
public ObservableCollection StationList
{
get { return _stationList; }
set { _stationList = value; }
}
private LightningChart _lChartAll;
///
/// 所有波形
///
public LightningChart LChartALL
{
get { return _lChartAll; }
set { _lChartAll = value; }
}
private LightningChart _lChartZ;
///
/// Z通道波形
///
public LightningChart LChartZ
{
get { return _lChartZ; }
set { _lChartZ = value; }
}
private LightningChart _lChartE;
///
/// E通道波形
///
public LightningChart LChartE
{
get { return _lChartE; }
set { _lChartE = value; }
}
private LightningChart _lChartN;
///
/// N通道波形
///
public LightningChart LChartN
{
get { return _lChartN; }
set { _lChartN = value; }
}
private FrameworkElement childContent;
public FrameworkElement ChildContent
{
get { return childContent; }
set { childContent = value; }
}
private Grid gridChart;
public Grid GridChart
{
get { return gridChart; }
set { gridChart = value; }
}
private string _btnContrlContent = "开始";
private int channelCount;
public string BtnContrlContent
{
get { return _btnContrlContent; }
set { _btnContrlContent = value; }
}
private ObservableCollection _showEvents;
public ObservableCollection ShowEvents
{
get { return _showEvents; }
set
{
SetProperty(ref _showEvents, value);
}
}
StationWorkModel _stationWorker;
public List smList;
//public static readonly DependencyProperty XAxesProperty =
//DependencyProperty.Register(
// "xAxes",
// typeof(AxisXCollection),
// typeof(WavesViewModel)
//);
//public AxisXCollection xAxes
//{
// get { return GetValue(XAxesProperty) as AxisXCollection; }
// set { SetValue(XAxesProperty, value); }
//}
#endregion
#region "Command"
#endregion
public WaveformViewModel(IUnityContainer unityContainer, IEventAggregator ea, ISearchMsEventBLL searchMsEventBLL)
{
this._ea = ea;
this._searchMsEventBLL = searchMsEventBLL;
_dispatcher = unityContainer.Resolve();
//this.remoteDownloadDataBLL = remoteDownloadDataBLL;
SelectResult = 10;
//this.SelectCommand = new CommandBase();
//this.SelectCommand.ExcuteAction = new Action