123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- using DevExpress.Mvvm.ModuleInjection.Native;
- using DevExpress.XtraEditors;
- using DevExpress.XtraEditors.DXErrorProvider;
- using DevExpress.XtraLayout;
- 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.Security.Policy;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Documents;
- using System.Windows.Forms;
- using XdCxRhDw.Dto;
- using XdCxRhDW.App.App.Properties;
- using XdCxRhDW.Core;
- using XdCxRhDW.Core.Api;
- using XdCxRhDW.Repostory.EFContext;
- using XdCxRhDW.Repostory.Model;
- namespace XdCxRhDW.App.EditForms
- {
- public partial class X2D1PosParamEditor : DevExpress.XtraEditors.XtraUserControl
- {
- private List<SatInfo> listSat;
- private PosRes info;
- private CgRes cg;
- public X2D1PosParamEditor(PosRes info)
- {
- InitializeComponent();
- this.Text = $"{info.PosResType.GetEnumDisplayName()}手动定位";
- this.info = info;
- this.listSat = new List<SatInfo>();
- txtsatStation.EditValueChanged += TxtsatStation_EditValueChanged;
- txtcdbStation.EditValueChanged += TxtcdbStation_EditValueChanged;
- txtRefLocation.EditValueChanged += TxtRefLocation_EditValueChanged;
- }
- 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 X2D1DTOParamEditor_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.txtDtoSx.Text = $"{cg.Dto1.Value:f3}";
- this.txtDtoCdb.Text = $"{cg.DtoCdb.Value:f3}";
- if (info.PosResType == EnumPosResType.X2D1)
- {
- this.txtYbMain.Text = $"{cg.YbMainDto.Value:f3}";
- this.txtYbAdja.Text = $"{cg.YbAdja1Dto.Value:f3}";
- }
- this.txtSigTime.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.txtAdjaX.Text = $"{cg.Adja1X.Value:f3}";
- this.txtAdjaY.Text = $"{cg.Adja1Y.Value:f3}";
- this.txtAdjaZ.Text = $"{cg.Adja1Z.Value: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}";
- }
- if (info.PosResType == EnumPosResType.X2D1NoRef)
- {
- txtYbMain.Properties.ReadOnly = true;
- txtYbAdja.Properties.ReadOnly = true;
- txtRefLocation.Properties.ReadOnly = true;
- this.txtRefLocation.Text = $"{0},{0}";
- }
- }
- public bool CheckParam()
- {
- if (!txtsatStation.CheckLonLat(dxErrorProvider, "接收站"))
- {
- return false;
- }
- if (!txtcdbStation.CheckLonLat(dxErrorProvider, "超短波"))
- {
- return false;
- }
- if (info.PosResType == EnumPosResType.X2D1 && !txtRefLocation.CheckLonLat(dxErrorProvider, "参考站"))
- {
- return false;
- }
- return true;
- }
- private async void btnOk_Click(object sender, EventArgs e)
- {
- if (!CheckParam()) { return; }
- lblRes.Text = string.Empty;
- try
- {
- var MsAnt = txtsatStation.GetLonLat();
- var CDBAnt = txtcdbStation.GetLonLat();
- var RefGeod = info.PosResType == EnumPosResType.X2D1 ? txtRefLocation.GetLonLat() : new double[3] { 0, 0, 0 };
- var DtoSx = Convert.ToDouble(this.txtDtoSx.Text);
- var DtoCdb = Convert.ToDouble(this.txtDtoCdb.Text);
- var YbMainDto = info.PosResType == EnumPosResType.X2D1 ? Convert.ToDouble(this.txtYbMain.Text) : 0;
- var YbAdja1Dto = info.PosResType == EnumPosResType.X2D1 ? Convert.ToDouble(this.txtYbAdja.Text) : 0;
- var MainX = Convert.ToDouble(this.txtMainX.Text);
- var MainY = Convert.ToDouble(this.txtMainY.Text);
- var MainZ = Convert.ToDouble(this.txtMainZ.Text);
- var AdjaX = Convert.ToDouble(this.txtAdjaX.Text);
- var AdjaY = Convert.ToDouble(this.txtAdjaY.Text);
- var AdjaZ = Convert.ToDouble(this.txtAdjaZ.Text);
- double[] msEph = new double[] { MainX, MainY, MainZ, 0, 0, 0 };
- double[] NsEph = new double[] { AdjaX, AdjaY, AdjaZ, 0, 0, 0 };
- var sigTime = txtSigTime.DateTime;
- var msat = listSat.FirstOrDefault(m => m.SatCode == cg.MainCode.Value)?.Sat;
- if (string.IsNullOrWhiteSpace(msat)) msat = cg.MainCode.Value.ToString();
- var nsat = listSat.FirstOrDefault(m => m.SatCode == cg.Adja1Code.Value)?.Sat;
- if (string.IsNullOrWhiteSpace(nsat)) nsat = cg.Adja1Code.Value.ToString();
- var settings = new SysSetings();
- using (RHDWContext db = new RHDWContext())
- {
- settings = await db.SysSetings.FirstOrDefaultAsync();
- }
- string url = string.Format("http://{0}:{1}/Api/Pos/", IpHelper.GetLocalIp(), settings.HttpPort);
- if (info.PosResType == EnumPosResType.X2D1NoRef)
- {
- url += "PosX2D1NoParAsync";
- X2D1NoParPosDto X2D1PosDto = new X2D1NoParPosDto()
- {
- SigTime = sigTime,
- MainCode = Convert.ToInt32(msat),
- AdjaCode = Convert.ToInt32(nsat),
- SxDto = DtoSx * 1e6,
- XdDto = DtoCdb * 1e6,
- MainX = MainX,
- MainY = MainY,
- MainZ = MainZ,
- AdjaX = AdjaX,
- AdjaY = AdjaY,
- AdjaZ = AdjaZ,
- SatTxLon = MsAnt[0],
- SatTxLat = MsAnt[1],
- CdbTxLon = CDBAnt[0],
- CdbTxLat = CDBAnt[1],
- };
- var result = await HttpHelper.PostRequestAsync<PosResDto>(url, X2D1PosDto);
- if (result.code == 200)
- {
- lblRes.Text = $"定位结果{result.data.PosLon},{result.data.PosLat}";
- }
- }
- else
- {
- url += "PosX2D1Async";
- X2D1PosDto X2D1PosDto = new X2D1PosDto()
- {
- SigTime = sigTime,
- MainCode = Convert.ToInt32(msat),
- AdjaCode = Convert.ToInt32(nsat),
- SxDto = DtoSx * 1e6,
- XdDto = DtoCdb * 1e6,
- MainYbDto = YbMainDto * 1e6,
- AdjaYbDto = YbAdja1Dto * 1e6,
- MainX = MainX,
- MainY = MainY,
- MainZ = MainZ,
- AdjaX = AdjaX,
- AdjaY = AdjaY,
- AdjaZ = AdjaZ,
- SatTxLon = MsAnt[0],
- SatTxLat = MsAnt[1],
- CdbTxLon = CDBAnt[0],
- CdbTxLat = CDBAnt[1],
- RefLon = RefGeod[0],
- RefLat = RefGeod[1],
- };
- var result = await HttpHelper.PostRequestAsync<PosResDto>(url, X2D1PosDto);
- if (result.code == 200)
- {
- lblRes.Text = $"定位结果{result.data.PosLon},{result.data.PosLat}";
- }
- }
- }
- catch (Exception ex)
- {
- Serilog.Log.Error(ex, $"定位{info.PosResType.GetEnumDisplayName()}失败.PosID={info.ID},SigTime={info.SigTime}");
- DxHelper.MsgBoxHelper.ShowWarning($"定位{info.PosResType.GetEnumDisplayName()}失败");
- }
- }
- private void btnRefXl_Click(object sender, EventArgs e)
- {
- }
- }
- }
|