diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index d616520..60d2327 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -239,6 +239,7 @@ + diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index d616520..60d2327 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -239,6 +239,7 @@ + diff --git a/Correlator/Model/ParamConfigModel.cs b/Correlator/Model/ParamConfigModel.cs new file mode 100644 index 0000000..67041fd --- /dev/null +++ b/Correlator/Model/ParamConfigModel.cs @@ -0,0 +1,38 @@ +namespace Correlator.Model +{ + /// + /// 用户选择的管材等参数 + /// + public class ParamConfigModel + { + /// + /// 管材 + /// + public string PipeMaterial { get; set; } + + /// + /// 管径 + /// + public string PipeDiameter { get; set; } + + /// + /// 管长 + /// + public string PipeLength { get; set; } + + /// + /// 工作模式 + /// + public string WorkMode { get; set; } + + /// + /// 低频 + /// + public string MinFrequency { get; set; } + + /// + /// 高频 + /// + public string MaxFrequency { get; set; } + } +} \ No newline at end of file diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index d616520..60d2327 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -239,6 +239,7 @@ + diff --git a/Correlator/Model/ParamConfigModel.cs b/Correlator/Model/ParamConfigModel.cs new file mode 100644 index 0000000..67041fd --- /dev/null +++ b/Correlator/Model/ParamConfigModel.cs @@ -0,0 +1,38 @@ +namespace Correlator.Model +{ + /// + /// 用户选择的管材等参数 + /// + public class ParamConfigModel + { + /// + /// 管材 + /// + public string PipeMaterial { get; set; } + + /// + /// 管径 + /// + public string PipeDiameter { get; set; } + + /// + /// 管长 + /// + public string PipeLength { get; set; } + + /// + /// 工作模式 + /// + public string WorkMode { get; set; } + + /// + /// 低频 + /// + public string MinFrequency { get; set; } + + /// + /// 高频 + /// + public string MaxFrequency { get; set; } + } +} \ No newline at end of file diff --git a/Correlator/ViewModels/MainWindowViewModel.cs b/Correlator/ViewModels/MainWindowViewModel.cs index 223ce8a..539a18c 100644 --- a/Correlator/ViewModels/MainWindowViewModel.cs +++ b/Correlator/ViewModels/MainWindowViewModel.cs @@ -2,6 +2,7 @@ using System.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; +using System.IO; using System.IO.Ports; using System.Linq; using System.Runtime.InteropServices; @@ -73,6 +74,7 @@ private string _locateDataDir; private int _locateTimes; private string _snapShotPath = string.Empty; + private ParamConfigModel _paramConfig; //自动截屏倒计时 private readonly DispatcherTimer _snapShotTimer = new DispatcherTimer @@ -448,7 +450,6 @@ public DelegateCommand OpenAudioFileCommand { set; get; } public DelegateCommand OpenListenAudioCommand { set; get; } public DelegateCommand PipeItemSelectedCommand { set; get; } - public DelegateCommand SoundSettingsCommand { private set; get; } public DelegateCommand ImportDataCommand { private set; get; } public DelegateCommand SaveAudioCommand { private set; get; } @@ -612,13 +613,18 @@ _eventAggregator.GetEvent().Publish(array); + var time = DateTime.Now.ToString("HHmmss"); + //保存参数 + var paramConfigFileName = $"{_locateDataDir}\\参数配置.{_locateTimes}.{time}.json"; + File.AppendAllText(paramConfigFileName, JsonConvert.SerializeObject(_paramConfig)); + //保存数据 - var fileName = $"{_locateDataDir}\\测试数据.{_locateTimes}.{DateTime.Now.ToString("HHmmss")}.txt"; + var fileName = $"{_locateDataDir}\\测试数据.{_locateTimes}.{time}.txt"; fileName.SaveLocateData(dataModel); "MainWindowViewModel".WriteLog("定位数据路径:" + fileName); //保存了数据之后3s再截图 - _snapShotPath = $"{_locateDataDir}\\快照.{_locateTimes}.{DateTime.Now.ToString("HHmmss")}.png"; + _snapShotPath = $"{_locateDataDir}\\快照.{_locateTimes}.{time}.png"; _snapShotTimer.Start(); _runningTimer.Stop(); @@ -817,20 +823,17 @@ //导入数据 ImportDataCommand = new DelegateCommand(delegate { - if (CheckParamLegitimacy()) + _dialogService.ShowDialog("ImportResponseDialog", null, delegate(IDialogResult result) { - _dialogService.ShowDialog("ImportResponseDialog", null, delegate(IDialogResult result) + if (result.Result == ButtonResult.Cancel) { - if (result.Result == ButtonResult.Cancel) - { - MessageBox.Show("取消导入数据", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Information); - return; - } + MessageBox.Show("取消导入数据", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Information); + return; + } - //导入数据完成,可以计算数据 - StartCalculateData(); - }); - } + //导入数据完成,可以计算数据 + StartCalculateData(); + }); }); //管道材料选择 @@ -987,8 +990,10 @@ var low = Convert.ToInt32(_lowFrequency); var high = Convert.ToInt32(_highFrequency); + string workMode; if (FlowStatus.IsHydrophone) { + workMode = "水听器模式"; if (low < 10 || low > 300 || high < 10 || high > 300 || low >= high) { MessageBox.Show("频段范围10 ~ 300Hz,请重新输入", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); @@ -997,6 +1002,7 @@ } else { + workMode = "加速度计模式"; if (low < 100 || low > 3000 || high < 100 || high > 3000 || low >= high) { MessageBox.Show("频段范围100 ~ 3000Hz,请重新输入", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); @@ -1008,6 +1014,17 @@ //声速 var soundVelocity = _soundSpeedDataService.GetSoundVelocity(_materialName, Convert.ToInt32(_pipeDiameter)); SoundSpeed = soundVelocity.ToString(); + + //缓存计算参数 + _paramConfig = new ParamConfigModel + { + PipeMaterial = _materialName, + PipeDiameter = _pipeDiameter, + PipeLength = _pipeLength, + WorkMode = workMode, + MinFrequency = _lowFrequency, + MaxFrequency = _highFrequency + }; return true; } }