X3DFGDOPParam .cs 7.8 KB

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