1修改钉钉发送问题(client重连没有登录),设备震级阈值

2 增加mseedC.dll同时使用问题;
3修改波形时间位置
master
mzhifa 7 months ago
parent a85d2d45c8
commit 92776e6a97

@ -31,6 +31,7 @@ namespace StartServerWPF.Models
private string chartsavepath1; private string chartsavepath1;
private string apmsavepath1; private string apmsavepath1;
private string toolsavepath1; private string toolsavepath1;
private double apmpush2ddmag1;
private int delayTime1; private int delayTime1;
private ApmsModel apmModel1; private ApmsModel apmModel1;
@ -54,6 +55,10 @@ namespace StartServerWPF.Models
[JsonProperty("toolpush2wx")] [JsonProperty("toolpush2wx")]
public bool toolpush2wx { get => toolpush2wx1; set => SetProperty(ref toolpush2wx1, value); } public bool toolpush2wx { get => toolpush2wx1; set => SetProperty(ref toolpush2wx1, value); }
[JsonProperty("apmpush2ddmag")]
public double apmpush2ddmag { get => apmpush2ddmag1; set => SetProperty(ref apmpush2ddmag1, value); }
[JsonProperty("delayTime")] [JsonProperty("delayTime")]
public int delayTime { get => delayTime1; set => SetProperty(ref delayTime1, value); } public int delayTime { get => delayTime1; set => SetProperty(ref delayTime1, value); }

