RHGDOPParam.cs 8.1 KB

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