X1D1GDOPParam.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. using DevExpress.XtraCharts.Design;
  12. using System.Runtime.ConstrainedExecution;
  13. using XdCxRhDW.Dto;
  14. using System.Configuration;
  15. using XdCxRhDW.Framework;
  16. namespace XdCxRhDW.App.UserControl
  17. {
  18. public partial class X1D1GDOPParam : DevExpress.XtraEditors.XtraUserControl
  19. {
  20. public MapControl mapControl1;
  21. public GDOP星地一星一地接口 Model => new GDOP星地一星一地接口()
  22. {
  23. EphMain = ucEphXYZMain.EphParam(),
  24. CapTime = txtCapTime.DateTime,
  25. CDBStation = txtStationLocation1.GetLonLat(),
  26. CXStation = txtCXStation.GetLonLat(),
  27. RefStation = txtRefLocation1.GetLonLat(),
  28. DtousErr = Convert.ToDouble(txtDtousErr1.Text),
  29. SatLocErr = Convert.ToDouble(txtSatLocErr1.Text),
  30. CXErr = Convert.ToDouble(txtCxErr.Text),
  31. };
  32. private EnumPosResType PosResType;
  33. public X1D1GDOPParam(PosRes item)
  34. {
  35. InitializeComponent();
  36. this.layoutControl1.UseDefault();
  37. txtCapTime.UseDefault();
  38. txtStationLocation1.UseDoubleClickToSelectAll();
  39. txtRefLocation1.UseDoubleClickToSelectAll();
  40. txtCXStation.UseDoubleClickToSelectAll();
  41. this.txtCapTime.DateTime = item.SigTime;
  42. this.txtDtousErr1.EditValue = 1;
  43. this.txtSatLocErr1.EditValue = 10000;
  44. this.txtCxErr.EditValue = 0.001;
  45. PosResType = item.PosResType;
  46. using (RHDWPartContext db = RHDWPartContext.GetContext(item.SigTime))
  47. {
  48. var cg = db?.CgRes.Where(m => m.ID == item.CgResID).FirstOrDefault();
  49. var station = db?.StationRes.Where(m => m.ID == item.StationResID).FirstOrDefault();
  50. if (station != null)
  51. {
  52. this.txtStationLocation1.Text = $"{station.CdbTxLon},{station.CdbTxLat}";
  53. this.txtRefLocation1.Text = $"{station.RefLon},{station.RefLat}";
  54. this.txtCXStation.Text = $"{station.CxLon},{station.CxLat}";
  55. }
  56. if (cg != null)
  57. {
  58. var mainEph = (cg.MainX, cg.MainY, cg.MainZ, cg.MainVx, cg.MainVy, cg.MainVz);
  59. ucEphXYZMain.SetParam($"主星", cg.MainCode, mainEph, Color.Black);
  60. }
  61. }
  62. }
  63. private bool ParamValidate()
  64. {
  65. dxErrorProvider.ClearErrors();
  66. if (!ucEphXYZMain.CheckEph(dxErrorProvider))
  67. {
  68. return false;
  69. }
  70. if (!txtStationLocation1.CheckLonLat(dxErrorProvider, "超短波"))
  71. {
  72. return false;
  73. }
  74. if (!txtCXStation.CheckLonLat(dxErrorProvider, "测向站"))
  75. {
  76. return false;
  77. }
  78. if (!txtRefLocation1.CheckLonLat(dxErrorProvider, "参考站"))
  79. {
  80. return false;
  81. }
  82. if (!txtDtousErr1.CheckDouble(dxErrorProvider, "时差误差"))
  83. {
  84. return false;
  85. }
  86. if (!txtSatLocErr1.CheckDouble(dxErrorProvider, "星历位置误差"))
  87. {
  88. return false;
  89. }
  90. if (!txtCxErr.CheckDouble(dxErrorProvider, "测向误差"))
  91. {
  92. return false;
  93. }
  94. return true;
  95. }
  96. private void btnOK_Click(object sender, EventArgs e)
  97. {
  98. if (!ParamValidate()) { return; }
  99. try
  100. {
  101. mapControl1.ClearMap();
  102. var data = GdopHelper.Gdop1Sat1DByXyzNew(Model.EphMain, Model.CDBStation, Model.CXStation,
  103. Model.DtousErr, Model.CXErr, Model.SatLocErr, Model.RefStation);
  104. if (data.Count == 0)
  105. {
  106. DxHelper.MsgBoxHelper.ShowInfo($"绘制{PosResType.GetEnumDisplayName()}GDOP没有{GdopParam.误差配置.误差距离km.Max()}公里以内的误差!");
  107. return;
  108. }
  109. List<MapPolyline> polylines = new List<MapPolyline>();
  110. for (int i = 0; i < data.Count; i++)
  111. {
  112. var errLins = data[i];
  113. var mapline = mapControl1.GetLine(errLins.ErrDistanceKm, errLins.MapDots);
  114. if (mapline == null)
  115. {
  116. continue;
  117. }
  118. polylines.Add(mapline);
  119. }
  120. mapControl1.DrawDtoLine(polylines);
  121. }
  122. catch (Exception ex)
  123. {
  124. DxHelper.MsgBoxHelper.ShowError($"绘制{PosResType.GetEnumDisplayName()}GDOP失败,{ex.Message}");
  125. }
  126. }
  127. private void btnClose_Click(object sender, EventArgs e)
  128. {
  129. DxHelper.PopupHelper.HidePopup(this);
  130. }
  131. private async void btnEphCalc_Click(object sender, EventArgs e)
  132. {
  133. dxErrorProvider.ClearErrors();
  134. if (txtCapTime.DateTime == DateTime.MinValue)
  135. {
  136. dxErrorProvider.SetError(txtCapTime, "信号时间不能为空!");
  137. return;
  138. }
  139. var sigTime = txtCapTime.DateTime;
  140. try
  141. {
  142. var mainCode = ucEphXYZMain.GetSatCode();
  143. var mainxlInfo = await XlRepository.GetLatestAsync(mainCode, sigTime);
  144. if (mainxlInfo == null)
  145. {
  146. DxHelper.MsgBoxHelper.ShowWarning($"卫星:{mainCode}未找到对应的星历信息,请导入星历");
  147. return;
  148. }
  149. var XlCalcDto = new XlCalcDto() { tleStr = mainxlInfo.TwoLine, SigTime = sigTime };
  150. var maineph = await HttpHelper.PostRequestAsync<SatEphResDto>(SysConfig.GetUrl("Xl/Calc"), XlCalcDto);
  151. ucEphXYZMain.SetParam("主星", mainCode, (maineph.data.X, maineph.data.Y, maineph.data.Z, maineph.data.VX, maineph.data.VY, maineph.data.VZ), Color.Red);
  152. }
  153. catch (Exception ex)
  154. {
  155. Serilog.Log.Error(ex, $"手动推算{PosResType.GetEnumDisplayName()}星历失败,SigTime={sigTime}");
  156. DxHelper.MsgBoxHelper.ShowError($"手动推算{PosResType.GetEnumDisplayName()}星历失败,{ex.Message}");
  157. }
  158. }
  159. }
  160. public class GDOP星地一星一地接口
  161. {
  162. /// <summary>
  163. /// 主星星历 x y z vx vy vz
  164. /// </summary>
  165. public double[] EphMain { get; set; }
  166. /// <summary>
  167. /// 采集时刻
  168. /// </summary>
  169. public DateTime CapTime { get; set; }
  170. /// <summary>
  171. /// 超短接收站-经度 纬度 高度
  172. /// </summary>
  173. public double[] CDBStation { get; set; }
  174. /// <summary>
  175. /// 参考站位置-经度 纬度 高度
  176. /// </summary>
  177. public double[] RefStation { get; set; }
  178. /// <summary>
  179. /// 测向站位置-经度 纬度 高度
  180. /// </summary>
  181. public double[] CXStation { get; set; }
  182. /// <summary>
  183. /// 时差误差(单位us)
  184. /// </summary>
  185. public double DtousErr { get; set; } = 1;
  186. /// <summary>
  187. /// 星历位置误差(单位米)
  188. /// </summary>
  189. public double SatLocErr { get; set; } = 10000;
  190. /// <summary>
  191. /// 测向误差(单位°)
  192. /// </summary>
  193. public double CXErr { get; set; } = 0.01;
  194. }
  195. }