Form1.cs 49 KB

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