Form1.cs 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937
  1. using Newtonsoft.Json;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Net;
  10. using System.Net.Http;
  11. using System.Net.Sockets;
  12. using System.Text;
  13. using System.Threading;
  14. using System.Threading.Tasks;
  15. using System.Windows.Forms;
  16. using XdCxRhDW.Dto;
  17. namespace XdCxRhDW.Sender
  18. {
  19. public partial class Form1 : DevExpress.XtraEditors.XtraForm
  20. {
  21. public Form1()
  22. {
  23. InitializeComponent();
  24. this.IconOptions.SvgImage = DxHelper.SvgHelper.LoadFromFile("Service.svg");
  25. }
  26. CancellationTokenSource cts1;
  27. private async void btn1_Click(object sender, EventArgs e)
  28. {
  29. layoutControlItem1.Enabled = false;
  30. layoutControlItem7.Enabled = false;
  31. if (btn1.Text == "推送")
  32. {
  33. try
  34. {
  35. cts1 = new CancellationTokenSource();
  36. btn1.Text = "停止";
  37. var addrArr = txtAddr1.Text.Trim().Replace(":", ":").Split(":".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  38. string ip = addrArr[0];
  39. int port = Convert.ToInt32(addrArr[1]);
  40. if (txtTskType.EditValue == null)
  41. {
  42. Log($"请选择定位类型");
  43. return;
  44. }
  45. string tskType = txtTskType.EditValue.ToString();
  46. await Task.Run(async () =>
  47. {
  48. //while (true)
  49. //{
  50. // if (cts1.IsCancellationRequested)
  51. // break;
  52. using (var client = new HttpClient())
  53. {
  54. try
  55. {
  56. string url = string.Format("http://{0}:{1}/Api/Pos/", ip, port);
  57. if (tskType == "X1D1CX")//一星一地测向定位
  58. {
  59. var lines = File.ReadAllLines("Simulation_Data2023.dat");
  60. int idx = 1;
  61. url += "PosX1D1Async";
  62. foreach (var line in lines)
  63. {
  64. if (cts1.IsCancellationRequested) break;
  65. if (string.IsNullOrWhiteSpace(line)) continue;
  66. var items = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  67. CheckResDto checkResDto = new CheckResDto()
  68. {
  69. UserName = "UserName",
  70. FileName = "FileName",
  71. SmpStart = 1,
  72. SmpCount = 2,
  73. ModType = "ModType",
  74. PosCheckType = EnumPosCheckTypeDto.Ky5758,
  75. ModRate = null
  76. };
  77. X1D1PosDto dto = new X1D1PosDto()
  78. {
  79. SigTime = DateTime.Now,
  80. MainCode = 23467,
  81. XdDto = Convert.ToDouble(items[1]) * 1e6,
  82. MainYbDto = Convert.ToDouble(items[2]) * 1e6,
  83. CxRes = Convert.ToDouble(items[4]),
  84. MainX = Convert.ToDouble(items[7]),
  85. MainY = Convert.ToDouble(items[8]),
  86. MainZ = Convert.ToDouble(items[9]),
  87. FreqDown = 295.425e6,//For Api Test
  88. FreqUp = 260.425e6,//For Api Test
  89. XdDfo = 1529,//For Api Test
  90. XdSnr = 25,//For Api Test
  91. SatTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lon"),
  92. SatTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lat"),
  93. CdbTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lon"),
  94. CdbTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lat"),
  95. CxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lon"),
  96. CxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lat"),
  97. RefLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lon"),
  98. RefLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lat"),
  99. CheckRes = checkResDto,
  100. };
  101. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, dto);
  102. if (result.code != 200)
  103. {
  104. Log($"{result.msg}");
  105. return;
  106. }
  107. //Thread.Sleep(1000);
  108. Log($"已向[{txtAddr1.Text}]发送第{idx++}条仿真结果");
  109. }
  110. }
  111. if (tskType == "X2D1")//两星一地定位
  112. {
  113. var lines = File.ReadAllLines("Simulation_Data2023.dat");
  114. int idx = 1;
  115. url += "PosX2D1Async";
  116. foreach (var line in lines)
  117. {
  118. if (cts1.IsCancellationRequested) break;
  119. if (string.IsNullOrWhiteSpace(line)) continue;
  120. var items = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  121. X2D1PosDto X2D1PosDto = new X2D1PosDto()
  122. {
  123. SigTime = DateTime.Now,
  124. MainCode = 23467,
  125. AdjaCode = 39206,
  126. FreqDown = 295.425e6,//For Api Test
  127. FreqUp = 260.425e6,//For Api Test
  128. XdDfo = 1529,//For Api Test
  129. XdSnr = 25,//For Api Test
  130. SxDfo = 1024,//For Api Test
  131. SxSnr = 25,//For Api Test
  132. MainVX = 1,//For Api Test
  133. MainVY = 1,//For Api Test
  134. MainVZ = 1,//For Api Test
  135. AdjaVX = 1,//For Api Test
  136. AdjaVY = 1,//For Api Test
  137. AdjaVZ = 1,//For Api Test
  138. SxDto = Convert.ToDouble(items[0]) * 1e6,
  139. XdDto = Convert.ToDouble(items[1]) * 1e6,
  140. MainYbDto = Convert.ToDouble(items[2]) * 1e6,
  141. AdjaYbDto = Convert.ToDouble(items[3]) * 1e6,
  142. MainX = Convert.ToDouble(items[7]),
  143. MainY = Convert.ToDouble(items[8]),
  144. MainZ = Convert.ToDouble(items[9]),
  145. AdjaX = Convert.ToDouble(items[10]),
  146. AdjaY = Convert.ToDouble(items[11]),
  147. AdjaZ = Convert.ToDouble(items[12]),
  148. SatTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lon"),
  149. SatTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lat"),
  150. CdbTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lon"),
  151. CdbTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lat"),
  152. RefLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lon"),
  153. RefLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lat"),
  154. CalcConfidence = true,
  155. TheoryDfoCalc = true,
  156. };
  157. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, X2D1PosDto);
  158. if (result.code != 200)
  159. {
  160. Log($"{result.msg}");
  161. return;
  162. }
  163. Thread.Sleep(1000);
  164. Log($"已向[{txtAddr1.Text}]发送第{idx++}条仿真结果");
  165. }
  166. }
  167. if (tskType == "X2D1NoPar")//两星一地无参定位
  168. {
  169. url += "PosX2D1NoParAsync";
  170. var res = X2D1NoPar();
  171. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  172. if (result.code != 200)
  173. {
  174. Log($"{result.msg}");
  175. return;
  176. }
  177. Log($"已向[{txtAddr1.Text}]发送两星一地无参定位仿真结果");
  178. }
  179. if (tskType == "RH")//融合定位
  180. {
  181. var lines = File.ReadAllLines("Simulation_Data2023.dat");
  182. int idx = 1;
  183. url += "PosRHAsync";
  184. foreach (var line in lines)
  185. {
  186. if (cts1.IsCancellationRequested) break;
  187. if (string.IsNullOrWhiteSpace(line)) continue;
  188. var items = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  189. RHPosDto RHPosDto = new RHPosDto()
  190. {
  191. SigTime = DateTime.Now,
  192. MainCode = 23467,
  193. AdjaCode = 39206,
  194. SxDto = Convert.ToDouble(items[0]) * 1e6,
  195. XdDto = Convert.ToDouble(items[1]) * 1e6,
  196. MainYbDto = Convert.ToDouble(items[2]) * 1e6,
  197. AdjaYbDto = Convert.ToDouble(items[3]) * 1e6,
  198. CxRes = Convert.ToDouble(items[4]),
  199. MainX = Convert.ToDouble(items[7]),
  200. MainY = Convert.ToDouble(items[8]),
  201. MainZ = Convert.ToDouble(items[9]),
  202. AdjaX = Convert.ToDouble(items[10]),
  203. AdjaY = Convert.ToDouble(items[11]),
  204. AdjaZ = Convert.ToDouble(items[12]),
  205. FreqDown = 295.425e6,//For Api Test
  206. FreqUp = 260.425e6,//For Api Test
  207. XdDfo = 1529,//For Api Test
  208. XdSnr = 25,//For Api Test
  209. SxDfo = 1024,//For Api Test
  210. SxSnr = 25,//For Api Test
  211. SatTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lon"),
  212. SatTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lat"),
  213. CdbTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lon"),
  214. CdbTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lat"),
  215. CxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lon"),
  216. CxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lat"),
  217. RefLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lon"),
  218. RefLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lat"),
  219. };
  220. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, RHPosDto);
  221. if (result.code != 200)
  222. {
  223. Log($"{result.msg}");
  224. return;
  225. }
  226. Thread.Sleep(1000);
  227. Log($"已向[{txtAddr1.Text}]发送第{idx++}条仿真结果");
  228. }
  229. }
  230. if (tskType == "X3TwoDto")//三星双时差定位
  231. {
  232. url += "PosX3TwoDtoAsync";
  233. var res = X3TwoDto();
  234. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  235. if (result.code != 200)
  236. {
  237. Log($"{result.msg}");
  238. return;
  239. }
  240. Log($"已向[{txtAddr1.Text}]发送三星双时差定位仿真结果");
  241. }
  242. if (tskType == "X3TwoDtoNoPar")//三星双时差无参定位
  243. {
  244. url += "PosX3TwoDtoNoParAsync";
  245. var res = X3TwoDtoNoPar();
  246. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  247. if (result.code != 200)
  248. {
  249. Log($"{result.msg}");
  250. return;
  251. }
  252. Log($"已向[{txtAddr1.Text}]发送三星双时差定位仿真结果");
  253. }
  254. if (tskType == "X3TwoDfo")//三星双频差定位
  255. {
  256. url += "PosX3TwoDfoAsync";
  257. var res = X3TwoDfo();
  258. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  259. if (result.code != 200)
  260. {
  261. Log($"{result.msg}");
  262. return;
  263. }
  264. Log($"已向[{txtAddr1.Text}]发送三星双频差定位仿真结果");
  265. }
  266. if (tskType == "X2Dfo")//双星时频差定位
  267. {
  268. url += "PosX2DtoDfoAsync";
  269. var res = X2Dfo();
  270. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  271. if (result.code != 200)
  272. {
  273. Log($"{result.msg}");
  274. return;
  275. }
  276. Log($"已向[{txtAddr1.Text}]发送双星时频差定位仿真结果");
  277. }
  278. if (tskType == "X1D1CXNoXL")//一星一地测向定位无星历
  279. {
  280. var lines = File.ReadAllLines("Simulation_Data2023.dat");
  281. int idx = 1;
  282. url += "PosX1D1NoXlAsync";
  283. foreach (var line in lines)
  284. {
  285. if (cts1.IsCancellationRequested) break;
  286. if (string.IsNullOrWhiteSpace(line)) continue;
  287. var items = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  288. X1D1NoXlPosDto dto = new X1D1NoXlPosDto()
  289. {
  290. SigTime = DateTime.Now,
  291. MainCode = 23467,
  292. XdDto = Convert.ToDouble(items[1]) * 1e6,
  293. MainYbDto = Convert.ToDouble(items[2]) * 1e6,
  294. CxRes = Convert.ToDouble(items[4]),
  295. SatTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lon"),
  296. SatTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lat"),
  297. CdbTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lon"),
  298. CdbTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lat"),
  299. CxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lon"),
  300. CxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lat"),
  301. RefLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lon"),
  302. RefLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lat"),
  303. FreqDown = 295.425e6,//For Api Test
  304. FreqUp = 260.425e6,//For Api Test
  305. XdDfo = 1529,//For Api Test
  306. XdSnr = 25,//For Api Test
  307. };
  308. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, dto);
  309. if (result.code != 200)
  310. {
  311. Log($"{result.msg}");
  312. return;
  313. }
  314. Thread.Sleep(1000);
  315. Log($"已向[{txtAddr1.Text}]发送第{idx++}条仿真结果");
  316. }
  317. }
  318. if (tskType == "X2D1NoXL")//两星一地定位无星历
  319. {
  320. var lines = File.ReadAllLines("Simulation_Data2023.dat");
  321. int idx = 1;
  322. url += "PosX2D1NoXlAsync";
  323. foreach (var line in lines)
  324. {
  325. if (cts1.IsCancellationRequested) break;
  326. if (string.IsNullOrWhiteSpace(line)) continue;
  327. var items = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  328. X2D1NoXlPosDto X2D1NoXlPosDto = new X2D1NoXlPosDto()
  329. {
  330. SigTime = DateTime.Now,
  331. MainCode = 23467,
  332. AdjaCode = 39206,
  333. SxDto = Convert.ToDouble(items[0]) * 1e6,
  334. XdDto = Convert.ToDouble(items[1]) * 1e6,
  335. MainYbDto = Convert.ToDouble(items[2]) * 1e6,
  336. AdjaYbDto = Convert.ToDouble(items[3]) * 1e6,
  337. SatTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lon"),
  338. SatTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lat"),
  339. CdbTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lon"),
  340. CdbTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lat"),
  341. RefLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lon"),
  342. RefLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lat"),
  343. FreqDown = 295.425e6,//For Api Test
  344. FreqUp = 260.425e6,//For Api Test
  345. XdDfo = 1529,//For Api Test
  346. XdSnr = 25,//For Api Test
  347. SxDfo = 1024,//For Api Test
  348. SxSnr = 25,//For Api Test
  349. CalcConfidence = true,
  350. TheoryDfoCalc = true,
  351. };
  352. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, X2D1NoXlPosDto);
  353. if (result.code != 200)
  354. {
  355. Log($"{result.msg}");
  356. return;
  357. }
  358. Thread.Sleep(1000);
  359. Log($"已向[{txtAddr1.Text}]发送第{idx++}条仿真结果");
  360. }
  361. }
  362. if (tskType == "X2D1NoParNoXL")//两星一地无参定位无星历
  363. {
  364. url += "PosX2D1NoXlNoParAsync";
  365. var res = X2D1NoParNoXL();
  366. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  367. if (result.code != 200)
  368. {
  369. Log($"{result.msg}");
  370. return;
  371. }
  372. Log($"已向[{txtAddr1.Text}]发送两星一地无参定位仿真结果");
  373. }
  374. if (tskType == "RHNoXL")//融合定位无星历
  375. {
  376. var lines = File.ReadAllLines("Simulation_Data2023.dat");
  377. int idx = 1;
  378. url += "PosRhNoXlAsync";
  379. foreach (var line in lines)
  380. {
  381. if (cts1.IsCancellationRequested) break;
  382. if (string.IsNullOrWhiteSpace(line)) continue;
  383. var items = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  384. RHNoXlPosDto RHNoXlPosDto = new RHNoXlPosDto()
  385. {
  386. SigTime = DateTime.Now,
  387. MainCode = 23467,
  388. AdjaCode = 39206,
  389. SxDto = Convert.ToDouble(items[0]) * 1e6,
  390. XdDto = Convert.ToDouble(items[1]) * 1e6,
  391. MainYbDto = Convert.ToDouble(items[2]) * 1e6,
  392. AdjaYbDto = Convert.ToDouble(items[3]) * 1e6,
  393. CxRes = Convert.ToDouble(items[4]),
  394. SatTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lon"),
  395. SatTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lat"),
  396. CdbTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lon"),
  397. CdbTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lat"),
  398. CxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lon"),
  399. CxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lat"),
  400. RefLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lon"),
  401. RefLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lat"),
  402. FreqDown = 295.425e6,//For Api Test
  403. FreqUp = 260.425e6,//For Api Test
  404. XdDfo = 1529,//For Api Test
  405. XdSnr = 25,//For Api Test
  406. SxDfo = 1024,//For Api Test
  407. SxSnr = 25,//For Api Test
  408. };
  409. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, RHNoXlPosDto);
  410. if (result.code != 200)
  411. {
  412. Log($"{result.msg}");
  413. return;
  414. }
  415. Thread.Sleep(1000);
  416. Log($"已向[{txtAddr1.Text}]发送第{idx++}条仿真结果");
  417. }
  418. }
  419. if (tskType == "X3TwoDtoNoXL")//三星双时差定位无星历
  420. {
  421. url += "PosX3TwoDtoNoXlAsync";
  422. var res = X3TwoDtoNoXL();
  423. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  424. if (result.code != 200)
  425. {
  426. Log($"{result.msg}");
  427. return;
  428. }
  429. Log($"已向[{txtAddr1.Text}]发送三星双时差定位仿真结果");
  430. }
  431. if (tskType == "X3TwoDtoNoParNoXL")//三星双时差无参定位无星历
  432. {
  433. url += "PosX3TwoDtoNoXlNoParAsync";
  434. var res = X3TwoDtoNoParNoXL();
  435. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  436. if (result.code != 200)
  437. {
  438. Log($"{result.msg}");
  439. return;
  440. }
  441. Log($"已向[{txtAddr1.Text}]发送三星双时差定位仿真结果");
  442. }
  443. if (tskType == "X3TwoDfoNoXL")//三星双频差定位无星历
  444. {
  445. url += "PosX3TwoDfoNoXlAsync";
  446. var res = X3TwoDfoNoXL();
  447. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  448. if (result.code != 200)
  449. {
  450. Log($"{result.msg}");
  451. return;
  452. }
  453. Log($"已向[{txtAddr1.Text}]发送三星双频差定位仿真结果");
  454. }
  455. if (tskType == "X2DfoNoXL")//双星时频差定位无星历
  456. {
  457. url += "PosX2DtoDfoNoXlAsync";
  458. var res = X2DfoNoXL();
  459. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  460. if (result.code != 200)
  461. {
  462. Log($"{result.msg}");
  463. return;
  464. }
  465. Log($"已向[{txtAddr1.Text}]发送双星时频差定位仿真结果");
  466. }
  467. }
  468. catch (Exception ex)
  469. {
  470. Log($"向[{txtAddr1.Text}]发送结果失败.{ex.Message}");
  471. }
  472. }
  473. // await Task.Delay(1000);
  474. //}
  475. });
  476. }
  477. catch (Exception ex)
  478. {
  479. Log(ex);
  480. }
  481. finally
  482. {
  483. btn1.Text = "推送";
  484. layoutControlItem1.Enabled = true;
  485. layoutControlItem7.Enabled = true;
  486. }
  487. }
  488. else
  489. {
  490. cts1?.Cancel();
  491. }
  492. }
  493. /// <summary>
  494. /// 两星一地定位无参
  495. /// </summary>
  496. private X2D1NoParPosDto X2D1NoPar()
  497. {
  498. X2D1NoParPosDto X2D1PosDto = new X2D1NoParPosDto()
  499. {
  500. SigTime = DateTime.Now,
  501. MainCode = 25630,
  502. AdjaCode = 33276,
  503. SxDto = -0.002198485309353 * 1e6,
  504. XdDto = 0.245961726007262 * 1e6,
  505. MainX = -38209016,
  506. MainY = 17858458,
  507. MainZ = 13250,
  508. AdjaX = 4750323,
  509. AdjaY = 41902879,
  510. AdjaZ = 50515,
  511. SatTxLon = 118.8833,
  512. SatTxLat = 32.0667,
  513. CdbTxLon = 109.4082,
  514. CdbTxLat = 18.3878,
  515. FreqDown = 252.325e6,//For Api Test
  516. FreqUp = 310.85e6,//For Api Test
  517. XdDfo = 1529,//For Api Test
  518. XdSnr = 25,//For Api Test
  519. SxDfo = 1024,//For Api Test
  520. SxSnr = 25,//For Api Test
  521. MainVX = 1,//For Api Test
  522. MainVY = 1,//For Api Test
  523. MainVZ = 1,//For Api Test
  524. AdjaVX = 1,//For Api Test
  525. AdjaVY = 1,//For Api Test
  526. AdjaVZ = 1,//For Api Test
  527. };
  528. return X2D1PosDto;
  529. }
  530. /// <summary>
  531. /// 两星一地定位无参无星历
  532. /// </summary>
  533. private X2D1NoXlNoParlPosDto X2D1NoParNoXL()
  534. {
  535. X2D1NoXlNoParlPosDto X2D1NoXlNoParlPosDto = new X2D1NoXlNoParlPosDto()
  536. {
  537. SigTime = DateTime.Now,
  538. MainCode = 25630,
  539. AdjaCode = 33276,
  540. SxDto = -0.002198485309353 * 1e6,
  541. XdDto = 0.245961726007262 * 1e6,
  542. SatTxLon = 118.8833,
  543. SatTxLat = 32.0667,
  544. CdbTxLon = 109.4082,
  545. CdbTxLat = 18.3878,
  546. FreqDown = 252.325e6,//For Api Test
  547. FreqUp = 310.85e6,//For Api Test
  548. XdDfo = 1529,//For Api Test
  549. XdSnr = 25,//For Api Test
  550. SxDfo = 1024,//For Api Test
  551. SxSnr = 25,//For Api Test
  552. };
  553. return X2D1NoXlNoParlPosDto;
  554. }
  555. /// <summary>
  556. /// 三星双时差定位
  557. /// </summary>
  558. private X3TwoDtoPosDto X3TwoDto()
  559. {
  560. X3TwoDtoPosDto X3TwoDtoPosDto = new X3TwoDtoPosDto()
  561. {
  562. SigTime = DateTime.Now,
  563. MainCode = 23467,
  564. Adja1Code = 39206,
  565. Adja2Code = 40892,
  566. Dto1 = -0.0037683828 * 1e6,
  567. Dto2 = 0.00411476 * 1e6,
  568. YbMainDto = 0.253339246 * 1e6,
  569. YbAdja1Dto = 0.254082015 * 1e6,
  570. YbAdja2Dto = 0.247747625 * 1e6,
  571. MainX = -38209016,
  572. MainY = 17858458,
  573. MainZ = 13250,
  574. Adja1X = 4750323,
  575. Adja1Y = 41902879,
  576. Adja1Z = 50515,
  577. Adja2X = -30932433,
  578. Adja2Y = 28638701,
  579. Adja2Z = -582065,
  580. SatTxLon = 118.8833,
  581. SatTxLat = 32.0667,
  582. RefLon = 121.538,
  583. RefLat = 30.8385,
  584. FreqDown = 252.325e6,//For Api Test
  585. FreqUp = 310.85e6,//For Api Test
  586. Dfo1 = 1629,//For Api Test
  587. Snr1 = 27.1,//For Api Test
  588. Dfo2 = 1025,//For Api Test
  589. Snr2 = 27.4,//For Api Test
  590. CalcConfidence = true,
  591. };
  592. return X3TwoDtoPosDto;
  593. }
  594. /// <summary>
  595. /// 三星双时差无参定位
  596. /// </summary>
  597. private X3TwoDtoNoParPosDto X3TwoDtoNoPar()
  598. {
  599. X3TwoDtoNoParPosDto X3TwoDtoNoParPosDto = new X3TwoDtoNoParPosDto()
  600. {
  601. SigTime = DateTime.Now,
  602. MainCode = 23467,
  603. Adja1Code = 39206,
  604. Adja2Code = 40892,
  605. Dto1 = -0.008361002956792 * 1e6,
  606. Dto2 = 0.004191941221694 * 1e6,
  607. MainX = -38214804,
  608. MainY = 17780164,
  609. MainZ = -6857,
  610. Adja1X = 4824458,
  611. Adja1Y = 41896265,
  612. Adja1Z = -55899,
  613. Adja2X = -27105105,
  614. Adja2Y = 32302912,
  615. Adja2Z = 11952,
  616. SatTxLon = 121.3555,
  617. SatTxLat = 31.3667,
  618. FreqDown = 252.325e6,//For Api Test
  619. FreqUp = 310.85e6,//For Api Test
  620. Dfo1 = 1629,//For Api Test
  621. Snr1 = 27.1,//For Api Test
  622. Dfo2 = 1025,//For Api Test
  623. Snr2 = 27.4,//For Api Test
  624. MainVX = 1,//For Api Test
  625. MainVY = 1,//For Api Test
  626. MainVZ = 1,//For Api Test
  627. Adja1VX = 1,//For Api Test
  628. Adja1VY = 1,//For Api Test
  629. Adja1VZ = 1,//For Api Test
  630. Adja2VX = 1,//For Api Test
  631. Adja2VY = 1,//For Api Test
  632. Adja2VZ = 1,//For Api Test
  633. };
  634. return X3TwoDtoNoParPosDto;
  635. }
  636. /// <summary>
  637. /// 三星双频差定位
  638. /// </summary>
  639. private X3TwoDfoPosDto X3TwoDfo()
  640. {
  641. X3TwoDfoPosDto X3TwoDfoPosDto = new X3TwoDfoPosDto()
  642. {
  643. SigTime = DateTime.Now,
  644. MainCode = 23467,
  645. Adja1Code = 39206,
  646. Adja2Code = 40892,
  647. Dfo1 = -17.601977254734404,
  648. Dfo2 = -36.885840020369514,
  649. YbMainDfo = 0,
  650. YbAdja1Dfo = 17.453698229247941,
  651. YbAdja2Dfo = 37.022577554138941,
  652. TarFreqUp = 3808 * 1e6 + 2225 * 1e6,
  653. TarFreqDown = 3808 * 1e6,
  654. RefFreqUp = 3796 * 1e6 + 2225 * 1e6,
  655. RefFreqDown = 3796 * 1e6,
  656. MainX = -18149981.873274,
  657. MainY = 38039767.675679,
  658. MainZ = -5662.335149,
  659. MainVx = -2.006064,
  660. MainVy = -1.4693,
  661. MainVz = 1.62569,
  662. Adja1X = -14770224.082665,
  663. Adja1Y = 39479299.786862,
  664. Adja1Z = -53188.063002,
  665. Adja1Vx = -1.764989,
  666. Adja1Vy = -0.528101,
  667. Adja1Vz = 1.808949,
  668. Adja2X = -33231255.13,
  669. Adja2Y = 25948042.76,
  670. Adja2Z = 27091.80,
  671. Adja2Vx = -0.607289,
  672. Adja2Vy = 0.089864,
  673. Adja2Vz = -0.069086,
  674. SatTxLon = 116.254567,
  675. SatTxLat = 39.65955,
  676. RefLon = 106.698,
  677. RefLat = 26.567,
  678. Dto1 = 829.2,//For Api Test
  679. Snr1 = 27.7,//For Api Test
  680. Dto2 = 1928.3,//For Api Test
  681. Snr2 = 27.9,//For Api Test
  682. };
  683. return X3TwoDfoPosDto;
  684. }
  685. /// <summary>
  686. /// 双星时频差定位
  687. /// </summary>
  688. private X2DtoDfoPosDto X2Dfo()
  689. {
  690. X2DtoDfoPosDto X2DtoDfoPosDto = new X2DtoDfoPosDto()
  691. {
  692. SigTime = DateTime.Now,
  693. MainCode = 23467,
  694. AdjaCode = 39206,
  695. Dto = -3.587980198938979e-06 * 1e6,
  696. Dfo = -17.601977254734404,
  697. YbMainDto = 0.26 * 1e6,
  698. YbAdjaDto = 0.25993647195 * 1e6,
  699. YbMainDfo = 0,
  700. YbAdjaDfo = 17.453698229247941,
  701. TarFreqUp = 3808 * 1e6 + 2225 * 1e6,
  702. TarFreqDown = 3808 * 1e6,
  703. RefFreqUp = 3796 * 1e6 + 2225 * 1e6,
  704. RefFreqDown = 3796 * 1e6,
  705. MainX = -18149981.873274,
  706. MainY = 38039767.675679,
  707. MainZ = -5662.335149,
  708. MainVx = -2.006064,
  709. MainVy = -1.4693,
  710. MainVz = 1.62569,
  711. AdjaX = -14770224.082665,
  712. AdjaY = 39479299.786862,
  713. AdjaZ = -53188.063002,
  714. AdjaVx = -1.764989,
  715. AdjaVy = -0.528101,
  716. AdjaVz = 1.808949,
  717. SatTxLon = 116.254567,
  718. SatTxLat = 39.65955,
  719. RefLon = 106.698,
  720. RefLat = 26.567,
  721. Snr = 19.27,//For Api Test
  722. };
  723. return X2DtoDfoPosDto;
  724. }
  725. /// <summary>
  726. /// 三星双时差定位无星历
  727. /// </summary>
  728. private X3TwoDtoNoXlPosDto X3TwoDtoNoXL()
  729. {
  730. X3TwoDtoNoXlPosDto X3TwoDtoNoXlPosDto = new X3TwoDtoNoXlPosDto()
  731. {
  732. SigTime = DateTime.Now,
  733. MainCode = 23467,
  734. Adja1Code = 39206,
  735. Adja2Code = 40892,
  736. Dto1 = -0.0037683828 * 1e6,
  737. Dto2 = 0.00411476 * 1e6,
  738. YbMainDto = 0.253339246 * 1e6,
  739. YbAdja1Dto = 0.254082015 * 1e6,
  740. YbAdja2Dto = 0.247747625 * 1e6,
  741. SatTxLon = 118.8833,
  742. SatTxLat = 32.0667,
  743. RefLon = 121.538,
  744. RefLat = 30.8385,
  745. FreqDown = 252.325e6,//For Api Test
  746. FreqUp = 310.85e6,//For Api Test
  747. Dfo1 = 1629,//For Api Test
  748. Snr1 = 27.1,//For Api Test
  749. Dfo2 = 1025,//For Api Test
  750. Snr2 = 27.4,//For Api Test
  751. CalcConfidence = true,
  752. };
  753. return X3TwoDtoNoXlPosDto;
  754. }
  755. /// <summary>
  756. /// 三星双时差无参定位无星历
  757. /// </summary>
  758. private X3TwoDtoNoXlNoParPosDto X3TwoDtoNoParNoXL()
  759. {
  760. X3TwoDtoNoXlNoParPosDto X3TwoDtoNoParPosDto = new X3TwoDtoNoXlNoParPosDto()
  761. {
  762. SigTime = DateTime.Now,
  763. MainCode = 23467,
  764. Adja1Code = 39206,
  765. Adja2Code = 40892,
  766. Dto1 = -0.008361002956792 * 1e6,
  767. Dto2 = 0.004191941221694 * 1e6,
  768. SatTxLon = 121.3555,
  769. SatTxLat = 31.3667,
  770. FreqDown = 252.325e6,//For Api Test
  771. FreqUp = 310.85e6,//For Api Test
  772. Dfo1 = 1629,//For Api Test
  773. Snr1 = 27.1,//For Api Test
  774. Dfo2 = 1025,//For Api Test
  775. Snr2 = 27.4,//For Api Test
  776. };
  777. return X3TwoDtoNoParPosDto;
  778. }
  779. /// <summary>
  780. /// 三星双频差定位无星历
  781. /// </summary>
  782. private X3TwoDfoNoXlPosDto X3TwoDfoNoXL()
  783. {
  784. X3TwoDfoNoXlPosDto X3TwoDfoNoXlPosDto = new X3TwoDfoNoXlPosDto()
  785. {
  786. SigTime = DateTime.Now,
  787. MainCode = 23467,
  788. Adja1Code = 39206,
  789. Adja2Code = 40892,
  790. Dfo1 = -17.601977254734404,
  791. Dfo2 = -36.885840020369514,
  792. YbMainDfo = 0,
  793. YbAdja1Dfo = 17.453698229247941,
  794. YbAdja2Dfo = 37.022577554138941,
  795. TarFreqUp = 3808 * 1e6 + 2225 * 1e6,
  796. TarFreqDown = 3808 * 1e6,
  797. RefFreqUp = 3796 * 1e6 + 2225 * 1e6,
  798. RefFreqDown = 3796 * 1e6,
  799. SatTxLon = 116.254567,
  800. SatTxLat = 39.65955,
  801. RefLon = 106.698,
  802. RefLat = 26.567,
  803. };
  804. return X3TwoDfoNoXlPosDto;
  805. }
  806. /// <summary>
  807. /// 双星时频差定位无星历
  808. /// </summary>
  809. private X2DtoDfoNoXlPosDto X2DfoNoXL()
  810. {
  811. X2DtoDfoNoXlPosDto X2DtoDfoNoXlPosDto = new X2DtoDfoNoXlPosDto()
  812. {
  813. SigTime = DateTime.Now,
  814. MainCode = 23467,
  815. AdjaCode = 39206,
  816. Dto = -3.587980198938979e-06 * 1e6,
  817. Dfo = -17.601977254734404,
  818. YbMainDto = 0.26 * 1e6,
  819. YbAdjaDto = 0.25993647195 * 1e6,
  820. YbMainDfo = 0,
  821. YbAdjaDfo = 17.453698229247941,
  822. TarFreqUp = 3808 * 1e6 + 2225 * 1e6,
  823. TarFreqDown = 3808 * 1e6,
  824. RefFreqUp = 3796 * 1e6 + 2225 * 1e6,
  825. RefFreqDown = 3796 * 1e6,
  826. SatTxLon = 116.254567,
  827. SatTxLat = 39.65955,
  828. RefLon = 106.698,
  829. RefLat = 26.567,
  830. Snr = 20 + new Random().Next(-5, 15)
  831. };
  832. return X2DtoDfoNoXlPosDto;
  833. }
  834. private void Log(string msg)
  835. {
  836. try
  837. {
  838. if (this.InvokeRequired)
  839. {
  840. this.Invoke(new Action(() =>
  841. {
  842. if (listBoxControl1.ItemCount > 5000)
  843. listBoxControl1.Items.Clear();
  844. listBoxControl1.Items.Insert(0, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}--{msg}");
  845. listBoxControl1.SelectedIndex = 0;
  846. }));
  847. }
  848. else
  849. {
  850. if (listBoxControl1.ItemCount > 5000)
  851. listBoxControl1.Items.Clear();
  852. listBoxControl1.Items.Insert(0, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}--{msg}");
  853. listBoxControl1.SelectedIndex = 0;
  854. }
  855. }
  856. catch
  857. { }
  858. }
  859. private void Log(Exception ex)
  860. {
  861. try
  862. {
  863. if (this.InvokeRequired)
  864. {
  865. this.Invoke(new Action(() =>
  866. {
  867. if (listBoxControl1.ItemCount > 5000)
  868. listBoxControl1.Items.Clear();
  869. listBoxControl1.Items.Insert(0, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}--{ex.Message}");
  870. listBoxControl1.SelectedIndex = 0;
  871. }));
  872. }
  873. else
  874. {
  875. if (listBoxControl1.ItemCount > 5000)
  876. listBoxControl1.Items.Clear();
  877. listBoxControl1.Items.Insert(0, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}--{ex.Message}");
  878. listBoxControl1.SelectedIndex = 0;
  879. }
  880. }
  881. catch
  882. { }
  883. }
  884. private void listBoxControl1_MouseClick(object sender, MouseEventArgs e)
  885. {
  886. if (e.Button == MouseButtons.Right)
  887. {
  888. popupMenu1.ShowPopup(MousePosition);
  889. }
  890. }
  891. private void btnClear_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
  892. {
  893. listBoxControl1.Items.Clear();
  894. }
  895. private void btnCopyAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
  896. {
  897. StringBuilder sb = new StringBuilder();
  898. foreach (var item in listBoxControl1.Items)
  899. {
  900. sb.AppendLine(item.ToString());
  901. }
  902. var data = sb.ToString();
  903. if (string.IsNullOrWhiteSpace(data)) return;
  904. Clipboard.SetText(sb.ToString());
  905. }
  906. }
  907. }