X2D1PosParam.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 XdCxRhDW.Repostory.Model;
  8. using XdCxRhDW.Repostory.EFContext;
  9. using XdCxRhDW.Core.Api;
  10. using DxHelper;
  11. using XdCxRhDW.Repostory;
  12. namespace XdCxRhDW.App.UserControl
  13. {
  14. public partial class X2D1PosParam : DevExpress.XtraEditors.XtraUserControl
  15. {
  16. public MapControl mapControl1;
  17. private EnumPosResType PosResType;
  18. public X2D1PosParam(PosRes item)
  19. {
  20. InitializeComponent();
  21. this.layoutControl1.UseDefault();
  22. txtCapTime.UseDefault();
  23. txtTleMain.UseDoubleClickToSelectAll();
  24. txtTleAdja.UseDoubleClickToSelectAll();
  25. txtStationLocation1.UseDoubleClickToSelectAll();
  26. txtRefLocation1.UseDoubleClickToSelectAll();
  27. this.txtCapTime.DateTime = item.SigTime;
  28. this.txtDtousErr1.EditValue = 1;
  29. this.txtSatLocErr1.EditValue = 10000;
  30. List<string> xlall = new List<string>();
  31. string mainTle = string.Empty;
  32. string adjaTle = string.Empty;
  33. PosResType = item.PosResType;
  34. if (PosResType == EnumPosResType.X2D1NoRef)
  35. {
  36. layoutControlItem14.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
  37. }
  38. List<SatInfo> sats = null;
  39. using (RHDWContext db = new RHDWContext())
  40. {
  41. sats = db.SatInfos.ToList();
  42. }
  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. var xlList = XlCache.GetAllAsync().Result;
  53. xlall.AddRange(xlList.Select(m => m.TwoLine));
  54. if (xlall.Count == 0) return;
  55. if (cg.MainCode.HasValue && xlList.Any(m => m.SatCode == cg.MainCode.Value))
  56. {
  57. mainTle = xlList.First(m => m.SatCode == cg.MainCode.Value).TwoLine;
  58. }
  59. else
  60. {
  61. mainTle = xlList.First().TwoLine;
  62. }
  63. if (cg.Adja1Code.HasValue && xlList.Any(m => m.SatCode == cg.Adja1Code.Value))
  64. {
  65. adjaTle = xlList.First(m => m.SatCode == cg.Adja1Code.Value).TwoLine;
  66. }
  67. else
  68. {
  69. adjaTle = xlList.First().TwoLine;
  70. }
  71. }
  72. txtTleMain.UseDefault().SetStringData(xlall).Text = mainTle;
  73. txtTleAdja.UseDefault().SetStringData(xlall).Text = adjaTle;
  74. }
  75. private (bool, string) ParamValidate()
  76. {
  77. if (string.IsNullOrWhiteSpace(txtTleMain.Text.Trim()))
  78. {
  79. return (false, "主星星历不能为空!");
  80. }
  81. if (string.IsNullOrWhiteSpace(txtTleAdja.Text.Trim()))
  82. {
  83. return (false, "主星星历不能为空!");
  84. }
  85. if (txtTleMain.Text.Trim() == txtTleAdja.Text.Trim())
  86. {
  87. return (false, "主邻星历不能相同!");
  88. }
  89. if (txtCapTime.DateTime == DateTime.MinValue)
  90. {
  91. return (false, "采集时刻不能为空!");
  92. }
  93. var txtstat = txtStationLocation1.CheckLonLat("超短波");
  94. if (!txtstat.Item1)
  95. {
  96. return txtstat;
  97. }
  98. var refsta = txtRefLocation1.CheckLonLat("参考站");
  99. if (PosResType == EnumPosResType.X2D1 && !refsta.Item1)
  100. {
  101. return refsta;
  102. }
  103. return (true, "");
  104. }
  105. private void btnOK_Click(object sender, EventArgs e)
  106. {
  107. //var pv = ParamValidate();
  108. //if (!pv.Item1)
  109. //{
  110. // DxHelper.MsgBoxHelper.ShowWarning($"{pv.Item2}");
  111. // return;
  112. //}
  113. //try
  114. //{
  115. // mapControl1.ClearMap();
  116. // var cdb = new double[] { Model.StationLon, Model.StationLat, 0 };
  117. // var refstation = new double[] { Model.RefLon, Model.RefLat, 0 };
  118. // var (listSat, data) = GdopHelper.Gdop2Sat1D(Model.TleMain, Model.TleAdja, Model.CapTime, cdb
  119. // , Model.DtousErr, Model.SatLocErr, PosResType == EnumPosResType.X2D1NoRef ? null : refstation);
  120. // foreach (var errLins in data)//画GDOP
  121. // {
  122. // var mapDots = errLins.MapDots.Select(p => p).Select(p => (p.Lon, p.Lat));
  123. // mapControl1.DrawGdopLineTwo(errLins.ErrDistanceKm, mapDots, 1);
  124. // }
  125. //}
  126. //catch (Exception ex)
  127. //{
  128. // DxHelper.MsgBoxHelper.ShowError($"绘制{PosResType.GetEnumDisplayName()}GDOP失败,{ex.Message}");
  129. //}
  130. }
  131. private void btnClose_Click(object sender, EventArgs e)
  132. {
  133. DxHelper.PopupHelper.HidePopup(this);
  134. }
  135. }
  136. }