X2DFGDOPParam.cs 6.9 KB

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