X1D1GDOPParam.cs 8.0 KB

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