using DevExpress.Mvvm.ModuleInjection.Native; using DevExpress.XtraEditors; using DevExpress.XtraEditors.DXErrorProvider; using DevExpress.XtraLayout; using DevExpress.XtraMap; using DevExpress.XtraTreeList.Data; using DxHelper; using ExtensionsDev; using System; using System.CodeDom; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.Entity; using System.Data.Entity.Migrations; using System.Drawing; using System.Linq; using System.Security.Policy; using System.Text; using System.Threading.Tasks; using System.Windows.Documents; using System.Windows.Forms; using XdCxRhDW.Dto; using XdCxRhDW.Repostory; using XdCxRhDW.Entity; using XdCxRhDW.Api; namespace XdCxRhDW.App.EditForms { public partial class X2PosParamEditor : DevExpress.XtraEditors.XtraUserControl { private PosRes info; private CgRes cg; public X2PosParamEditor(PosRes info) { InitializeComponent(); this.info = info; itemSigTime.Text = $"{itemSigTime.Text}({SysConfig.Config.TimeZoneUTC})"; this.layoutControl1.UseDefault(); txtSigTime.UseDefault(); this.Text = $"{info.PosResType.GetEnumDisplayName()}手动定位"; txtsatStation.EditValueChanged += TxtsatStation_EditValueChanged; txtRefLocation.EditValueChanged += TxtRefLocation_EditValueChanged; } private void TxtRefLocation_EditValueChanged(object sender, EventArgs e) { txtRefLocation.CheckLonLat(dxErrorProvider, "参考站"); } private void TxtsatStation_EditValueChanged(object sender, EventArgs e) { txtsatStation.CheckLonLat(dxErrorProvider, "接收站"); } private async void X2DTOParamEditor_Load(object sender, EventArgs e) { StationRes station = null; using (RHDWPartContext db = RHDWPartContext.GetContext(info.SigTime)) { cg = await db?.CgRes.Where(m => m.ID == info.CgResID).FirstOrDefaultAsync(); station = await db?.StationRes.Where(m => m.ID == info.StationResID).FirstOrDefaultAsync(); } if (cg != null) { this.txtDtoSx.Text = $"{cg.Dto1.Value:f4}"; this.txtYbMain.Text = $"{cg.YbMainDto.Value:f4}"; this.txtYbAdja.Text = $"{cg.YbAdja1Dto.Value:f4}"; this.txtSigTime.EditValue = info.SigTime; var mainEph = (cg.MainX, cg.MainY, cg.MainZ, cg.MainVx, cg.MainVy, cg.MainVz); ucEphXYZMain.SetParam($"主星", cg.MainCode, mainEph, Color.Black); var adjaEph = (cg.Adja1X, cg.Adja1Y, cg.Adja1Z, cg.Adja1Vx, cg.Adja1Vy, cg.Adja1Vz); ucEphXYZAdja.SetParam($"邻星", cg.Adja1Code, adjaEph, Color.Black); this.txtDfo.Text = $"{cg.Dfo1.Value:f4}"; this.txtYbMainDfo.Text = $"{cg.YbMainDfo.Value:f4}"; this.txtYbAdjaDfo.Text = $"{cg.YbAdja1Dfo.Value:f4}"; this.txtTarFreqUp.EditValue = cg.TarFreqUp.HasValue ? cg.TarFreqUp.Value * 1e-6 : 950; this.txtTarFreqDown.EditValue = cg.TarFreqDown.HasValue ? cg.TarFreqDown.Value * 1e-6 : 950; this.txtRefFreqUp.EditValue = cg.RefFreqUp.HasValue ? cg.RefFreqUp.Value * 1e-6 : 950; this.txtRefFreqDown.EditValue = cg.RefFreqDown.HasValue ? cg.RefFreqDown.Value * 1e-6 : 950; } if (station != null) { this.txtsatStation.Text = $"{station.SatTxLon:f4},{station.SatTxLat:f4}"; this.txtRefLocation.Text = $"{station.RefLon:f4},{station.RefLat:f4}"; } } public bool CheckParam() { if (!txtsatStation.CheckLonLat(dxErrorProvider, "接收站")) { return false; } if (!txtRefLocation.CheckLonLat(dxErrorProvider, "参考站")) { return false; } return true; } private void btnOk_Click(object sender, EventArgs e) { if (!CheckParam()) { return; } try { var MsAnt = txtsatStation.GetLonLat(); var RefGeod = txtRefLocation.GetLonLat(); var DtoSx = Convert.ToDouble(this.txtDtoSx.Text); var YbMainDto = Convert.ToDouble(this.txtYbMain.Text); var YbAdja1Dto = Convert.ToDouble(this.txtYbAdja.Text); var msEph = ucEphXYZMain.EphParam(); var ns1Eph = ucEphXYZAdja.EphParam(); var Dfo = Convert.ToDouble(this.txtDfo.Text); var YbMainDfo = Convert.ToDouble(this.txtYbMainDfo.Text); var YbAdja1Dfo = Convert.ToDouble(this.txtYbAdjaDfo.Text); var TarFreqUp = Convert.ToDouble(this.txtTarFreqUp.Text) * 1e6; var TarFreqDown = Convert.ToDouble(this.txtTarFreqDown.Text) * 1e6; var RefFreqUp = Convert.ToDouble(this.txtRefFreqUp.Text) * 1e6; var RefFreqDown = Convert.ToDouble(this.txtRefFreqDown.Text) * 1e6; var sigTime = txtSigTime.DateTime; var StationRes = new StationRes() { SatTxLon = MsAnt[0], SatTxLat = MsAnt[1], RefLon = RefGeod[0], RefLat = RefGeod[1], }; X2DtoDfoPosDto dto = new X2DtoDfoPosDto() { SigTime = sigTime, MainCode = cg.MainCode.Value, AdjaCode = cg.Adja1Code.Value, Dto = DtoSx, Dfo = Dfo, YbMainDto = YbMainDto, YbAdjaDto = YbAdja1Dto, YbMainDfo = YbMainDfo, YbAdjaDfo = YbAdja1Dfo, TarFreqUp = TarFreqUp, TarFreqDown = TarFreqDown, RefFreqUp = RefFreqUp, RefFreqDown = RefFreqDown, MainX = msEph[0], MainY = msEph[1], MainZ = msEph[2], MainVx = msEph[3], MainVy = msEph[4], MainVz = msEph[5], AdjaX = ns1Eph[0], AdjaY = ns1Eph[1], AdjaZ = ns1Eph[2], AdjaVx = ns1Eph[3], AdjaVy = ns1Eph[4], AdjaVz = ns1Eph[5], SatTxLon = MsAnt[0], SatTxLat = MsAnt[1], RefLon = RefGeod[0], RefLat = RefGeod[1], }; var cgRes = new CgRes() { SigTime = dto.SigTime, Dto1 = dto.Dto, Dfo1 = dto.Dfo, Snr1 = dto.Snr, YbMainDto = dto.YbMainDto, YbAdja1Dto = dto.YbAdjaDto, YbMainDfo = dto.YbMainDfo, YbAdja1Dfo = dto.YbAdjaDfo, TarFreqUp = dto.TarFreqUp, TarFreqDown = dto.TarFreqDown, RefFreqUp = dto.RefFreqUp, RefFreqDown = dto.RefFreqDown, // StationResID = StationRes.ID, MainCode = dto.MainCode, Adja1Code = dto.AdjaCode, // TaskID = runTask.ID, MainX = dto.MainX, MainY = dto.MainY, MainZ = dto.MainZ, MainVx = dto.MainVx, MainVy = dto.MainVy, MainVz = dto.MainVz, Adja1X = dto.AdjaX, Adja1Y = dto.AdjaY, Adja1Z = dto.AdjaZ, Adja1Vx = dto.AdjaVx, Adja1Vy = dto.AdjaVy, Adja1Vz = dto.AdjaVz, }; var res = PosApi.X2_PosDtoDfo(cgRes, StationRes); this.lblRes.Text = $"{info.PosResType.GetEnumDisplayName()}定位点:[{res[0]:f4},{res[1]:f4}] 镜像点:[{res[3]:f4},{res[4]:f4}]"; } catch (Exception ex) { Serilog.Log.Error(ex, $"{info.PosResType.GetEnumDisplayName()}手动定位失败.PosID={info.ID},SigTime={info.SigTime}"); DxHelper.MsgBoxHelper.ShowWarning($"{info.PosResType.GetEnumDisplayName()}手动定位失败"); } } private async void txtEphCalc_Click(object sender, EventArgs e) { if (txtSigTime.DateTime == DateTime.MinValue) { DxHelper.MsgBoxHelper.ShowWarning("信号时间不能为空!"); return; } var sigTime = txtSigTime.DateTime; try { var mainxlInfo = await XlRepository.GetLatestAsync(cg.MainCode.Value, sigTime); if (mainxlInfo == null) { DxHelper.MsgBoxHelper.ShowWarning($"卫星:{cg.MainCode.Value}未找到对应的星历信息,请导入星历"); return; } var XlCalcDto = new XlCalcDto() { tleStr = mainxlInfo.TwoLine, SigTime = sigTime }; string url = string.Format("http://{0}:{1}/Api/Xl/Calc", IpHelper.GetLocalIp(), SysConfig.Config.HttpPort); var maineph = await HttpHelper.PostRequestAsync(url, XlCalcDto); ucEphXYZMain.SetParam("主星", cg.MainCode.Value, (maineph.data.X, maineph.data.Y, maineph.data.Z, maineph.data.VX, maineph.data.VY, maineph.data.VZ), Color.Red); var adjaxlInfo = await XlRepository.GetLatestAsync(cg.Adja1Code.Value, sigTime); if (adjaxlInfo == null) { DxHelper.MsgBoxHelper.ShowWarning($"卫星:{cg.Adja1Code.Value}未找到对应的星历信息,请导入星历"); return; } XlCalcDto.tleStr = adjaxlInfo.TwoLine; var adjaeph = await HttpHelper.PostRequestAsync(url, XlCalcDto); ucEphXYZAdja.SetParam("邻星", cg.Adja1Code.Value, (adjaeph.data.X, adjaeph.data.Y, adjaeph.data.Z, adjaeph.data.VX, adjaeph.data.VY, adjaeph.data.VZ), Color.Red); } catch (Exception ex) { Serilog.Log.Error(ex, $"手动推算{info.PosResType.GetEnumDisplayName()}星历失败,SigTime={sigTime}"); DxHelper.MsgBoxHelper.ShowError($"手动推算{info.PosResType.GetEnumDisplayName()}星历失败,{ex.Message}"); } } } }