TheoryDtoDfoApi.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.InteropServices;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using DW5S.Entity;
  8. namespace DW5S.KxcApi
  9. {
  10. /// <summary>
  11. /// 理论时频差API
  12. /// </summary>
  13. public static class TheoryDtoDfoApi
  14. {
  15. #region cpp dll Interop
  16. //一星一地测向带参定位
  17. private const string dll = @"AddIns\GDOP误差椭圆\GDOP_Draw_11.dll";
  18. //主接收站位置[3],
  19. //邻接收站位置[3]
  20. //主星历[6](x,y,z,Vx,Vy,Vz)
  21. //邻星历[6](x,y,z,Vx,Vy,Vz)
  22. //上行频(单位,Hz)
  23. //下行频(单位,Hz)
  24. [DllImport(dll, EntryPoint = "theryDfo", CallingConvention = CallingConvention.Cdecl)]//双星理论频差
  25. private extern static double TheoryDfo(double[] target_llh, double[] rec_llh1, double[] rec_llh2, double[] main_sat, double[] neigh_sat, double fu, double fd);
  26. #endregion
  27. public static EnumTargetState TheoryDfo(CgRes cRes, StationRes sRes, PosRes posRes, int YDPZThreshold)
  28. {
  29. //张老板说理论频差如果和参估计算出来的频差差值比较大,就说明目标在运动(多路参估每一路都要比较,有一路判定运动则为运动)
  30. //?具体多少差异需要确定一下
  31. //主邻星本振不一样时该怎么计算
  32. if (cRes.TarFreqUp == null || cRes.TarFreqDown == null || YDPZThreshold <= 0)
  33. return EnumTargetState.Unknown;
  34. double[] target = new double[3] { posRes.PosLon, posRes.PosLat, 0 };
  35. double[] rec = new double[3] { sRes.SatTxLon, sRes.SatTxLat, 0 };
  36. if (cRes.MainVx == null || cRes.MainVy == null || cRes.MainVz == null) return EnumTargetState.Unknown;
  37. double[] xlMain = new double[6] { cRes.MainX.Value, cRes.MainY.Value, cRes.MainZ.Value, cRes.MainVx.Value, cRes.MainVy.Value, cRes.MainVz.Value };
  38. if (posRes.PosResType == EnumPosResType.X2D1 || posRes.PosResType == EnumPosResType.X2D1NoRef )
  39. {
  40. if (cRes.Dfo1 == null || cRes.Adja1Vx == null || cRes.Adja1Vy == null || cRes.Adja1Vz == null) return EnumTargetState.Unknown;
  41. var xlAdja1 = new double[6] { cRes.Adja1X.Value, cRes.Adja1Y.Value, cRes.Adja1Z.Value, cRes.Adja1Vx.Value, cRes.Adja1Vy.Value, cRes.Adja1Vz.Value };
  42. double res = TheoryDfo(target, rec, rec, xlMain, xlAdja1, cRes.TarFreqUp.Value, cRes.TarFreqDown.Value);
  43. var val = Math.Abs(res - cRes.Dfo1.Value);
  44. if (val < YDPZThreshold)
  45. return EnumTargetState.Stationary;
  46. else
  47. return EnumTargetState.Movement;
  48. }
  49. else if (posRes.PosResType == EnumPosResType.X1D1CX)
  50. {
  51. //星地不知道接口是否支持
  52. return EnumTargetState.Unknown;
  53. }
  54. else
  55. {
  56. return EnumTargetState.Unknown;
  57. }
  58. }
  59. }
  60. }