diff --git a/StartServerWPF.Assets/StartServerWPF.Assets.csproj b/StartServerWPF.Assets/StartServerWPF.Assets.csproj
index 4e0cc9a..8d0b5b3 100644
--- a/StartServerWPF.Assets/StartServerWPF.Assets.csproj
+++ b/StartServerWPF.Assets/StartServerWPF.Assets.csproj
@@ -31,6 +31,42 @@
prompt
4
+
+ true
+ bin\x86\Debug\
+ DEBUG;TRACE
+ full
+ x86
+ 7.3
+ prompt
+
+
+ bin\x86\Release\
+ TRACE
+ true
+ pdbonly
+ x86
+ 7.3
+ prompt
+
+
+ true
+ bin\x64\Debug\
+ DEBUG;TRACE
+ full
+ x64
+ 7.3
+ prompt
+
+
+ bin\x64\Release\
+ TRACE
+ true
+ pdbonly
+ x64
+ 7.3
+ prompt
+
diff --git a/StartServerWPF.Modules.Main/JsonParser.cs b/StartServerWPF.Modules.Main/JsonParser.cs
index c5b9e65..cd46ea1 100644
--- a/StartServerWPF.Modules.Main/JsonParser.cs
+++ b/StartServerWPF.Modules.Main/JsonParser.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
@@ -141,5 +139,26 @@ namespace StartServerWPF.Modules.Main
" -btime " + beginTime.GetDateTimeFormats('s')[0].ToString() + " >outMonitor.txt";
return moniSp;
}
+
+
+ public static string[] ReadApmsJson(string apmsJsonPath)
+ {
+ using (StreamReader sr = File.OpenText(apmsJsonPath))
+ {
+
+ JsonTextReader reader = new JsonTextReader(sr);
+ JObject jobj = (JObject)JToken.ReadFrom(reader);
+ JObject jordb = JObject.Parse(jobj["channels"].ToString());
+
+ string sta = jordb["station"].ToString();
+
+ var staList= sta.Split(",");
+ return staList;
+ }
+
+ }
+
+
+
}
}
diff --git a/StartServerWPF.Modules.Main/StartServerWPF.Modules.Main.csproj b/StartServerWPF.Modules.Main/StartServerWPF.Modules.Main.csproj
index 3fa0cc5..6b587a0 100644
--- a/StartServerWPF.Modules.Main/StartServerWPF.Modules.Main.csproj
+++ b/StartServerWPF.Modules.Main/StartServerWPF.Modules.Main.csproj
@@ -2,7 +2,8 @@
net6.0-windows
true
- True
+ True
+ AnyCPU;x86;x64
diff --git a/StartServerWPF.Modules.Main/ViewModels/TreeMenuViewModel.cs b/StartServerWPF.Modules.Main/ViewModels/TreeMenuViewModel.cs
index cc56951..e52f3e7 100644
--- a/StartServerWPF.Modules.Main/ViewModels/TreeMenuViewModel.cs
+++ b/StartServerWPF.Modules.Main/ViewModels/TreeMenuViewModel.cs
@@ -74,6 +74,6 @@ namespace StartServerWPF.Modules.Main.ViewModels
}
}
List menuNames = new List() {"首页","实时波形","波形回放","设置","日志", };
- List viewName = new List() { "MainView", "ChartPlotView", "ChartPlotView", "SetParamView", "LogManagementView"};
+ List viewName = new List() { "MainView", "ChartPlotRealDataView", "ChartPlotView", "SetParamView", "LogManagementView"};
}
}
diff --git a/StartServerWPF.Modules.MseedChart/Init/RedisConfigInfo.cs b/StartServerWPF.Modules.MseedChart/Init/RedisConfigInfo.cs
new file mode 100644
index 0000000..d585d7b
--- /dev/null
+++ b/StartServerWPF.Modules.MseedChart/Init/RedisConfigInfo.cs
@@ -0,0 +1,45 @@
+using System.Configuration;
+
+namespace ZhaoXi.Advanced.MyRedis.Init
+{
+ ///
+ /// redis配置文件信息
+ /// 也可以放到配置文件去
+ ///
+ public sealed class RedisConfigInfo
+ {
+ ///
+ /// 可写的Redis链接地址
+ /// format:ip1,ip2
+ ///
+ /// 默认6379端口
+ ///
+ public string WriteServerList = "127.0.0.1:6379";
+ ///
+ /// 可读的Redis链接地址
+ /// format:ip1,ip2
+ ///
+ public string ReadServerList = "127.0.0.1:6379";
+ ///
+ /// 最大写链接数
+ ///
+ public int MaxWritePoolSize = 60;
+ ///
+ /// 最大读链接数
+ ///
+ public int MaxReadPoolSize = 60;
+ ///
+ /// 本地缓存到期时间,单位:秒
+ ///
+ public int LocalCacheTime = 180;
+ ///
+ /// 自动重启
+ ///
+ public bool AutoStart = true;
+ ///
+ /// 是否记录日志,该设置仅用于排查redis运行时出现的问题,
+ /// 如redis工作正常,请关闭该项
+ ///
+ public bool RecordeLog = false;
+ }
+}
\ No newline at end of file
diff --git a/StartServerWPF.Modules.MseedChart/Init/RedisManager.cs b/StartServerWPF.Modules.MseedChart/Init/RedisManager.cs
new file mode 100644
index 0000000..3640d33
--- /dev/null
+++ b/StartServerWPF.Modules.MseedChart/Init/RedisManager.cs
@@ -0,0 +1,62 @@
+
+using ServiceStack.Redis;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ZhaoXi.Advanced.MyRedis.Init
+{
+ ///
+ /// Redis管理中心 创建Redis链接
+ ///
+ public class RedisManager
+ {
+ ///
+ /// redis配置文件信息
+ ///
+ private static RedisConfigInfo RedisConfigInfo = new RedisConfigInfo();
+
+ ///
+ /// Redis客户端池化管理
+ ///
+ private static PooledRedisClientManager prcManager;
+
+ ///
+ /// 静态构造方法,初始化链接池管理对象
+ ///
+ static RedisManager()
+ {
+ CreateManager();
+ }
+
+ ///
+ /// 创建链接池管理对象
+ ///
+ private static void CreateManager()
+ {
+ string[] WriteServerConStr = RedisConfigInfo.WriteServerList.Split(',');
+ string[] ReadServerConStr = RedisConfigInfo.ReadServerList.Split(',');
+ prcManager = new PooledRedisClientManager(ReadServerConStr, WriteServerConStr,
+ new RedisClientManagerConfig
+ {
+ MaxWritePoolSize = RedisConfigInfo.MaxWritePoolSize,
+ MaxReadPoolSize = RedisConfigInfo.MaxReadPoolSize,
+ AutoStart = RedisConfigInfo.AutoStart,
+ DefaultDb=1
+ });
+ }
+
+ ///
+ /// 客户端缓存操作对象
+ ///
+ public static IRedisClient GetClient()
+ {
+ string[] WriteServerConStr = RedisConfigInfo.WriteServerList.Split(':');
+ var client = new RedisClient(WriteServerConStr[0], Convert.ToInt32(WriteServerConStr[1]),password: "beijingtianxiangguoyue",db:1);
+ // return prcManager.GetClient();
+ return client;
+ }
+ }
+}
diff --git a/StartServerWPF.Modules.MseedChart/Interface/RedisBase.cs b/StartServerWPF.Modules.MseedChart/Interface/RedisBase.cs
new file mode 100644
index 0000000..8ef402d
--- /dev/null
+++ b/StartServerWPF.Modules.MseedChart/Interface/RedisBase.cs
@@ -0,0 +1,95 @@
+
+using ServiceStack.Redis;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ZhaoXi.Advanced.MyRedis.Init;
+
+namespace ZhaoXi.Advanced.MyRedis.Interface
+{
+ ///
+ /// RedisBase类,是redis操作的基类,继承自IDisposable接口,主要用于释放内存
+ ///
+ public abstract class RedisBase : IDisposable
+ {
+ public IRedisClient iClient { get; private set; }
+ ///
+ /// 构造时完成链接的打开
+ ///
+ public RedisBase()
+ {
+ iClient = RedisManager.GetClient();
+ }
+
+ //public static IRedisClient iClient { get; private set; }
+ //static RedisBase()
+ //{
+ // iClient = RedisManager.GetClient();
+ //}
+
+
+ private bool _disposed = false;
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!this._disposed)
+ {
+ if (disposing)
+ {
+ iClient.Dispose();
+ iClient = null;
+ }
+ }
+ this._disposed = true;
+ }
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ public void Transcation()
+ {
+ using (IRedisTransaction irt = this.iClient.CreateTransaction())
+ {
+ try
+ {
+ irt.QueueCommand(r => r.Set("key", 20));
+ irt.QueueCommand(r => r.Increment("key", 1));
+ irt.Commit(); // 提交事务
+ }
+ catch (Exception ex)
+ {
+ irt.Rollback();
+ throw ex;
+ }
+ }
+ }
+
+
+ ///
+ /// 清除全部数据 请小心
+ ///
+ public virtual void FlushAll()
+ {
+ iClient.FlushAll();
+ }
+
+ ///
+ /// 保存数据DB文件到硬盘
+ ///
+ public void Save()
+ {
+ iClient.Save();//阻塞式save
+ }
+
+ ///
+ /// 异步保存数据DB文件到硬盘
+ ///
+ public void SaveAsync()
+ {
+ iClient.SaveAsync();//异步save
+ }
+ }
+}
diff --git a/StartServerWPF.Modules.MseedChart/Models/StationModel.cs b/StartServerWPF.Modules.MseedChart/Models/StationModel.cs
index f116476..a5950f6 100644
--- a/StartServerWPF.Modules.MseedChart/Models/StationModel.cs
+++ b/StartServerWPF.Modules.MseedChart/Models/StationModel.cs
@@ -30,7 +30,7 @@ namespace StartServerWPF.Modules.MseedChart.Models
public int SamplingFrequency { get; set; }
- public DateTime BeginTime;
+ public DateTime BeginTime=DateTime.Now;
public bool IsVisible = true;
diff --git a/StartServerWPF.Modules.MseedChart/Models/WavesModel.cs b/StartServerWPF.Modules.MseedChart/Models/WavesModel.cs
index abd0ec2..2f500b0 100644
--- a/StartServerWPF.Modules.MseedChart/Models/WavesModel.cs
+++ b/StartServerWPF.Modules.MseedChart/Models/WavesModel.cs
@@ -25,7 +25,7 @@ namespace StartServerWPF.Modules.MseedChart.Models
//添加Z分量波形
if (item.dz.Count > 0)
{
- axisY.SetRange(item.dz.Min(), item.dz.Max());
+ axisY.SetRange(0, 6000);
}
axisY.Title.Text = string.Format("Ch{0}.Z", item.Name);
axisY.Title.DistanceToAxis = distancetoX;
@@ -33,8 +33,8 @@ namespace StartServerWPF.Modules.MseedChart.Models
//添加N分量波形
axisY = new AxisY(curChart.ViewXY);
if (item.dn.Count > 0)
- {
- axisY.SetRange(item.dn.Min(), item.dn.Max());
+ {
+ axisY.SetRange(0, 6000);
}
axisY.Title.Text = string.Format("Ch{0}.N", item.Name);
axisY.Title.DistanceToAxis = distancetoX;
@@ -43,8 +43,8 @@ namespace StartServerWPF.Modules.MseedChart.Models
//添加E分量波形
axisY = new AxisY(curChart.ViewXY);
if (item.de.Count > 0)
- {
- axisY.SetRange(item.de.Min(), item.de.Max());
+ {
+ axisY.SetRange(0, 6000);
}
axisY.Title.Text = string.Format("Ch{0}.E", item.Name);
axisY.Title.DistanceToAxis = distancetoX;
@@ -272,5 +272,30 @@ namespace StartServerWPF.Modules.MseedChart.Models
return null;
}
+
+
+
+ #region 实时数据解析
+
+ public ConcurrentQueue ReadWavesFromJson(string[] stations)
+ {
+ ConcurrentQueue temSM = new ConcurrentQueue();
+
+ StationModel station = new StationModel();
+
+ for (int i = 0; i < stations.Length; i++)
+ {
+ station = new StationModel();
+ station.Name = stations[i].Trim();
+ station.dz.Add(0);
+ station.dn.Add(0);
+ station.de.Add(0);
+ temSM.Enqueue(station);
+ }
+
+ temSM.Reverse();
+ return temSM;
+ }
+ #endregion
}
}
diff --git a/StartServerWPF.Modules.MseedChart/Mseed2asciiApi.cs b/StartServerWPF.Modules.MseedChart/Mseed2asciiApi.cs
new file mode 100644
index 0000000..7a967d1
--- /dev/null
+++ b/StartServerWPF.Modules.MseedChart/Mseed2asciiApi.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StartServerWPF.Modules.MseedChart
+{
+ public class Mseed2asciiApi
+ {
+ public delegate void LoopCallbackHandler(AsciiDataStruct asciiData);
+ [DllImport("mseedC.dll", EntryPoint = "MseedDatas")]
+ public extern static int MseedDatas(int a, string[] name);
+ //public extern static int MseedDatas(Byte[] bytes, int lenght);
+ [DllImport("mseedC.dll", EntryPoint = "bufferMseedData")]
+ public extern static int bufferMseedData(int argc, Byte[] argv);
+ [DllImport("mseedC.dll", EntryPoint = "testc")]
+ public extern static int testc(int a, int b);
+ [DllImport("mseedC.dll")]
+ public static extern void MseedDatasCallFun(LoopCallbackHandler callback);
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ public struct AsciiDataStruct
+ {
+ public string sid;
+ // [MarshalAs(UnmanagedType.ByValArray, SizeConst = 30)]
+ public string starttime; //!< Time of first sample
+ // [MarshalAs(UnmanagedType.ByValArray, SizeConst = 30)]
+ public string endtime; //!< Time of last sample
+ public double samprate; //!< Nominal sample rate (Hz)
+ public Int64 samplecnt; //!< Number of samples in trace coverage
+ public UInt64 datasize; //!< Size of datasamples buffer in bytes
+ public Int64 numsamples; //!< Number of data samples in datasamples
+ public char sampletype; //!< Sample type code, see @ref sample-types
+ public char samplesize;
+ public System.IntPtr datasamples; //!< Data samples, \a numsamples of type \a sampletype
+ }
+}
diff --git a/StartServerWPF.Modules.MseedChart/MseedChartModule.cs b/StartServerWPF.Modules.MseedChart/MseedChartModule.cs
index ebd632f..9a6599b 100644
--- a/StartServerWPF.Modules.MseedChart/MseedChartModule.cs
+++ b/StartServerWPF.Modules.MseedChart/MseedChartModule.cs
@@ -18,7 +18,9 @@ namespace StartServerWPF.Modules.MseedChart
public void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.RegisterForNavigation();
+ containerRegistry.RegisterForNavigation();
containerRegistry.RegisterSingleton();
+ containerRegistry.RegisterSingleton();
}
}
diff --git a/StartServerWPF.Modules.MseedChart/Service/RedisListService.cs b/StartServerWPF.Modules.MseedChart/Service/RedisListService.cs
new file mode 100644
index 0000000..cb3f14d
--- /dev/null
+++ b/StartServerWPF.Modules.MseedChart/Service/RedisListService.cs
@@ -0,0 +1,299 @@
+using ZhaoXi.Advanced.MyRedis.Interface;
+using ServiceStack.Redis;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.IO;
+using ServiceStack;
+using System.Collections;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Runtime.Serialization;
+using static System.Net.WebRequestMethods;
+
+namespace ZhaoXi.Advanced.MyRedis.Service
+{
+ ///
+ /// Redis list的实现为一个双向链表,即可以支持反向查找和遍历,更方便操作,不过带来了部分额外的内存开销,
+ /// Redis内部的很多实现,包括发送缓冲队列等也都是用的这个数据结构。
+ ///
+ public class RedisListService : RedisBase
+ {
+ #region 赋值
+ ///
+ /// 从左侧向list中添加值
+ ///
+ public void LPush(string key, string value)
+ {
+ base.iClient.PushItemToList(key, value);
+ }
+ ///
+ /// 从左侧向list中添加值,并设置过期时间
+ ///
+ public void LPush(string key, string value, DateTime dt)
+ {
+
+ base.iClient.PushItemToList(key, value);
+ base.iClient.ExpireEntryAt(key, dt);
+ }
+ ///
+ /// 从左侧向list中添加值,设置过期时间
+ ///
+ public void LPush(string key, string value, TimeSpan sp)
+ {
+ base.iClient.PushItemToList(key, value);
+ base.iClient.ExpireEntryIn(key, sp);
+ }
+ ///
+ /// 从右侧向list中添加值
+ ///
+ public void RPush(string key, string value)
+ {
+ base.iClient.PrependItemToList(key, value);
+ }
+ ///
+ /// 从右侧向list中添加值,并设置过期时间
+ ///
+ public void RPush(string key, string value, DateTime dt)
+ {
+ base.iClient.PrependItemToList(key, value);
+ base.iClient.ExpireEntryAt(key, dt);
+ }
+ ///
+ /// 从右侧向list中添加值,并设置过期时间
+ ///
+ public void RPush(string key, string value, TimeSpan sp)
+ {
+ base.iClient.PrependItemToList(key, value);
+ base.iClient.ExpireEntryIn(key, sp);
+ }
+ ///
+ /// 添加key/value
+ ///
+ public void Add(string key, string value)
+ {
+ base.iClient.AddItemToList(key, value);
+ }
+ ///
+ /// 添加key/value ,并设置过期时间
+ ///
+ public void Add(string key, string value, DateTime dt)
+ {
+ base.iClient.AddItemToList(key, value);
+ base.iClient.ExpireEntryAt(key, dt);
+ }
+ ///
+ /// 添加key/value。并添加过期时间
+ ///
+ public void Add(string key, string value, TimeSpan sp)
+ {
+ base.iClient.AddItemToList(key, value);
+ base.iClient.ExpireEntryIn(key, sp);
+ }
+ ///
+ /// 为key添加多个值
+ ///
+ public void Add(string key, List values)
+ {
+ base.iClient.AddRangeToList(key, values);
+ }
+ ///
+ /// 为key添加多个值,并设置过期时间
+ ///
+ public void Add(string key, List values, DateTime dt)
+ {
+ base.iClient.AddRangeToList(key, values);
+ base.iClient.ExpireEntryAt(key, dt);
+ }
+ ///
+ /// 为key添加多个值,并设置过期时间
+ ///
+ public void Add(string key, List values, TimeSpan sp)
+ {
+ base.iClient.AddRangeToList(key, values);
+ base.iClient.ExpireEntryIn(key, sp);
+ }
+ #endregion
+
+ #region 获取值
+ ///
+ /// 获取list中key包含的数据数量
+ ///
+ public long Count(string key)
+ {
+ return base.iClient.GetListCount(key);
+ }
+ ///
+ /// 获取key包含的所有数据集合
+ ///
+ public List Get(string key)
+ {
+ return base.iClient.GetAllItemsFromList(key);
+ }
+ ///
+ /// 获取key中下标为star到end的值集合
+ ///
+ public List Get(string key, int star, int end)
+ {
+ return base.iClient.GetRangeFromList(key, star, end);
+ }
+ #endregion
+
+ #region 阻塞命令
+ ///
+ /// 阻塞命令:从list为key的尾部移除一个值,并返回移除的值,阻塞时间为sp
+ ///
+ public string BlockingPopItemFromList(string key, TimeSpan? sp)
+ {
+ return base.iClient.BlockingPopItemFromList(key, sp);
+ }
+ ///
+ /// 阻塞命令:从多个list中尾部移除一个值,并返回移除的值&key,阻塞时间为sp
+ ///
+ public ItemRef BlockingPopItemFromLists(string[] keys, TimeSpan? sp)
+ {
+ return base.iClient.BlockingPopItemFromLists(keys, sp);
+ }
+
+
+ ///
+ /// 阻塞命令:从list中keys的尾部移除一个值,并返回移除的值,阻塞时间为sp
+ ///
+ public string BlockingDequeueItemFromList(string key, TimeSpan? sp)
+ {
+ return base.iClient.BlockingDequeueItemFromList(key, sp);
+ }
+
+ ///
+ /// 阻塞命令:从多个list中尾部移除一个值,并返回移除的值&key,阻塞时间为sp
+ ///
+ public ItemRef BlockingDequeueItemFromLists(string[] keys, TimeSpan? sp)
+ {
+ return base.iClient.BlockingDequeueItemFromLists(keys, sp);
+ }
+
+ ///
+ /// 阻塞命令:从list中一个fromkey的尾部移除一个值,添加到另外一个tokey的头部,并返回移除的值,阻塞时间为sp
+ ///
+ public string BlockingPopAndPushItemBetweenLists(string fromkey, string tokey, TimeSpan? sp)
+ {
+ return base.iClient.BlockingPopAndPushItemBetweenLists(fromkey, tokey, sp);
+ }
+ #endregion
+
+ #region 删除
+ ///
+ /// 从尾部移除数据,返回移除的数据
+ ///
+ public string PopItemFromList(string key)
+ {
+ var sa = base.iClient.CreateSubscription();
+ return base.iClient.PopItemFromList(key);
+ }
+ ///
+ /// 从尾部移除数据,返回移除的数据
+ ///
+ public string DequeueItemFromList(string key)
+ {
+ return base.iClient.DequeueItemFromList(key);
+ }
+
+ ///
+ /// 移除list中,key/value,与参数相同的值,并返回移除的数量
+ ///
+ public long RemoveItemFromList(string key, string value)
+ {
+ return base.iClient.RemoveItemFromList(key, value);
+ }
+ ///
+ /// 从list的尾部移除一个数据,返回移除的数据
+ ///
+ public string RemoveEndFromList(string key)
+ {
+ return base.iClient.RemoveEndFromList(key);
+ }
+ ///
+ /// 从list的头部移除一个数据,返回移除的值
+ ///
+ public string RemoveStartFromList(string key)
+ {
+ return base.iClient.RemoveStartFromList(key);
+ }
+ #endregion
+
+ #region 其它
+ ///
+ /// 从一个list的尾部移除一个数据,添加到另外一个list的头部,并返回移动的值
+ ///
+ public string PopAndPushItemBetweenLists(string fromKey, string toKey)
+ {
+ return base.iClient.PopAndPushItemBetweenLists(fromKey, toKey);
+ }
+
+
+ public void TrimList(string key, int start, int end)
+ {
+ base.iClient.TrimList(key, start, end);
+ }
+ #endregion
+
+ #region 发布订阅
+ public void Publish(string channel, string message)
+ {
+ base.iClient.PublishMessage(channel, message);
+ }
+
+ public void Subscribe(string channel, Action actionOnMessage)
+ {
+ var subscription = base.iClient.CreateSubscription();
+ subscription.OnSubscribe = c =>
+ {
+ Console.WriteLine($"订阅频道{c}");
+ Console.WriteLine();
+ };
+ //取消订阅
+ subscription.OnUnSubscribe = c =>
+ {
+ Console.WriteLine($"取消订阅 {c}");
+ Console.WriteLine();
+ };
+ subscription.OnMessage += (c, s) =>
+ {
+ // actionOnMessage(c, s, subscription);
+ };
+ subscription.OnMessageBytes += (c, s) =>
+ {
+ // ByteToFile(s, "test.mseed");
+ actionOnMessage(c, s, subscription);
+ };
+ Console.WriteLine($"开始启动监听 {channel}");
+ subscription.SubscribeToChannels(channel); //blocking
+ }
+
+ public void UnSubscribeFromChannels(string channel)
+ {
+ var subscription = base.iClient.CreateSubscription();
+ subscription.UnSubscribeFromChannels(channel);
+ }
+
+ public static bool ByteToFile(byte[] byteArray, string fileName)
+ {
+ bool result = false;
+ try
+ {
+ using (FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write))
+ {
+ fs.Write(byteArray, 0, byteArray.Length);
+ result = true;
+ }
+ }
+ catch
+ {
+ result = false;
+ }
+ return result;
+ }
+ #endregion
+ }
+}
diff --git a/StartServerWPF.Modules.MseedChart/Service/RedisStringService.cs b/StartServerWPF.Modules.MseedChart/Service/RedisStringService.cs
new file mode 100644
index 0000000..23be397
--- /dev/null
+++ b/StartServerWPF.Modules.MseedChart/Service/RedisStringService.cs
@@ -0,0 +1,136 @@
+using ZhaoXi.Advanced.MyRedis.Interface;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ZhaoXi.Advanced.MyRedis.Service
+{
+ ///
+ /// key-value 键值对:value可以是序列化的数据
+ ///
+ public class RedisStringService : RedisBase
+ {
+ #region 赋值
+ ///
+ /// 设置key的value
+ ///
+ public bool Set(string key, T value)
+ {
+ //iClient.Db =2;
+ return base.iClient.Set(key, value);
+ }
+ ///
+ /// 设置key的value并设置过期时间
+ ///
+ public bool Set(string key, T value, DateTime dt)
+ {
+ //iClient.Db = 2;
+ return base.iClient.Set(key, value, dt);
+ }
+ ///
+ /// 设置key的value并设置过期时间
+ ///
+ public bool Set(string key, T value, TimeSpan sp)
+ {
+ //iClient.Db = 2;
+ return base.iClient.Set(key, value, sp);
+ }
+ ///
+ /// 设置多个key/value 可以一次保存多个key value ---多个key value 不是分多次,是一个独立的命令;
+ ///
+ public void Set(Dictionary dic)
+ {
+ //iClient.Db = 2;
+ base.iClient.SetAll(dic);
+ }
+
+ #endregion
+
+ #region 追加
+ ///
+ /// 在原有key的value值之后追加value,没有就新增一项
+ ///
+ public long Append(string key, string value)
+ {
+ return base.iClient.AppendToValue(key, value);
+ }
+ #endregion
+
+ #region 获取值
+ ///
+ /// 获取key的value值
+ ///
+ public string Get(string key)
+ {
+ return base.iClient.GetValue(key);
+ }
+ ///
+ /// 获取多个key的value值
+ ///
+ public List Get(List keys)
+ {
+ return base.iClient.GetValues(keys);
+ }
+ ///
+ /// 获取多个key的value值
+ ///
+ public List Get(List keys)
+ {
+ return base.iClient.GetValues(keys);
+ }
+ #endregion
+
+ #region 获取旧值赋上新值
+ ///
+ /// 获取旧值赋上新值
+ ///
+ public string GetAndSetValue(string key, string value)
+ {
+ return base.iClient.GetAndSetValue(key, value);
+ }
+ #endregion
+
+ #region 辅助方法
+ ///
+ /// 获取值的长度
+ ///
+ public long GetLength(string key)
+ {
+ return base.iClient.GetStringCount(key);
+ }
+ ///
+ /// 自增1,返回自增后的值 保存的是10 调用后,+1 返回11
+ ///
+ public long Incr(string key)
+ {
+ return base.iClient.IncrementValue(key);
+ }
+ ///
+ /// 自增count,返回自增后的值 自定义自增的步长值
+ ///
+ public long IncrBy(string key, int count)
+ {
+ return base.iClient.IncrementValueBy(key, count);
+ }
+ ///
+ /// 自减1,返回自减后的值,Redis操作是单线程操作;不会出现超卖的情况
+ ///
+ public long Decr(string key)
+ {
+ return base.iClient.DecrementValue(key);
+ }
+ ///
+ /// 自减count ,返回自减后的值
+ ///
+ ///
+ ///
+ ///
+ public long DecrBy(string key, int count)
+ {
+ return base.iClient.DecrementValueBy(key, count);
+ }
+ #endregion
+ }
+}
diff --git a/StartServerWPF.Modules.MseedChart/StartServerWPF.Modules.MseedChart.csproj b/StartServerWPF.Modules.MseedChart/StartServerWPF.Modules.MseedChart.csproj
index 81b86c7..d9e34c4 100644
--- a/StartServerWPF.Modules.MseedChart/StartServerWPF.Modules.MseedChart.csproj
+++ b/StartServerWPF.Modules.MseedChart/StartServerWPF.Modules.MseedChart.csproj
@@ -1,5 +1,6 @@
+
Debug
@@ -13,6 +14,8 @@
{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
4
true
+
+
true
@@ -31,6 +34,42 @@
prompt
4
+
+ true
+ bin\x86\Debug\
+ DEBUG;TRACE
+ full
+ x86
+ 7.3
+ prompt
+
+
+ bin\x86\Release\
+ TRACE
+ true
+ pdbonly
+ x86
+ 7.3
+ prompt
+
+
+ true
+ bin\x64\Debug\
+ DEBUG;TRACE
+ full
+ x64
+ 7.3
+ prompt
+
+
+ bin\x64\Release\
+ TRACE
+ true
+ pdbonly
+ x64
+ 7.3
+ prompt
+
False
@@ -71,6 +110,96 @@
..\packages\DryIoc.dll.4.7.7\lib\net45\DryIoc.dll
+
+ ..\packages\Microsoft.AspNetCore.Cryptography.Internal.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Cryptography.Internal.dll
+
+
+ ..\packages\Microsoft.AspNetCore.Cryptography.KeyDerivation.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Cryptography.KeyDerivation.dll
+
+
+ ..\packages\Microsoft.AspNetCore.Hosting.2.2.7\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.dll
+
+
+ ..\packages\Microsoft.AspNetCore.Hosting.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.Abstractions.dll
+
+
+ ..\packages\Microsoft.AspNetCore.Hosting.Server.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.Server.Abstractions.dll
+
+
+ ..\packages\Microsoft.AspNetCore.Http.2.2.2\lib\netstandard2.0\Microsoft.AspNetCore.Http.dll
+
+
+ ..\packages\Microsoft.AspNetCore.Http.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Abstractions.dll
+
+
+ ..\packages\Microsoft.AspNetCore.Http.Extensions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Extensions.dll
+
+
+ ..\packages\Microsoft.AspNetCore.Http.Features.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Features.dll
+
+
+ ..\packages\Microsoft.AspNetCore.WebUtilities.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.WebUtilities.dll
+
+
+ ..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll
+
+
+ ..\packages\Microsoft.Extensions.Configuration.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll
+
+
+ ..\packages\Microsoft.Extensions.Configuration.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll
+
+
+ ..\packages\Microsoft.Extensions.Configuration.Binder.2.2.4\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll
+
+
+ ..\packages\Microsoft.Extensions.Configuration.EnvironmentVariables.2.2.4\lib\netstandard2.0\Microsoft.Extensions.Configuration.EnvironmentVariables.dll
+
+
+ ..\packages\Microsoft.Extensions.Configuration.FileExtensions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.FileExtensions.dll
+
+
+ ..\packages\Microsoft.Extensions.Configuration.Json.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Json.dll
+
+
+ ..\packages\Microsoft.Extensions.Configuration.UserSecrets.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.UserSecrets.dll
+
+
+ ..\packages\Microsoft.Extensions.DependencyInjection.2.2.0\lib\net461\Microsoft.Extensions.DependencyInjection.dll
+
+
+ ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll
+
+
+ ..\packages\Microsoft.Extensions.FileProviders.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileProviders.Abstractions.dll
+
+
+ ..\packages\Microsoft.Extensions.FileProviders.Physical.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileProviders.Physical.dll
+
+
+ ..\packages\Microsoft.Extensions.FileSystemGlobbing.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileSystemGlobbing.dll
+
+
+ ..\packages\Microsoft.Extensions.Hosting.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Hosting.Abstractions.dll
+
+
+ ..\packages\Microsoft.Extensions.Logging.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.dll
+
+
+ ..\packages\Microsoft.Extensions.Logging.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll
+
+
+ ..\packages\Microsoft.Extensions.ObjectPool.2.2.0\lib\netstandard2.0\Microsoft.Extensions.ObjectPool.dll
+
+
+ ..\packages\Microsoft.Extensions.Options.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Options.dll
+
+
+ ..\packages\Microsoft.Extensions.Primitives.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll
+
+
+ ..\packages\Microsoft.Net.Http.Headers.2.2.0\lib\netstandard2.0\Microsoft.Net.Http.Headers.dll
+
..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.31\lib\net45\Microsoft.Xaml.Behaviors.dll
@@ -86,12 +215,143 @@
..\packages\Prism.Wpf.8.1.97\lib\net461\Prism.Wpf.dll
+
+ ..\packages\ServiceStack.6.0.2\lib\netstandard2.0\ServiceStack.dll
+
+
+ ..\packages\ServiceStack.Client.6.0.2\lib\netstandard2.0\ServiceStack.Client.dll
+
+
+ ..\packages\ServiceStack.Common.6.0.2\lib\netstandard2.0\ServiceStack.Common.dll
+
+
+ ..\packages\ServiceStack.Interfaces.6.0.2\lib\netstandard2.0\ServiceStack.Interfaces.dll
+
+
+ ..\packages\ServiceStack.Redis.6.0.2\lib\netstandard2.0\ServiceStack.Redis.dll
+
+
+ ..\packages\ServiceStack.Text.6.0.2\lib\netstandard2.0\ServiceStack.Text.dll
+
+
+ ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll
+
+
+ ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll
+
+
+ ..\packages\System.Collections.NonGeneric.4.3.0\lib\net46\System.Collections.NonGeneric.dll
+ True
+ True
+
+
+ ..\packages\System.Collections.Specialized.4.3.0\lib\net46\System.Collections.Specialized.dll
+ True
+ True
+
+
+ ..\packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll
+
+
+
+
+ ..\packages\System.ComponentModel.Primitives.4.3.0\lib\net45\System.ComponentModel.Primitives.dll
+ True
+ True
+
+
+ ..\packages\System.Data.Common.4.3.0\lib\net451\System.Data.Common.dll
+ True
+ True
+
+
+ ..\packages\System.Diagnostics.DiagnosticSource.4.5.1\lib\net46\System.Diagnostics.DiagnosticSource.dll
+
+
+
+ ..\packages\System.Drawing.Common.5.0.2\lib\net461\System.Drawing.Common.dll
+
+
+
+ ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll
+
+
+
+ ..\packages\System.Net.NameResolution.4.3.0\lib\net46\System.Net.NameResolution.dll
+ True
+ True
+
+
+ ..\packages\System.Net.NetworkInformation.4.3.0\lib\net46\System.Net.NetworkInformation.dll
+ True
+ True
+
+
+ ..\packages\System.Net.Security.4.3.2\lib\net46\System.Net.Security.dll
+ True
+ True
+
+
+
+ ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll
+
+
+ ..\packages\System.Reflection.Metadata.1.6.0\lib\netstandard2.0\System.Reflection.Metadata.dll
+
+
+ ..\packages\System.Reflection.TypeExtensions.4.7.0\lib\net461\System.Reflection.TypeExtensions.dll
+
+
+ ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll
+
+
+
+ ..\packages\System.Runtime.Serialization.Primitives.4.3.0\lib\net46\System.Runtime.Serialization.Primitives.dll
+ True
+ True
+
+
+ ..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll
+ True
+ True
+
+
+ ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll
+ True
+ True
+
+
+ ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll
+ True
+ True
+
+
+ ..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll
+ True
+ True
+
+
+
+ ..\packages\System.ServiceModel.Primitives.4.8.1\lib\net461\System.ServiceModel.Primitives.dll
+
+
+ ..\packages\System.Text.Encodings.Web.4.5.0\lib\netstandard2.0\System.Text.Encodings.Web.dll
+
+
+ ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll
+
+
+ ..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll
+ True
+ True
+
..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll
+
@@ -107,6 +367,10 @@
+
+
+
+
@@ -128,7 +392,13 @@
True
+
+
+
+
+ ChartPlotRealDataView.xaml
+
ChartPlotView.xaml
@@ -136,6 +406,7 @@
ResXFileCodeGenerator
Resources.Designer.cs
+
SettingsSingleFileGenerator
@@ -143,6 +414,10 @@
+
+ MSBuild:Compile
+ Designer
+
MSBuild:Compile
Designer
@@ -155,4 +430,12 @@
+
+
+ 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。
+
+
+
+
+
\ No newline at end of file
diff --git a/StartServerWPF.Modules.MseedChart/ViewModels/ChartPlotRealDataViewModel.cs b/StartServerWPF.Modules.MseedChart/ViewModels/ChartPlotRealDataViewModel.cs
new file mode 100644
index 0000000..13ccb2a
--- /dev/null
+++ b/StartServerWPF.Modules.MseedChart/ViewModels/ChartPlotRealDataViewModel.cs
@@ -0,0 +1,1029 @@
+using Arction.Wpf.Charting;
+using Arction.Wpf.Charting.Axes;
+using Arction.Wpf.Charting.SeriesXY;
+using Arction.Wpf.Charting.Views.ViewXY;
+using Microsoft.Win32;
+using StartServerWPF.Modules.MseedChart.Models;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using SharpDX.Direct2D1;
+using SharpDX.DirectWrite;
+using System;
+using System.Collections;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Net.Http.Headers;
+using System.Reflection;
+using System.Security.Cryptography;
+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;
+using System.Windows.Threading;
+using System.Xml.Linq;
+using Prism.Regions;
+using static System.Collections.Specialized.BitVector32;
+using ZhaoXi.Advanced.MyRedis.Service;
+using ServiceStack;
+using ServiceStack.Redis;
+using Arction.Licensing;
+using System.Runtime.InteropServices;
+
+namespace StartServerWPF.Modules.MseedChart.ViewModels
+{
+ public class ChartPlotRealDataViewModel : BindableBase, INavigationAware
+ {
+
+ Mseed2asciiApi.LoopCallbackHandler loopCallback;
+ public ChartPlotRealDataViewModel()
+ {
+ _dispatcher = Application.Current.Dispatcher;
+ _wavesModel = new WavesModel();
+ (Application.Current.MainWindow as System.Windows.Window).Closing += ApplicationClosingDispose;
+ IntervalTime=100;
+ CreateChart();
+ loopCallback = new Mseed2asciiApi.LoopCallbackHandler(Mseed2AsciiEvent);
+ Mseed2asciiApi.MseedDatasCallFun(loopCallback);
+ GC.KeepAlive(loopCallback);
+ }
+
+ #region 字段
+ Dispatcher _dispatcher;
+ public int CurPoints;
+ int _channelCount = 0;
+ int _samplingFrequency = 500; // 采样频率 (Hz).
+ WavesModel _wavesModel;
+ private int _lChartCount = 1;
+ public ConcurrentQueue smList=new ConcurrentQueue();
+
+ public List _chartAxisY=new List();
+
+ private DispatcherTimer dispatcherTimer=new DispatcherTimer();
+ #endregion
+
+ #region 属性
+ private string _title = "数据中心";
+ public string Title
+ {
+ get { return _title; }
+ set
+ {
+ SetProperty(ref _title, value);
+ }
+ }
+ private bool _isRealtimeData =false;
+ public bool IsRealtimeData
+ {
+ get { return _isRealtimeData; }
+ set
+ {
+ SetProperty(ref _isRealtimeData, value);
+ }
+ }
+
+ private bool _isMultFiles;
+ public bool IsMultFiles
+ {
+ get { return _isMultFiles; }
+ set
+ {
+ SetProperty(ref _isMultFiles, value);
+ }
+ }
+ private int _xaisInterval;
+
+ public int XaisInterval
+ {
+ get { return _xaisInterval; }
+ set
+ {
+ SetProperty(ref _xaisInterval, value);
+ }
+ }
+ ///
+ /// 波形控件数量
+ ///
+ public int LChartCount
+ {
+ get { return _lChartCount; }
+ set { _lChartCount = value; }
+ }
+ private LightningChart _lChartAll;
+ ///
+ /// 所有波形
+ ///
+ public LightningChart LChartALL
+ {
+ get { return _lChartAll; }
+ set { _lChartAll = 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 StationEventJson _currentEventTime;
+
+ public StationEventJson CurrentEventTime
+ {
+
+ get { return _currentEventTime; }
+ set { _currentEventTime = value; }
+ }
+
+ private List _stationsName;
+
+ public List StationsName
+ {
+ get { return _stationsName; }
+ set {
+
+ SetProperty(ref _stationsName, value);
+ }
+ }
+
+ private string _currentTime;
+
+ public string CurrentTime
+ {
+ get { return _currentTime; }
+ set {
+
+ SetProperty(ref _currentTime, value);
+ }
+ }
+
+ private YAxisAutoPlacement _yaxisPlacement;
+
+ public YAxisAutoPlacement YaxisPlacement
+ {
+ get { return _yaxisPlacement; }
+ set
+ {
+ LChartALL.ViewXY.AxisLayout.YAxisAutoPlacement = value;
+ int distancetoX =_wavesModel.SetYasixPlacement(LChartALL);
+ foreach (var item in LChartALL.ViewXY.YAxes)
+ {
+ item.Title.DistanceToAxis = distancetoX;
+ }
+ SetProperty(ref _yaxisPlacement, value);
+ }
+ }
+
+ private int _IntervalTime=10;
+
+ public int IntervalTime
+ {
+ get { return _IntervalTime; }
+ set
+ {
+ if (value >=10)
+ {
+ dispatcherTimer.Interval = TimeSpan.FromMilliseconds(value);
+ }
+ SetProperty(ref _IntervalTime, value);
+ }
+ }
+
+
+ private bool _SingleChannel=false;
+
+ public bool SingleChannel
+ {
+ get { return _SingleChannel; }
+ set
+ {
+ if(!value)
+ {
+ YasixZENVisible("SHZ", false);
+ YasixZENVisible("SHN", false);
+ YasixZENVisible("SHE", false);
+ }
+ else
+ {
+ YasixZENVisible("SHZ", true);
+ YasixZENVisible("SHN", true);
+ YasixZENVisible("SHE", true);
+ YasixZENVisible(SelectChannel, false);
+ }
+
+ SetProperty(ref _SingleChannel, value);
+ }
+ }
+
+ private string _SelectChannel;
+ public string SelectChannel
+ {
+ get { return _SelectChannel; }
+ set
+ {
+ if (SingleChannel)
+ {
+ //隐藏上当前轴
+ YasixZENVisible(_SelectChannel, true);
+ //显示选择轴
+ YasixZENVisible(value, false);
+ }
+ SetProperty(ref _SelectChannel, value);
+ }
+ }
+ #endregion
+
+ #region 事件
+ public DelegateCommand LoadedCommand => new DelegateCommand(Loaded);
+ public DelegateCommand UnloadedCommand => new DelegateCommand(UnLoaded);
+ public DelegateCommand