123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- using DevExpress.XtraMap;
- using DxHelper;
- using ExtensionsDev;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Data.Entity;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using XdCxRhDW.Api;
- using XdCxRhDW.Entity;
- using XdCxRhDW.Repostory;
- namespace XdCxRhDW.App.EditForms
- {
- public partial class X1D1PosParamEditor : DevExpress.XtraEditors.XtraUserControl
- {
- private MapControl mapControl1;
- private PosRes info;
- private CgRes cg;
- private List<SatInfo> listSat;
- public X1D1PosParamEditor(PosRes info, MapControl mapControl)
- {
- InitializeComponent();
- this.info = info;
- this.listSat = new List<SatInfo>();
- this.mapControl1 = mapControl;
- this.labelControl1.Text = $"";
- //this.StartPosition = FormStartPosition.CenterParent;
- txtsatStation.EditValueChanged += TxtsatStation_EditValueChanged;
- txtcdbStation.EditValueChanged += TxtcdbStation_EditValueChanged;
- txtRefLocation.EditValueChanged += TxtRefLocation_EditValueChanged;
- txtCxLocation.EditValueChanged += TxtCxLocation_EditValueChanged;
- }
- private void TxtCxLocation_EditValueChanged(object sender, EventArgs e)
- {
- txtCxLocation.CheckLonLat(dxErrorProvider, "测向站");
- }
- private void TxtRefLocation_EditValueChanged(object sender, EventArgs e)
- {
- txtRefLocation.CheckLonLat(dxErrorProvider, "参考站");
- }
- private void TxtcdbStation_EditValueChanged(object sender, EventArgs e)
- {
- txtcdbStation.CheckLonLat(dxErrorProvider, "超短波");
- }
- private void TxtsatStation_EditValueChanged(object sender, EventArgs e)
- {
- txtsatStation.CheckLonLat(dxErrorProvider, "接收站");
- }
- private async void X1D1DTOParamEditor_Load(object sender, EventArgs e)
- {
- StationRes station;
- CxRes cx;
- 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();
- cx = await db.CxRes.Where(m => m.ID == info.CxResID).FirstOrDefaultAsync();
- }
- if (cg != null)
- {
- this.txtDtoCdb.Text = $"{cg.DtoCdb.Value:f3}";
- this.txtYbMain.Text = $"{cg.YbMainDto.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}";
- }
- if (cx != null)
- {
- this.txtcxFx.Text = $"{cx.Fx:f3}";
- }
- if (station != null)
- {
- this.txtsatStation.Text = $"{station.SatTxLon:f3},{station.SatTxLat:f3}";
- this.txtcdbStation.Text = $"{station.CdbTxLon:f3},{station.CdbTxLat:f3}";
- this.txtRefLocation.Text = $"{station.RefLon:f3},{station.RefLat:f3}";
- this.txtCxLocation.Text = $"{station.CxLon:f3},{station.CxLat:f3}";
- }
- }
- public bool CheckParam()
- {
- if (!txtsatStation.CheckLonLat(dxErrorProvider, "接收站"))
- {
- return false;
- }
- if (!txtcdbStation.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 CDBAnt = txtcdbStation.GetLonLat();
- var RefGeod = txtRefLocation.GetLonLat();
- var CXStation = txtCxLocation.GetLonLat();
- var sigTime = this.sigTime.DateTime;
- var DtoCdb = Convert.ToDouble(this.txtDtoCdb.Text);
- var YbMainDto = Convert.ToDouble(this.txtYbMain.Text);
- var Fx = Convert.ToDouble(this.txtcxFx.Text);
- var MainX = Convert.ToDouble(this.txtMainX.Text);
- var MainY = Convert.ToDouble(this.txtMainY.Text);
- var MainZ = Convert.ToDouble(this.txtMainZ.Text);
- var StationRes = new StationRes()
- {
- SatTxLon = MsAnt[0],
- SatTxLat = MsAnt[1],
- CdbTxLon = CDBAnt[0],
- CdbTxLat = CDBAnt[1],
- CxLon = CXStation[0],
- CxLat = CXStation[1],
- RefLon = RefGeod[0],
- RefLat = RefGeod[1],
- };
- var cgRes = new CgRes()
- {
- SigTime = sigTime,
- DtoCdb = DtoCdb,
- YbMainDto = YbMainDto,
- MainX = MainX,
- MainY = MainY,
- MainZ = MainZ,
- };
- var cxRes = new CxRes()
- {
- SigTime = sigTime,
- Fx = Fx,
- };
- var res = PosApi.X1D1_Pos(cgRes, StationRes, cxRes);
- 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 btnCalcXl_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 p = EphHelper.Calc(xlInfo.TwoLine, sigTime);
- this.txtMainX.Text = $"{p.X:f3}";
- this.txtMainY.Text = $"{p.Y:f3}";
- this.txtMainZ.Text = $"{p.Z:f3}";
- }
- catch (Exception ex)
- {
- Serilog.Log.Error(ex, $"手动{info.PosResType.GetEnumDisplayName()}推算星历失败.PosID={info.ID},SigTime={info.SigTime}");
- DxHelper.MsgBoxHelper.ShowWarning($"手动{info.PosResType.GetEnumDisplayName()}推算星历失败");
- }
- }
- }
- }
|