X2DFGDOPParam.cs 7.1 KB

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