Form1.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 (fsHz <= 0 || fsHz > 100000000)
  49. {
  50. XtraMessageBox.Show("采样率范围(0,100000000]!");
  51. return;
  52. }
  53. if (sigTimeLen <= 0 || sigTimeLen > 120)
  54. {
  55. XtraMessageBox.Show("信号时长范围(0,120]!");
  56. return;
  57. }
  58. btnBuilder.Enabled = false;
  59. await Task.Run(() =>
  60. {
  61. try
  62. {
  63. DataEmulationHelper.GenSignalsWithDtDf(file1, file2, fsHz, (int)(sigTimeLen * 1000), dt / 1e6, df);
  64. }
  65. catch (Exception ex)
  66. {
  67. }
  68. });
  69. btnBuilder.Enabled = true;
  70. }
  71. }
  72. }