Form1.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. if (!long.TryParse(txtFsHz.Text, out long fsHz))
  27. {
  28. XtraMessageBox.Show("采样率非数字!");
  29. return;
  30. }
  31. if (!double.TryParse(txtSigLen.Text, out double sigTimeLen))
  32. {
  33. XtraMessageBox.Show("信号时长非数字!");
  34. return;
  35. }
  36. if (!double.TryParse(txtDto.Text, out double dt))
  37. {
  38. XtraMessageBox.Show("时差非数字!");
  39. return;
  40. }
  41. if (!double.TryParse(txtDfo.Text, out double df))
  42. {
  43. XtraMessageBox.Show("频差非数字!");
  44. return;
  45. }
  46. if (!double.TryParse(txtSnr1.Text, out double snr1))
  47. {
  48. XtraMessageBox.Show("文件1信噪比非数字!");
  49. return;
  50. }
  51. if (!double.TryParse(txtSnr2.Text, out double snr2))
  52. {
  53. XtraMessageBox.Show("文件2信噪比非数字!");
  54. return;
  55. }
  56. if (fsHz <= 0 || fsHz > 100000000)
  57. {
  58. XtraMessageBox.Show("采样率范围(0,100000000]!");
  59. return;
  60. }
  61. if (sigTimeLen <= 0 || sigTimeLen > 120)
  62. {
  63. XtraMessageBox.Show("信号时长范围(0,120]!");
  64. return;
  65. }
  66. btnBuildNormal.Enabled = false;
  67. btnBuildBrust.Enabled = false;
  68. await Task.Run(() =>
  69. {
  70. if (sender == btnBuildNormal)
  71. {
  72. DataEmulationHelper.GenNormalFiles("常规信号_ch1.dat", "常规信号_ch2.dat", fsHz, (int)(sigTimeLen * 1000), dt / 1e6, df, (int)snr1, (int)snr2);
  73. }
  74. else
  75. {
  76. DataEmulationHelper.GenBrustFiles("突发信号_ch1.dat", "突发信号_ch2.dat", fsHz, (int)(sigTimeLen * 1000), dt / 1e6, df);
  77. }
  78. });
  79. btnBuildNormal.Enabled = true;
  80. btnBuildBrust.Enabled = true;
  81. }
  82. }
  83. }