Form1.cs 49 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. };
  155. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, X2D1PosDto);
  156. if (result.code != 200)
  157. {
  158. Log($"{result.msg}");
  159. return;
  160. }
  161. Thread.Sleep(1000);
  162. Log($"已向[{txtAddr1.Text}]发送第{idx++}条仿真结果");
  163. }
  164. }
  165. if (tskType == "X2D1NoPar")//两星一地无参定位
  166. {
  167. url += "PosX2D1NoParAsync";
  168. var res = X2D1NoPar();
  169. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  170. if (result.code != 200)
  171. {
  172. Log($"{result.msg}");
  173. return;
  174. }
  175. Log($"已向[{txtAddr1.Text}]发送两星一地无参定位仿真结果");
  176. }
  177. if (tskType == "RH")//融合定位
  178. {
  179. var lines = File.ReadAllLines("Simulation_Data2023.dat");
  180. int idx = 1;
  181. url += "PosRHAsync";
  182. foreach (var line in lines)
  183. {
  184. if (cts1.IsCancellationRequested) break;
  185. if (string.IsNullOrWhiteSpace(line)) continue;
  186. var items = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  187. RHPosDto RHPosDto = new RHPosDto()
  188. {
  189. SigTime = DateTime.Now,
  190. MainCode = 23467,
  191. AdjaCode = 39206,
  192. SxDto = Convert.ToDouble(items[0]) * 1e6,
  193. XdDto = Convert.ToDouble(items[1]) * 1e6,
  194. MainYbDto = Convert.ToDouble(items[2]) * 1e6,
  195. AdjaYbDto = Convert.ToDouble(items[3]) * 1e6,
  196. CxRes = Convert.ToDouble(items[4]),
  197. MainX = Convert.ToDouble(items[7]),
  198. MainY = Convert.ToDouble(items[8]),
  199. MainZ = Convert.ToDouble(items[9]),
  200. AdjaX = Convert.ToDouble(items[10]),
  201. AdjaY = Convert.ToDouble(items[11]),
  202. AdjaZ = Convert.ToDouble(items[12]),
  203. FreqDown = 295.425e6,//For Api Test
  204. FreqUp = 260.425e6,//For Api Test
  205. XdDfo = 1529,//For Api Test
  206. XdSnr = 25,//For Api Test
  207. SxDfo = 1024,//For Api Test
  208. SxSnr = 25,//For Api Test
  209. SatTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lon"),
  210. SatTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lat"),
  211. CdbTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lon"),
  212. CdbTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lat"),
  213. CxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lon"),
  214. CxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lat"),
  215. RefLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lon"),
  216. RefLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lat"),
  217. };
  218. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, RHPosDto);
  219. if (result.code != 200)
  220. {
  221. Log($"{result.msg}");
  222. return;
  223. }
  224. Thread.Sleep(1000);
  225. Log($"已向[{txtAddr1.Text}]发送第{idx++}条仿真结果");
  226. }
  227. }
  228. if (tskType == "X3TwoDto")//三星双时差定位
  229. {
  230. url += "PosX3TwoDtoAsync";
  231. var res = X3TwoDto();
  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 == "X3TwoDtoNoPar")//三星双时差无参定位
  241. {
  242. url += "PosX3TwoDtoNoParAsync";
  243. var res = X3TwoDtoNoPar();
  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 == "X3TwoDfo")//三星双频差定位
  253. {
  254. url += "PosX3TwoDfoAsync";
  255. var res = X3TwoDfo();
  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 == "X2Dfo")//双星时频差定位
  265. {
  266. url += "PosX2DtoDfoAsync";
  267. var res = X2Dfo();
  268. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  269. if (result.code != 200)
  270. {
  271. Log($"{result.msg}");
  272. return;
  273. }
  274. Log($"已向[{txtAddr1.Text}]发送双星时频差定位仿真结果");
  275. }
  276. if (tskType == "X1D1CXNoXL")//一星一地测向定位无星历
  277. {
  278. var lines = File.ReadAllLines("Simulation_Data2023.dat");
  279. int idx = 1;
  280. url += "PosX1D1NoXlAsync";
  281. foreach (var line in lines)
  282. {
  283. if (cts1.IsCancellationRequested) break;
  284. if (string.IsNullOrWhiteSpace(line)) continue;
  285. var items = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  286. X1D1NoXlPosDto dto = new X1D1NoXlPosDto()
  287. {
  288. SigTime = DateTime.Now,
  289. MainCode = 23467,
  290. XdDto = Convert.ToDouble(items[1]) * 1e6,
  291. MainYbDto = Convert.ToDouble(items[2]) * 1e6,
  292. CxRes = Convert.ToDouble(items[4]),
  293. SatTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lon"),
  294. SatTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lat"),
  295. CdbTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lon"),
  296. CdbTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lat"),
  297. CxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lon"),
  298. CxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lat"),
  299. RefLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lon"),
  300. RefLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lat"),
  301. FreqDown = 295.425e6,//For Api Test
  302. FreqUp = 260.425e6,//For Api Test
  303. XdDfo = 1529,//For Api Test
  304. XdSnr = 25,//For Api Test
  305. };
  306. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, dto);
  307. if (result.code != 200)
  308. {
  309. Log($"{result.msg}");
  310. return;
  311. }
  312. Thread.Sleep(1000);
  313. Log($"已向[{txtAddr1.Text}]发送第{idx++}条仿真结果");
  314. }
  315. }
  316. if (tskType == "X2D1NoXL")//两星一地定位无星历
  317. {
  318. var lines = File.ReadAllLines("Simulation_Data2023.dat");
  319. int idx = 1;
  320. url += "PosX2D1NoXlAsync";
  321. foreach (var line in lines)
  322. {
  323. if (cts1.IsCancellationRequested) break;
  324. if (string.IsNullOrWhiteSpace(line)) continue;
  325. var items = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  326. X2D1NoXlPosDto X2D1NoXlPosDto = new X2D1NoXlPosDto()
  327. {
  328. SigTime = DateTime.Now,
  329. MainCode = 23467,
  330. AdjaCode = 39206,
  331. SxDto = Convert.ToDouble(items[0]) * 1e6,
  332. XdDto = Convert.ToDouble(items[1]) * 1e6,
  333. MainYbDto = Convert.ToDouble(items[2]) * 1e6,
  334. AdjaYbDto = Convert.ToDouble(items[3]) * 1e6,
  335. SatTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lon"),
  336. SatTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lat"),
  337. CdbTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lon"),
  338. CdbTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lat"),
  339. RefLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lon"),
  340. RefLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lat"),
  341. FreqDown = 295.425e6,//For Api Test
  342. FreqUp = 260.425e6,//For Api Test
  343. XdDfo = 1529,//For Api Test
  344. XdSnr = 25,//For Api Test
  345. SxDfo = 1024,//For Api Test
  346. SxSnr = 25,//For Api Test
  347. };
  348. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, X2D1NoXlPosDto);
  349. if (result.code != 200)
  350. {
  351. Log($"{result.msg}");
  352. return;
  353. }
  354. Thread.Sleep(1000);
  355. Log($"已向[{txtAddr1.Text}]发送第{idx++}条仿真结果");
  356. }
  357. }
  358. if (tskType == "X2D1NoParNoXL")//两星一地无参定位无星历
  359. {
  360. url += "PosX2D1NoXlNoParAsync";
  361. var res = X2D1NoParNoXL();
  362. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  363. if (result.code != 200)
  364. {
  365. Log($"{result.msg}");
  366. return;
  367. }
  368. Log($"已向[{txtAddr1.Text}]发送两星一地无参定位仿真结果");
  369. }
  370. if (tskType == "RHNoXL")//融合定位无星历
  371. {
  372. var lines = File.ReadAllLines("Simulation_Data2023.dat");
  373. int idx = 1;
  374. url += "PosRhNoXlAsync";
  375. foreach (var line in lines)
  376. {
  377. if (cts1.IsCancellationRequested) break;
  378. if (string.IsNullOrWhiteSpace(line)) continue;
  379. var items = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  380. RHNoXlPosDto RHNoXlPosDto = new RHNoXlPosDto()
  381. {
  382. SigTime = DateTime.Now,
  383. MainCode = 23467,
  384. AdjaCode = 39206,
  385. SxDto = Convert.ToDouble(items[0]) * 1e6,
  386. XdDto = Convert.ToDouble(items[1]) * 1e6,
  387. MainYbDto = Convert.ToDouble(items[2]) * 1e6,
  388. AdjaYbDto = Convert.ToDouble(items[3]) * 1e6,
  389. CxRes = Convert.ToDouble(items[4]),
  390. SatTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lon"),
  391. SatTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lat"),
  392. CdbTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lon"),
  393. CdbTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lat"),
  394. CxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lon"),
  395. CxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lat"),
  396. RefLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lon"),
  397. RefLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lat"),
  398. FreqDown = 295.425e6,//For Api Test
  399. FreqUp = 260.425e6,//For Api Test
  400. XdDfo = 1529,//For Api Test
  401. XdSnr = 25,//For Api Test
  402. SxDfo = 1024,//For Api Test
  403. SxSnr = 25,//For Api Test
  404. };
  405. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, RHNoXlPosDto);
  406. if (result.code != 200)
  407. {
  408. Log($"{result.msg}");
  409. return;
  410. }
  411. Thread.Sleep(1000);
  412. Log($"已向[{txtAddr1.Text}]发送第{idx++}条仿真结果");
  413. }
  414. }
  415. if (tskType == "X3TwoDtoNoXL")//三星双时差定位无星历
  416. {
  417. url += "PosX3TwoDtoNoXlAsync";
  418. var res = X3TwoDtoNoXL();
  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 == "X3TwoDtoNoParNoXL")//三星双时差无参定位无星历
  428. {
  429. url += "PosX3TwoDtoNoXlNoParAsync";
  430. var res = X3TwoDtoNoParNoXL();
  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 == "X3TwoDfoNoXL")//三星双频差定位无星历
  440. {
  441. url += "PosX3TwoDfoNoXlAsync";
  442. var res = X3TwoDfoNoXL();
  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. if (tskType == "X2DfoNoXL")//双星时频差定位无星历
  452. {
  453. url += "PosX2DtoDfoNoXlAsync";
  454. var res = X2DfoNoXL();
  455. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  456. if (result.code != 200)
  457. {
  458. Log($"{result.msg}");
  459. return;
  460. }
  461. Log($"已向[{txtAddr1.Text}]发送双星时频差定位仿真结果");
  462. }
  463. }
  464. catch (Exception ex)
  465. {
  466. Log($"向[{txtAddr1.Text}]发送结果失败.{ex.Message}");
  467. }
  468. }
  469. // await Task.Delay(1000);
  470. //}
  471. });
  472. }
  473. catch (Exception ex)
  474. {
  475. Log(ex);
  476. }
  477. finally
  478. {
  479. btn1.Text = "推送";
  480. layoutControlItem1.Enabled = true;
  481. layoutControlItem7.Enabled = true;
  482. }
  483. }
  484. else
  485. {
  486. cts1?.Cancel();
  487. }
  488. }
  489. /// <summary>
  490. /// 两星一地定位
  491. /// </summary>
  492. /// <returns></returns>
  493. private X2D1PosDto X2D1()
  494. {
  495. X2D1PosDto X2D1PosDto = new X2D1PosDto();
  496. X2D1PosDto.SigTime = DateTime.Now;
  497. X2D1PosDto.MainCode = 23467;
  498. X2D1PosDto.AdjaCode = 39206;
  499. X2D1PosDto.SxDto = 5507.5653;
  500. X2D1PosDto.XdDto = 240292.558;
  501. X2D1PosDto.MainYbDto = 0;
  502. X2D1PosDto.AdjaYbDto = 0;
  503. X2D1PosDto.MainX = 0;
  504. X2D1PosDto.MainY = 0;
  505. X2D1PosDto.MainZ = 0;
  506. X2D1PosDto.AdjaX = 0;
  507. X2D1PosDto.AdjaY = 0;
  508. X2D1PosDto.AdjaZ = 0;
  509. X2D1PosDto.SatTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lon");
  510. X2D1PosDto.SatTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lat");
  511. X2D1PosDto.CdbTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lon");
  512. X2D1PosDto.CdbTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lat");
  513. X2D1PosDto.RefLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lon");
  514. X2D1PosDto.RefLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lat");
  515. return X2D1PosDto;
  516. }
  517. /// <summary>
  518. /// 两星一地定位无参
  519. /// </summary>
  520. private X2D1NoParPosDto X2D1NoPar()
  521. {
  522. X2D1NoParPosDto X2D1PosDto = new X2D1NoParPosDto()
  523. {
  524. SigTime = DateTime.Now,
  525. MainCode = 25630,
  526. AdjaCode = 33276,
  527. SxDto = -0.002198485309353 * 1e6,
  528. XdDto = 0.245961726007262 * 1e6,
  529. MainX = -38209016,
  530. MainY = 17858458,
  531. MainZ = 13250,
  532. AdjaX = 4750323,
  533. AdjaY = 41902879,
  534. AdjaZ = 50515,
  535. SatTxLon = 118.8833,
  536. SatTxLat = 32.0667,
  537. CdbTxLon = 109.4082,
  538. CdbTxLat = 18.3878,
  539. FreqDown = 295.425e6,//For Api Test
  540. FreqUp = 260.425e6,//For Api Test
  541. XdDfo = 1529,//For Api Test
  542. XdSnr = 25,//For Api Test
  543. SxDfo = 1024,//For Api Test
  544. SxSnr = 25,//For Api Test
  545. MainVX = 1,//For Api Test
  546. MainVY = 1,//For Api Test
  547. MainVZ = 1,//For Api Test
  548. AdjaVX = 1,//For Api Test
  549. AdjaVY = 1,//For Api Test
  550. AdjaVZ = 1,//For Api Test
  551. };
  552. return X2D1PosDto;
  553. }
  554. /// <summary>
  555. /// 三星双时差定位
  556. /// </summary>
  557. private X3TwoDtoPosDto X3TwoDto()
  558. {
  559. X3TwoDtoPosDto X3TwoDtoPosDto = new X3TwoDtoPosDto()
  560. {
  561. SigTime = DateTime.Now,
  562. MainCode = 23467,
  563. Adja1Code = 39206,
  564. Adja2Code = 40892,
  565. Dto1 = -0.0037683828 * 1e6,
  566. Dto2 = 0.00411476 * 1e6,
  567. YbMainDto = 0.253339246 * 1e6,
  568. YbAdja1Dto = 0.254082015 * 1e6,
  569. YbAdja2Dto = 0.247747625 * 1e6,
  570. MainX = -38209016,
  571. MainY = 17858458,
  572. MainZ = 13250,
  573. Adja1X = 4750323,
  574. Adja1Y = 41902879,
  575. Adja1Z = 50515,
  576. Adja2X = -30932433,
  577. Adja2Y = 28638701,
  578. Adja2Z = -582065,
  579. SatTxLon = 118.8833,
  580. SatTxLat = 32.0667,
  581. RefLon = 121.538,
  582. RefLat = 30.8385,
  583. FreqDown = 295.425e6,//For Api Test
  584. FreqUp = 260.425e6,//For Api Test
  585. Dfo1 = 1629,//For Api Test
  586. Snr1 = 27.1,//For Api Test
  587. Dfo2 = 1025,//For Api Test
  588. Snr2 = 27.4,//For Api Test
  589. };
  590. return X3TwoDtoPosDto;
  591. }
  592. /// <summary>
  593. /// 三星双时差无参定位
  594. /// </summary>
  595. private X3TwoDtoNoParPosDto X3TwoDtoNoPar()
  596. {
  597. X3TwoDtoNoParPosDto X3TwoDtoNoParPosDto = new X3TwoDtoNoParPosDto()
  598. {
  599. SigTime = DateTime.Now,
  600. MainCode = 23467,
  601. Adja1Code = 39206,
  602. Adja2Code = 40892,
  603. Dto1 = -0.008361002956792 * 1e6,
  604. Dto2 = 0.004191941221694 * 1e6,
  605. MainX = -38214804,
  606. MainY = 17780164,
  607. MainZ = -6857,
  608. Adja1X = 4824458,
  609. Adja1Y = 41896265,
  610. Adja1Z = -55899,
  611. Adja2X = -27105105,
  612. Adja2Y = 32302912,
  613. Adja2Z = 11952,
  614. SatTxLon = 121.3555,
  615. SatTxLat = 31.3667,
  616. FreqDown = 295.425e6,//For Api Test
  617. FreqUp = 260.425e6,//For Api Test
  618. Dfo1 = 1629,//For Api Test
  619. Snr1 = 27.1,//For Api Test
  620. Dfo2 = 1025,//For Api Test
  621. Snr2 = 27.4,//For Api Test
  622. MainVX = 1,//For Api Test
  623. MainVY = 1,//For Api Test
  624. MainVZ = 1,//For Api Test
  625. Adja1VX = 1,//For Api Test
  626. Adja1VY = 1,//For Api Test
  627. Adja1VZ = 1,//For Api Test
  628. Adja2VX = 1,//For Api Test
  629. Adja2VY = 1,//For Api Test
  630. Adja2VZ = 1,//For Api Test
  631. };
  632. return X3TwoDtoNoParPosDto;
  633. }
  634. /// <summary>
  635. /// 三星双频差定位
  636. /// </summary>
  637. private X3TwoDfoPosDto X3TwoDfo()
  638. {
  639. X3TwoDfoPosDto X3TwoDfoPosDto = new X3TwoDfoPosDto()
  640. {
  641. SigTime = DateTime.Now,
  642. MainCode = 23467,
  643. Adja1Code = 39206,
  644. Adja2Code = 40892,
  645. Dfo1 = -17.601977254734404,
  646. Dfo2 = -36.885840020369514,
  647. YbMainDfo = 0,
  648. YbAdja1Dfo = 17.453698229247941,
  649. YbAdja2Dfo = 37.022577554138941,
  650. TarFreqUp = 3808 * 1e6 + 2225 * 1e6,
  651. TarFreqDown = 3808 * 1e6,
  652. RefFreqUp = 3796 * 1e6 + 2225 * 1e6,
  653. RefFreqDown = 3796 * 1e6,
  654. MainX = -18149981.873274,
  655. MainY = 38039767.675679,
  656. MainZ = -5662.335149,
  657. MainVx = -2.006064,
  658. MainVy = -1.4693,
  659. MainVz = 1.62569,
  660. Adja1X = -14770224.082665,
  661. Adja1Y = 39479299.786862,
  662. Adja1Z = -53188.063002,
  663. Adja1Vx = -1.764989,
  664. Adja1Vy = -0.528101,
  665. Adja1Vz = 1.808949,
  666. Adja2X = -33231255.13,
  667. Adja2Y = 25948042.76,
  668. Adja2Z = 27091.80,
  669. Adja2Vx = -0.607289,
  670. Adja2Vy = 0.089864,
  671. Adja2Vz = -0.069086,
  672. SatTxLon = 116.254567,
  673. SatTxLat = 39.65955,
  674. RefLon = 106.698,
  675. RefLat = 26.567,
  676. Dto1 = 829.2,//For Api Test
  677. Snr1 = 27.7,//For Api Test
  678. Dto2 = 1928.3,//For Api Test
  679. Snr2 = 27.9,//For Api Test
  680. };
  681. return X3TwoDfoPosDto;
  682. }
  683. /// <summary>
  684. /// 双星时频差定位
  685. /// </summary>
  686. private X2DtoDfoPosDto X2Dfo()
  687. {
  688. X2DtoDfoPosDto X2DtoDfoPosDto = new X2DtoDfoPosDto()
  689. {
  690. SigTime = DateTime.Now,
  691. MainCode = 23467,
  692. AdjaCode = 39206,
  693. Dto = -3.587980198938979e-06 * 1e6,
  694. Dfo = -17.601977254734404,
  695. YbMainDto = 0.26 * 1e6,
  696. YbAdjaDto = 0.25993647195 * 1e6,
  697. YbMainDfo = 0,
  698. YbAdjaDfo = 17.453698229247941,
  699. TarFreqUp = 3808 * 1e6 + 2225 * 1e6,
  700. TarFreqDown = 3808 * 1e6,
  701. RefFreqUp = 3796 * 1e6 + 2225 * 1e6,
  702. RefFreqDown = 3796 * 1e6,
  703. MainX = -18149981.873274,
  704. MainY = 38039767.675679,
  705. MainZ = -5662.335149,
  706. MainVx = -2.006064,
  707. MainVy = -1.4693,
  708. MainVz = 1.62569,
  709. AdjaX = -14770224.082665,
  710. AdjaY = 39479299.786862,
  711. AdjaZ = -53188.063002,
  712. AdjaVx = -1.764989,
  713. AdjaVy = -0.528101,
  714. AdjaVz = 1.808949,
  715. SatTxLon = 116.254567,
  716. SatTxLat = 39.65955,
  717. RefLon = 106.698,
  718. RefLat = 26.567,
  719. Snr = 19.27,//For Api Test
  720. };
  721. return X2DtoDfoPosDto;
  722. }
  723. /// <summary>
  724. /// 两星一地定位无参无星历
  725. /// </summary>
  726. private X2D1NoXlNoParlPosDto X2D1NoParNoXL()
  727. {
  728. X2D1NoXlNoParlPosDto X2D1NoXlNoParlPosDto = new X2D1NoXlNoParlPosDto();
  729. X2D1NoXlNoParlPosDto.SigTime = DateTime.Now;
  730. X2D1NoXlNoParlPosDto.MainCode = 25630;
  731. X2D1NoXlNoParlPosDto.AdjaCode = 33276;
  732. X2D1NoXlNoParlPosDto.SxDto = -0.002198485309353 * 1e6;
  733. X2D1NoXlNoParlPosDto.XdDto = 0.245961726007262 * 1e6;
  734. X2D1NoXlNoParlPosDto.SatTxLon = 118.8833;
  735. X2D1NoXlNoParlPosDto.SatTxLat = 32.0667;
  736. X2D1NoXlNoParlPosDto.CdbTxLon = 109.4082;
  737. X2D1NoXlNoParlPosDto.CdbTxLat = 18.3878;
  738. return X2D1NoXlNoParlPosDto;
  739. }
  740. /// <summary>
  741. /// 三星双时差定位无星历
  742. /// </summary>
  743. private X3TwoDtoNoXlPosDto X3TwoDtoNoXL()
  744. {
  745. X3TwoDtoNoXlPosDto X3TwoDtoNoXlPosDto = new X3TwoDtoNoXlPosDto();
  746. X3TwoDtoNoXlPosDto.SigTime = DateTime.Now;
  747. X3TwoDtoNoXlPosDto.MainCode = 23467;
  748. X3TwoDtoNoXlPosDto.Adja1Code = 39206;
  749. X3TwoDtoNoXlPosDto.Adja2Code = 40892;
  750. X3TwoDtoNoXlPosDto.Dto1 = -0.0037683828 * 1e6;
  751. X3TwoDtoNoXlPosDto.Dto2 = 0.00411476 * 1e6;
  752. X3TwoDtoNoXlPosDto.YbMainDto = 0.253339246 * 1e6;
  753. X3TwoDtoNoXlPosDto.YbAdja1Dto = 0.254082015 * 1e6;
  754. X3TwoDtoNoXlPosDto.YbAdja2Dto = 0.247747625 * 1e6;
  755. X3TwoDtoNoXlPosDto.SatTxLon = 118.8833;
  756. X3TwoDtoNoXlPosDto.SatTxLat = 32.0667;
  757. X3TwoDtoNoXlPosDto.RefLon = 121.538;
  758. X3TwoDtoNoXlPosDto.RefLat = 30.8385;
  759. return X3TwoDtoNoXlPosDto;
  760. }
  761. /// <summary>
  762. /// 三星双时差无参定位无星历
  763. /// </summary>
  764. private X3TwoDtoNoXlNoParPosDto X3TwoDtoNoParNoXL()
  765. {
  766. X3TwoDtoNoXlNoParPosDto X3TwoDtoNoParPosDto = new X3TwoDtoNoXlNoParPosDto()
  767. {
  768. SigTime = DateTime.Now,
  769. MainCode = 23467,
  770. Adja1Code = 39206,
  771. Adja2Code = 40892,
  772. Dto1 = -0.008361002956792 * 1e6,
  773. Dto2 = 0.004191941221694 * 1e6,
  774. SatTxLon = 121.3555,
  775. SatTxLat = 31.3667,
  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. }