X2DFGDOPParam.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. 
  2. using DevExpress.XtraMap;
  3. using DxHelper;
  4. using ExtensionsDev;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Data;
  9. using System.Drawing;
  10. using System.Linq;
  11. using XdCxRhDW.App.Api.GDOP误差椭圆;
  12. using XdCxRhDW.Repostory.EFContext;
  13. using XdCxRhDW.Repostory.Model;
  14. namespace XdCxRhDW.App.UserControl
  15. {
  16. public partial class X2DFGDOPParam : DevExpress.XtraEditors.XtraUserControl
  17. {
  18. public MapControl mapControl1;
  19. public X2DFGDOP接口 Model => new X2DFGDOP接口()
  20. {
  21. TleLeo1 = txtTleLeo1.Text.Trim(),
  22. TleLeo2 = txtTleLeo2.Text.Trim(),
  23. CapTime = txtCapTime.DateTime,
  24. RefLon = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[0].Trim()),
  25. RefLat = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
  26. DfoErr = Convert.ToDouble(txtDfoErr1.Text),
  27. DtousErr = Convert.ToDouble(txtDtousErr1.Text),
  28. SatLocErr = Convert.ToDouble(txtSatLocErr1.Text),
  29. EphVelErr = Convert.ToDouble(txtEphVelErr1.Text),
  30. fu1 = Convert.ToDouble(txtFu1.Text) * 1e6,
  31. fu2 = Convert.ToDouble(txtFu2.Text) * 1e6,
  32. };
  33. public X2DFGDOPParam(PosRes item)
  34. {
  35. InitializeComponent();
  36. txtCapTime.UseDefault();
  37. txtTleLeo1.UseDoubleClickToSelectAll();
  38. txtTleLeo2.UseDoubleClickToSelectAll();
  39. txtRefLocation1.UseDoubleClickToSelectAll();
  40. this.txtCapTime.DateTime = item.SigTime;
  41. this.txtSatLocErr1.EditValue = 1000;
  42. this.txtEphVelErr1.EditValue = 0.1;
  43. this.txtDfoErr1.EditValue = 0.01;
  44. this.txtDtousErr1.EditValue = 1;
  45. List<string> xlall = new List<string>();
  46. string mainTle = string.Empty;
  47. string adjaTle1 = string.Empty;
  48. using (RHDWContext db = new RHDWContext())
  49. {
  50. var sats = db.SatInfos.ToList();
  51. var cg = db.CgRes.Where(m => m.ID == item.CgResID).FirstOrDefault();
  52. var station = db.StationRes.Where(m => m.ID == item.StationResID).FirstOrDefault();
  53. if (station != null)
  54. {
  55. this.txtRefLocation1.Text = $"{station.RefLon},{station.RefLat}";
  56. }
  57. this.txtFu1.EditValue = cg.TarFreqUp.HasValue ? cg.TarFreqUp.Value : 950;
  58. this.txtFu2.EditValue = cg.RefFreqUp.HasValue ? cg.RefFreqUp.Value : 950;
  59. var xlList = db.XlInfos.OrderBy(p => p.SatName).OrderByDescending(p => p.TimeBJ).ToList();
  60. xlall.AddRange(xlList.Select(m => m.TwoLine));
  61. if (xlall.Count() == 0) return;
  62. if (cg.MainCode.HasValue && xlList.Any(m => m.SatCode == cg.MainCode.Value))
  63. {
  64. mainTle = xlList.First(m => m.SatCode == cg.MainCode.Value).TwoLine;
  65. }
  66. else
  67. {
  68. mainTle = xlList.First().TwoLine;
  69. }
  70. if (cg.Adja1Code.HasValue && xlList.Any(m => m.SatCode == cg.Adja1Code.Value))
  71. {
  72. adjaTle1 = xlList.First(m => m.SatCode == cg.Adja1Code.Value).TwoLine;
  73. }
  74. else
  75. {
  76. adjaTle1 = xlList.First().TwoLine;
  77. }
  78. }
  79. txtTleLeo1.UseDefault().SetStringData(xlall).Text = mainTle;
  80. txtTleLeo2.UseDefault().SetStringData(xlall).Text = adjaTle1;
  81. }
  82. private void btnOK_Click(object sender, EventArgs e)
  83. {
  84. mapControl1.ClearMap();
  85. var refs = new double[] { Model.RefLon, Model.RefLat, 0 };
  86. var (listSat, data) = GdopHelper.Gdop2SatDRef(Model.TleLeo1, Model.TleLeo2,
  87. Model.CapTime, Model.fu1, Model.fu2, Model.DtousErr, Model.DfoErr, Model.SatLocErr, Model.EphVelErr, refs);
  88. if (data == null)
  89. {
  90. return;
  91. }
  92. foreach (var errLins in data)//画GDOP
  93. {
  94. var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
  95. mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, mapDots.Count() / 2);
  96. }
  97. }
  98. private void btnClose_Click(object sender, EventArgs e)
  99. {
  100. PopupHelper.HidePopup(this);
  101. }
  102. }
  103. public class X2DFGDOP接口
  104. {
  105. /// <summary>
  106. /// 主星星历(Tle)
  107. /// </summary>
  108. public string TleLeo1 { get; set; }
  109. /// <summary>
  110. /// 邻星1星历(Tle)
  111. /// </summary>
  112. public string TleLeo2 { get; set; }
  113. /// <summary>
  114. /// 采集时刻
  115. /// </summary>
  116. public DateTime CapTime { get; set; }
  117. /// <summary>
  118. /// 参考站位置经度
  119. /// </summary>
  120. public double RefLon { get; set; }
  121. /// <summary>
  122. /// 参考站位置纬度
  123. /// </summary>
  124. public double RefLat { get; set; }
  125. /// <summary>
  126. /// 时差误差(单位us)
  127. /// </summary>
  128. public double DtousErr { get; set; } = 1;
  129. /// <summary>
  130. /// 频差误差(Hz)
  131. /// </summary>
  132. public double DfoErr { get; set; }
  133. /// <summary>
  134. /// 星历位置误差(单位米)
  135. /// </summary>
  136. public double SatLocErr { get; set; } = 10000;
  137. /// <summary>
  138. ///星历速度误差
  139. /// </summary>
  140. public double EphVelErr { get; set; }
  141. /// <summary>
  142. /// 上行频点1(Hz)
  143. /// </summary>
  144. public double fu1 { get; set; }
  145. /// <summary>
  146. /// 上行频点2(Hz)
  147. /// </summary>
  148. public double fu2 { get; set; }
  149. }
  150. }