123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- using DevExpress.XtraMap;
- using DxHelper;
- using ExtensionsDev;
- using System;
- using System.CodeDom;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Configuration;
- 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.Dto;
- using XdCxRhDW.Entity;
- using XdCxRhDW.Repostory;
- namespace XdCxRhDW.App.EditForms
- {
- public partial class X3EllipesEditor : DevExpress.XtraEditors.XtraUserControl
- {
- private MapControl mapControl1;
- private PosRes info;
- private CgRes cg;
- public X3EllipesEditor(PosRes info, MapControl mapControl)
- {
- InitializeComponent();
- this.info = info;
- itemSigTime.Text = $"{itemSigTime.Text}({SysConfig.Config.TimeZoneUTC})";
- this.layoutControl1.UseDefault();
- txtSigTime.UseDefault();
- this.mapControl1 = mapControl;
- }
- private async void X2D1DTOParamEditor_Load(object sender, EventArgs e)
- {
- this.layoutControl1.BestFit();
- 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.txtSigTime.EditValue = info.SigTime;
- txtEphMain.SetXYZ("主星", cg.MainCode, (cg.MainX, cg.MainY, cg.MainZ), Color.Black);
- txtEphAdja1.SetXYZ("邻星", cg.Adja1Code, (cg.Adja1X, cg.Adja1Y, cg.Adja1Z), Color.Black);
- }
- if (station != null)
- {
- this.txtsatStation.Text = $"{station.SatTxLon},{station.SatTxLat}";
- this.txtRefLocation.Text = $"{station.RefLon},{station.RefLat}";
- }
- if (info.PosResType == EnumPosResType.X3TwoDtoNoRef)
- {
- txtRefLocation.Properties.ReadOnly = true;
- this.txtRefLocation.Text = $"{0},{0}";
- }
- this.txtPosLocation.Text = $"{info.PosLon},{info.PosLat}";
- }
- public bool CheckParam()
- {
- dxErrorProvider.ClearErrors();
- if (!txtsatStation.CheckLonLat(dxErrorProvider, "接收站"))
- {
- return false;
- }
- if (!txtEphMain.CheckEphXYZ(dxErrorProvider))
- {
- return false;
- }
- if (!txtEphAdja1.CheckEphXYZ(dxErrorProvider))
- {
- return false;
- }
- return true;
- }
- private async void btnEllipes_Click(object sender, EventArgs e)
- {
- //if (!CheckParam()) { return; }
- //try
- //{
- // var MsAnt = txtsatStation.GetLonLat();
- // var pos = txtPosLocation.GetLonLat();
- // var RefGeod = txtRefLocation.GetLonLat();
- // double[] ephMain = txtEphMain.EphXYZ();
- // double[] ephAdja = txtEphAdja1.EphXYZ();
- // var dto = new ErrorEllipseLeoX3Dto()
- // {
-
- // };
- // AjaxResult<ErrEllipseResDto> rsp;
- // if (info.PosResType != EnumPosResType.X2D1)
- // {
- // dto = dto.WithRef(112, 11);
- // rsp = await HttpHelper.PostRequestAsync<ErrEllipseResDto>(SysConfig.GetUrl("Ellipse/X2D1"), dto, 30);
- // }
- // else
- // {
- // rsp = await HttpHelper.PostRequestAsync<ErrEllipseResDto>(SysConfig.GetUrl("Ellipse/X2D1NoRef"), dto, 30);
- // }
- // if (rsp.code != 200)
- // {
- // await LogHelper.Error($"绘制{info.PosResType.GetEnumDisplayName()}误差椭圆失败,{rsp.msg}");
- // DxHelper.MsgBoxHelper.ShowWarning($"绘制{info.PosResType.GetEnumDisplayName()}误差椭圆失败,{rsp.msg}");
- // }
- // else
- // {
- // this.mapControl1.DrawErrEllipse(rsp.data.LongRadius / 1e3, rsp.data.ShortRadius / 1e3, rsp.data.GeoPoints.Select(t => (t.Lon, t.Lat)));
- // this.txtPosRes.Text = $"{info.PosResType.GetEnumDisplayName()}误差椭圆.长半轴={rsp.data.LongRadius:f0}m,短半轴={rsp.data.ShortRadius:f0}m,倾角={rsp.data.DipAngle:f1}°";
- // }
- //}
- //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 btnEphCalc_Click(object sender, EventArgs e)
- {
- dxErrorProvider.ClearErrors();
- if (this.txtSigTime.DateTime == DateTime.MinValue)
- {
- dxErrorProvider.SetError(txtSigTime, "信号时间不能为空!");
- return;
- }
- var sigTime = this.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 };
- var maineph = await HttpHelper.PostRequestAsync<SatEphResDto>(SysConfig.GetUrl("Xl/Calc"), XlCalcDto);
- txtEphMain.SetXYZ("主星", cg.MainCode.Value, (maineph.data.X, maineph.data.Y, maineph.data.Z), Color.Red);
- var adjaxlInfo = await XlRepository.GetLatestAsync(cg.Adja1Code.Value, sigTime);
- if (adjaxlInfo == null)
- {
- DxHelper.MsgBoxHelper.ShowWarning($"卫星:{cg.Adja1Code.Value}未找到对应的星历信息,请导入星历");
- return;
- }
- XlCalcDto = new XlCalcDto() { tleStr = adjaxlInfo.TwoLine, SigTime = sigTime };
- var adjaeph = await HttpHelper.PostRequestAsync<SatEphResDto>(SysConfig.GetUrl("Xl/Calc"), XlCalcDto);
- txtEphAdja1.SetXYZ("邻星", cg.Adja1Code.Value, (adjaeph.data.X, adjaeph.data.Y, adjaeph.data.Z), Color.Red);
- }
- catch (Exception ex)
- {
- Serilog.Log.Error(ex, $"手动推算{info.PosResType.GetEnumDisplayName()}星历失败,SigTime={sigTime}");
- DxHelper.MsgBoxHelper.ShowError($"手动推算{info.PosResType.GetEnumDisplayName()}星历失败,{ex.Message}");
- }
- }
- }
- }
|