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.Text; using System.Threading.Tasks; using System.Windows.Documents; using System.Windows.Forms; using XdCxRhDW.Api; using XdCxRhDW.Entity; using XdCxRhDW.Repostory; namespace XdCxRhDW.App.EditForms { public partial class X3DfoPosParamEditor : DevExpress.XtraEditors.XtraUserControl { private MapControl mapControl1; private PosRes info; private CgRes cg; private List listSat; public X3DfoPosParamEditor(PosRes info, MapControl mapControl) { InitializeComponent(); this.info = info; this.labelControl1.Text = $""; this.mapControl1 = mapControl; 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 X3DTOParamEditor_Load(object sender, EventArgs e) { StationRes station; using (RHDWContext db = new RHDWContext()) { listSat = await db.SatInfos.ToListAsync(); } 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.txtDfoSx.Text = $"{cg.Dfo1.Value:f3}"; this.txtDfoSx1.Text = $"{cg.Dfo2.Value:f3}"; this.txtYbMain.Text = $"{cg.YbMainDfo.Value:f3}"; this.txtYbAdja.Text = $"{cg.YbAdja1Dfo.Value:f3}"; this.txtYbAdja1.Text = $"{cg.YbAdja2Dfo.Value:f3}"; this.sigTime.EditValue = info.SigTime; this.txtMainX.Text = $"{cg.MainX.Value:f3}"; this.txtMainY.Text = $"{cg.MainY.Value:f3}"; this.txtMainZ.Text = $"{cg.MainZ.Value:f3}"; this.txtMainVX.Text = $"{cg.MainVx.Value:f3}"; this.txtMainVY.Text = $"{cg.MainVy.Value:f3}"; this.txtMainVZ.Text = $"{cg.MainVz.Value:f3}"; this.txtAdjaX.Text = $"{cg.Adja1X.Value:f3}"; this.txtAdjaY.Text = $"{cg.Adja1Y.Value:f3}"; this.txtAdjaZ.Text = $"{cg.Adja1Z.Value:f3}"; this.txtAdjaVX.Text = $"{cg.Adja1Vx.Value:f3}"; this.txtAdjaVY.Text = $"{cg.Adja1Vy.Value:f3}"; this.txtAdjaVZ.Text = $"{cg.Adja1Vz.Value:f3}"; this.txtAdjaX1.Text = $"{cg.Adja2X.Value:f3}"; this.txtAdjaY1.Text = $"{cg.Adja2Y.Value:f3}"; this.txtAdjaZ1.Text = $"{cg.Adja2Z.Value:f3}"; this.txtAdjaVX1.Text = $"{cg.Adja2Vx.Value:f3}"; this.txtAdjaVY1.Text = $"{cg.Adja2Vy.Value:f3}"; this.txtAdjaVZ1.Text = $"{cg.Adja2Vz.Value:f3}"; this.txtTargetFreq.EditValue = cg.TarFreqUp.HasValue ? cg.TarFreqUp.Value * 1e-6 : 950; this.txtTargetDFreq.EditValue = cg.TarFreqDown.HasValue ? cg.TarFreqDown.Value * 1e-6 : 950; this.txtRefFreq.EditValue = cg.RefFreqUp.HasValue ? cg.RefFreqUp.Value * 1e-6 : 950; this.txtRefDFreq.EditValue = cg.RefFreqDown.HasValue ? cg.RefFreqDown.Value * 1e-6 : 950; } if (station != null) { this.txtsatStation.Text = $"{station.SatTxLon:f3},{station.SatTxLat:f3}"; this.txtRefLocation.Text = $"{station.RefLon:f3},{station.RefLat:f3}"; } if (info.PosResType == EnumPosResType.X3NoRef) { txtYbMain.Properties.ReadOnly = true; txtYbAdja.Properties.ReadOnly = true; txtYbAdja1.Properties.ReadOnly = true; txtRefLocation.Properties.ReadOnly = true; this.txtRefLocation.Text = $"{0},{0}"; } } public bool CheckParam() { if (!txtsatStation.CheckLonLat(dxErrorProvider, "接收站")) { return false; } if (info.PosResType == EnumPosResType.X3 && !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 sigTime = this.sigTime.DateTime; var DfoSx = Convert.ToDouble(this.txtDfoSx.Text); var DfoSx1 = Convert.ToDouble(this.txtDfoSx1.Text); var YbMainDfo = Convert.ToDouble(this.txtYbMain.Text); var YbAdja1Dfo = Convert.ToDouble(this.txtYbAdja.Text); var YbAdja2Dfo = Convert.ToDouble(this.txtYbAdja1.Text); var tFreq = Convert.ToDouble(this.txtTargetFreq.Text) * 1e6; var tdFreq = Convert.ToDouble(this.txtTargetDFreq.Text) * 1e6; var rFreq = Convert.ToDouble(this.txtRefFreq.Text) * 1e6; var rdFreq = Convert.ToDouble(this.txtRefDFreq.Text) * 1e6; var StationRes = new StationRes() { SatTxLon = MsAnt[0], SatTxLat = MsAnt[1], RefLon = RefGeod[0], RefLat = RefGeod[1], }; var cgRes = new CgRes() { SigTime = sigTime, Dfo1 = DfoSx, Dfo2 = DfoSx1, YbMainDfo = YbMainDfo, YbAdja1Dfo = YbAdja1Dfo, YbAdja2Dfo = YbAdja2Dfo, TarFreqUp = tFreq, TarFreqDown = tdFreq, RefFreqUp = rFreq, RefFreqDown = rdFreq, MainX = Convert.ToDouble(this.txtMainX.Text), MainY = Convert.ToDouble(this.txtMainY.Text), MainZ = Convert.ToDouble(this.txtMainZ.Text), MainVx = Convert.ToDouble(this.txtMainVX.Text), MainVy = Convert.ToDouble(this.txtMainVY.Text), MainVz = Convert.ToDouble(this.txtMainVZ.Text), Adja1X = Convert.ToDouble(this.txtAdjaX.Text), Adja1Y = Convert.ToDouble(this.txtAdjaY.Text), Adja1Z = Convert.ToDouble(this.txtAdjaZ.Text), Adja1Vx = Convert.ToDouble(this.txtAdjaVX.Text), Adja1Vy = Convert.ToDouble(this.txtAdjaVY.Text), Adja1Vz = Convert.ToDouble(this.txtAdjaVZ.Text), Adja2X = Convert.ToDouble(this.txtAdjaX1.Text), Adja2Y = Convert.ToDouble(this.txtAdjaY1.Text), Adja2Z = Convert.ToDouble(this.txtAdjaZ1.Text), Adja2Vx = Convert.ToDouble(this.txtAdjaVX1.Text), Adja2Vy = Convert.ToDouble(this.txtAdjaVY1.Text), Adja2Vz = Convert.ToDouble(this.txtAdjaVZ1.Text), }; var res = PosApi.X3_PosTwoDfo(cgRes, StationRes); this.labelControl1.Text = $"{info.PosResType.GetEnumDisplayName()}定位点:[{res[0]:f3},{res[1]:f3}] 镜像点:[{res[3]:f3},{res[4]:f3}]"; } 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 btnXl_Click(object sender, EventArgs e) { try { var sigTime = this.sigTime.DateTime; var xlInfo = await XlRepository.GetLatestAsync(cg.MainCode.Value, sigTime); if (xlInfo == null) { DxHelper.MsgBoxHelper.ShowWarning($"卫星:{cg.MainCode.Value}未找到对应的星历信息,请导入星历"); return; } var xlInfo1 = await XlRepository.GetLatestAsync(cg.Adja1Code.Value, sigTime); if (xlInfo1 == null) { DxHelper.MsgBoxHelper.ShowWarning($"卫星:{cg.Adja1Code.Value}未找到对应的星历信息,请导入星历"); return; } var xlInfo2 = await XlRepository.GetLatestAsync(cg.Adja2Code.Value, sigTime); if (xlInfo2 == null) { DxHelper.MsgBoxHelper.ShowWarning($"卫星:{cg.Adja2Code.Value}未找到对应的星历信息,请导入星历"); return; } var mEph = EphHelper.Calc(xlInfo.TwoLine, sigTime); this.txtMainX.Text = $"{mEph.X:f3}"; this.txtMainY.Text = $"{mEph.Y:f3}"; this.txtMainZ.Text = $"{mEph.Z:f3}"; var nEph1 = EphHelper.Calc(xlInfo1.TwoLine, sigTime); this.txtAdjaX.Text = $"{nEph1.X:f3}"; this.txtAdjaY.Text = $"{nEph1.Y:f3}"; this.txtAdjaZ.Text = $"{nEph1.Z:f3}"; var nEph2 = EphHelper.Calc(xlInfo2.TwoLine, sigTime); this.txtAdjaX1.Text = $"{nEph2.X:f3}"; this.txtAdjaY1.Text = $"{nEph2.Y:f3}"; this.txtAdjaZ1.Text = $"{nEph2.Z:f3}"; } catch (Exception ex) { Serilog.Log.Error(ex, $"手动{info.PosResType.GetEnumDisplayName()}推算星历失败.PosID={info.ID},SigTime={info.SigTime}"); DxHelper.MsgBoxHelper.ShowWarning($"手动{info.PosResType.GetEnumDisplayName()}推算星历失败"); } } } }