diff --git a/Correlator/App.xaml.cs b/Correlator/App.xaml.cs index 5fd331e..b0f88ee 100644 --- a/Correlator/App.xaml.cs +++ b/Correlator/App.xaml.cs @@ -38,12 +38,12 @@ private void Dispatcher_UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { - "App".WriteLog($"UI线程异常:{e.Exception.StackTrace}"); + "App".WriteLog($"{e.Exception.StackTrace}"); } private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { - "App".WriteLog($"Task线程异常:{e.Exception.StackTrace}"); + "App".WriteLog($"{e.Exception.StackTrace}"); } private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) diff --git a/Correlator/App.xaml.cs b/Correlator/App.xaml.cs index 5fd331e..b0f88ee 100644 --- a/Correlator/App.xaml.cs +++ b/Correlator/App.xaml.cs @@ -38,12 +38,12 @@ private void Dispatcher_UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { - "App".WriteLog($"UI线程异常:{e.Exception.StackTrace}"); + "App".WriteLog($"{e.Exception.StackTrace}"); } private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { - "App".WriteLog($"Task线程异常:{e.Exception.StackTrace}"); + "App".WriteLog($"{e.Exception.StackTrace}"); } private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) diff --git a/Correlator/DataService/ApplicationDataServiceImpl.cs b/Correlator/DataService/ApplicationDataServiceImpl.cs index f588bc6..a3c0270 100644 --- a/Correlator/DataService/ApplicationDataServiceImpl.cs +++ b/Correlator/DataService/ApplicationDataServiceImpl.cs @@ -5,7 +5,6 @@ using System.Windows.Media; using Correlator.Model; using Correlator.Util; -using Newtonsoft.Json; namespace Correlator.DataService { @@ -73,8 +72,6 @@ velocity.LowDiameter = Convert.ToInt32(minDiameter); velocity.HighDiameter = Convert.ToInt32(maxDiameter); velocity.Velocity = Convert.ToInt32(soundSpeed); - - "ApplicationDataServiceImpl".WriteLog("正在修改的管材是:" + JsonConvert.SerializeObject(velocity)); manager.Update(velocity); } } diff --git a/Correlator/App.xaml.cs b/Correlator/App.xaml.cs index 5fd331e..b0f88ee 100644 --- a/Correlator/App.xaml.cs +++ b/Correlator/App.xaml.cs @@ -38,12 +38,12 @@ private void Dispatcher_UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { - "App".WriteLog($"UI线程异常:{e.Exception.StackTrace}"); + "App".WriteLog($"{e.Exception.StackTrace}"); } private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { - "App".WriteLog($"Task线程异常:{e.Exception.StackTrace}"); + "App".WriteLog($"{e.Exception.StackTrace}"); } private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) diff --git a/Correlator/DataService/ApplicationDataServiceImpl.cs b/Correlator/DataService/ApplicationDataServiceImpl.cs index f588bc6..a3c0270 100644 --- a/Correlator/DataService/ApplicationDataServiceImpl.cs +++ b/Correlator/DataService/ApplicationDataServiceImpl.cs @@ -5,7 +5,6 @@ using System.Windows.Media; using Correlator.Model; using Correlator.Util; -using Newtonsoft.Json; namespace Correlator.DataService { @@ -73,8 +72,6 @@ velocity.LowDiameter = Convert.ToInt32(minDiameter); velocity.HighDiameter = Convert.ToInt32(maxDiameter); velocity.Velocity = Convert.ToInt32(soundSpeed); - - "ApplicationDataServiceImpl".WriteLog("正在修改的管材是:" + JsonConvert.SerializeObject(velocity)); manager.Update(velocity); } } diff --git a/Correlator/DataService/SerialPortServiceImpl.cs b/Correlator/DataService/SerialPortServiceImpl.cs index 2d48916..890934e 100644 --- a/Correlator/DataService/SerialPortServiceImpl.cs +++ b/Correlator/DataService/SerialPortServiceImpl.cs @@ -68,7 +68,6 @@ if (length < 12) { Sp.DiscardInBuffer(); //长度数据不符合,丢弃 - "SerialPortServiceImpl".WriteLog("上传数组长度不够,丢弃数据"); } else { diff --git a/Correlator/App.xaml.cs b/Correlator/App.xaml.cs index 5fd331e..b0f88ee 100644 --- a/Correlator/App.xaml.cs +++ b/Correlator/App.xaml.cs @@ -38,12 +38,12 @@ private void Dispatcher_UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { - "App".WriteLog($"UI线程异常:{e.Exception.StackTrace}"); + "App".WriteLog($"{e.Exception.StackTrace}"); } private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { - "App".WriteLog($"Task线程异常:{e.Exception.StackTrace}"); + "App".WriteLog($"{e.Exception.StackTrace}"); } private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) diff --git a/Correlator/DataService/ApplicationDataServiceImpl.cs b/Correlator/DataService/ApplicationDataServiceImpl.cs index f588bc6..a3c0270 100644 --- a/Correlator/DataService/ApplicationDataServiceImpl.cs +++ b/Correlator/DataService/ApplicationDataServiceImpl.cs @@ -5,7 +5,6 @@ using System.Windows.Media; using Correlator.Model; using Correlator.Util; -using Newtonsoft.Json; namespace Correlator.DataService { @@ -73,8 +72,6 @@ velocity.LowDiameter = Convert.ToInt32(minDiameter); velocity.HighDiameter = Convert.ToInt32(maxDiameter); velocity.Velocity = Convert.ToInt32(soundSpeed); - - "ApplicationDataServiceImpl".WriteLog("正在修改的管材是:" + JsonConvert.SerializeObject(velocity)); manager.Update(velocity); } } diff --git a/Correlator/DataService/SerialPortServiceImpl.cs b/Correlator/DataService/SerialPortServiceImpl.cs index 2d48916..890934e 100644 --- a/Correlator/DataService/SerialPortServiceImpl.cs +++ b/Correlator/DataService/SerialPortServiceImpl.cs @@ -68,7 +68,6 @@ if (length < 12) { Sp.DiscardInBuffer(); //长度数据不符合,丢弃 - "SerialPortServiceImpl".WriteLog("上传数组长度不够,丢弃数据"); } else { diff --git a/Correlator/Util/MethodExtensions.cs b/Correlator/Util/MethodExtensions.cs index d83c5c7..667540c 100644 --- a/Correlator/Util/MethodExtensions.cs +++ b/Correlator/Util/MethodExtensions.cs @@ -167,7 +167,6 @@ var valueBytes = new byte[tagValueLength]; Array.Copy(tagBytes, i + 6, valueBytes, 0, tagValueLength); - // Console.WriteLine($@"第{n}个Tag => {BitConverter.ToString(valueBytes)}"); i = i + 6 + tagValueLength; var tag = TagFactory.Create(oid, tagValueLength, valueBytes); diff --git a/Correlator/App.xaml.cs b/Correlator/App.xaml.cs index 5fd331e..b0f88ee 100644 --- a/Correlator/App.xaml.cs +++ b/Correlator/App.xaml.cs @@ -38,12 +38,12 @@ private void Dispatcher_UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { - "App".WriteLog($"UI线程异常:{e.Exception.StackTrace}"); + "App".WriteLog($"{e.Exception.StackTrace}"); } private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { - "App".WriteLog($"Task线程异常:{e.Exception.StackTrace}"); + "App".WriteLog($"{e.Exception.StackTrace}"); } private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) diff --git a/Correlator/DataService/ApplicationDataServiceImpl.cs b/Correlator/DataService/ApplicationDataServiceImpl.cs index f588bc6..a3c0270 100644 --- a/Correlator/DataService/ApplicationDataServiceImpl.cs +++ b/Correlator/DataService/ApplicationDataServiceImpl.cs @@ -5,7 +5,6 @@ using System.Windows.Media; using Correlator.Model; using Correlator.Util; -using Newtonsoft.Json; namespace Correlator.DataService { @@ -73,8 +72,6 @@ velocity.LowDiameter = Convert.ToInt32(minDiameter); velocity.HighDiameter = Convert.ToInt32(maxDiameter); velocity.Velocity = Convert.ToInt32(soundSpeed); - - "ApplicationDataServiceImpl".WriteLog("正在修改的管材是:" + JsonConvert.SerializeObject(velocity)); manager.Update(velocity); } } diff --git a/Correlator/DataService/SerialPortServiceImpl.cs b/Correlator/DataService/SerialPortServiceImpl.cs index 2d48916..890934e 100644 --- a/Correlator/DataService/SerialPortServiceImpl.cs +++ b/Correlator/DataService/SerialPortServiceImpl.cs @@ -68,7 +68,6 @@ if (length < 12) { Sp.DiscardInBuffer(); //长度数据不符合,丢弃 - "SerialPortServiceImpl".WriteLog("上传数组长度不够,丢弃数据"); } else { diff --git a/Correlator/Util/MethodExtensions.cs b/Correlator/Util/MethodExtensions.cs index d83c5c7..667540c 100644 --- a/Correlator/Util/MethodExtensions.cs +++ b/Correlator/Util/MethodExtensions.cs @@ -167,7 +167,6 @@ var valueBytes = new byte[tagValueLength]; Array.Copy(tagBytes, i + 6, valueBytes, 0, tagValueLength); - // Console.WriteLine($@"第{n}个Tag => {BitConverter.ToString(valueBytes)}"); i = i + 6 + tagValueLength; var tag = TagFactory.Create(oid, tagValueLength, valueBytes); diff --git a/Correlator/ViewModels/MainWindowViewModel.cs b/Correlator/ViewModels/MainWindowViewModel.cs index f1c0f28..d2643e5 100644 --- a/Correlator/ViewModels/MainWindowViewModel.cs +++ b/Correlator/ViewModels/MainWindowViewModel.cs @@ -559,8 +559,6 @@ var dev = args.DeviceDevStatus; if (args.DeviceId.Equals(RuntimeCache.Dev1)) { - "MainWindowViewModel".WriteLog("Red Sensor收到消息:" + JsonConvert.SerializeObject(dev)); - //新协议不计算实际信号 RedTransmitterBattery = Convert.ToInt32(dev.Cell); RedTransmitterSignal = 5; @@ -569,8 +567,6 @@ } else { - "MainWindowViewModel".WriteLog("Blue Sensor收到消息:" + JsonConvert.SerializeObject(dev)); - //新协议不计算实际信号 BlueTransmitterBattery = Convert.ToInt32(dev.Cell); BlueTransmitterSignal = 5; @@ -965,7 +961,6 @@ if (_backgroundWorker.IsBusy) { - "MainWindowViewModel".WriteLog("正在计算中,请稍后..."); return; } diff --git a/Correlator/App.xaml.cs b/Correlator/App.xaml.cs index 5fd331e..b0f88ee 100644 --- a/Correlator/App.xaml.cs +++ b/Correlator/App.xaml.cs @@ -38,12 +38,12 @@ private void Dispatcher_UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { - "App".WriteLog($"UI线程异常:{e.Exception.StackTrace}"); + "App".WriteLog($"{e.Exception.StackTrace}"); } private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { - "App".WriteLog($"Task线程异常:{e.Exception.StackTrace}"); + "App".WriteLog($"{e.Exception.StackTrace}"); } private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) diff --git a/Correlator/DataService/ApplicationDataServiceImpl.cs b/Correlator/DataService/ApplicationDataServiceImpl.cs index f588bc6..a3c0270 100644 --- a/Correlator/DataService/ApplicationDataServiceImpl.cs +++ b/Correlator/DataService/ApplicationDataServiceImpl.cs @@ -5,7 +5,6 @@ using System.Windows.Media; using Correlator.Model; using Correlator.Util; -using Newtonsoft.Json; namespace Correlator.DataService { @@ -73,8 +72,6 @@ velocity.LowDiameter = Convert.ToInt32(minDiameter); velocity.HighDiameter = Convert.ToInt32(maxDiameter); velocity.Velocity = Convert.ToInt32(soundSpeed); - - "ApplicationDataServiceImpl".WriteLog("正在修改的管材是:" + JsonConvert.SerializeObject(velocity)); manager.Update(velocity); } } diff --git a/Correlator/DataService/SerialPortServiceImpl.cs b/Correlator/DataService/SerialPortServiceImpl.cs index 2d48916..890934e 100644 --- a/Correlator/DataService/SerialPortServiceImpl.cs +++ b/Correlator/DataService/SerialPortServiceImpl.cs @@ -68,7 +68,6 @@ if (length < 12) { Sp.DiscardInBuffer(); //长度数据不符合,丢弃 - "SerialPortServiceImpl".WriteLog("上传数组长度不够,丢弃数据"); } else { diff --git a/Correlator/Util/MethodExtensions.cs b/Correlator/Util/MethodExtensions.cs index d83c5c7..667540c 100644 --- a/Correlator/Util/MethodExtensions.cs +++ b/Correlator/Util/MethodExtensions.cs @@ -167,7 +167,6 @@ var valueBytes = new byte[tagValueLength]; Array.Copy(tagBytes, i + 6, valueBytes, 0, tagValueLength); - // Console.WriteLine($@"第{n}个Tag => {BitConverter.ToString(valueBytes)}"); i = i + 6 + tagValueLength; var tag = TagFactory.Create(oid, tagValueLength, valueBytes); diff --git a/Correlator/ViewModels/MainWindowViewModel.cs b/Correlator/ViewModels/MainWindowViewModel.cs index f1c0f28..d2643e5 100644 --- a/Correlator/ViewModels/MainWindowViewModel.cs +++ b/Correlator/ViewModels/MainWindowViewModel.cs @@ -559,8 +559,6 @@ var dev = args.DeviceDevStatus; if (args.DeviceId.Equals(RuntimeCache.Dev1)) { - "MainWindowViewModel".WriteLog("Red Sensor收到消息:" + JsonConvert.SerializeObject(dev)); - //新协议不计算实际信号 RedTransmitterBattery = Convert.ToInt32(dev.Cell); RedTransmitterSignal = 5; @@ -569,8 +567,6 @@ } else { - "MainWindowViewModel".WriteLog("Blue Sensor收到消息:" + JsonConvert.SerializeObject(dev)); - //新协议不计算实际信号 BlueTransmitterBattery = Convert.ToInt32(dev.Cell); BlueTransmitterSignal = 5; @@ -965,7 +961,6 @@ if (_backgroundWorker.IsBusy) { - "MainWindowViewModel".WriteLog("正在计算中,请稍后..."); return; } diff --git a/Correlator/Views/MainWindow.xaml.cs b/Correlator/Views/MainWindow.xaml.cs index 6f0ef17..b764985 100644 --- a/Correlator/Views/MainWindow.xaml.cs +++ b/Correlator/Views/MainWindow.xaml.cs @@ -4,6 +4,7 @@ using System.Text.RegularExpressions; using System.Windows; using System.Windows.Input; +using System.Windows.Threading; using Correlator.Dialog; using Correlator.Events; using Correlator.Util; @@ -15,6 +16,16 @@ public partial class MainWindow : Window { private readonly Regex _regex = new Regex("[^0-9]+"); + + #region DispatcherTimer + + private readonly DispatcherTimer _checkLoadingDialogTimer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(1) + }; + + #endregion + private LoadingDialog _loadingDialog; public MainWindow(IEventAggregator eventAggregator) @@ -80,6 +91,15 @@ #endregion + _checkLoadingDialogTimer.Tick += delegate + { + if (_loadingDialog != null && _loadingDialog.IsVisible) + { + Dispatcher.Invoke(delegate { _loadingDialog.Close(); }); + _checkLoadingDialogTimer.Stop(); + } + }; + RenderDataTextBlock.Text = "渲染耗时:0 秒"; eventAggregator.GetEvent().Subscribe(delegate @@ -101,6 +121,8 @@ Dispatcher.Invoke(delegate { _loadingDialog.Close(); + //补丁:实际长时间使用概率性出现_loadingDialog无法关闭的问题,用一个定时器检查_loadingDialog的状态 + _checkLoadingDialogTimer.Start(); var startTime = DateTime.Now; "MainWindow".WriteLog("开始渲染计算结果"); //最大相关系数