TarDfoLeoX1Calc.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. using ExtensionsDev;
  2. using System;
  3. using System.IO;
  4. using System.Threading.Tasks;
  5. using System.Windows.Forms;
  6. using XdCxRhDW.Api;
  7. using XdCxRhDW.Api.AddIns;
  8. using XdCxRhDW.Dto;
  9. namespace XdCxRhDW.App.EditForms
  10. {
  11. public partial class TarDfoLeoX1Calc : DevExpress.XtraEditors.XtraForm
  12. {
  13. private string time1SatInfo;
  14. private string time2SatInfo;
  15. private string time3SatInfo;
  16. private string CapDir;
  17. public TarDfoLeoX1Calc()
  18. {
  19. InitializeComponent();
  20. this.Text = "一星频差预测";
  21. this.layoutControl1.UseDefault();
  22. this.StartPosition = FormStartPosition.CenterParent;
  23. }
  24. public TarDfoLeoX1Calc(double lon, double lat)
  25. : this()
  26. {
  27. this.txtTar.Text = $"{lon:f3},{lat:f3}";
  28. }
  29. private async void TarDfoLeoX1Calc_Load(object sender, EventArgs e)
  30. {
  31. await GetAppSetAsync();
  32. this.lcX1.Text = "第一时刻主星坐标X";
  33. this.lcY1.Text = "第一时刻主星坐标Y";
  34. this.lcZ1.Text = "第一时刻主星坐标Z";
  35. this.lcVX1.Text = "第一时刻主星坐标VX";
  36. this.lcVY1.Text = "第一时刻主星坐标VY";
  37. this.lcVZ1.Text = "第一时刻主星坐标VZ";
  38. this.lcX2.Text = "第二时刻主星坐标X";
  39. this.lcY2.Text = "第二时刻主星坐标Y";
  40. this.lcZ2.Text = "第二时刻主星坐标Z";
  41. this.lcVX2.Text = "第二时刻主星坐标VX";
  42. this.lcVY2.Text = "第二时刻主星坐标VY";
  43. this.lcVZ2.Text = "第二时刻主星坐标VZ";
  44. var t1 = time1SatInfo.Split(',');
  45. int idx = 0;
  46. txtX1.EditValue = t1[++idx];
  47. txtY1.EditValue = t1[++idx];
  48. txtZ1.EditValue = t1[++idx];
  49. txtVX1.EditValue = t1[++idx];
  50. txtVY1.EditValue = t1[++idx];
  51. txtVZ1.EditValue = t1[++idx];
  52. var t2 = time2SatInfo.Split(',');
  53. idx = 0;
  54. txtX2.EditValue = t2[++idx];
  55. txtY2.EditValue = t2[++idx];
  56. txtZ2.EditValue = t2[++idx];
  57. txtVX2.EditValue = t2[++idx];
  58. txtVY2.EditValue = t2[++idx];
  59. txtVZ2.EditValue = t2[++idx];
  60. var t3 = time3SatInfo.Split(',');
  61. idx = 0;
  62. txtX21.EditValue = t3[++idx];
  63. txtY21.EditValue = t3[++idx];
  64. txtZ21.EditValue = t3[++idx];
  65. txtVX21.EditValue = t3[++idx];
  66. txtVY21.EditValue = t3[++idx];
  67. txtVZ21.EditValue = t3[++idx];
  68. }
  69. private async Task GetAppSetAsync()
  70. {
  71. try
  72. {
  73. time1SatInfo = "1234,-1608416.82,5994263.83,3139842.12,-6632.9542,-373.9141,-2678.0471";
  74. time2SatInfo = "1234,-3479304.94,5612482.70,2187901.77,-5784.2167,-2163.5059,-3632.7021";
  75. time3SatInfo = "1234,-5018683.88,4714452.40,1001435.81,-4399.2159,-3780.5070,-4206.3348";
  76. CapDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "信号仿真", "低轨单星仿真数据");
  77. var svtItem = ServerContext.Instance.GetRandomOne(EnumSvrType.LeoX1Task54);
  78. if (svtItem == null)
  79. {
  80. return;
  81. }
  82. var rsp = await HttpHelper.GetRequestAsync<LeoSat1AppSettingDto>($"{svtItem.BaseHttpAddr}LeoSat1TaskProcessing/GetAppSetting", 10);
  83. if (rsp.code == 200)
  84. {
  85. time1SatInfo = rsp.data.Time1SatInfo;
  86. time2SatInfo = rsp.data.Time2SatInfo;
  87. time3SatInfo = rsp.data.Time3SatInfo;
  88. }
  89. }
  90. catch (Exception)
  91. {
  92. }
  93. }
  94. private async void btnOk_Click(object sender, EventArgs e)
  95. {
  96. await DfoCalcAsync(false);
  97. }
  98. private async Task DfoCalcAsync(bool beCreateData)
  99. {
  100. try
  101. {
  102. var strTar = txtTar.Text.Replace(",", ",");
  103. var tarfuHz = (Convert.ToDouble(txtTarFuMhz.Text) + 44) * 1e6;
  104. var DtarfuHz = (Convert.ToDouble(txtTarFuMhz.Text)) * 1e6;
  105. double lon = Convert.ToDouble(strTar.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[0]);
  106. double lat = Convert.ToDouble(strTar.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[1]);
  107. double x1 = Convert.ToDouble(txtX1.Text);
  108. double y1 = Convert.ToDouble(txtY1.Text);
  109. double z1 = Convert.ToDouble(txtZ1.Text);
  110. double vx1 = Convert.ToDouble(txtVX1.Text);
  111. double vy1 = Convert.ToDouble(txtVY1.Text);
  112. double vz1 = Convert.ToDouble(txtVZ1.Text);
  113. double[] ephX1 = new double[6] { x1, y1, z1, vx1, vy1, vz1 };
  114. double x2 = Convert.ToDouble(txtX2.Text);
  115. double y2 = Convert.ToDouble(txtY2.Text);
  116. double z2 = Convert.ToDouble(txtZ2.Text);
  117. double vx2 = Convert.ToDouble(txtVX2.Text);
  118. double vy2 = Convert.ToDouble(txtVY2.Text);
  119. double vz2 = Convert.ToDouble(txtVZ2.Text);
  120. double[] ephX2 = new double[6] { x2, y2, z2, vx2, vy2, vz2 };
  121. double[] targetPos = new double[3] { lon, lat, 0 };
  122. var tardf1 = DfoCalcAPI.DfoCalc(targetPos, ephX1, tarfuHz);
  123. var tardf2 = DfoCalcAPI.DfoCalc(targetPos, ephX2, tarfuHz);
  124. double x3 = Convert.ToDouble(txtX21.Text);
  125. double y3 = Convert.ToDouble(txtY21.Text);
  126. double z3 = Convert.ToDouble(txtZ21.Text);
  127. double vx3 = Convert.ToDouble(txtVX21.Text);
  128. double vy3 = Convert.ToDouble(txtVY21.Text);
  129. double vz3 = Convert.ToDouble(txtVZ21.Text);
  130. double[] ephX3 = new double[6] { x3, y3, z3, vx3, vy3, vz3 };
  131. var tardf3 = DfoCalcAPI.DfoCalc(targetPos, ephX3, tarfuHz);
  132. this.txtRes.Text = $"第二时刻目标频差预测值:{tardf2 - tardf1:f3}Hz 第三时刻目标频差预测值:{tardf3 - tardf1:f3}Hz";
  133. if (beCreateData)
  134. {
  135. long fsHz = 96000;
  136. int brustCount = 15;
  137. var dt1 = 1000 / 1e6;
  138. var dt2 = 1500 / 1e6;
  139. var df1 = tardf2 - tardf1;
  140. var df2 = tardf3 - tardf1;
  141. await Task.Run(() =>
  142. {
  143. try
  144. {
  145. Directory.CreateDirectory(CapDir);
  146. var t1 = DateTime.Now;
  147. var t2 = t1.AddSeconds(30);
  148. var t3 = t2.AddSeconds(30);
  149. var f1 = $"{CapDir}\\{t1:yyyyMMddHHmmss}_D{DtarfuHz * 1e-6}_FS{fsHz}_ch1.dat";
  150. var f2 = $"{CapDir}\\{t2:yyyyMMddHHmmss}_D{DtarfuHz * 1e-6}_FS{fsHz}_ch1.dat";
  151. var f3 = $"{CapDir}\\{t3:yyyyMMddHHmmss}_D{DtarfuHz * 1e-6}_FS{fsHz}_ch1.dat";
  152. DataEmulationHelper.GenBrustFiles(f1, f2, f3, fsHz, brustCount, dt1, df1, dt2, df2);
  153. System.Diagnostics.Process.Start("explorer.exe", CapDir);
  154. }
  155. catch (Exception ex)
  156. {
  157. DxHelper.MsgBoxHelper.ShowError("频差预测出错");
  158. }
  159. });
  160. }
  161. }
  162. catch (Exception ex)
  163. {
  164. await LogHelper.Error("频差预测出错", ex);
  165. DxHelper.MsgBoxHelper.ShowError("频差预测出错");
  166. }
  167. }
  168. private async void btnCreate_Click(object sender, EventArgs e)
  169. {
  170. await DfoCalcAsync(true);
  171. }
  172. }
  173. }