X1D1GDOPParam.cs 7.8 KB

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