X3EllipesEditor.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using DevExpress.XtraMap;
  2. using DxHelper;
  3. using ExtensionsDev;
  4. using System;
  5. using System.CodeDom;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Configuration;
  9. using System.Data;
  10. using System.Data.Entity;
  11. using System.Drawing;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. using XdCxRhDW.Api;
  16. using XdCxRhDW.Dto;
  17. using XdCxRhDW.Entity;
  18. using XdCxRhDW.Repostory;
  19. namespace XdCxRhDW.App.EditForms
  20. {
  21. public partial class X3EllipesEditor : DevExpress.XtraEditors.XtraUserControl
  22. {
  23. private MapControl mapControl1;
  24. private PosRes info;
  25. private CgRes cg;
  26. public X3EllipesEditor(PosRes info, MapControl mapControl)
  27. {
  28. InitializeComponent();
  29. this.info = info;
  30. itemSigTime.Text = $"{itemSigTime.Text}({SysConfig.Config.TimeZoneUTC})";
  31. this.layoutControl1.UseDefault();
  32. txtSigTime.UseDefault();
  33. this.mapControl1 = mapControl;
  34. }
  35. private async void X2D1DTOParamEditor_Load(object sender, EventArgs e)
  36. {
  37. this.layoutControl1.BestFit();
  38. StationRes station = null;
  39. using (RHDWPartContext db = RHDWPartContext.GetContext(info.SigTime))
  40. {
  41. cg = await db?.CgRes.Where(m => m.ID == info.CgResID).FirstOrDefaultAsync();
  42. station = await db?.StationRes.Where(m => m.ID == info.StationResID).FirstOrDefaultAsync();
  43. }
  44. if (cg != null)
  45. {
  46. this.txtSigTime.EditValue = info.SigTime;
  47. txtEphMain.SetXYZ("主星", cg.MainCode, (cg.MainX, cg.MainY, cg.MainZ), Color.Black);
  48. txtEphAdja1.SetXYZ("邻星", cg.Adja1Code, (cg.Adja1X, cg.Adja1Y, cg.Adja1Z), Color.Black);
  49. }
  50. if (station != null)
  51. {
  52. this.txtsatStation.Text = $"{station.SatTxLon},{station.SatTxLat}";
  53. this.txtRefLocation.Text = $"{station.RefLon},{station.RefLat}";
  54. }
  55. if (info.PosResType == EnumPosResType.X3TwoDtoNoRef)
  56. {
  57. txtRefLocation.Properties.ReadOnly = true;
  58. this.txtRefLocation.Text = $"{0},{0}";
  59. }
  60. this.txtPosLocation.Text = $"{info.PosLon},{info.PosLat}";
  61. }
  62. public bool CheckParam()
  63. {
  64. dxErrorProvider.ClearErrors();
  65. if (!txtsatStation.CheckLonLat(dxErrorProvider, "接收站"))
  66. {
  67. return false;
  68. }
  69. if (!txtEphMain.CheckEphXYZ(dxErrorProvider))
  70. {
  71. return false;
  72. }
  73. if (!txtEphAdja1.CheckEphXYZ(dxErrorProvider))
  74. {
  75. return false;
  76. }
  77. return true;
  78. }
  79. private async void btnEllipes_Click(object sender, EventArgs e)
  80. {
  81. //if (!CheckParam()) { return; }
  82. //try
  83. //{
  84. // var MsAnt = txtsatStation.GetLonLat();
  85. // var pos = txtPosLocation.GetLonLat();
  86. // var RefGeod = txtRefLocation.GetLonLat();
  87. // double[] ephMain = txtEphMain.EphXYZ();
  88. // double[] ephAdja = txtEphAdja1.EphXYZ();
  89. // var dto = new ErrorEllipseLeoX3Dto()
  90. // {
  91. // };
  92. // AjaxResult<ErrEllipseResDto> rsp;
  93. // if (info.PosResType != EnumPosResType.X2D1)
  94. // {
  95. // dto = dto.WithRef(112, 11);
  96. // rsp = await HttpHelper.PostRequestAsync<ErrEllipseResDto>(SysConfig.GetUrl("Ellipse/X2D1"), dto, 30);
  97. // }
  98. // else
  99. // {
  100. // rsp = await HttpHelper.PostRequestAsync<ErrEllipseResDto>(SysConfig.GetUrl("Ellipse/X2D1NoRef"), dto, 30);
  101. // }
  102. // if (rsp.code != 200)
  103. // {
  104. // await LogHelper.Error($"绘制{info.PosResType.GetEnumDisplayName()}误差椭圆失败,{rsp.msg}");
  105. // DxHelper.MsgBoxHelper.ShowWarning($"绘制{info.PosResType.GetEnumDisplayName()}误差椭圆失败,{rsp.msg}");
  106. // }
  107. // else
  108. // {
  109. // this.mapControl1.DrawErrEllipse(rsp.data.LongRadius / 1e3, rsp.data.ShortRadius / 1e3, rsp.data.GeoPoints.Select(t => (t.Lon, t.Lat)));
  110. // this.txtPosRes.Text = $"{info.PosResType.GetEnumDisplayName()}误差椭圆.长半轴={rsp.data.LongRadius:f0}m,短半轴={rsp.data.ShortRadius:f0}m,倾角={rsp.data.DipAngle:f1}°";
  111. // }
  112. //}
  113. //catch (Exception ex)
  114. //{
  115. // Serilog.Log.Error(ex, $"绘制{info.PosResType.GetEnumDisplayName()}误差椭圆失败.PosID={info.ID},SigTime={info.SigTime}");
  116. // DxHelper.MsgBoxHelper.ShowWarning($"绘制{info.PosResType.GetEnumDisplayName()}误差椭圆失败,{ex.Message}");
  117. //}
  118. }
  119. private async void btnEphCalc_Click(object sender, EventArgs e)
  120. {
  121. dxErrorProvider.ClearErrors();
  122. if (this.txtSigTime.DateTime == DateTime.MinValue)
  123. {
  124. dxErrorProvider.SetError(txtSigTime, "信号时间不能为空!");
  125. return;
  126. }
  127. var sigTime = this.txtSigTime.DateTime;
  128. try
  129. {
  130. var mainxlInfo = await XlRepository.GetLatestAsync(cg.MainCode.Value, sigTime);
  131. if (mainxlInfo == null)
  132. {
  133. DxHelper.MsgBoxHelper.ShowWarning($"卫星:{cg.MainCode.Value}未找到对应的星历信息,请导入星历");
  134. return;
  135. }
  136. var XlCalcDto = new XlCalcDto() { tleStr = mainxlInfo.TwoLine, SigTime = sigTime };
  137. var maineph = await HttpHelper.PostRequestAsync<SatEphResDto>(SysConfig.GetUrl("Xl/Calc"), XlCalcDto);
  138. txtEphMain.SetXYZ("主星", cg.MainCode.Value, (maineph.data.X, maineph.data.Y, maineph.data.Z), Color.Red);
  139. var adjaxlInfo = await XlRepository.GetLatestAsync(cg.Adja1Code.Value, sigTime);
  140. if (adjaxlInfo == null)
  141. {
  142. DxHelper.MsgBoxHelper.ShowWarning($"卫星:{cg.Adja1Code.Value}未找到对应的星历信息,请导入星历");
  143. return;
  144. }
  145. XlCalcDto = new XlCalcDto() { tleStr = adjaxlInfo.TwoLine, SigTime = sigTime };
  146. var adjaeph = await HttpHelper.PostRequestAsync<SatEphResDto>(SysConfig.GetUrl("Xl/Calc"), XlCalcDto);
  147. txtEphAdja1.SetXYZ("邻星", cg.Adja1Code.Value, (adjaeph.data.X, adjaeph.data.Y, adjaeph.data.Z), Color.Red);
  148. }
  149. catch (Exception ex)
  150. {
  151. Serilog.Log.Error(ex, $"手动推算{info.PosResType.GetEnumDisplayName()}星历失败,SigTime={sigTime}");
  152. DxHelper.MsgBoxHelper.ShowError($"手动推算{info.PosResType.GetEnumDisplayName()}星历失败,{ex.Message}");
  153. }
  154. }
  155. }
  156. }