X1D1GDOPParam.cs 7.8 KB

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