diff --git a/Correlator/ViewModel/HomePageProViewModel.cs b/Correlator/ViewModel/HomePageProViewModel.cs index e6d15f7..421f6c8 100644 --- a/Correlator/ViewModel/HomePageProViewModel.cs +++ b/Correlator/ViewModel/HomePageProViewModel.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Runtime.InteropServices; using System.Text.RegularExpressions; -using System.Threading.Tasks; +using System.Threading; using System.Windows; using System.Windows.Threading; using Correlator.Dialog; @@ -535,51 +535,12 @@ manager.Insert(configModel); } - // CalculateData(it); - // - // var fileName = _locateDataDir + "\\测试数据." + _locateTimes + "." + - // DateTime.Now.ToString("HHmmss") + ".txt"; - // StringUtil.SaveLocateData(it, fileName); - // "HomePageViewModel".WriteLog("定位数据路径:" + fileName); - // - // _snapShotPath = _locateDataDir + "\\快照." + _locateTimes + "." + - // DateTime.Now.ToString("HHmmss") + ".png"; - // _snapShotTimer.Start(); - // - // _runningTimer.Stop(); - // StartButtonEnabled = true; - // FlowStatus.RedSensorIsEnable = false; - // FlowStatus.BlueSensorIsEnable = false; - // DialogHub.Get.DismissLoadingDialog(); - //计算 //异步计算数据 - Task.Factory - .StartNew(() => CalculateData(it)) - .ContinueWith(delegate - { - //保存数据 - var fileName = _locateDataDir + "\\测试数据." + _locateTimes + "." + - DateTime.Now.ToString("HHmmss") + ".txt"; - StringUtil.SaveLocateData(it, fileName); - "HomePageViewModel".WriteLog("定位数据路径:" + fileName); - - //保存了数据之后5s再截图 - _snapShotPath = _locateDataDir + "\\快照." + _locateTimes + "." + - DateTime.Now.ToString("HHmmss") + ".png"; - _snapShotTimer.Start(); - - _runningTimer.Stop(); - StartButtonEnabled = true; - //清空缓存 - FlowStatus.RedSensorTagLists.Clear(); - FlowStatus.BlueSensorTagLists.Clear(); - FlowStatus.RedSensorIsEnable = false; - FlowStatus.BlueSensorIsEnable = false; - DialogHub.Get.DismissLoadingDialog(); - }, TaskContinuationOptions.OnlyOnRanToCompletion); + new Thread(() => CalculateData(it)).Start(); } + /// /// 算法计算 /// @@ -614,6 +575,27 @@ FilterValue = maxFreLowOut + " ~ " + maxFreHighOut + "Hz"; Messenger.Default.Send(array, MessengerToken.RenderOscillogram); + + //保存数据 + var fileName = _locateDataDir + "\\测试数据." + _locateTimes + "." + + DateTime.Now.ToString("HHmmss") + ".txt"; + StringUtil.SaveLocateData(dataModel, fileName); + "HomePageViewModel".WriteLog("定位数据路径:" + fileName); + + //保存了数据之后5s再截图 + _snapShotPath = _locateDataDir + "\\快照." + _locateTimes + "." + + DateTime.Now.ToString("HHmmss") + ".png"; + _snapShotTimer.Start(); + + _runningTimer.Stop(); + StartButtonEnabled = true; + //清空缓存 + FlowStatus.RedSensorTagLists.Clear(); + FlowStatus.BlueSensorTagLists.Clear(); + FlowStatus.RedSensorIsEnable = false; + FlowStatus.BlueSensorIsEnable = false; + + Application.Current.Dispatcher.Invoke(delegate { DialogHub.Get.DismissLoadingDialog(); }); } else { @@ -621,29 +603,6 @@ } } - // private MWArray[] CalculateData(CorrelatorDataModel dataModel) - // { - // if (dataModel.LeftDeviceDataArray.Any() && dataModel.RightDeviceDataArray.Any()) - // { - // Debug.WriteLine("HomePageProViewModel => 开始计算"); - // var array = _correlator.locating(11, - // (MWNumericArray)dataModel.LeftDeviceDataArray, (MWNumericArray)dataModel.RightDeviceDataArray, - // Constant.SamplingRate, - // 150, 1130, - // 0, 0, - // 0, 0, - // "铸铁", - // 300, 300, - // 1, -1, - // -1, -1, - // 10, 300); - // Debug.WriteLine("HomePageProViewModel => 计算结束"); - // return array; - // } - // - // return null; - // } - /// /// 各种定时器 ///