123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- using ExtensionsDev;
- using System;
- using System.IO;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using XdCxRhDW.Api;
- using XdCxRhDW.Api.AddIns;
- using XdCxRhDW.Dto;
- namespace XdCxRhDW.App.EditForms
- {
- public partial class TarDfoLeoX1Calc : DevExpress.XtraEditors.XtraForm
- {
- private string time1SatInfo;
- private string time2SatInfo;
- private string time3SatInfo;
- private string CapDir;
- public TarDfoLeoX1Calc()
- {
- InitializeComponent();
- this.Text = "一星频差预测";
- this.layoutControl1.UseDefault();
- this.StartPosition = FormStartPosition.CenterParent;
- }
- public TarDfoLeoX1Calc(double lon, double lat)
- : this()
- {
- this.txtTar.Text = $"{lon:f3},{lat:f3}";
- }
- private async void TarDfoLeoX1Calc_Load(object sender, EventArgs e)
- {
- await GetAppSetAsync();
- this.lcX1.Text = "第一时刻主星坐标X";
- this.lcY1.Text = "第一时刻主星坐标Y";
- this.lcZ1.Text = "第一时刻主星坐标Z";
- this.lcVX1.Text = "第一时刻主星坐标VX";
- this.lcVY1.Text = "第一时刻主星坐标VY";
- this.lcVZ1.Text = "第一时刻主星坐标VZ";
- this.lcX2.Text = "第二时刻主星坐标X";
- this.lcY2.Text = "第二时刻主星坐标Y";
- this.lcZ2.Text = "第二时刻主星坐标Z";
- this.lcVX2.Text = "第二时刻主星坐标VX";
- this.lcVY2.Text = "第二时刻主星坐标VY";
- this.lcVZ2.Text = "第二时刻主星坐标VZ";
- var t1 = time1SatInfo.Split(',');
- int idx = 0;
- txtX1.EditValue = t1[++idx];
- txtY1.EditValue = t1[++idx];
- txtZ1.EditValue = t1[++idx];
- txtVX1.EditValue = t1[++idx];
- txtVY1.EditValue = t1[++idx];
- txtVZ1.EditValue = t1[++idx];
- var t2 = time2SatInfo.Split(',');
- idx = 0;
- txtX2.EditValue = t2[++idx];
- txtY2.EditValue = t2[++idx];
- txtZ2.EditValue = t2[++idx];
- txtVX2.EditValue = t2[++idx];
- txtVY2.EditValue = t2[++idx];
- txtVZ2.EditValue = t2[++idx];
- var t3 = time3SatInfo.Split(',');
- idx = 0;
- txtX21.EditValue = t3[++idx];
- txtY21.EditValue = t3[++idx];
- txtZ21.EditValue = t3[++idx];
- txtVX21.EditValue = t3[++idx];
- txtVY21.EditValue = t3[++idx];
- txtVZ21.EditValue = t3[++idx];
- }
- private async Task GetAppSetAsync()
- {
- try
- {
- time1SatInfo = "1234,-1608416.82,5994263.83,3139842.12,-6632.9542,-373.9141,-2678.0471";
- time2SatInfo = "1234,-3479304.94,5612482.70,2187901.77,-5784.2167,-2163.5059,-3632.7021";
- time3SatInfo = "1234,-5018683.88,4714452.40,1001435.81,-4399.2159,-3780.5070,-4206.3348";
- CapDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "信号仿真", "低轨单星仿真数据");
- var svtItem = ServerContext.Instance.GetRandomOne(EnumSvrType.LeoX1Task54);
- if (svtItem == null)
- {
- return;
- }
- var rsp = await HttpHelper.GetRequestAsync<LeoSat1AppSettingDto>($"{svtItem.BaseHttpAddr}LeoSat1TaskProcessing/GetAppSetting", 10);
- if (rsp.code == 200)
- {
- time1SatInfo = rsp.data.Time1SatInfo;
- time2SatInfo = rsp.data.Time2SatInfo;
- time3SatInfo = rsp.data.Time3SatInfo;
- }
- }
- catch (Exception)
- {
- }
-
- }
- private async void btnOk_Click(object sender, EventArgs e)
- {
- await DfoCalcAsync(false);
- }
- private async Task DfoCalcAsync(bool beCreateData)
- {
- try
- {
- var strTar = txtTar.Text.Replace(",", ",");
- var tarfuHz = (Convert.ToDouble(txtTarFuMhz.Text) + 44) * 1e6;
- var DtarfuHz = (Convert.ToDouble(txtTarFuMhz.Text)) * 1e6;
- double lon = Convert.ToDouble(strTar.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[0]);
- double lat = Convert.ToDouble(strTar.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[1]);
- double x1 = Convert.ToDouble(txtX1.Text);
- double y1 = Convert.ToDouble(txtY1.Text);
- double z1 = Convert.ToDouble(txtZ1.Text);
- double vx1 = Convert.ToDouble(txtVX1.Text);
- double vy1 = Convert.ToDouble(txtVY1.Text);
- double vz1 = Convert.ToDouble(txtVZ1.Text);
- double[] ephX1 = new double[6] { x1, y1, z1, vx1, vy1, vz1 };
- double x2 = Convert.ToDouble(txtX2.Text);
- double y2 = Convert.ToDouble(txtY2.Text);
- double z2 = Convert.ToDouble(txtZ2.Text);
- double vx2 = Convert.ToDouble(txtVX2.Text);
- double vy2 = Convert.ToDouble(txtVY2.Text);
- double vz2 = Convert.ToDouble(txtVZ2.Text);
- double[] ephX2 = new double[6] { x2, y2, z2, vx2, vy2, vz2 };
- double[] targetPos = new double[3] { lon, lat, 0 };
- var tardf1 = DfoCalcAPI.DfoCalc(targetPos, ephX1, tarfuHz);
- var tardf2 = DfoCalcAPI.DfoCalc(targetPos, ephX2, tarfuHz);
- double x3 = Convert.ToDouble(txtX21.Text);
- double y3 = Convert.ToDouble(txtY21.Text);
- double z3 = Convert.ToDouble(txtZ21.Text);
- double vx3 = Convert.ToDouble(txtVX21.Text);
- double vy3 = Convert.ToDouble(txtVY21.Text);
- double vz3 = Convert.ToDouble(txtVZ21.Text);
- double[] ephX3 = new double[6] { x3, y3, z3, vx3, vy3, vz3 };
- var tardf3 = DfoCalcAPI.DfoCalc(targetPos, ephX3, tarfuHz);
- this.txtRes.Text = $"第二时刻目标频差预测值:{tardf2 - tardf1:f3}Hz 第三时刻目标频差预测值:{tardf3 - tardf1:f3}Hz";
- if (beCreateData)
- {
- long fsHz = 96000;
- int brustCount = 15;
- var dt1 = 1000 / 1e6;
- var dt2 = 1500 / 1e6;
- var df1 = tardf2 - tardf1;
- var df2 = tardf3 - tardf1;
- await Task.Run(() =>
- {
- try
- {
- Directory.CreateDirectory(CapDir);
- var t1 = DateTime.Now;
- var t2 = t1.AddSeconds(30);
- var t3 = t2.AddSeconds(30);
- var f1 = $"{CapDir}\\{t1:yyyyMMddHHmmss}_D{DtarfuHz * 1e-6}_FS{fsHz}_ch1.dat";
- var f2 = $"{CapDir}\\{t2:yyyyMMddHHmmss}_D{DtarfuHz * 1e-6}_FS{fsHz}_ch1.dat";
- var f3 = $"{CapDir}\\{t3:yyyyMMddHHmmss}_D{DtarfuHz * 1e-6}_FS{fsHz}_ch1.dat";
- DataEmulationHelper.GenBrustFiles(f1, f2, f3, fsHz, brustCount, dt1, df1, dt2, df2);
- System.Diagnostics.Process.Start("explorer.exe", CapDir);
- }
- catch (Exception ex)
- {
- DxHelper.MsgBoxHelper.ShowError("频差预测出错");
- }
- });
- }
- }
- catch (Exception ex)
- {
- await LogHelper.Error("频差预测出错", ex);
- DxHelper.MsgBoxHelper.ShowError("频差预测出错");
- }
- }
- private async void btnCreate_Click(object sender, EventArgs e)
- {
- await DfoCalcAsync(true);
- }
- }
- }
|