XZGDOPParam .cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. using DevExpress.Mvvm.ModuleInjection.Native;
  2. using DevExpress.XtraEditors;
  3. using DevExpress.XtraMap;
  4. using DxHelper;
  5. using ExtensionsDev;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using System.Windows.Forms;
  15. using XzXdDw.App;
  16. using XzXdDw.App.Api.星地GDOP误差椭圆;
  17. using XzXdDw.App.Model;
  18. namespace XdCxRhDW.App.UserControl
  19. {
  20. public partial class XZGDOPParam : DevExpress.XtraEditors.XtraUserControl
  21. {
  22. public MapControl mapControl1;
  23. public GDOP星座协同接口 Model => new GDOP星座协同接口()
  24. {
  25. TleLeo1 = txtTleLeo1.Text.Trim(),
  26. TleLeo2 = txtTleLeo2.Text.Trim(),
  27. CapTime = txtCapTime.DateTime,
  28. RefLon = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[0].Trim()),
  29. RefLat = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
  30. DtousErr = Convert.ToDouble(txtDtousErr1.Text),
  31. DfoErr = Convert.ToDouble(txtDfoErr1.Text),
  32. SatLocErr = Convert.ToDouble(txtSatLocErr1.Text),
  33. EphVelErr = Convert.ToDouble(txtEphVelErr1.Text),
  34. fu1 = Convert.ToDouble(txtFu1.Text) * 1e6,
  35. fu2 = Convert.ToDouble(txtFu2.Text) * 1e6,
  36. };
  37. public XZGDOPParam(TxInfo refTx, DateTime sigTime, double upfreqHz1, double upfreqHz2)
  38. {
  39. InitializeComponent();
  40. txtCapTime.UseDefault();
  41. txtTleLeo1.UseDoubleClickToSelectAll();
  42. txtTleLeo2.UseDoubleClickToSelectAll();
  43. txtRefLocation1.UseDoubleClickToSelectAll();
  44. this.txtCapTime.DateTime = sigTime;
  45. this.txtRefLocation1.Text = $"{refTx.Lon},{refTx.Lat}";
  46. txtTleLeo1.UseDefault().SetStringData(TestData.AllTle).Text = TestData.tleleo1;
  47. txtTleLeo2.UseDefault().SetStringData(TestData.AllTle).Text = TestData.tleleo2;
  48. this.txtDtousErr1.EditValue = TestData.DtousErr;
  49. this.txtDfoErr1.EditValue = TestData.DfoHzErr;
  50. this.txtSatLocErr1.EditValue = TestData.SatLocErr;
  51. this.txtEphVelErr1.EditValue = TestData.EphVelErr;
  52. this.txtFu1.EditValue = upfreqHz1 * 1e-6;
  53. this.txtFu2.EditValue = upfreqHz2 * 1e-6;
  54. }
  55. private void btnOK_Click(object sender, EventArgs e)
  56. {
  57. mapControl1.ClearMap();
  58. var (listSat, data) = GdopHelper.GdopLeoTowSatDRef(
  59. new double[] { Model.RefLon, Model.RefLat }, Model.TleLeo1, Model.TleLeo2, Model.CapTime, Model.DtousErr, Model.DfoErr, Model.SatLocErr, Model.EphVelErr, Model.fu1, Model.fu2);
  60. if (data == null)
  61. {
  62. return;
  63. }
  64. if (listSat != null)//画卫星
  65. {
  66. foreach (var sat in listSat)
  67. {
  68. mapControl1.Invoke(new Action(() =>
  69. {
  70. string satCode = sat.SatCode == null ? "未知" : sat.SatCode.ToString();
  71. mapControl1.DrawFixedImg("sat", sat.SatLat, sat.SatLon, DxHelper.SvgHelper.CreateSat(), new Size(32, 32), $"卫星编号:{satCode}\r\n轨道经度:{sat.SatLon}°\r\n轨道纬度:{sat.SatLat}°");
  72. }));
  73. }
  74. }
  75. foreach (var errLins in data)//画GDOP
  76. {
  77. foreach (var line in errLins.MapLines)
  78. {
  79. var newLine = SampleDots(line);
  80. mapControl1.Invoke(new Action(() =>
  81. {
  82. var mapLines = newLine.Line.Select(p => (errLins.ErrDistanceKm, p.Lon, p.Lat));
  83. mapControl1.DrawGdopLine(mapLines);
  84. }));
  85. }
  86. }
  87. }
  88. public XdCxRhDW.App.DTO.MapLine SampleDots(XdCxRhDW.App.DTO.MapLine line)
  89. {
  90. var dots = line.Line;
  91. if (dots.Count < 30) return line;
  92. var tmp = dots.Count / 30;
  93. var newLine = new XdCxRhDW.App.DTO.MapLine();
  94. for (int i = 0; i < dots.Count; i += tmp)
  95. {
  96. newLine.Line.Add(dots[i]);
  97. }
  98. if (!newLine.Line.Contains(dots.Last()))
  99. newLine.Line.Add(dots.Last());
  100. return newLine;
  101. }
  102. private void btnClose_Click(object sender, EventArgs e)
  103. {
  104. PopupHelper.HidePopup(this);
  105. }
  106. }
  107. public class GDOP星座协同接口
  108. {
  109. /// <summary>
  110. /// 主星星历(Tle)
  111. /// </summary>
  112. public string TleLeo1 { get; set; }
  113. /// <summary>
  114. /// 邻星星历(Tle)
  115. /// </summary>
  116. public string TleLeo2 { get; set; }
  117. /// <summary>
  118. /// 采集时刻
  119. /// </summary>
  120. public DateTime CapTime { get; set; }
  121. /// <summary>
  122. /// 参考站位置经度
  123. /// </summary>
  124. public double RefLon { get; set; }
  125. /// <summary>
  126. /// 参考站位置纬度
  127. /// </summary>
  128. public double RefLat { get; set; }
  129. /// <summary>
  130. /// 时差误差(单位us)
  131. /// </summary>
  132. public double DtousErr { get; set; } = 1;
  133. /// <summary>
  134. /// 频差误差(Hz)
  135. /// </summary>
  136. public double DfoErr { get; set; }
  137. /// <summary>
  138. /// 星历位置误差(单位米)
  139. /// </summary>
  140. public double SatLocErr { get; set; } = 10000;
  141. /// <summary>
  142. ///星历速度误差
  143. /// </summary>
  144. public double EphVelErr { get; set; }
  145. /// <summary>
  146. /// 上行频点1(Hz)
  147. /// </summary>
  148. public double fu1 { get; set; }
  149. /// <summary>
  150. /// 上行频点2(Hz)
  151. /// </summary>
  152. public double fu2 { get; set; }
  153. }
  154. }