Form1.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using DevExpress.XtraEditors;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. namespace XdCxRhDW.DataEmulation
  13. {
  14. public partial class Form1 : DevExpress.XtraEditors.XtraForm
  15. {
  16. public Form1()
  17. {
  18. InitializeComponent();
  19. }
  20. private void btnOpenDir_Click(object sender, EventArgs e)
  21. {
  22. System.Diagnostics.Process.Start("explorer.exe", ".\\");
  23. }
  24. private async void btnBuilder_ClickAsync(object sender, EventArgs e)
  25. {
  26. string file1 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, txtFile1.Text);
  27. string file2 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, txtFile2.Text);
  28. if (!long.TryParse(txtFsHz.Text, out long fsHz))
  29. {
  30. XtraMessageBox.Show("采样率非数字!");
  31. return;
  32. }
  33. if (!double.TryParse(txtSigLen.Text, out double sigTimeLen))
  34. {
  35. XtraMessageBox.Show("信号时长非数字!");
  36. return;
  37. }
  38. if (!double.TryParse(txtDto.Text, out double dt))
  39. {
  40. XtraMessageBox.Show("时差非数字!");
  41. return;
  42. }
  43. if (!double.TryParse(txtDfo.Text, out double df))
  44. {
  45. XtraMessageBox.Show("频差非数字!");
  46. return;
  47. }
  48. if (!double.TryParse(txtSnr1.Text, out double snr1))
  49. {
  50. XtraMessageBox.Show("文件1信噪比非数字!");
  51. return;
  52. }
  53. if (!double.TryParse(txtSnr2.Text, out double snr2))
  54. {
  55. XtraMessageBox.Show("文件2信噪比非数字!");
  56. return;
  57. }
  58. if (fsHz <= 0 || fsHz > 100000000)
  59. {
  60. XtraMessageBox.Show("采样率范围(0,100000000]!");
  61. return;
  62. }
  63. if (sigTimeLen <= 0 || sigTimeLen > 120)
  64. {
  65. XtraMessageBox.Show("信号时长范围(0,120]!");
  66. return;
  67. }
  68. btnBuilder.Enabled = false;
  69. await Task.Run(() =>
  70. {
  71. DataEmulationHelper.GenSignalsWithDtDf(file1, file2, fsHz, (int)(sigTimeLen * 1000), dt / 1e6, df, (int)snr1, (int)snr2);
  72. });
  73. btnBuilder.Enabled = true;
  74. }
  75. }
  76. }