using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using DevExpress.XtraBars.Docking2010.Views.Widget;
using Extensions;
using XzXdDw.App.Model;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox;
using static DevExpress.XtraPrinting.Native.ExportOptionsPropertiesNames;
namespace XdDw.App.Api
{
public static class PosApi
{
#region cpp dll Interop
//两星一地定位
private const string X2D1 = @"AddIns\DLL_SC_2X1D_DW.dll";
[DllImport(X2D1, EntryPoint = "SC_2X1D_DW", CallingConvention = CallingConvention.Cdecl)]//两星一地
private extern static void X2D1_POS_Core(double[] mainSat, double[] adjaSat, double[] cdbStation, double[] satStation1, double[] satStation2, double[] satStation3, double[] satStation4,
double[] satStation5, double[] refStation, double[] zone, double tarSxDto, double tarXdDto, double samp_main_dto, double samp_neigh_dto, double[] res);
private const string gzdw = @"Api\低轨时频差线及定位\DLL_XDXZ.dll";
///
/// 地轨双星dw
///
///
///
///
///
///
///
///
///
///
///
///
[DllImport(gzdw, EntryPoint = "TwoStar_DTFO_DW", CallingConvention = CallingConvention.Cdecl)]
public extern static void TwoStar_DTFO_DW(double[] main_sat, double[] neigh_sat, double[] Ref_Station_LLH
, double[] Zone, double target_dto, double target_dfo,
double ref_dto, double ref_dfo, double fu1, double fu2, double[] target_llh);
///
/// 单星dw
///
/// 第一时刻星历 长度6
/// 第二时刻星历 长度6
/// 第三时刻星历 长度6
///
/// 频差1(Hz)
/// 频差2(Hz)
/// 上行频点(Hz)
///
[DllImport(gzdw, EntryPoint = "SingleStar_DFO_DW", CallingConvention = CallingConvention.Cdecl)]//两星一地
public extern static void SingleStar_DFO_DW(double[] main_sat, double[] neigh_sat1, double[] neigh_sat2
, double[] Zone, double target_dfo1, double target_dfo2, double fu, double[] target_llh);
///
/// 底轨双星时差线
///
/// 主星星历 长度6
/// 邻星星历 长度6
/// 参考站位置
/// -85, 85, -180, 180
/// 目标时差(s)
/// 参考时差(s)
///
///
[DllImport(gzdw, EntryPoint = "TwoStar_SCX", CallingConvention = CallingConvention.Cdecl)]//两星一地
public extern static void TwoStar_SCX(double[] main_sat_pos, double[] neigh_sat_pos, double[] ref_pos, double[] Zone,
double target_dto, double ref_dto, out IntPtr LOP_Value, ref int LOP_Len);
///
/// 地轨双星频差线
///
///
///
///
///
/// 目标频差(Hz)
/// 参考频差(Hz)
/// 上行频点1(Hz)
/// 上行频点2(Hz)
///
///
[DllImport(gzdw, EntryPoint = "TwoStar_PCX", CallingConvention = CallingConvention.Cdecl)]//两星一地
public extern static void TwoStar_PCX(double[] main_sat, double[] neigh_sat, double[] ref_pos,
double[] Zone, double target_dfo, double ref_dfo, double fu1, double fu2, out IntPtr LOP_Value, ref int LOP_Len);
///
/// 单星频差线
///
///
///
///
///
///
///
///
[DllImport(gzdw, EntryPoint = "SingleStar_PCX", CallingConvention = CallingConvention.Cdecl)]//两星一地
public extern static void SingleStar_PCX(double[] main_sat, double[] neigh_sat
, double[] Zone, double target_dfo, double fu, out IntPtr LOP_Value, ref int LOP_Len);
private const string XdtsDll = @"Api\时差线\Positioning.dll";
///
///
///
///
///
///
///
///
///
/// 目标时差 (s)
/// 参考时差 (s)
///
///
[DllImport(XdtsDll, EntryPoint = "CurveByTwoTDOA", CallingConvention = CallingConvention.Cdecl)]//两星一地
public extern static void CurveByTwoTDOA(double[] main_sat_pos, double[] neigh_sat_pos, double[] rec1_pos, double[] rec2_pos, double[] ref_pos, double[] Zone,
double target_dto, double ref_dto, out IntPtr LOP_Value, ref int LOP_Len);
#endregion
///
/// 两星一地,返回经度纬度高度及镜像点,数组长度为6
///
///
///
public static double[] X2D1_POS(CgRes cgRes, List listTx)
{
var satTx = listTx.Find(p => p.TxType == EnumTxType.MainSat);
var cdbTx = listTx.Find(p => p.TxType == EnumTxType.Cdb);
var refTx = listTx.Find(p => p.TxType == EnumTxType.Ref);
double[] mainSat = new double[3] { cgRes.MainX, cgRes.MainY, cgRes.MainZ };
double[] adjaSat = new double[3] { cgRes.AdjaX, cgRes.AdjaY, cgRes.AdjaZ };
double[] satStation = new double[3] { satTx.Lon, satTx.Lat, 0 };
double[] cdbStation = new double[3] { cdbTx.Lon, cdbTx.Lat, 0 };
double[] refStation = new double[3] { refTx.Lon, refTx.Lat, 0 };
double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
double[] res = new double[6];
X2D1_POS_Core(mainSat, adjaSat, cdbStation, satStation, satStation, satStation, satStation, satStation, refStation, zone, cgRes.DtoSx / 1e6, cgRes.DtoCdb / 1e6, cgRes.YbMain / 1e6, cgRes.YbAdja / 1e6, res);
return res;
}
public static double[] X2D1_POS(CgRes cgRes, TxInfo satTx, TxInfo cdbTx, TxInfo refTx)
{
double[] mainSat = new double[3] { cgRes.MainX, cgRes.MainY, cgRes.MainZ };
double[] adjaSat = new double[3] { cgRes.AdjaX, cgRes.AdjaY, cgRes.AdjaZ };
double[] satStation = new double[3] { satTx.Lon, satTx.Lat, 0 };
double[] cdbStation = new double[3] { cdbTx.Lon, cdbTx.Lat, 0 };
double[] refStation = new double[3] { refTx.Lon, refTx.Lat, 0 };
double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
double[] res = new double[6];
X2D1_POS_Core(mainSat, adjaSat, cdbStation, satStation, satStation, satStation, satStation, satStation, refStation, zone, cgRes.DtoSx / 1e6, cgRes.DtoCdb / 1e6, cgRes.YbMain / 1e6, cgRes.YbAdja / 1e6, res);
return res;
}
}
}