X3DFGDOPParam .cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. using DevExpress.XtraMap;
  2. using DxHelper;
  3. using ExtensionsDev;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using XdCxRhDW.Api;
  10. using XdCxRhDW.Entity;
  11. using XdCxRhDW.Repostory;
  12. namespace XdCxRhDW.App.UserControl
  13. {
  14. public partial class X3DFGDOPParam : DevExpress.XtraEditors.XtraUserControl
  15. {
  16. public MapControl mapControl1;
  17. public X3DFGDOP接口 Model => new X3DFGDOP接口()
  18. {
  19. EphMain = ucEphXYZMain.EphParam(),
  20. EphAdja1 = ucEphXYZAdja1.EphParam(),
  21. EphAdja2 = ucEphXYZAdja2.EphParam(),
  22. CapTime = txtCapTime.DateTime,
  23. RefStation = txtRefLocation1.GetLonLat(),
  24. DfoErr = Convert.ToDouble(txtDfoErr1.Text),
  25. SatLocErr = Convert.ToDouble(txtSatLocErr1.Text),
  26. EphVelErr = Convert.ToDouble(txtEphVelErr1.Text),
  27. fu1 = Convert.ToDouble(txtFu1.Text) * 1e6,
  28. fu2 = Convert.ToDouble(txtFu2.Text) * 1e6,
  29. };
  30. private EnumPosResType PosResType;
  31. public X3DFGDOPParam(PosRes item)
  32. {
  33. InitializeComponent();
  34. this.layoutControl1.UseDefault();
  35. txtCapTime.UseDefault();
  36. txtRefLocation1.UseDoubleClickToSelectAll();
  37. this.txtCapTime.DateTime = item.SigTime;
  38. this.txtSatLocErr1.EditValue = 10000;
  39. this.txtEphVelErr1.EditValue = 0.1;
  40. this.txtDfoErr1.EditValue = 0.01;
  41. PosResType = item.PosResType;
  42. using (RHDWPartContext db = RHDWPartContext.GetContext(item.SigTime))
  43. {
  44. var cg = db?.CgRes.Where(m => m.ID == item.CgResID).FirstOrDefault();
  45. var station = db?.StationRes.Where(m => m.ID == item.StationResID).FirstOrDefault();
  46. if (station != null)
  47. {
  48. this.txtRefLocation1.Text = $"{station.RefLon},{station.RefLat}";
  49. }
  50. if (cg != null)
  51. {
  52. this.txtFu1.EditValue = cg.TarFreqUp.HasValue ? cg.TarFreqUp.Value * 1e-6 : 0;
  53. this.txtFu2.EditValue = cg.RefFreqUp.HasValue ? cg.RefFreqUp.Value * 1e-6 : 0;
  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 adja1Eph = (cg.Adja1X, cg.Adja1Y, cg.Adja1Z, cg.Adja1Vx, cg.Adja1Vy, cg.Adja1Vz);
  57. ucEphXYZAdja1.SetParam($"邻星1", cg.Adja1Code, adja1Eph, Color.Black);
  58. var adja2Eph = (cg.Adja2X, cg.Adja2Y, cg.Adja2Z, cg.Adja2Vx, cg.Adja2Vy, cg.Adja2Vz);
  59. ucEphXYZAdja2.SetParam($"邻星2", cg.Adja2Code, adja2Eph, Color.Black);
  60. }
  61. }
  62. }
  63. private bool ParamValidate()
  64. {
  65. if (!ucEphXYZMain.CheckEph(dxErrorProvider))
  66. {
  67. return false;
  68. }
  69. if (!ucEphXYZAdja1.CheckEph(dxErrorProvider))
  70. {
  71. return false;
  72. }
  73. if (!ucEphXYZAdja2.CheckEph(dxErrorProvider))
  74. {
  75. return false;
  76. }
  77. if (!txtRefLocation1.CheckLonLat(dxErrorProvider, "参考站"))
  78. {
  79. return false;
  80. }
  81. if (!txtDfoErr1.CheckDouble(dxErrorProvider, "频差误差"))
  82. {
  83. return false;
  84. }
  85. if (!txtSatLocErr1.CheckDouble(dxErrorProvider, "星历位置误差"))
  86. {
  87. return false;
  88. }
  89. if (!txtEphVelErr1.CheckDouble(dxErrorProvider, "星历速度误差"))
  90. {
  91. return false;
  92. }
  93. if (!txtFu1.CheckDouble(dxErrorProvider, "目标上行频点"))
  94. {
  95. return false;
  96. }
  97. if (!txtFu2.CheckDouble(dxErrorProvider, "参考上行频点"))
  98. {
  99. return false;
  100. }
  101. return true;
  102. }
  103. private void btnOK_Click(object sender, EventArgs e)
  104. {
  105. if (!ParamValidate()) { return; }
  106. try
  107. {
  108. mapControl1.ClearMap();
  109. var data = GdopHelper.Gdop3SatDFByXyz(Model.EphMain, Model.EphAdja1, Model.EphAdja2, Model.fu1, Model.fu2, Model.DfoErr, Model.SatLocErr, Model.EphVelErr, Model.RefStation);
  110. if (data == null)
  111. {
  112. return;
  113. }
  114. foreach (var errLins in data)//画GDOP
  115. {
  116. var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
  117. mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, mapDots.Count() / 2);
  118. }
  119. }
  120. catch (Exception ex)
  121. {
  122. DxHelper.MsgBoxHelper.ShowError($"绘制{PosResType.GetEnumDisplayName()}GDOP失败,{ex.Message}");
  123. }
  124. }
  125. private void btnClose_Click(object sender, EventArgs e)
  126. {
  127. PopupHelper.HidePopup(this);
  128. }
  129. private async void btnEphCalc_Click(object sender, EventArgs e)
  130. {
  131. dxErrorProvider.ClearErrors();
  132. if (txtCapTime.DateTime == DateTime.MinValue)
  133. {
  134. dxErrorProvider.SetError(txtCapTime, "信号时间不能为空!");
  135. return;
  136. }
  137. var sigTime = txtCapTime.DateTime;
  138. try
  139. {
  140. var mainCode = ucEphXYZMain.GetSatCode();
  141. var adja1Code = ucEphXYZAdja1.GetSatCode();
  142. var adja2Code = ucEphXYZAdja2.GetSatCode();
  143. var mainxlInfo = await XlRepository.GetLatestAsync(mainCode, sigTime);
  144. if (mainxlInfo == null)
  145. {
  146. DxHelper.MsgBoxHelper.ShowWarning($"卫星:{mainCode}未找到对应的星历信息,请导入星历");
  147. return;
  148. }
  149. var maineph = EphHelper.Calc(mainxlInfo.TwoLine, sigTime.ToUtc());
  150. ucEphXYZMain.SetParam("主星", mainCode, (maineph.X, maineph.Y, maineph.Z, maineph.VX, maineph.VY, maineph.VZ), Color.Red);
  151. var adja1xlInfo = await XlRepository.GetLatestAsync(adja1Code, sigTime);
  152. if (adja1xlInfo == null)
  153. {
  154. DxHelper.MsgBoxHelper.ShowWarning($"卫星:{adja1Code}未找到对应的星历信息,请导入星历");
  155. return;
  156. }
  157. var adja1eph = EphHelper.Calc(adja1xlInfo.TwoLine, sigTime.ToUtc());
  158. ucEphXYZAdja1.SetParam("邻星1", adja1Code, (adja1eph.X, adja1eph.Y, adja1eph.Z, adja1eph.VX, adja1eph.VY, adja1eph.VZ), Color.Red);
  159. var adja2xlInfo = await XlRepository.GetLatestAsync(adja2Code, sigTime);
  160. if (adja2xlInfo == null)
  161. {
  162. DxHelper.MsgBoxHelper.ShowWarning($"卫星:{adja2Code}未找到对应的星历信息,请导入星历");
  163. return;
  164. }
  165. var adja2eph = EphHelper.Calc(adja2xlInfo.TwoLine, sigTime.ToUtc());
  166. ucEphXYZAdja2.SetParam("邻星2", adja2Code, (adja2eph.X, adja2eph.Y, adja2eph.Z, adja2eph.VX, adja2eph.VY, adja2eph.VZ), Color.Red);
  167. }
  168. catch (Exception ex)
  169. {
  170. Serilog.Log.Error(ex, $"手动推算{PosResType.GetEnumDisplayName()}星历失败,SigTime={sigTime}");
  171. DxHelper.MsgBoxHelper.ShowError($"手动推算{PosResType.GetEnumDisplayName()}星历失败,{ex.Message}");
  172. }
  173. }
  174. }
  175. public class X3DFGDOP接口
  176. {
  177. /// <summary>
  178. /// 主星星历x y z vx vy vz
  179. /// </summary>
  180. public double[] EphMain { get; set; }
  181. /// <summary>
  182. /// 邻星1星历x y z vx vy vz
  183. /// </summary>
  184. public double[] EphAdja1 { get; set; }
  185. /// <summary>
  186. /// 邻星2星历x y z vx vy vz
  187. /// </summary>
  188. public double[] EphAdja2 { get; set; }
  189. /// <summary>
  190. /// 采集时刻
  191. /// </summary>
  192. public DateTime CapTime { get; set; }
  193. /// <summary>
  194. /// 参考站位置-经度 纬度 高度
  195. /// </summary>
  196. public double[] RefStation { get; set; }
  197. /// <summary>
  198. /// 频差误差(Hz)
  199. /// </summary>
  200. public double DfoErr { get; set; }
  201. /// <summary>
  202. /// 星历位置误差(单位米)
  203. /// </summary>
  204. public double SatLocErr { get; set; } = 10000;
  205. /// <summary>
  206. ///星历速度误差
  207. /// </summary>
  208. public double EphVelErr { get; set; }
  209. /// <summary>
  210. /// 上行频点1(Hz)
  211. /// </summary>
  212. public double fu1 { get; set; }
  213. /// <summary>
  214. /// 上行频点2(Hz)
  215. /// </summary>
  216. public double fu2 { get; set; }
  217. }
  218. }