123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- using DevExpress.XtraMap;
- using ExtensionsDev;
- using System;
- using System.Collections.Generic;
- using System.Data.Entity;
- using System.Drawing;
- using System.Linq;
- using XdCxRhDW.Api;
- using XdCxRhDW.Dto;
- using XdCxRhDW.Entity;
- using XdCxRhDW.Repostory;
- namespace XdCxRhDW.App.EditForms
- {
- public partial class LeoX1ParamEditor : DevExpress.XtraEditors.XtraUserControl
- {
- private PosRes info;
- private CgRes cg;
- private MapControl mapControl1;
- private List<SatInfo> listSat;
- StationRes station;
- public LeoX1ParamEditor(PosRes info, MapControl mapControl)
- {
- InitializeComponent();
- this.info = info;
- this.mapControl1 = mapControl;
- itemSigTime.Text = $"{itemSigTime.Text}({SysConfig.Config.TimeZoneUTC})";
- this.layoutControl1.UseDefault();
- sigTime.UseDefault();
- this.simpleLabelItem1.Text = $" ";
- }
- private async void LeoX1ParamEditor_Load(object sender, EventArgs e)
- {
- this.layoutControl1.BestFit();
- 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.txtDfo1.Text = $"{cg.Dfo1.Value}";
- this.txtDfo2.Text = $"{cg.Dfo2.Value}";
- this.sigTime.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 adja1Eph = (cg.Adja1X, cg.Adja1Y, cg.Adja1Z, cg.Adja1Vx, cg.Adja1Vy, cg.Adja1Vz);
- ucEphXYZAdja1.SetParam($"第二时刻", cg.Adja1Code, adja1Eph, Color.Black);
- var adja2Eph = (cg.Adja2X, cg.Adja2Y, cg.Adja2Z, cg.Adja2Vx, cg.Adja2Vy, cg.Adja2Vz);
- ucEphXYZAdja2.SetParam($"第三时刻", cg.Adja2Code, adja2Eph, Color.Black);
- this.txtTargetFreq.EditValue = cg.TarFreqUp.HasValue ? cg.TarFreqUp.Value * 1e-6 : 0;
- this.txtTargetDFreq.EditValue = cg.TarFreqDown.HasValue ? cg.TarFreqDown.Value * 1e-6 : 0;
- }
-
- }
- public bool CheckPosParam()
- {
- dxErrorProvider.ClearErrors();
-
- if (!txtDfo1.CheckDouble(dxErrorProvider, "主邻1频差"))
- {
- return false;
- }
- if (!txtDfo2.CheckDouble(dxErrorProvider, "主邻2频差"))
- {
- return false;
- }
- if (!txtTargetFreq.CheckDouble(dxErrorProvider, "目标上行频点"))
- {
- return false;
- }
- if (!txtTargetDFreq.CheckDouble(dxErrorProvider, "目标下行频点"))
- {
- return false;
- }
- if (!ucEphXYZMain.CheckEph(dxErrorProvider))
- {
- return false;
- }
- if (!ucEphXYZAdja1.CheckEph(dxErrorProvider))
- {
- return false;
- }
- if (!ucEphXYZAdja2.CheckEph(dxErrorProvider))
- {
- return false;
- }
- return true;
- }
- private void btnOk_Click(object sender, EventArgs e)
- {
- if (!CheckPosParam()) { return; }
- try
- {
- var sigTime = this.sigTime.DateTime;
- var DfoSx = Convert.ToDouble(this.txtDfo1.Text);
- var DfoSx1 = Convert.ToDouble(this.txtDfo2.Text);
- var tFreq = Convert.ToDouble(this.txtTargetFreq.Text) * 1e6;
- var tdFreq = Convert.ToDouble(this.txtTargetDFreq.Text) * 1e6;
- var msEph = ucEphXYZMain.EphParam();
- var ns1Eph = ucEphXYZAdja1.EphParam();
- var ns2Eph = ucEphXYZAdja2.EphParam();
-
- var cgRes = new CgRes()
- {
- SigTime = sigTime,
- Dfo1 = DfoSx,
- Dfo2 = DfoSx1,
- TarFreqUp = tFreq,
- TarFreqDown = tdFreq,
- MainX = msEph[0],
- MainY = msEph[1],
- MainZ = msEph[2],
- MainVx = msEph[3],
- MainVy = msEph[4],
- MainVz = msEph[5],
- Adja1X = ns1Eph[0],
- Adja1Y = ns1Eph[1],
- Adja1Z = ns1Eph[2],
- Adja1Vx = ns1Eph[3],
- Adja1Vy = ns1Eph[4],
- Adja1Vz = ns1Eph[5],
- Adja2X = ns2Eph[0],
- Adja2Y = ns2Eph[1],
- Adja2Z = ns2Eph[2],
- Adja2Vx = ns2Eph[3],
- Adja2Vy = ns2Eph[4],
- Adja2Vz = ns2Eph[5],
- };
- var res = LeoPosApi.X1_POS(cgRes, cgRes.TarFreqUp.Value);
- this.simpleLabelItem1.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()}手动定位失败,{ex.Message}");
- }
- }
- private async void btnXl_Click(object sender, EventArgs e)
- {
- dxErrorProvider.ClearErrors();
- if (this.sigTime.DateTime == DateTime.MinValue)
- {
- dxErrorProvider.SetError(this.sigTime, "信号时间不能为空!");
- return;
- }
- var sigTime = this.sigTime.DateTime;
- try
- {
- 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 XlCalcDto = new XlCalcDto() { tleStr = xlInfo.TwoLine, SigTime = sigTime };
- var mEph = await HttpHelper.PostRequestAsync<SatEphResDto>(SysConfig.GetUrl("Xl/Calc"), XlCalcDto);
- XlCalcDto.tleStr = xlInfo1.TwoLine;
- var nEph1 = await HttpHelper.PostRequestAsync<SatEphResDto>(SysConfig.GetUrl("Xl/Calc"), XlCalcDto);
- XlCalcDto.tleStr = xlInfo2.TwoLine;
- var nEph2 = await HttpHelper.PostRequestAsync<SatEphResDto>(SysConfig.GetUrl("Xl/Calc"), XlCalcDto);
- var mainEph = (mEph.data.X, mEph.data.Y, mEph.data.Z, mEph.data.VX, mEph.data.VY, mEph.data.VZ);
- ucEphXYZMain.SetParam($"主星", cg.MainCode, mainEph, Color.Red);
- var adja1Eph = (nEph1.data.X, nEph1.data.Y, nEph1.data.Z, nEph1.data.VX, nEph1.data.VY, nEph1.data.VZ);
- ucEphXYZAdja1.SetParam($"邻星1", cg.Adja1Code, adja1Eph, Color.Red);
- var adja2Eph = (nEph2.data.X, nEph2.data.Y, nEph2.data.Z, nEph2.data.VX, nEph2.data.VY, nEph2.data.VZ);
- ucEphXYZAdja2.SetParam($"邻星2", cg.Adja2Code, adja2Eph, Color.Red);
- }
- catch (Exception ex)
- {
- Serilog.Log.Error(ex, $"手动{info.PosResType.GetEnumDisplayName()}推算星历失败.PosID={info.ID},SigTime={info.SigTime}");
- DxHelper.MsgBoxHelper.ShowWarning($"手动{info.PosResType.GetEnumDisplayName()}推算星历失败,{ex.Message}");
- }
- }
- private void btnDfoCalc_Click(object sender, EventArgs e)
- {
- if (!CheckPosParam()) { return; }
- try
- {
-
- var sigTime = this.sigTime.DateTime;
- var DfoSx = Convert.ToDouble(this.txtDfo1.Text);
- var DfoSx1 = Convert.ToDouble(this.txtDfo2.Text);
- var tFreq = Convert.ToDouble(this.txtTargetFreq.Text) * 1e6;
- var tdFreq = Convert.ToDouble(this.txtTargetDFreq.Text) * 1e6;
- var msEph = ucEphXYZMain.EphParam();
- var ns1Eph = ucEphXYZAdja1.EphParam();
- var ns2Eph = ucEphXYZAdja2.EphParam();
-
- var tsDtoLine= LeoPosApi.DfoLineLeoX1(msEph,ns1Eph, DfoSx, tFreq);
- var msat = listSat?.FirstOrDefault(m => m.SatCode == cg.MainCode.Value)?.Sat;
- if (msat == null) msat = cg.MainCode.ToString();
- mapControl1.DrawDtoLine($"{info.PosResType.GetEnumDisplayName()}[{msat}]第一时刻频差线", tsDtoLine);
- var tsDtoLine1 = LeoPosApi.DfoLineLeoX1(msEph, ns2Eph, DfoSx1, tFreq);
- mapControl1.DrawDtoLine($"{info.PosResType.GetEnumDisplayName()}[{msat}]第二时刻频差线", tsDtoLine1);
- }
- catch (Exception ex)
- {
- Serilog.Log.Error(ex, $"绘制{info.PosResType.GetEnumDisplayName()}频差线失败.PosID={info.ID},SigTime={sigTime}");
- DxHelper.MsgBoxHelper.ShowError($"绘制{info.PosResType.GetEnumDisplayName()}频差线失败,{ex.Message}");
- }
- }
- }
- }
|