X1D1GDOPParam.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. using DevExpress.XtraMap;
  2. using ExtensionsDev;
  3. using System;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Collections.Generic;
  7. using XdCxRhDW.Repostory;
  8. using XdCxRhDW.Entity;
  9. using XdCxRhDW.Api;
  10. using System.Drawing;
  11. namespace XdCxRhDW.App.UserControl
  12. {
  13. public partial class X1D1GDOPParam : DevExpress.XtraEditors.XtraUserControl
  14. {
  15. public MapControl mapControl1;
  16. public GDOP星地一星一地接口 Model => new GDOP星地一星一地接口()
  17. {
  18. EphMain = ucEphXYZMain.EphParam(),
  19. CapTime = txtCapTime.DateTime,
  20. StationLon = Convert.ToDouble(txtStationLocation1.Text.Replace(",", ",").Split(',')[0].Trim()),
  21. StationLat = Convert.ToDouble(txtStationLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
  22. CXLon = Convert.ToDouble(txtCXStation.Text.Replace(",", ",").Split(',')[0].Trim()),
  23. CXLat = Convert.ToDouble(txtCXStation.Text.Replace(",", ",").Split(',')[1].Trim()),
  24. RefLon = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[0].Trim()),
  25. RefLat = Convert.ToDouble(txtRefLocation1.Text.Replace(",", ",").Split(',')[1].Trim()),
  26. DtousErr = Convert.ToDouble(txtDtousErr1.Text),
  27. SatLocErr = Convert.ToDouble(txtSatLocErr1.Text),
  28. CXErr = Convert.ToDouble(txtCxErr.Text),
  29. };
  30. private EnumPosResType PosResType;
  31. public X1D1GDOPParam(PosRes item)
  32. {
  33. InitializeComponent();
  34. this.layoutControl1.UseDefault();
  35. txtCapTime.UseDefault();
  36. txtStationLocation1.UseDoubleClickToSelectAll();
  37. txtRefLocation1.UseDoubleClickToSelectAll();
  38. txtCXStation.UseDoubleClickToSelectAll();
  39. this.txtCapTime.DateTime = item.SigTime;
  40. this.txtDtousErr1.EditValue = 1;
  41. this.txtSatLocErr1.EditValue = 10000;
  42. this.txtCxErr.EditValue = 0.001;
  43. PosResType = item.PosResType;
  44. using (RHDWPartContext db = RHDWPartContext.GetContext(item.SigTime))
  45. {
  46. var cg = db?.CgRes.Where(m => m.ID == item.CgResID).FirstOrDefault();
  47. var station = db?.StationRes.Where(m => m.ID == item.StationResID).FirstOrDefault();
  48. if (station != null)
  49. {
  50. this.txtStationLocation1.Text = $"{station.CdbTxLon},{station.CdbTxLat}";
  51. this.txtRefLocation1.Text = $"{station.RefLon},{station.RefLat}";
  52. this.txtCXStation.Text = $"{station.CxLon},{station.CxLat}";
  53. }
  54. if (cg != null)
  55. {
  56. var mainEph = (cg.MainX, cg.MainY, cg.MainZ, cg.MainVx, cg.MainVy, cg.MainVz);
  57. ucEphXYZMain.SetParam($"主星", cg.MainCode, mainEph, Color.Black);
  58. }
  59. }
  60. }
  61. private (bool, string) ParamValidate()
  62. {
  63. var mainparam = ucEphXYZMain.ValidateParam();
  64. if (!mainparam.Item1)
  65. {
  66. return (false, mainparam.Item2);
  67. }
  68. var txtstat = txtStationLocation1.CheckLonLat("超短波");
  69. if (!txtstat.Item1)
  70. {
  71. return txtstat;
  72. }
  73. var cxsta = txtCXStation.CheckLonLat("测向站");
  74. if (!cxsta.Item1)
  75. {
  76. return cxsta;
  77. }
  78. var refsta = txtRefLocation1.CheckLonLat("参考站");
  79. if (!refsta.Item1)
  80. {
  81. return refsta;
  82. }
  83. return (true, "");
  84. }
  85. private void btnOK_Click(object sender, EventArgs e)
  86. {
  87. var pv = ParamValidate();
  88. if (!pv.Item1)
  89. {
  90. DxHelper.MsgBoxHelper.ShowWarning($"{pv.Item2}");
  91. return;
  92. }
  93. try
  94. {
  95. mapControl1.ClearMap();
  96. var cdb = new double[] { Model.StationLon, Model.StationLat, 0 };
  97. var cx = new double[] { Model.StationLon, Model.StationLat, 0 };
  98. var refstation = new double[] { Model.RefLon, Model.RefLat, 0 };
  99. var data = GdopHelper.Gdop1Sat1DByXyz(Model.EphMain, cdb, cx,
  100. Model.DtousErr, Model.CXErr, Model.SatLocErr, refstation);
  101. if (data == null)
  102. {
  103. return;
  104. }
  105. foreach (var errLins in data)//画GDOP
  106. {
  107. var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
  108. mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, 1);
  109. }
  110. }
  111. catch (Exception ex)
  112. {
  113. DxHelper.MsgBoxHelper.ShowError($"绘制{PosResType.GetEnumDisplayName()}GDOP失败,{ex.Message}");
  114. }
  115. }
  116. private void btnClose_Click(object sender, EventArgs e)
  117. {
  118. DxHelper.PopupHelper.HidePopup(this);
  119. }
  120. private async void btnEphCalc_Click(object sender, EventArgs e)
  121. {
  122. if (txtCapTime.DateTime == DateTime.MinValue)
  123. {
  124. DxHelper.MsgBoxHelper.ShowWarning("信号时间不能为空!");
  125. return;
  126. }
  127. var sigTime = txtCapTime.DateTime;
  128. try
  129. {
  130. var mainCode = ucEphXYZMain.GetSatCode();
  131. var mainxlInfo = await XlRepository.GetLatestAsync(mainCode, sigTime);
  132. if (mainxlInfo == null)
  133. {
  134. DxHelper.MsgBoxHelper.ShowWarning($"卫星:{mainCode}未找到对应的星历信息,请导入星历");
  135. return;
  136. }
  137. var maineph = EphHelper.Calc(mainxlInfo.TwoLine, sigTime.ToUtc());
  138. ucEphXYZMain.SetParam("主星", mainCode, (maineph.X, maineph.Y, maineph.Z, maineph.VX, maineph.VY, maineph.VZ), Color.Red);
  139. }
  140. catch (Exception ex)
  141. {
  142. Serilog.Log.Error(ex, $"手动推算{PosResType.GetEnumDisplayName()}星历失败,SigTime={sigTime}");
  143. DxHelper.MsgBoxHelper.ShowError($"手动推算{PosResType.GetEnumDisplayName()}星历失败,{ex.Message}");
  144. }
  145. }
  146. }
  147. public class GDOP星地一星一地接口
  148. {
  149. /// <summary>
  150. /// 主星星历 x y z vx vy vz
  151. /// </summary>
  152. public double[] EphMain { get; set; }
  153. /// <summary>
  154. /// 采集时刻
  155. /// </summary>
  156. public DateTime CapTime { get; set; }
  157. /// <summary>
  158. /// 超短接收站-经度
  159. /// </summary>
  160. public double StationLon { get; set; }
  161. /// <summary>
  162. /// 超短接收站-纬度
  163. /// </summary>
  164. public double StationLat { get; set; }
  165. /// <summary>
  166. /// 参考站位置经度
  167. /// </summary>
  168. public double RefLon { get; set; }
  169. /// <summary>
  170. /// 参考站位置纬度
  171. /// </summary>
  172. public double RefLat { get; set; }
  173. /// <summary>
  174. /// 测向站位置经度
  175. /// </summary>
  176. public double CXLon { get; set; }
  177. /// <summary>
  178. ///测向站位置纬度
  179. /// </summary>
  180. public double CXLat { get; set; }
  181. /// <summary>
  182. /// 时差误差(单位us)
  183. /// </summary>
  184. public double DtousErr { get; set; } = 1;
  185. /// <summary>
  186. /// 星历位置误差(单位米)
  187. /// </summary>
  188. public double SatLocErr { get; set; } = 10000;
  189. /// <summary>
  190. /// 测向误差(单位°)
  191. /// </summary>
  192. public double CXErr { get; set; } = 0.01;
  193. }
  194. }