123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- 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 PosRes info;
- private CgRes cg;
- public X3DfoPosParamEditor(PosRes info)
- {
- InitializeComponent();
- this.info = info;
- itemSigTime.Text = $"{itemSigTime.Text}({SysConfig.Config.TimeZoneUTC})";
- this.layoutControl1.UseDefault();
- sigTime.UseDefault();
- this.labelControl1.Text = $"";
- 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 = 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.txtDfoSx.Text = $"{cg.Dfo1.Value:f4}";
- this.txtDfoSx1.Text = $"{cg.Dfo2.Value:f4}";
- this.txtYbMain.Text = $"{cg.YbMainDfo.Value:f4}";
- this.txtYbAdja.Text = $"{cg.YbAdja1Dfo.Value:f4}";
- this.txtYbAdja1.Text = $"{cg.YbAdja2Dfo.Value:f4}";
- 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($"邻星1", cg.Adja1Code, adja1Eph, Color.Black);
- var adja2Eph = (cg.Adja2X, cg.Adja2Y, cg.Adja2Z, cg.Adja2Vx, cg.Adja2Vy, cg.Adja2Vz);
- ucEphXYZAdja2.SetParam($"邻星2", cg.Adja2Code, adja2Eph, Color.Black);
- 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:f4},{station.SatTxLat:f4}";
- this.txtRefLocation.Text = $"{station.RefLon:f4},{station.RefLat:f4}";
- }
- 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 msEph = ucEphXYZMain.EphParam();
- var ns1Eph = ucEphXYZAdja1.EphParam();
- var ns2Eph = ucEphXYZAdja2.EphParam();
- 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 = 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 = PosApi.X3_PosTwoDfo(cgRes, StationRes);
- this.labelControl1.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 btnXl_Click(object sender, EventArgs e)
- {
- if (this.sigTime.DateTime == DateTime.MinValue)
- {
- DxHelper.MsgBoxHelper.ShowWarning("信号时间不能为空!");
- 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 mEph = EphHelper.Calc(xlInfo.TwoLine, sigTime.ToUtc());
- var nEph1 = EphHelper.Calc(xlInfo1.TwoLine, sigTime.ToUtc());
- var nEph2 = EphHelper.Calc(xlInfo2.TwoLine, sigTime.ToUtc());
- var mainEph = (mEph.X, mEph.Y, mEph.Z, mEph.VX, mEph.VY, mEph.VZ);
- ucEphXYZMain.SetParam($"主星", cg.MainCode, mainEph, Color.Red);
- var adja1Eph = (nEph1.X, nEph1.Y, nEph1.Z, nEph1.VX, nEph1.VY, nEph1.VZ);
- ucEphXYZAdja1.SetParam($"邻星1", cg.Adja1Code, adja1Eph, Color.Red);
- var adja2Eph = (nEph2.X, nEph2.Y, nEph2.Z, nEph2.VX, nEph2.VY, nEph2.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()}推算星历失败");
- }
- }
- }
- }
|