X3DFGDOPParam .cs 7.6 KB

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