X3DFGDOPParam .cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. using DevExpress.XtraMap;
  2. using DxHelper;
  3. using ExtensionsDev;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using XdCxRhDW.Api;
  9. using XdCxRhDW.Entity;
  10. using XdCxRhDW.Repostory;
  11. namespace XdCxRhDW.App.UserControl
  12. {
  13. public partial class X3DFGDOPParam : DevExpress.XtraEditors.XtraUserControl
  14. {
  15. public MapControl mapControl1;
  16. public X3DFGDOP接口 Model => new X3DFGDOP接口()
  17. {
  18. TleLeo1 = txtTleLeo1.Text.Trim(),
  19. TleLeo2 = txtTleLeo2.Text.Trim(),
  20. TleLeo3 = txtTleLeo3.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. SatLocErr = Convert.ToDouble(txtSatLocErr1.Text),
  26. EphVelErr = Convert.ToDouble(txtEphVelErr1.Text),
  27. fu1 = Convert.ToDouble(txtFu1.Text) * 1e6,
  28. fu2 = Convert.ToDouble(txtFu2.Text) * 1e6,
  29. };
  30. public X3DFGDOPParam(PosRes item)
  31. {
  32. InitializeComponent();
  33. this.layoutControl1.UseDefault();
  34. txtCapTime.UseDefault();
  35. txtTleLeo1.UseDoubleClickToSelectAll();
  36. txtTleLeo2.UseDoubleClickToSelectAll();
  37. txtTleLeo3.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. List<string> xlall = new List<string>();
  44. string mainTle = string.Empty;
  45. string adjaTle1 = string.Empty;
  46. string adjaTle2 = 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. if (cg != null && cg.Adja2Code.HasValue && xlList.Any(m => m.SatCode == cg.Adja2Code.Value))
  72. {
  73. adjaTle2 = xlList.First(m => m.SatCode == cg.Adja2Code.Value).TwoLine;
  74. }
  75. txtMainSat.Text = "主星:" + cg.MainCode;
  76. txtAdjaSat1.Text = "邻1星:" + cg.Adja1Code;
  77. txtAdjaSat2.Text = "邻2星:" + cg.Adja1Code;
  78. }
  79. txtTleLeo1.UseDefault().SetStringData(xlall).Text = mainTle;
  80. txtTleLeo2.UseDefault().SetStringData(xlall).Text = adjaTle1;
  81. txtTleLeo3.UseDefault().SetStringData(xlall).Text = adjaTle2;
  82. }
  83. private (bool, string) ParamValidate()
  84. {
  85. if (string.IsNullOrWhiteSpace(txtTleLeo1.Text.Trim()))
  86. {
  87. return (false, "主星星历不能为空!");
  88. }
  89. if (string.IsNullOrWhiteSpace(txtTleLeo2.Text.Trim()))
  90. {
  91. return (false, "邻星1星历不能为空!");
  92. }
  93. if (string.IsNullOrWhiteSpace(txtTleLeo3.Text.Trim()))
  94. {
  95. return (false, "邻星2星历不能为空!");
  96. }
  97. if (txtTleLeo1.Text.Trim() == txtTleLeo2.Text.Trim() || txtTleLeo1.Text.Trim() == txtTleLeo3.Text.Trim() || txtTleLeo2.Text.Trim() == txtTleLeo3.Text.Trim())
  98. {
  99. return (false, "主邻星历不能相同!");
  100. }
  101. if (txtCapTime.DateTime == DateTime.MinValue)
  102. {
  103. return (false, "采集时刻不能为空!");
  104. }
  105. var refsta = txtRefLocation1.CheckLonLat("参考站");
  106. if (!refsta.Item1)
  107. {
  108. return refsta;
  109. }
  110. return (true, "");
  111. }
  112. private void btnOK_Click(object sender, EventArgs e)
  113. {
  114. var pv = ParamValidate();
  115. if (!pv.Item1)
  116. {
  117. DxHelper.MsgBoxHelper.ShowWarning($"{pv.Item2}");
  118. return;
  119. }
  120. try
  121. {
  122. mapControl1.ClearMap();
  123. var refs = new double[] { Model.RefLon, Model.RefLat, 0 };
  124. var (listSat, data) = GdopHelper.Gdop3SatDF(Model.TleLeo1, Model.TleLeo2, Model.TleLeo3,
  125. Model.CapTime, Model.fu1, Model.fu2, Model.DfoErr, Model.SatLocErr, Model.EphVelErr, refs);
  126. if (data == null)
  127. {
  128. return;
  129. }
  130. foreach (var errLins in data)//画GDOP
  131. {
  132. var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
  133. mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, mapDots.Count() / 2);
  134. }
  135. }
  136. catch (Exception ex)
  137. {
  138. DxHelper.MsgBoxHelper.ShowError($"绘制GDOP失败,{ex.Message}");
  139. }
  140. }
  141. private void btnClose_Click(object sender, EventArgs e)
  142. {
  143. PopupHelper.HidePopup(this);
  144. }
  145. }
  146. public class X3DFGDOP接口
  147. {
  148. /// <summary>
  149. /// 主星星历(Tle)
  150. /// </summary>
  151. public string TleLeo1 { get; set; }
  152. /// <summary>
  153. /// 邻星1星历(Tle)
  154. /// </summary>
  155. public string TleLeo2 { get; set; }
  156. /// <summary>
  157. /// 邻星2星历(Tle)
  158. /// </summary>
  159. public string TleLeo3 { get; set; }
  160. /// <summary>
  161. /// 采集时刻
  162. /// </summary>
  163. public DateTime CapTime { get; set; }
  164. /// <summary>
  165. /// 参考站位置经度
  166. /// </summary>
  167. public double RefLon { get; set; }
  168. /// <summary>
  169. /// 参考站位置纬度
  170. /// </summary>
  171. public double RefLat { get; set; }
  172. /// <summary>
  173. /// 频差误差(Hz)
  174. /// </summary>
  175. public double DfoErr { get; set; }
  176. /// <summary>
  177. /// 星历位置误差(单位米)
  178. /// </summary>
  179. public double SatLocErr { get; set; } = 10000;
  180. /// <summary>
  181. ///星历速度误差
  182. /// </summary>
  183. public double EphVelErr { get; set; }
  184. /// <summary>
  185. /// 上行频点1(Hz)
  186. /// </summary>
  187. public double fu1 { get; set; }
  188. /// <summary>
  189. /// 上行频点2(Hz)
  190. /// </summary>
  191. public double fu2 { get; set; }
  192. }
  193. }