@ -29,11 +29,12 @@ namespace StartServerWPF.Modules.Main.ViewModels
{ {
public class MainViewModel : BindableBase public class MainViewModel : BindableBase
{ {
public MainViewModel(SystemConfigModel systemConfig, IDialogService dialogService, WebsocketClient websocket, LoginViewDialogViewModel loginViewDialogViewModel) public MainViewModel(SystemConfigModel systemConfig, WorkareaModel workareaModel, IDialogService dialogService, WebsocketClient websocket, LoginViewDialogViewModel loginViewDialogViewModel)
{ {
Message = "View A" ; Message = "View A" ;
Console.WriteLine(System.Environment.CurrentDirectory + "\\" + JsonParser.systemConfigPath); Console.WriteLine(System.Environment.CurrentDirectory + "\\" + JsonParser.systemConfigPath);
_systemConfig = systemConfig; _systemConfig = systemConfig;
this._workareaModel = workareaModel;
ApmsIsEnable = _systemConfig.proApms.IsEnable; ApmsIsEnable = _systemConfig.proApms.IsEnable;
ToolsIsEnable= _systemConfig.proTools.IsEnable; ToolsIsEnable= _systemConfig.proTools.IsEnable;
DingdingIsEnable = _systemConfig.remoteDb.DingdingIsEnable; DingdingIsEnable = _systemConfig.remoteDb.DingdingIsEnable;
@ -523,7 +524,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
public bool vpnStatus = false; public bool vpnStatus = false;
private SystemConfigModel _systemConfig; private SystemConfigModel _systemConfig;
private readonly WorkareaModel _workareaModel;
private DispatcherTimer timer1= new DispatcherTimer(); private DispatcherTimer timer1= new DispatcherTimer();
private readonly IDialogService _dialogService; private readonly IDialogService _dialogService;
private readonly WebsocketClient _websocket; private readonly WebsocketClient _websocket;
@ -627,7 +628,8 @@ namespace StartServerWPF.Modules.Main.ViewModels
message = outLine.Data, message = outLine.Data,
}; };
string jsonStr = JsonSerializer.Serialize(cSDevicePublish); string jsonStr = JsonSerializer.Serialize(cSDevicePublish);
if (_systemConfig.remoteDb.DingdingIsEnable) //判断震级大小设置值
if (_systemConfig.remoteDb.DingdingIsEnable && (ms.ML >= _workareaModel.apmpush2ddmag))
{ {
_websocket.SendMes(jsonStr); _websocket.SendMes(jsonStr);
} }

@ -82,13 +82,15 @@
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"> <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="后处理路径:" Width="65" VerticalAlignment="Center"/> <TextBlock Text="后处理路径:" Width="65" VerticalAlignment="Center"/>
<TextBox DockPanel.Dock="Left" Width="100" Text="{Binding WareaModel.toolsavepath}"/> <TextBox DockPanel.Dock="Left" Width="100" Text="{Binding WareaModel.toolsavepath}"/>
<TextBlock Text="后理微信通知:" Width="90" VerticalAlignment="Center"/> <TextBlock Text="后理微信通知:" Width="90" VerticalAlignment="Center"/>
<CheckBox IsChecked="{Binding WareaModel.toolpush2wx}"/> <CheckBox IsChecked="{Binding WareaModel.toolpush2wx}"/>
</StackPanel> </StackPanel>
<DockPanel VerticalAlignment="Center"> <DockPanel VerticalAlignment="Center">
<TextBlock Text="延时时间(min):" VerticalAlignment="Center"/> <TextBlock Text="延时时间(min):" VerticalAlignment="Center"/>
<hc:NumericUpDown Value="{Binding WareaModel.delayTime}" Width="70" HorizontalAlignment="Left"/> <hc:NumericUpDown Value="{Binding WareaModel.delayTime}" Width="70" HorizontalAlignment="Left"/>
<TextBlock Text="震级钉钉通知:" Width="90" VerticalAlignment="Center"/>
<hc:NumericUpDown Value="{Binding WareaModel.apmpush2ddmag}" Width="70" HorizontalAlignment="Left"/>
</DockPanel> </DockPanel>
<DockPanel VerticalAlignment="Center"> <DockPanel VerticalAlignment="Center">
<TextBlock Text="network:" VerticalAlignment="Center"/> <TextBlock Text="network:" VerticalAlignment="Center"/>

@ -4,6 +4,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Security.Principal;
using System.Text; using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Threading; using System.Threading;
@ -25,20 +26,25 @@ namespace StartServerWPF.Modules.Main
webSocket4Net.Opened += WebSocket4Net_Opened; webSocket4Net.Opened += WebSocket4Net_Opened;
webSocket4Net.Error += new EventHandler<ErrorEventArgs>(WebSocket_Error); webSocket4Net.Error += new EventHandler<ErrorEventArgs>(WebSocket_Error);
webSocket4Net.MessageReceived += WebSocket4Net_MessageReceived; webSocket4Net.MessageReceived += WebSocket4Net_MessageReceived;
webSocket4Net.Open();
Debug.WriteLine("客户端连接成功!"); Debug.WriteLine("客户端连接成功!");
// thread.Start(); // thread.Start();
} }
private string name = string.Empty;
private string pwd = string.Empty;
public void SiginServer(string account,string password) public void SiginServer(string account,string password)
{ {
isHeartbeat = false;
string jsonstr= JsonSerializer.Serialize(new CSUserSigin { type = CSMessage.sigin, utype = "device", account=account,password=password}); isHeartbeat = false;
SendMes(jsonstr); name = account;
pwd = password;
webSocket4Net.Open();
// string jsonstr= JsonSerializer.Serialize(new CSUserSigin { type = CSMessage.sigin, utype = "device", account=account,password=password});
// SendMes(jsonstr);
Task.Run(async () =>{ Task.Run(async () =>{
await Task.Delay(2000); await Task.Delay(2000);
isHeartbeat = true; isHeartbeat = true;
SendHeartbeat(); SendHeartbeat();
}); });
} }
@ -58,22 +64,21 @@ namespace StartServerWPF.Modules.Main
{ {
while (isHeartbeat) while (isHeartbeat)
{ {
//Console.WriteLine($"客户端发送数据{i++}"); try
if (webSocket4Net.State == WebSocketState.Open)
{ {
webSocket4Net.Send("{\"type\":\"heartbeat\",\"utype\":\"device\"}"); if (webSocket4Net.State == WebSocketState.Open)
}
else if (webSocket4Net.State == WebSocketState.Closed)
{
try
{ {
webSocket4Net.Open(); webSocket4Net.Send("{\"type\":\"heartbeat\",\"utype\":\"device\"}");
} }
catch (Exception ex) else if (webSocket4Net.State == WebSocketState.Closed)
{ {
Debug.WriteLine(ex.ToString()); webSocket4Net.Open();
} }
Thread.Sleep(TimeSpan.FromSeconds(20)); }
catch (Exception ex)
{
Debug.WriteLine("连接报错:"+ ex.ToString());
Thread.Sleep(TimeSpan.FromSeconds(10));
} }
Thread.Sleep(TimeSpan.FromSeconds(5)); Thread.Sleep(TimeSpan.FromSeconds(5));
} }
@ -86,7 +91,9 @@ namespace StartServerWPF.Modules.Main
private void WebSocket4Net_Opened(object sender, EventArgs e) private void WebSocket4Net_Opened(object sender, EventArgs e)
{ {
Debug.WriteLine("连接websocket成功****************");
string jsonstr = JsonSerializer.Serialize(new CSUserSigin { type = CSMessage.sigin, utype = "device", account = name, password = pwd });
SendMes(jsonstr);
} }
void WebSocket_Error(object sender, ErrorEventArgs e) void WebSocket_Error(object sender, ErrorEventArgs e)
{ {

@ -15,6 +15,8 @@ namespace StartServerWPF.Modules.MseedChart.Models
{ {
public class WavesModel public class WavesModel
{ {
public const int lineTextX = 60;
public const int lineTextY = -5;
public List<AxisY> CreateYAxisChart(List<StationModel> stationModels, LightningChart curChart) public List<AxisY> CreateYAxisChart(List<StationModel> stationModels, LightningChart curChart)
{ {
List<AxisY> axisYList = new List<AxisY>(); List<AxisY> axisYList = new List<AxisY>();
@ -90,14 +92,14 @@ namespace StartServerWPF.Modules.MseedChart.Models
lineCollection.LineStyle.Color = System.Windows.Media.Colors.Red; lineCollection.LineStyle.Color = System.Windows.Media.Colors.Red;
lineCollection.Title.Text = chartV.YAxes[assignYAxisIndex].Title.Text + ph.atime.ToString(); lineCollection.Title.Text = chartV.YAxes[assignYAxisIndex].Title.Text + ph.atime.ToString();
lineCollection.Title.Visible = true; lineCollection.Title.Visible = true;
lineCollection.Title.Font.Size = 10; lineCollection.Title.Font.Size = 12;
lineCollection.Title.Shadow.DropColor = System.Windows.Media.Colors.Transparent; lineCollection.Title.Shadow.DropColor = System.Windows.Media.Colors.Transparent;
//lineCollection.Title.Shadow.ContrastColor = System.Windows.Media.Colors.Transparent; //lineCollection.Title.Shadow.ContrastColor = System.Windows.Media.Colors.Transparent;
lineCollection.Title.AutoPlacement = false; lineCollection.Title.AutoPlacement = false;
lineCollection.Title.HorizontalAlign = AlignmentHorizontal.Left; lineCollection.Title.HorizontalAlign = AlignmentHorizontal.Left;
var b = chartV.XAxes[0].ValueToCoordD(chartV.XAxes[0].DateTimeToAxisValue(ph.atime))-80; var b = chartV.XAxes[0].ValueToCoordD(chartV.XAxes[0].DateTimeToAxisValue(ph.atime))- WavesModel.lineTextX;
lineCollection.Title.Offset.SetValues((int)b, 3); lineCollection.Title.Offset.SetValues((int)b, WavesModel.lineTextY);
lineCollection.Title.Color = System.Windows.Media.Colors.Red; lineCollection.Title.Color = System.Windows.Media.Colors.Blue;
chartV.LineCollections.Add(lineCollection); chartV.LineCollections.Add(lineCollection);
} }
@ -121,14 +123,14 @@ namespace StartServerWPF.Modules.MseedChart.Models
lineCollection.LineStyle.Color = System.Windows.Media.Colors.Red; lineCollection.LineStyle.Color = System.Windows.Media.Colors.Red;
lineCollection.Title.Text = chartV.YAxes[assignYAxisIndex].Title.Text+ " "+ am.atime.ToString("HH:mm:ss.fff"); lineCollection.Title.Text = chartV.YAxes[assignYAxisIndex].Title.Text+ " "+ am.atime.ToString("HH:mm:ss.fff");
lineCollection.Title.Visible = true; lineCollection.Title.Visible = true;
lineCollection.Title.Font.Size = 10; lineCollection.Title.Font.Size = 12;
lineCollection.Title.Shadow.DropColor = System.Windows.Media.Colors.Transparent; lineCollection.Title.Shadow.DropColor = System.Windows.Media.Colors.Transparent;
// lineCollection.Title.Shadow.ContrastColor = System.Windows.Media.Colors.Transparent; // lineCollection.Title.Shadow.ContrastColor = System.Windows.Media.Colors.Transparent;
lineCollection.Title.AutoPlacement = false; lineCollection.Title.AutoPlacement = false;
lineCollection.Title.HorizontalAlign = AlignmentHorizontal.Left; lineCollection.Title.HorizontalAlign = AlignmentHorizontal.Left;
var b= chartV.XAxes[0].ValueToCoordD(chartV.XAxes[0].DateTimeToAxisValue(am.atime))-80; var b= chartV.XAxes[0].ValueToCoordD(chartV.XAxes[0].DateTimeToAxisValue(am.atime))- WavesModel.lineTextX;
lineCollection.Title.Offset.SetValues((int)b,3); lineCollection.Title.Offset.SetValues((int)b, WavesModel.lineTextY);
lineCollection.Title.Color = System.Windows.Media.Colors.Red; lineCollection.Title.Color = System.Windows.Media.Colors.Blue;
chartV.LineCollections.Add(lineCollection); chartV.LineCollections.Add(lineCollection);
} }
return new List<AxisY>(); return new List<AxisY>();

@ -24,7 +24,20 @@ namespace StartServerWPF.Modules.MseedChart
[DllImport("mseedC.dll")] [DllImport("mseedC.dll")]
public static extern void MseedDatasCallFun(LoopCallbackHandler callback); public static extern void MseedDatasCallFun(LoopCallbackHandler callback);
} }
//实时波形调用,确定切换页面时数据继续接收
public class MseedReal2asciiApi
{
public delegate void LoopCallbackHandler(AsciiDataStruct asciiData);
[DllImport("mseedCReal.dll", EntryPoint = "MseedDatas")]
public extern static int MseedDatas(int a, string[] name);
//public extern static int MseedDatas(Byte[] bytes, int lenght);
[DllImport("mseedCReal.dll", EntryPoint = "bufferMseedData")]
public extern static int bufferMseedData(int length, Byte[] data);
[DllImport("mseedCReal.dll", EntryPoint = "testc")]
public extern static int testc(int a, int b);
[DllImport("mseedCReal.dll")]
public static extern void MseedDatasCallFun(LoopCallbackHandler callback);
}
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct AsciiDataStruct public struct AsciiDataStruct
{ {

@ -33,17 +33,17 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
public class ChartPlotRealDataViewModel : BindableBase, INavigationAware public class ChartPlotRealDataViewModel : BindableBase, INavigationAware
{ {
Mseed2asciiApi.LoopCallbackHandler loopCallback; MseedReal2asciiApi.LoopCallbackHandler loopCallback;
WorkareaModel workarea; WorkareaModel workarea;
public ChartPlotRealDataViewModel(SystemConfigModel configModel,WorkareaModel workareaModel, IDialogService dialogService) public ChartPlotRealDataViewModel(SystemConfigModel configModel, WorkareaModel workareaModel, IDialogService dialogService)
{ {
(Application.Current.MainWindow as System.Windows.Window).Closing += ApplicationClosingDispose; (Application.Current.MainWindow as System.Windows.Window).Closing += ApplicationClosingDispose;
_dispatcher = Application.Current.Dispatcher; _dispatcher = Application.Current.Dispatcher;
IntervalTime =1000; IntervalTime = 1000;
loopCallback = new Mseed2asciiApi.LoopCallbackHandler(Mseed2AsciiEvent); loopCallback = new MseedReal2asciiApi.LoopCallbackHandler(Mseed2AsciiEvent);
MseedReal2asciiApi.MseedDatasCallFun(loopCallback);
GC.KeepAlive(loopCallback); GC.KeepAlive(loopCallback);
workarea= workareaModel; workarea = workareaModel;
_wavesModel = new WavesModel(); _wavesModel = new WavesModel();
CreateChart(); CreateChart();
if (workarea.StationConfig.Stations != null) if (workarea.StationConfig.Stations != null)
@ -281,12 +281,12 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
private void Loaded() private void Loaded()
{ {
Mseed2asciiApi.MseedDatasCallFun(loopCallback);
} }
private void UnLoaded() private void UnLoaded()
{ {
Mseed2asciiApi.MseedDatasCallFun(null);
} }
private void Sure() private void Sure()
@ -574,7 +574,7 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
{ {
iRedisSubscription.UnSubscribeFromChannels(subNameList.Keys.ToArray()); iRedisSubscription.UnSubscribeFromChannels(subNameList.Keys.ToArray());
} }
Mseed2asciiApi.bufferMseedData(message.Length, message); MseedReal2asciiApi.bufferMseedData(message.Length, message);
}, subNameList.Keys.ToArray()); }, subNameList.Keys.ToArray());
} }
}); });

@ -50,6 +50,7 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
IntervalTime=100; IntervalTime=100;
CreateChart(); CreateChart();
loopCallback = new Mseed2asciiApi.LoopCallbackHandler(Mseed2AsciiEvent); loopCallback = new Mseed2asciiApi.LoopCallbackHandler(Mseed2AsciiEvent);
Mseed2asciiApi.MseedDatasCallFun(loopCallback);
GC.KeepAlive(loopCallback); GC.KeepAlive(loopCallback);
} }
@ -324,12 +325,12 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
private void Loaded() private void Loaded()
{ {
Mseed2asciiApi.MseedDatasCallFun(loopCallback);
} }
private void UnLoaded() private void UnLoaded()
{ {
Mseed2asciiApi.MseedDatasCallFun(null);
} }
private void AxesYVisible(object isCheck) private void AxesYVisible(object isCheck)
{ {
@ -698,8 +699,8 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
{ {
foreach (var item in LChartALL.ViewXY.LineCollections) foreach (var item in LChartALL.ViewXY.LineCollections)
{ {
double b = LChartALL.ViewXY.XAxes[0].ValueToCoordD(item.Lines[0].AX) - 80; double b = LChartALL.ViewXY.XAxes[0].ValueToCoordD(item.Lines[0].AX) - WavesModel.lineTextX;
item.Title.Offset.SetValues((int)b, 3); item.Title.Offset.SetValues((int)b, WavesModel.lineTextY);
} }
} }
@ -707,8 +708,8 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
{ {
foreach (var item in LChartALL.ViewXY.LineCollections) foreach (var item in LChartALL.ViewXY.LineCollections)
{ {
double b = LChartALL.ViewXY.XAxes[0].ValueToCoordD(item.Lines[0].AX) - 80; double b = LChartALL.ViewXY.XAxes[0].ValueToCoordD(item.Lines[0].AX) - WavesModel.lineTextX;
item.Title.Offset.SetValues((int)b, 3); item.Title.Offset.SetValues((int)b, WavesModel.lineTextY);
} }
} }
@ -721,8 +722,8 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
} }
foreach (var item in LChartALL.ViewXY.LineCollections) foreach (var item in LChartALL.ViewXY.LineCollections)
{ {
double b = LChartALL.ViewXY.XAxes[0].ValueToCoordD(item.Lines[0].AX)-80; double b = LChartALL.ViewXY.XAxes[0].ValueToCoordD(item.Lines[0].AX)- WavesModel.lineTextX;
item.Title.Offset.SetValues((int)b, 3); item.Title.Offset.SetValues((int)b, WavesModel.lineTextY);
} }
} }

@ -29,7 +29,11 @@ namespace StartServerWPF
{ {
System.AppDomain.CurrentDomain.UnhandledException += new System.UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); System.AppDomain.CurrentDomain.UnhandledException += new System.UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
// AddSecurity(@"C:\ProgramData\Microsoft\Network\Connections"); // AddSecurity(@"C:\ProgramData\Microsoft\Network\Connections");
if(File.Exists("mseedC.dll"))
{
File.Copy("mseedC.dll", "mseedCReal.dll",true);
}
} }
/// <summary> /// <summary>

@ -6,6 +6,7 @@
"toolsavepath": "Post", "toolsavepath": "Post",
"apmpush2wx": false, "apmpush2wx": false,
"toolpush2wx": false, "toolpush2wx": false,
"apmpush2ddmag": -1.2,
"delayTime": 10, "delayTime": 10,
"apmModel": { "apmModel": {
"station": "N2107_1116.csv", "station": "N2107_1116.csv",

Loading…
Cancel
Save