X3DTOParamEditor.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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.Data;
  9. using System.Data.Entity;
  10. using System.Drawing;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using XdCxRhDW.Api;
  15. using XdCxRhDW.Entity;
  16. using XdCxRhDW.Repostory;
  17. namespace XdCxRhDW.App.EditForms
  18. {
  19. public partial class X3DTOParamEditor : DevExpress.XtraEditors.XtraUserControl
  20. {
  21. private MapControl mapControl1;
  22. private PosRes info;
  23. private CgRes cg;
  24. private List<SatInfo> listSat;
  25. public X3DTOParamEditor(PosRes info, MapControl mapControl)
  26. {
  27. InitializeComponent();
  28. this.Text = $"{info.PosResType.GetEnumDisplayName()}时差参数";
  29. this.info = info;
  30. this.mapControl1 = mapControl;
  31. //this.StartPosition = FormStartPosition.CenterParent;
  32. txtsatStation.EditValueChanged += TxtsatStation_EditValueChanged;
  33. txtRefLocation.EditValueChanged += TxtRefLocation_EditValueChanged;
  34. }
  35. private void TxtRefLocation_EditValueChanged(object sender, EventArgs e)
  36. {
  37. txtRefLocation.CheckLonLat(dxErrorProvider, "参考站");
  38. }
  39. private void TxtsatStation_EditValueChanged(object sender, EventArgs e)
  40. {
  41. txtsatStation.CheckLonLat(dxErrorProvider, "接收站");
  42. }
  43. private async void X3DTOParamEditor_Load(object sender, EventArgs e)
  44. {
  45. StationRes station;
  46. using (RHDWContext db = new RHDWContext())
  47. {
  48. listSat = await db.SatInfos.ToListAsync();
  49. }
  50. using (RHDWPartContext db = RHDWPartContext.GetContext(info.SigTime))
  51. {
  52. cg = await db.CgRes.Where(m => m.ID == info.CgResID).FirstOrDefaultAsync();
  53. station = await db.StationRes.Where(m => m.ID == info.StationResID).FirstOrDefaultAsync();
  54. }
  55. if (cg != null)
  56. {
  57. this.txtDtoSx.Text = $"{cg.Dto1.Value:f3}";
  58. this.txtDtoSx1.Text = $"{cg.Dto2.Value:f3}";
  59. if (info.PosResType == EnumPosResType.X3)
  60. {
  61. this.txtYbMain.Text = $"{cg.YbMainDto.Value:f3}";
  62. this.txtYbAdja.Text = $"{cg.YbAdja1Dto.Value:f3}";
  63. this.txtYbAdja1.Text = $"{cg.YbAdja2Dto.Value:f3}";
  64. }
  65. this.sigTime.EditValue = info.SigTime;
  66. this.txtMainX.Text = $"{cg.MainX.Value:f3}";
  67. this.txtMainY.Text = $"{cg.MainY.Value:f3}";
  68. this.txtMainZ.Text = $"{cg.MainZ.Value:f3}";
  69. this.txtAdjaX.Text = $"{cg.Adja1X.Value:f3}";
  70. this.txtAdjaY.Text = $"{cg.Adja1Y.Value:f3}";
  71. this.txtAdjaZ.Text = $"{cg.Adja1Z.Value:f3}";
  72. this.txtAdjaX1.Text = $"{cg.Adja2X.Value:f3}";
  73. this.txtAdjaY1.Text = $"{cg.Adja2Y.Value:f3}";
  74. this.txtAdjaZ1.Text = $"{cg.Adja2Z.Value:f3}";
  75. }
  76. if (station != null)
  77. {
  78. this.txtsatStation.Text = $"{station.SatTxLon:f3},{station.SatTxLat:f3}";
  79. this.txtRefLocation.Text = $"{station.RefLon:f3},{station.RefLat:f3}";
  80. }
  81. if (info.PosResType == EnumPosResType.X3NoRef)
  82. {
  83. txtYbMain.Properties.ReadOnly = true;
  84. txtYbAdja.Properties.ReadOnly = true;
  85. txtYbAdja1.Properties.ReadOnly = true;
  86. txtRefLocation.Properties.ReadOnly = true;
  87. this.txtRefLocation.Text = $"{0},{0}";
  88. }
  89. }
  90. public bool CheckParam()
  91. {
  92. if (!txtsatStation.CheckLonLat(dxErrorProvider, "接收站"))
  93. {
  94. return false;
  95. }
  96. if (info.PosResType == EnumPosResType.X3 && !txtRefLocation.CheckLonLat(dxErrorProvider, "参考站"))
  97. {
  98. return false;
  99. }
  100. return true;
  101. }
  102. private void btnOk_Click(object sender, EventArgs e)
  103. {
  104. if (!CheckParam()) { return; }
  105. try
  106. {
  107. var MsAnt = txtsatStation.GetLonLat();
  108. var RefGeod = info.PosResType == EnumPosResType.X3 ? txtRefLocation.GetLonLat() : new double[3] { 0, 0, 0 };
  109. var DtoSx = Convert.ToDouble(this.txtDtoSx.Text);
  110. var DtoSx1 = Convert.ToDouble(this.txtDtoSx1.Text);
  111. var YbMainDto = info.PosResType == EnumPosResType.X3 ? Convert.ToDouble(this.txtYbMain.Text) : 0;
  112. var YbAdja1Dto = info.PosResType == EnumPosResType.X3 ? Convert.ToDouble(this.txtYbAdja.Text) : 0;
  113. var YbAdja2Dto = info.PosResType == EnumPosResType.X3 ? Convert.ToDouble(this.txtYbAdja1.Text) : 0;
  114. var MainX = Convert.ToDouble(this.txtMainX.Text);
  115. var MainY = Convert.ToDouble(this.txtMainY.Text);
  116. var MainZ = Convert.ToDouble(this.txtMainZ.Text);
  117. var AdjaX = Convert.ToDouble(this.txtAdjaX.Text);
  118. var AdjaY = Convert.ToDouble(this.txtAdjaY.Text);
  119. var AdjaZ = Convert.ToDouble(this.txtAdjaZ.Text);
  120. var AdjaX2 = Convert.ToDouble(this.txtAdjaX1.Text);
  121. var AdjaY2 = Convert.ToDouble(this.txtAdjaY1.Text);
  122. var AdjaZ2 = Convert.ToDouble(this.txtAdjaZ1.Text);
  123. double[] msEph = new double[] { MainX, MainY, MainZ, 0, 0, 0 };
  124. double[] Ns1Eph = new double[] { AdjaX, AdjaY, AdjaZ, 0, 0, 0 };
  125. double[] Ns2Eph = new double[] { AdjaX2, AdjaY2, AdjaZ2, 0, 0, 0 };
  126. DtoLineTwoStartOption twoStartOption = new DtoLineTwoStartOption();
  127. twoStartOption.MsEph = msEph;
  128. twoStartOption.NsEph = Ns1Eph;
  129. twoStartOption.MsAnt = MsAnt;
  130. twoStartOption.NsAnt = MsAnt;
  131. twoStartOption.RefGeod = RefGeod;
  132. twoStartOption.TargetDto = DtoSx;
  133. twoStartOption.RefDto = YbMainDto - YbAdja1Dto;
  134. twoStartOption.PosLon = info.PosLon;
  135. twoStartOption.PosLat = info.PosLat;
  136. var msat = listSat.FirstOrDefault(m => m.SatCode == cg.MainCode.Value)?.Sat;
  137. if (string.IsNullOrWhiteSpace(msat)) msat = cg.MainCode.Value.ToString();
  138. var nsat = listSat.FirstOrDefault(m => m.SatCode == cg.Adja1Code.Value)?.Sat;
  139. if (string.IsNullOrWhiteSpace(nsat)) nsat = cg.Adja1Code.Value.ToString();
  140. var ad2sat = listSat.FirstOrDefault(m => m.SatCode == cg.Adja2Code.Value)?.Sat;
  141. if (string.IsNullOrWhiteSpace(ad2sat)) ad2sat = cg.Adja2Code.Value.ToString();
  142. if (info.PosResType == EnumPosResType.X3)
  143. {
  144. var tsDtoLine = DrawDtoLineHelper.DtoLine2XStart(twoStartOption);
  145. mapControl1.DrawDtoPonit($"[{msat},{nsat}]带参时差线", tsDtoLine);
  146. twoStartOption.NsEph = Ns2Eph;
  147. twoStartOption.RefDto = YbMainDto - YbAdja2Dto;
  148. twoStartOption.TargetDto = DtoSx1;
  149. var tsDtoLine1 = DrawDtoLineHelper.DtoLine2XStart(twoStartOption);
  150. mapControl1.DrawDtoPonit($"[{msat},{ad2sat}]带参时差线", tsDtoLine1);
  151. }
  152. else
  153. {
  154. var tsDtoLine = DrawDtoLineHelper.DtoLine2XNoRefStart(twoStartOption);
  155. mapControl1.DrawDtoPonit($"[{msat},{nsat}]无参时差线", tsDtoLine);
  156. twoStartOption.NsEph = Ns2Eph;
  157. twoStartOption.TargetDto = DtoSx1;
  158. var tsDtoLine1 = DrawDtoLineHelper.DtoLine2XNoRefStart(twoStartOption);
  159. mapControl1.DrawDtoPonit($"[{msat},{ad2sat}]无参时差线", tsDtoLine1);
  160. }
  161. }
  162. catch (Exception ex)
  163. {
  164. Serilog.Log.Error(ex, $"绘制{info.PosResType.GetEnumDisplayName()}时差线失败.PosID={info.ID},SigTime={info.SigTime}");
  165. DxHelper.MsgBoxHelper.ShowWarning($"绘制{info.PosResType.GetEnumDisplayName()}时差线失败");
  166. }
  167. }
  168. }
  169. }