GdopHelper.cs 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. using DevExpress.Charts.Native;
  2. using DevExpress.Internal.WinApi.Windows.UI.Notifications;
  3. using DevExpress.XtraPrinting;
  4. using Newtonsoft.Json;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Diagnostics;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using XdCxRhDW.App.DTO;
  13. using static DevExpress.XtraCharts.GLGraphics.Platform.EGL;
  14. using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
  15. namespace XzXdDw.App.Api.星地GDOP误差椭圆
  16. {
  17. /// <summary>
  18. /// Gdop误差分布计算帮助类.该类调用了GdopCore.exe进程
  19. /// 每种GDOP算法提供了两个接口,这两种接口是完全等价的,一种传入双行根,一种直接传入卫星状态x、y、z等
  20. /// </summary>
  21. public static class GdopHelper
  22. {
  23. private static string exePath = "Api\\星地GDOP误差椭圆\\GDOP";
  24. private const string exeName = "GdopCore.exe";
  25. /// <summary>
  26. /// 三星双时差GDOP误差分布带参
  27. /// </summary>
  28. /// <param name="refLonLat">参考站经纬度,数组长度=2</param>
  29. /// <param name="mainSatTle">主星双行根数</param>
  30. /// <param name="adja1SatTle">邻1星双行根数</param>
  31. /// <param name="adja2SatTle">邻2星双行根数</param>
  32. /// <param name="time">采集时刻</param>
  33. /// <param name="dtousErr">时差误差(单位us)</param>
  34. /// <param name="satLocErr">星历位置误差(单位米)</param>
  35. /// <returns></returns>
  36. public static (List<SatInfo>, List<ErrDistanceMapLines>) Gdop3Sat2DtoRef(double[] refLonLat, string mainSatTle, string adja1SatTle, string adja2SatTle, DateTime time, double dtousErr = 1, double satLocErr = 10000)
  37. {
  38. if (string.IsNullOrWhiteSpace(exePath))
  39. throw new Exception($"请先调用SetExePath指定{exeName}进程所在路径,支持相对路径");
  40. if (!Directory.Exists(exePath))
  41. throw new Exception($"路径[{exePath}]不存在");
  42. var exeFile = Path.Combine(exePath, exeName);
  43. if (!File.Exists(exeFile))
  44. throw new Exception($"文件[{exeFile}]不存在");
  45. Process p = new Process();
  46. p.StartInfo.WorkingDirectory = exePath;
  47. p.StartInfo.FileName = exeFile;
  48. p.StartInfo.Arguments = $"60 \"{mainSatTle}\" \"{adja1SatTle}\" \"{adja2SatTle}\" \"{time:yyyy-MM-dd HH:mm:ss.000000}\" {string.Join(" ", refLonLat)} {dtousErr} {satLocErr}";
  49. p.StartInfo.CreateNoWindow = true;
  50. p.StartInfo.RedirectStandardError = true;
  51. p.StartInfo.RedirectStandardOutput = true;
  52. p.StartInfo.UseShellExecute = false;
  53. StringBuilder sb = new StringBuilder();
  54. p.OutputDataReceived += (sender, e) => sb.Append(e.Data);
  55. p.Start();
  56. p.BeginOutputReadLine();
  57. p.WaitForExit();//WaitForExit加了超时时间的话进程退出后不能保证异步流已经读取完成,这是.NET框架的BUG
  58. return ParseResult(3, sb.ToString());
  59. }
  60. /// <summary>
  61. /// 三星双时差GDOP误差分布带参
  62. /// </summary>
  63. /// <param name="refLonLat">参考站经纬度,数组长度=2</param>
  64. /// <param name="mainSatEph">主星xyz星历,数组长度=3</param>
  65. /// <param name="adja1SatEph">邻1星xyz星历,数组长度=3</param>
  66. /// <param name="adja2SatEph">邻2星xyz星历,数组长度=3</param>
  67. /// <param name="dtousErr">时差误差(单位us)</param>
  68. /// <param name="satLocErr">星历位置误差(单位米)</param>
  69. /// <returns></returns>
  70. /// <exception cref="Exception"></exception>
  71. public static (List<SatInfo>, List<ErrDistanceMapLines>) Gdop3Sat2DtoRef(double[] refLonLat, double[] mainSatEph, double[] adja1SatEph, double[] adja2SatEph, double dtousErr = 1, double satLocErr = 10000)
  72. {
  73. if (string.IsNullOrWhiteSpace(exePath))
  74. throw new Exception($"请先调用SetExePath指定{exeName}进程所在路径,支持相对路径");
  75. if (!Directory.Exists(exePath))
  76. throw new Exception($"路径[{exePath}]不存在");
  77. var exeFile = Path.Combine(exePath, exeName);
  78. if (!File.Exists(exeFile))
  79. throw new Exception($"文件[{exeFile}]不存在");
  80. Process p = new Process();
  81. p.StartInfo.WorkingDirectory = exePath;
  82. p.StartInfo.FileName = exeFile;
  83. p.StartInfo.Arguments = $"61 {string.Join(" ", mainSatEph)} {string.Join(" ", adja1SatEph)} {string.Join(" ", adja2SatEph)} {string.Join(" ", refLonLat)} {dtousErr} {satLocErr}";
  84. p.StartInfo.CreateNoWindow = true;
  85. p.StartInfo.RedirectStandardError = true;
  86. p.StartInfo.RedirectStandardOutput = true;
  87. p.StartInfo.UseShellExecute = false;
  88. StringBuilder sb = new StringBuilder();
  89. p.OutputDataReceived += (sender, e) => sb.Append(e.Data);
  90. p.Start();
  91. p.BeginOutputReadLine();
  92. p.WaitForExit();//WaitForExit加了超时时间的话进程退出后不能保证异步流已经读取完成,这是.NET框架的BUG
  93. return ParseResult(3, sb.ToString());
  94. }
  95. /// <summary>
  96. /// 三星双时差GDOP误差分布无参
  97. /// </summary>
  98. /// <param name="recLonLat">接收站经纬度,数组长度=2</param>
  99. /// <param name="mainSatTle">主星双行根数</param>
  100. /// <param name="adja1SatTle">邻1星双行根数</param>
  101. /// <param name="adja2SatTle">邻2星双行根数</param>
  102. /// <param name="time">采集时刻</param>
  103. /// <param name="dtousErr">时差误差(单位us)</param>
  104. /// <param name="satLocErr">星历位置误差(单位米)</param>
  105. /// <returns></returns>
  106. public static (List<SatInfo>, List<ErrDistanceMapLines>) Gdop3Sat2Dto(double[] recLonLat, string mainSatTle, string adja1SatTle, string adja2SatTle, DateTime time, double dtousErr = 1, double satLocErr = 10000)
  107. {
  108. if (string.IsNullOrWhiteSpace(exePath))
  109. throw new Exception($"请先调用SetExePath指定{exeName}进程所在路径,支持相对路径");
  110. if (!Directory.Exists(exePath))
  111. throw new Exception($"路径[{exePath}]不存在");
  112. var exeFile = Path.Combine(exePath, exeName);
  113. if (!File.Exists(exeFile))
  114. throw new Exception($"文件[{exeFile}]不存在");
  115. Process p = new Process();
  116. p.StartInfo.WorkingDirectory = exePath;
  117. p.StartInfo.FileName = exeFile;
  118. p.StartInfo.Arguments = $"62 \"{mainSatTle}\" \"{adja1SatTle}\" \"{adja2SatTle}\" \"{time:yyyy-MM-dd HH:mm:ss.000000}\" {string.Join(" ", recLonLat)} {dtousErr} {satLocErr}";
  119. p.StartInfo.CreateNoWindow = true;
  120. p.StartInfo.RedirectStandardError = true;
  121. p.StartInfo.RedirectStandardOutput = true;
  122. p.StartInfo.UseShellExecute = false;
  123. StringBuilder sb = new StringBuilder();
  124. p.OutputDataReceived += (sender, e) => sb.Append(e.Data);
  125. p.Start();
  126. p.BeginOutputReadLine();
  127. p.WaitForExit();//WaitForExit加了超时时间的话进程退出后不能保证异步流已经读取完成,这是.NET框架的BUG
  128. return ParseResult(3, sb.ToString());
  129. }
  130. /// <summary>
  131. /// 三星双时差GDOP误差分布无参
  132. /// </summary>
  133. /// <param name="recLonLat">接收站经纬度,数组长度=2</param>
  134. /// <param name="mainSatEph">主星xyz星历,数组长度=3</param>
  135. /// <param name="adja1SatEph">邻1星xyz星历,数组长度=3</param>
  136. /// <param name="adja2SatEph">邻2星xyz星历,数组长度=3</param>
  137. /// <param name="dtousErr">时差误差(单位us)</param>
  138. /// <param name="satLocErr">星历位置误差(单位米)</param>
  139. /// <returns></returns>
  140. /// <exception cref="Exception"></exception>
  141. public static (List<SatInfo>, List<ErrDistanceMapLines>) Gdop3Sat2Dto(double[] recLonLat, double[] mainSatEph, double[] adja1SatEph, double[] adja2SatEph, double dtousErr = 1, double satLocErr = 10000)
  142. {
  143. if (string.IsNullOrWhiteSpace(exePath))
  144. throw new Exception($"请先调用SetExePath指定{exeName}进程所在路径,支持相对路径");
  145. if (!Directory.Exists(exePath))
  146. throw new Exception($"路径[{exePath}]不存在");
  147. var exeFile = Path.Combine(exePath, exeName);
  148. if (!File.Exists(exeFile))
  149. throw new Exception($"文件[{exeFile}]不存在");
  150. Process p = new Process();
  151. p.StartInfo.WorkingDirectory = exePath;
  152. p.StartInfo.FileName = exeFile;
  153. p.StartInfo.Arguments = $"63 {string.Join(" ", mainSatEph)} {string.Join(" ", adja1SatEph)} {string.Join(" ", adja2SatEph)} {string.Join(" ", recLonLat)} {dtousErr} {satLocErr}";
  154. p.StartInfo.CreateNoWindow = true;
  155. p.StartInfo.RedirectStandardError = true;
  156. p.StartInfo.RedirectStandardOutput = true;
  157. p.StartInfo.UseShellExecute = false;
  158. StringBuilder sb = new StringBuilder();
  159. p.OutputDataReceived += (sender, e) => sb.Append(e.Data);
  160. p.Start();
  161. p.BeginOutputReadLine();
  162. p.WaitForExit();//WaitForExit加了超时时间的话进程退出后不能保证异步流已经读取完成,这是.NET框架的BUG
  163. return ParseResult(3, sb.ToString());
  164. }
  165. /// <summary>
  166. /// 双星时频差GDOP误差分布带参
  167. /// </summary>
  168. /// <param name="tarFreqUpMHz">目标上行频点MHz</param>
  169. /// <param name="refFreqUpMHz">参考上行频点MHz</param>
  170. /// <param name="mainSatTransMHz">主星转发器本振MHz</param>
  171. /// <param name="adjaSatTransMHz">邻星转发器本振MHz</param>
  172. /// <param name="recLonLat">接收站经纬度,数组长度=2</param>
  173. /// <param name="refLonLat">参考站经纬度,数组长度=2</param>
  174. /// <param name="mainTle">主星双行根数</param>
  175. /// <param name="adjaTle">邻星双行根数</param>
  176. /// <param name="time">采集时刻</param>
  177. /// <param name="dtousErr">时差误差(单位us)</param>
  178. /// <param name="dfoHzErr">频差误差(单位Hz)</param>
  179. /// <param name="satLocErr">星历位置误差(单位米)</param>
  180. /// <returns></returns>
  181. public static (List<SatInfo>, List<ErrDistanceMapLines>) Gdop2SatDtoDfoRef(double tarFreqUpMHz, double refFreqUpMHz, double mainSatTransMHz, double adjaSatTransMHz, double[] recLonLat, double[] refLonLat, string mainTle, string adjaTle, DateTime time, double dtousErr = 1, double dfoHzErr = 1, double satLocErr = 10000)
  182. {
  183. if (string.IsNullOrWhiteSpace(exePath))
  184. throw new Exception($"请先调用SetExePath指定{exeName}进程所在路径,支持相对路径");
  185. if (!Directory.Exists(exePath))
  186. throw new Exception($"路径[{exePath}]不存在");
  187. var exeFile = Path.Combine(exePath, exeName);
  188. if (!File.Exists(exeFile))
  189. throw new Exception($"文件[{exeFile}]不存在");
  190. Process p = new Process();
  191. p.StartInfo.WorkingDirectory = exePath;
  192. p.StartInfo.FileName = exeFile;
  193. p.StartInfo.Arguments = $"64 \"{mainTle}\" \"{adjaTle}\" \"{time:yyyy-MM-dd HH:mm:ss.000000}\" {string.Join(" ", recLonLat)} {string.Join(" ", refLonLat)} {tarFreqUpMHz} {refFreqUpMHz} {mainSatTransMHz} {adjaSatTransMHz} {dtousErr} {dfoHzErr} {satLocErr}";
  194. p.StartInfo.CreateNoWindow = true;
  195. p.StartInfo.RedirectStandardError = true;
  196. p.StartInfo.RedirectStandardOutput = true;
  197. p.StartInfo.UseShellExecute = false;
  198. StringBuilder sb = new StringBuilder();
  199. p.OutputDataReceived += (sender, e) => sb.Append(e.Data);
  200. p.Start();
  201. p.BeginOutputReadLine();
  202. p.WaitForExit();//WaitForExit加了超时时间的话进程退出后不能保证异步流已经读取完成,这是.NET框架的BUG
  203. return ParseResult(2, sb.ToString());
  204. }
  205. /// <summary>
  206. /// 双星时频差GDOP误差分布带参
  207. /// </summary>
  208. /// <param name="tarFreqUpMHz">目标上行频点MHz</param>
  209. /// <param name="refFreqUpMHz">参考上行频点MHz</param>
  210. /// <param name="mainSatTransMHz">主星转发器本振MHz</param>
  211. /// <param name="adjaSatTransMHz">邻星转发器本振MHz</param>
  212. /// <param name="recLonLat">接收站经纬度,数组长度=2</param>
  213. /// <param name="refLonLat">参考站经纬度,数组长度=2</param>
  214. /// <param name="mainSatEph">主星星历xyz vx vy vz,数组长度=6</param>
  215. /// <param name="adjaSatEph">邻星星历xyz vx vy vz,数组长度=6</param>
  216. /// <param name="dtousErr">时差误差(单位us)</param>
  217. /// <param name="dfoHzErr">频差误差(单位Hz)</param>
  218. /// <param name="satLocErr">星历位置误差(单位米)</param>
  219. /// <returns></returns>
  220. public static (List<SatInfo>, List<ErrDistanceMapLines>) Gdop2SatDtoDfoRef(double tarFreqUpMHz, double refFreqUpMHz, double mainSatTransMHz, double adjaSatTransMHz, double[] recLonLat, double[] refLonLat, double[] mainSatEph, double[] adjaSatEph, double dtousErr = 1, double dfoHzErr = 1, double satLocErr = 10000)
  221. {
  222. if (string.IsNullOrWhiteSpace(exePath))
  223. throw new Exception($"请先调用SetExePath指定{exeName}进程所在路径,支持相对路径");
  224. if (!Directory.Exists(exePath))
  225. throw new Exception($"路径[{exePath}]不存在");
  226. var exeFile = Path.Combine(exePath, exeName);
  227. if (!File.Exists(exeFile))
  228. throw new Exception($"文件[{exeFile}]不存在");
  229. Process p = new Process();
  230. p.StartInfo.WorkingDirectory = exePath;
  231. p.StartInfo.FileName = exeFile;
  232. p.StartInfo.Arguments = $"65 {string.Join(" ", mainSatEph)} {string.Join(" ", adjaSatEph)} {string.Join(" ", recLonLat)} {string.Join(" ", refLonLat)} {tarFreqUpMHz} {refFreqUpMHz} {mainSatTransMHz} {adjaSatTransMHz} {dtousErr} {dfoHzErr} {satLocErr}";
  233. p.StartInfo.CreateNoWindow = true;
  234. p.StartInfo.RedirectStandardError = true;
  235. p.StartInfo.RedirectStandardOutput = true;
  236. p.StartInfo.UseShellExecute = false;
  237. StringBuilder sb = new StringBuilder();
  238. p.OutputDataReceived += (sender, e) => sb.Append(e.Data);
  239. p.Start();
  240. p.BeginOutputReadLine();
  241. p.WaitForExit();//WaitForExit加了超时时间的话进程退出后不能保证异步流已经读取完成,这是.NET框架的BUG
  242. return ParseResult(2, sb.ToString());
  243. }
  244. /// <summary>
  245. /// 双星时频差GDOP误差分布无参
  246. /// </summary>
  247. /// <param name="tarFreqUpMHz">目标上行频点MHz</param>
  248. /// <param name="refFreqUpMHz">参考上行频点MHz</param>
  249. /// <param name="mainSatTransMHz">主星转发器本振MHz</param>
  250. /// <param name="adjaSatTransMHz">邻星转发器本振MHz</param>
  251. /// <param name="recLonLat">接收站经纬度,数组长度=2</param>
  252. /// <param name="refLonLat">参考站经纬度,数组长度=2</param>
  253. /// <param name="mainTle">主星双行根数</param>
  254. /// <param name="adjaTle">邻星双行根数</param>
  255. /// <param name="time">采集时刻</param>
  256. /// <param name="dtousErr">时差误差(单位us)</param>
  257. /// <param name="dfoHzErr">频差误差(单位Hz)</param>
  258. /// <param name="satLocErr">星历位置误差(单位米)</param>
  259. /// <returns></returns>
  260. public static (List<SatInfo>, List<ErrDistanceMapLines>) Gdop2SatDtoDfo(double tarFreqUpMHz, double mainSatTransMHz, double adjaSatTransMHz, double[] recLonLat, string mainTle, string adjaTle, DateTime time, double dtousErr = 1, double dfoHzErr = 1, double satLocErr = 10000)
  261. {
  262. if (string.IsNullOrWhiteSpace(exePath))
  263. throw new Exception($"请先调用SetExePath指定{exeName}进程所在路径,支持相对路径");
  264. if (!Directory.Exists(exePath))
  265. throw new Exception($"路径[{exePath}]不存在");
  266. var exeFile = Path.Combine(exePath, exeName);
  267. if (!File.Exists(exeFile))
  268. throw new Exception($"文件[{exeFile}]不存在");
  269. Process p = new Process();
  270. p.StartInfo.WorkingDirectory = exePath;
  271. p.StartInfo.FileName = exeFile;
  272. p.StartInfo.Arguments = $"66 \"{mainTle}\" \"{adjaTle}\" \"{time:yyyy-MM-dd HH:mm:ss.000000}\" {string.Join(" ", recLonLat)} {tarFreqUpMHz} {mainSatTransMHz} {adjaSatTransMHz} {dtousErr} {dfoHzErr} {satLocErr}";
  273. p.StartInfo.CreateNoWindow = true;
  274. p.StartInfo.RedirectStandardError = true;
  275. p.StartInfo.RedirectStandardOutput = true;
  276. p.StartInfo.UseShellExecute = false;
  277. StringBuilder sb = new StringBuilder();
  278. p.OutputDataReceived += (sender, e) => sb.Append(e.Data);
  279. p.Start();
  280. p.BeginOutputReadLine();
  281. p.WaitForExit();//WaitForExit加了超时时间的话进程退出后不能保证异步流已经读取完成,这是.NET框架的BUG
  282. return ParseResult(2, sb.ToString());
  283. }
  284. /// <summary>
  285. /// 双星时频差GDOP误差分布无参
  286. /// </summary>
  287. /// <param name="tarFreqUpMHz">目标上行频点MHz</param>
  288. /// <param name="refFreqUpMHz">参考上行频点MHz</param>
  289. /// <param name="mainSatTransMHz">主星转发器本振MHz</param>
  290. /// <param name="adjaSatTransMHz">邻星转发器本振MHz</param>
  291. /// <param name="recLonLat">接收站经纬度,数组长度=2</param>
  292. /// <param name="refLonLat">参考站经纬度,数组长度=2</param>
  293. /// <param name="mainSatEph">主星星历xyz vx vy vz,数组长度=6</param>
  294. /// <param name="adjaSatEph">邻星星历xyz vx vy vz,数组长度=6</param>
  295. /// <param name="dtousErr">时差误差(单位us)</param>
  296. /// <param name="dfoHzErr">频差误差(单位Hz)</param>
  297. /// <param name="satLocErr">星历位置误差(单位米)</param>
  298. /// <returns></returns>
  299. public static (List<SatInfo>, List<ErrDistanceMapLines>) Gdop2SatDtoDfo(double tarFreqUpMHz, double mainSatTransMHz, double adjaSatTransMHz, double[] recLonLat, double[] mainSatEph, double[] adjaSatEph, double dtousErr = 1, double dfoHzErr = 1, double satLocErr = 10000)
  300. {
  301. if (string.IsNullOrWhiteSpace(exePath))
  302. throw new Exception($"请先调用SetExePath指定{exeName}进程所在路径,支持相对路径");
  303. if (!Directory.Exists(exePath))
  304. throw new Exception($"路径[{exePath}]不存在");
  305. var exeFile = Path.Combine(exePath, exeName);
  306. if (!File.Exists(exeFile))
  307. throw new Exception($"文件[{exeFile}]不存在");
  308. Process p = new Process();
  309. p.StartInfo.WorkingDirectory = exePath;
  310. p.StartInfo.FileName = exeFile;
  311. p.StartInfo.Arguments = $"67 {string.Join(" ", mainSatEph)} {string.Join(" ", adjaSatEph)} {string.Join(" ", recLonLat)} {tarFreqUpMHz} {mainSatTransMHz} {adjaSatTransMHz} {dtousErr} {dfoHzErr} {satLocErr}";
  312. p.StartInfo.CreateNoWindow = true;
  313. p.StartInfo.RedirectStandardError = true;
  314. p.StartInfo.RedirectStandardOutput = true;
  315. p.StartInfo.UseShellExecute = false;
  316. StringBuilder sb = new StringBuilder();
  317. p.OutputDataReceived += (sender, e) => sb.Append(e.Data);
  318. p.Start();
  319. p.BeginOutputReadLine();
  320. p.WaitForExit();//WaitForExit加了超时时间的话进程退出后不能保证异步流已经读取完成,这是.NET框架的BUG
  321. return ParseResult(2, sb.ToString());
  322. }
  323. /// <summary>
  324. /// 两星一地GDOP带参
  325. /// </summary>
  326. /// <param name="cdbLonLat">超短波天线经纬度,数组长度=2</param>
  327. /// <param name="refLonLat">参考站经纬度,数组长度=2</param>
  328. /// <param name="mainTle">主星双行根数</param>
  329. /// <param name="adjaTle">邻星双行根数</param>
  330. /// <param name="time">采集时刻</param>
  331. /// <param name="dtousErr">时差误差(单位us)</param>
  332. /// <param name="satLocErr">星历位置误差(单位米)</param>
  333. /// <returns></returns>
  334. public static (List<SatInfo>, List<ErrDistanceMapLines>) Gdop2Sat1DRef(double[] cdbLonLat, double[] refLonLat, string mainTle, string adjaTle, DateTime time, double dtousErr = 1, double satLocErr = 10000)
  335. {
  336. if (string.IsNullOrWhiteSpace(exePath))
  337. throw new Exception($"请先调用SetExePath指定{exeName}进程所在路径,支持相对路径");
  338. if (!Directory.Exists(exePath))
  339. throw new Exception($"路径[{exePath}]不存在");
  340. var exeFile = Path.Combine(exePath, exeName);
  341. if (!File.Exists(exeFile))
  342. throw new Exception($"文件[{exeFile}]不存在");
  343. Process p = new Process();
  344. p.StartInfo.WorkingDirectory = exePath;
  345. p.StartInfo.FileName = exeFile;
  346. p.StartInfo.Arguments = $"68 \"{mainTle}\" \"{adjaTle}\" \"{time:yyyy-MM-dd HH:mm:ss.000000}\" {string.Join(" ", cdbLonLat)} {string.Join(" ", refLonLat)} {dtousErr} {satLocErr}";
  347. p.StartInfo.CreateNoWindow = true;
  348. p.StartInfo.RedirectStandardError = true;
  349. p.StartInfo.RedirectStandardOutput = true;
  350. p.StartInfo.UseShellExecute = false;
  351. StringBuilder sb = new StringBuilder();
  352. p.OutputDataReceived += (sender, e) => sb.Append(e.Data);
  353. p.Start();
  354. p.BeginOutputReadLine();
  355. p.WaitForExit();//WaitForExit加了超时时间的话进程退出后不能保证异步流已经读取完成,这是.NET框架的BUG
  356. return ParseResult(2, sb.ToString());
  357. }
  358. /// <summary>
  359. /// 低轨两星GDOP
  360. /// </summary>
  361. /// <param name="refLonLat">参考站位置 长度2</param>
  362. /// <param name="mainTle">主星星历双行根</param>
  363. /// <param name="adjaTle">邻星星历双行根</param>
  364. /// <param name="time">采集时刻</param>
  365. /// <param name="dtousErr">时差误差(us)</param>
  366. /// <param name="dfoHzErr">频差误差(Hz)</param>
  367. /// <param name="ephLocErr">星历位置误差(m)</param>
  368. /// <param name="ephVLocErr">星历速度误差(m/s)</param>
  369. /// <param name="fu1">主星上行频点</param>
  370. /// <param name="fu2">邻星上行频点</param>
  371. /// <returns></returns>
  372. /// <exception cref="Exception"></exception>
  373. public static (List<SatInfo>, List<ErrDistanceMapLines>) GdopLeoTowSatDRef( double[] refLonLat, string mainTle, string adjaTle, DateTime time, double dtousErr,double dfoHzErr, double ephLocErr,double ephVLocErr,double fuHz1,double fuHz2)
  374. {
  375. if (string.IsNullOrWhiteSpace(exePath))
  376. throw new Exception($"请先调用SetExePath指定{exeName}进程所在路径,支持相对路径");
  377. if (!Directory.Exists(exePath))
  378. throw new Exception($"路径[{exePath}]不存在");
  379. var exeFile = Path.Combine(exePath, exeName);
  380. if (!File.Exists(exeFile))
  381. throw new Exception($"文件[{exeFile}]不存在");
  382. Process p = new Process();
  383. p.StartInfo.WorkingDirectory = exePath;
  384. p.StartInfo.FileName = exeFile;
  385. p.StartInfo.Arguments = $"73 \"{mainTle}\" \"{adjaTle}\" \"{time:yyyy-MM-dd HH:mm:ss.000000}\" {string.Join(" ", refLonLat)} {dtousErr} {dfoHzErr} {ephLocErr} {ephVLocErr} {fuHz1} {fuHz2}";
  386. p.StartInfo.CreateNoWindow = true;
  387. p.StartInfo.RedirectStandardError = true;
  388. p.StartInfo.RedirectStandardOutput = true;
  389. p.StartInfo.UseShellExecute = false;
  390. StringBuilder sb = new StringBuilder();
  391. p.OutputDataReceived += (sender, e) => sb.Append(e.Data);
  392. p.Start();
  393. p.BeginOutputReadLine();
  394. p.WaitForExit();//WaitForExit加了超时时间的话进程退出后不能保证异步流已经读取完成,这是.NET框架的BUG
  395. return ParseResult(2, sb.ToString());
  396. }
  397. /// <summary>
  398. /// 单星GDOP
  399. /// </summary>
  400. /// <param name="mainTle">第一刻时刻星历双行根</param>
  401. /// <param name="adjaTle1">第二刻时刻星历双行根</param>
  402. /// <param name="adjaTle2">第三刻时刻星历双行根></param>
  403. /// <param name="time">采集时刻</param>
  404. /// <param name="dfoHzErr">频差误差(Hz)</param>
  405. /// <param name="ephLocErr">星历位置误差(m</param>
  406. /// <param name="ephVLocErr">星历速度误差(m/s)</param>
  407. /// <param name="fuHz">卫星上行频点(Hz)</param>
  408. /// <returns></returns>
  409. /// <exception cref="Exception"></exception>
  410. public static (List<SatInfo>, List<ErrDistanceMapLines>) GdopSingleSatDRef(string mainTle, DateTime time1, DateTime time2, DateTime time3, double dfoHzErr, double ephLocErr, double ephVLocErr, double fuHz)
  411. {
  412. if (string.IsNullOrWhiteSpace(exePath))
  413. throw new Exception($"请先调用SetExePath指定{exeName}进程所在路径,支持相对路径");
  414. if (!Directory.Exists(exePath))
  415. throw new Exception($"路径[{exePath}]不存在");
  416. var exeFile = Path.Combine(exePath, exeName);
  417. if (!File.Exists(exeFile))
  418. throw new Exception($"文件[{exeFile}]不存在");
  419. Process p = new Process();
  420. p.StartInfo.WorkingDirectory = exePath;
  421. p.StartInfo.FileName = exeFile;
  422. p.StartInfo.Arguments = $"74 \"{mainTle}\" \"{time1:yyyy-MM-dd HH:mm:ss.000000}\" \"{time2:yyyy-MM-dd HH:mm:ss.000000}\" \"{time3:yyyy-MM-dd HH:mm:ss.000000}\" {dfoHzErr} {ephLocErr} {ephVLocErr} {fuHz}";
  423. p.StartInfo.CreateNoWindow = true;
  424. p.StartInfo.RedirectStandardError = true;
  425. p.StartInfo.RedirectStandardOutput = true;
  426. p.StartInfo.UseShellExecute = false;
  427. StringBuilder sb = new StringBuilder();
  428. p.OutputDataReceived += (sender, e) => sb.Append(e.Data);
  429. p.Start();
  430. p.BeginOutputReadLine();
  431. p.WaitForExit();//WaitForExit加了超时时间的话进程退出后不能保证异步流已经读取完成,这是.NET框架的BUG
  432. return ParseResult(1, sb.ToString());
  433. }
  434. /// <summary>
  435. /// 两星一地GDOP带参
  436. /// </summary>
  437. /// <param name="cdbLonLat">超短波天线经纬度,数组长度=2</param>
  438. /// <param name="refLonLat">参考站经纬度,数组长度=2</param>
  439. /// <param name="mainSatEph">主星星历xyz,数组长度=3</param>
  440. /// <param name="adjaSatEph">邻星星历xyz,数组长度=3</param>
  441. /// <param name="dtousErr">时差误差(单位us)</param>
  442. /// <param name="satLocErr">星历位置误差(单位米)</param>
  443. /// <returns></returns>
  444. public static (List<SatInfo>, List<ErrDistanceMapLines>) Gdop2Sat1DRef(double[] cdbLonLat, double[] refLonLat, double[] mainSatEph, double[] adjaSatEph, double dtousErr = 1, double satLocErr = 10000)
  445. {
  446. if (string.IsNullOrWhiteSpace(exePath))
  447. throw new Exception($"请先调用SetExePath指定{exeName}进程所在路径,支持相对路径");
  448. if (!Directory.Exists(exePath))
  449. throw new Exception($"路径[{exePath}]不存在");
  450. var exeFile = Path.Combine(exePath, exeName);
  451. if (!File.Exists(exeFile))
  452. throw new Exception($"文件[{exeFile}]不存在");
  453. Process p = new Process();
  454. p.StartInfo.WorkingDirectory = exePath;
  455. p.StartInfo.FileName = exeFile;
  456. p.StartInfo.Arguments = $"69 {string.Join(" ", mainSatEph)} {string.Join(" ", adjaSatEph)} {string.Join(" ", cdbLonLat)} {string.Join(" ", refLonLat)} {dtousErr} {satLocErr}";
  457. p.StartInfo.CreateNoWindow = true;
  458. p.StartInfo.RedirectStandardError = true;
  459. p.StartInfo.RedirectStandardOutput = true;
  460. p.StartInfo.UseShellExecute = false;
  461. StringBuilder sb = new StringBuilder();
  462. p.OutputDataReceived += (sender, e) => sb.Append(e.Data);
  463. p.Start();
  464. p.BeginOutputReadLine();
  465. p.WaitForExit();//WaitForExit加了超时时间的话进程退出后不能保证异步流已经读取完成,这是.NET框架的BUG
  466. return ParseResult(2, sb.ToString());
  467. }
  468. /// <summary>
  469. /// 一星两地GDOP带参
  470. /// </summary>
  471. /// <param name="cdb1LonLat">超短波阵地1天线经纬度,数组长度=2</param>
  472. /// <param name="cdb2LonLat">超短波阵地2天线经纬度,数组长度=2</param>
  473. /// <param name="refLonLat">参考站经纬度,数组长度=2</param>
  474. /// <param name="mainTle">主星双行根数</param>
  475. /// <param name="time">采集时刻</param>
  476. /// <param name="dtousErr">时差误差(单位us)</param>
  477. /// <param name="satLocErr">星历位置误差(单位米)</param>
  478. /// <returns></returns>
  479. public static (List<SatInfo>, List<ErrDistanceMapLines>) Gdop1Sat2DRef(double[] cdb1LonLat, double[] cdb2LonLat, double[] refLonLat, string mainTle, DateTime time, double dtousErr = 1, double satLocErr = 10000)
  480. {
  481. if (string.IsNullOrWhiteSpace(exePath))
  482. throw new Exception($"请先调用SetExePath指定{exeName}进程所在路径,支持相对路径");
  483. if (!Directory.Exists(exePath))
  484. throw new Exception($"路径[{exePath}]不存在");
  485. var exeFile = Path.Combine(exePath, exeName);
  486. if (!File.Exists(exeFile))
  487. throw new Exception($"文件[{exeFile}]不存在");
  488. Process p = new Process();
  489. p.StartInfo.WorkingDirectory = exePath;
  490. p.StartInfo.FileName = exeFile;
  491. p.StartInfo.Arguments = $"70 \"{mainTle}\" \"{time:yyyy-MM-dd HH:mm:ss.000000}\" {string.Join(" ", cdb1LonLat)} {string.Join(" ", cdb2LonLat)} {string.Join(" ", refLonLat)} {dtousErr} {satLocErr}";
  492. p.StartInfo.CreateNoWindow = true;
  493. p.StartInfo.RedirectStandardError = true;
  494. p.StartInfo.RedirectStandardOutput = true;
  495. p.StartInfo.UseShellExecute = false;
  496. StringBuilder sb = new StringBuilder();
  497. p.OutputDataReceived += (sender, e) => sb.Append(e.Data);
  498. p.Start();
  499. p.BeginOutputReadLine();
  500. p.WaitForExit();//WaitForExit加了超时时间的话进程退出后不能保证异步流已经读取完成,这是.NET框架的BUG
  501. return ParseResult(1, sb.ToString());
  502. }
  503. /// <summary>
  504. /// 一星两地GDOP带参
  505. /// </summary>
  506. /// <param name="cdb1LonLat">超短波阵地1天线经纬度,数组长度=2</param>
  507. /// <param name="cdb2LonLat">超短波阵地2天线经纬度,数组长度=2</param>
  508. /// <param name="refLonLat">参考站经纬度,数组长度=2</param>
  509. /// <param name="mainSatEph">主星星历xyz,数组长度=3</param>
  510. /// <param name="dtousErr">时差误差(单位us)</param>
  511. /// <param name="satLocErr">星历位置误差(单位米)</param>
  512. /// <returns></returns>
  513. public static (List<SatInfo>, List<ErrDistanceMapLines>) Gdop1Sat2DRef(double[] cdb1LonLat, double[] cdb2LonLat, double[] refLonLat, double[] mainSatEph, double dtousErr = 1, double satLocErr = 10000)
  514. {
  515. if (string.IsNullOrWhiteSpace(exePath))
  516. throw new Exception($"请先调用SetExePath指定{exeName}进程所在路径,支持相对路径");
  517. if (!Directory.Exists(exePath))
  518. throw new Exception($"路径[{exePath}]不存在");
  519. var exeFile = Path.Combine(exePath, exeName);
  520. if (!File.Exists(exeFile))
  521. throw new Exception($"文件[{exeFile}]不存在");
  522. Process p = new Process();
  523. p.StartInfo.WorkingDirectory = exePath;
  524. p.StartInfo.FileName = exeFile;
  525. p.StartInfo.Arguments = $"71 {string.Join(" ", mainSatEph)} {string.Join(" ", cdb1LonLat)} {string.Join(" ", cdb2LonLat)} {string.Join(" ", refLonLat)} {dtousErr} {satLocErr}";
  526. p.StartInfo.CreateNoWindow = true;
  527. p.StartInfo.RedirectStandardError = true;
  528. p.StartInfo.RedirectStandardOutput = true;
  529. p.StartInfo.UseShellExecute = false;
  530. StringBuilder sb = new StringBuilder();
  531. p.OutputDataReceived += (sender, e) => sb.Append(e.Data);
  532. p.Start();
  533. p.BeginOutputReadLine();
  534. p.WaitForExit();//WaitForExit加了超时时间的话进程退出后不能保证异步流已经读取完成,这是.NET框架的BUG
  535. return ParseResult(1, sb.ToString());
  536. }
  537. /// <summary>
  538. /// 高低轨两高一低GDOP带参
  539. /// </summary>
  540. /// <param name="refLonLat">参考站经纬度,数组长度=2</param>
  541. /// <param name="mainSatEph">主星星历xyz,数组长度=3</param>
  542. /// <param name="adjaSatEph">邻星星历xyz,数组长度=3</param>
  543. /// <param name="lowSatEph">低轨卫星星历xyz,数组长度=3</param>
  544. /// <param name="time">采集时刻</param>
  545. /// <param name="dtousErr">时差误差(单位us)</param>
  546. /// <param name="satLocErr">星历位置误差(单位米)</param>
  547. /// <returns></returns>
  548. public static (List<SatInfo>, List<ErrDistanceMapLines>) Gdop3Sat2High1LowRef(double[] refLonLat, double[] mainSatEph, double[] adjaSatEph, double[] lowSatEph, double dtousErr = 1, double satLocErr = 10000)
  549. {
  550. if (string.IsNullOrWhiteSpace(exePath))
  551. throw new Exception($"请先调用SetExePath指定{exeName}进程所在路径,支持相对路径");
  552. if (!Directory.Exists(exePath))
  553. throw new Exception($"路径[{exePath}]不存在");
  554. var exeFile = Path.Combine(exePath, exeName);
  555. if (!File.Exists(exeFile))
  556. throw new Exception($"文件[{exeFile}]不存在");
  557. Process p = new Process();
  558. p.StartInfo.WorkingDirectory = exePath;
  559. p.StartInfo.FileName = exeFile;
  560. p.StartInfo.Arguments = $"72 {string.Join(" ", mainSatEph)} {string.Join(" ", adjaSatEph)} {string.Join(" ", lowSatEph)} {string.Join(" ", refLonLat)} {dtousErr} {satLocErr}";
  561. p.StartInfo.CreateNoWindow = true;
  562. p.StartInfo.RedirectStandardError = true;
  563. p.StartInfo.RedirectStandardOutput = true;
  564. p.StartInfo.UseShellExecute = false;
  565. StringBuilder sb = new StringBuilder();
  566. p.OutputDataReceived += (sender, e) => sb.Append(e.Data);
  567. p.Start();
  568. p.BeginOutputReadLine();
  569. p.WaitForExit();//WaitForExit加了超时时间的话进程退出后不能保证异步流已经读取完成,这是.NET框架的BUG
  570. return ParseResult(3, sb.ToString());
  571. }
  572. private static (List<SatInfo>, List<ErrDistanceMapLines>) ParseResult(int satCount, string txt)
  573. {
  574. if (string.IsNullOrWhiteSpace(txt))
  575. {
  576. throw new Exception("GDOP计算出现未知错误!");
  577. }
  578. if (txt.StartsWith("1 "))
  579. {
  580. throw new Exception(txt.Remove(0, 2));
  581. }
  582. var arr = txt.Split(' ');
  583. List<SatInfo> list = new List<SatInfo>();
  584. for (int i = 0; i < satCount; i++)
  585. {
  586. SatInfo satInfo = new SatInfo();
  587. var satCode = Convert.ToInt32(arr[3 * i + 1]);
  588. if (satCode > 0)
  589. satInfo.SatCode = satCode;
  590. satInfo.SatLon = Convert.ToDouble(arr[3 * i + 2]);
  591. satInfo.SatLat = Convert.ToDouble(arr[3 * i + 3]);
  592. list.Add(satInfo);
  593. }
  594. var jsonStr = arr[1 + satCount * 3];
  595. var res = JsonConvert.DeserializeObject<List<ErrDistanceMapLines>>(jsonStr);
  596. return (list, res);
  597. }
  598. }
  599. }