Form1.cs 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931
  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. private X2D1NoParPosDto X2D1NoPar()
  493. {
  494. X2D1NoParPosDto X2D1PosDto = new X2D1NoParPosDto()
  495. {
  496. SigTime = DateTime.Now,
  497. MainCode = 25630,
  498. AdjaCode = 33276,
  499. SxDto = -0.002198485309353 * 1e6,
  500. XdDto = 0.245961726007262 * 1e6,
  501. MainX = -38209016,
  502. MainY = 17858458,
  503. MainZ = 13250,
  504. AdjaX = 4750323,
  505. AdjaY = 41902879,
  506. AdjaZ = 50515,
  507. SatTxLon = 118.8833,
  508. SatTxLat = 32.0667,
  509. CdbTxLon = 109.4082,
  510. CdbTxLat = 18.3878,
  511. FreqDown = 252.325e6,//For Api Test
  512. FreqUp = 310.85e6,//For Api Test
  513. XdDfo = 1529,//For Api Test
  514. XdSnr = 25,//For Api Test
  515. SxDfo = 1024,//For Api Test
  516. SxSnr = 25,//For Api Test
  517. MainVX = 1,//For Api Test
  518. MainVY = 1,//For Api Test
  519. MainVZ = 1,//For Api Test
  520. AdjaVX = 1,//For Api Test
  521. AdjaVY = 1,//For Api Test
  522. AdjaVZ = 1,//For Api Test
  523. };
  524. return X2D1PosDto;
  525. }
  526. /// <summary>
  527. /// 两星一地定位无参无星历
  528. /// </summary>
  529. private X2D1NoXlNoParlPosDto X2D1NoParNoXL()
  530. {
  531. X2D1NoXlNoParlPosDto X2D1NoXlNoParlPosDto = new X2D1NoXlNoParlPosDto()
  532. {
  533. SigTime = DateTime.Now,
  534. MainCode = 25630,
  535. AdjaCode = 33276,
  536. SxDto = -0.002198485309353 * 1e6,
  537. XdDto = 0.245961726007262 * 1e6,
  538. SatTxLon = 118.8833,
  539. SatTxLat = 32.0667,
  540. CdbTxLon = 109.4082,
  541. CdbTxLat = 18.3878,
  542. FreqDown = 252.325e6,//For Api Test
  543. FreqUp = 310.85e6,//For Api Test
  544. XdDfo = 1529,//For Api Test
  545. XdSnr = 25,//For Api Test
  546. SxDfo = 1024,//For Api Test
  547. SxSnr = 25,//For Api Test
  548. };
  549. return X2D1NoXlNoParlPosDto;
  550. }
  551. /// <summary>
  552. /// 三星双时差定位
  553. /// </summary>
  554. private X3TwoDtoPosDto X3TwoDto()
  555. {
  556. X3TwoDtoPosDto X3TwoDtoPosDto = new X3TwoDtoPosDto()
  557. {
  558. SigTime = DateTime.Now,
  559. MainCode = 23467,
  560. Adja1Code = 39206,
  561. Adja2Code = 40892,
  562. Dto1 = -0.0037683828 * 1e6,
  563. Dto2 = 0.00411476 * 1e6,
  564. YbMainDto = 0.253339246 * 1e6,
  565. YbAdja1Dto = 0.254082015 * 1e6,
  566. YbAdja2Dto = 0.247747625 * 1e6,
  567. MainX = -38209016,
  568. MainY = 17858458,
  569. MainZ = 13250,
  570. Adja1X = 4750323,
  571. Adja1Y = 41902879,
  572. Adja1Z = 50515,
  573. Adja2X = -30932433,
  574. Adja2Y = 28638701,
  575. Adja2Z = -582065,
  576. SatTxLon = 118.8833,
  577. SatTxLat = 32.0667,
  578. RefLon = 121.538,
  579. RefLat = 30.8385,
  580. FreqDown = 252.325e6,//For Api Test
  581. FreqUp = 310.85e6,//For Api Test
  582. Dfo1 = 1629,//For Api Test
  583. Snr1 = 27.1,//For Api Test
  584. Dfo2 = 1025,//For Api Test
  585. Snr2 = 27.4,//For Api Test
  586. };
  587. return X3TwoDtoPosDto;
  588. }
  589. /// <summary>
  590. /// 三星双时差无参定位
  591. /// </summary>
  592. private X3TwoDtoNoParPosDto X3TwoDtoNoPar()
  593. {
  594. X3TwoDtoNoParPosDto X3TwoDtoNoParPosDto = new X3TwoDtoNoParPosDto()
  595. {
  596. SigTime = DateTime.Now,
  597. MainCode = 23467,
  598. Adja1Code = 39206,
  599. Adja2Code = 40892,
  600. Dto1 = -0.008361002956792 * 1e6,
  601. Dto2 = 0.004191941221694 * 1e6,
  602. MainX = -38214804,
  603. MainY = 17780164,
  604. MainZ = -6857,
  605. Adja1X = 4824458,
  606. Adja1Y = 41896265,
  607. Adja1Z = -55899,
  608. Adja2X = -27105105,
  609. Adja2Y = 32302912,
  610. Adja2Z = 11952,
  611. SatTxLon = 121.3555,
  612. SatTxLat = 31.3667,
  613. FreqDown = 252.325e6,//For Api Test
  614. FreqUp = 310.85e6,//For Api Test
  615. Dfo1 = 1629,//For Api Test
  616. Snr1 = 27.1,//For Api Test
  617. Dfo2 = 1025,//For Api Test
  618. Snr2 = 27.4,//For Api Test
  619. MainVX = 1,//For Api Test
  620. MainVY = 1,//For Api Test
  621. MainVZ = 1,//For Api Test
  622. Adja1VX = 1,//For Api Test
  623. Adja1VY = 1,//For Api Test
  624. Adja1VZ = 1,//For Api Test
  625. Adja2VX = 1,//For Api Test
  626. Adja2VY = 1,//For Api Test
  627. Adja2VZ = 1,//For Api Test
  628. };
  629. return X3TwoDtoNoParPosDto;
  630. }
  631. /// <summary>
  632. /// 三星双频差定位
  633. /// </summary>
  634. private X3TwoDfoPosDto X3TwoDfo()
  635. {
  636. X3TwoDfoPosDto X3TwoDfoPosDto = new X3TwoDfoPosDto()
  637. {
  638. SigTime = DateTime.Now,
  639. MainCode = 23467,
  640. Adja1Code = 39206,
  641. Adja2Code = 40892,
  642. Dfo1 = -17.601977254734404,
  643. Dfo2 = -36.885840020369514,
  644. YbMainDfo = 0,
  645. YbAdja1Dfo = 17.453698229247941,
  646. YbAdja2Dfo = 37.022577554138941,
  647. TarFreqUp = 3808 * 1e6 + 2225 * 1e6,
  648. TarFreqDown = 3808 * 1e6,
  649. RefFreqUp = 3796 * 1e6 + 2225 * 1e6,
  650. RefFreqDown = 3796 * 1e6,
  651. MainX = -18149981.873274,
  652. MainY = 38039767.675679,
  653. MainZ = -5662.335149,
  654. MainVx = -2.006064,
  655. MainVy = -1.4693,
  656. MainVz = 1.62569,
  657. Adja1X = -14770224.082665,
  658. Adja1Y = 39479299.786862,
  659. Adja1Z = -53188.063002,
  660. Adja1Vx = -1.764989,
  661. Adja1Vy = -0.528101,
  662. Adja1Vz = 1.808949,
  663. Adja2X = -33231255.13,
  664. Adja2Y = 25948042.76,
  665. Adja2Z = 27091.80,
  666. Adja2Vx = -0.607289,
  667. Adja2Vy = 0.089864,
  668. Adja2Vz = -0.069086,
  669. SatTxLon = 116.254567,
  670. SatTxLat = 39.65955,
  671. RefLon = 106.698,
  672. RefLat = 26.567,
  673. Dto1 = 829.2,//For Api Test
  674. Snr1 = 27.7,//For Api Test
  675. Dto2 = 1928.3,//For Api Test
  676. Snr2 = 27.9,//For Api Test
  677. };
  678. return X3TwoDfoPosDto;
  679. }
  680. /// <summary>
  681. /// 双星时频差定位
  682. /// </summary>
  683. private X2DtoDfoPosDto X2Dfo()
  684. {
  685. X2DtoDfoPosDto X2DtoDfoPosDto = new X2DtoDfoPosDto()
  686. {
  687. SigTime = DateTime.Now,
  688. MainCode = 23467,
  689. AdjaCode = 39206,
  690. Dto = -3.587980198938979e-06 * 1e6,
  691. Dfo = -17.601977254734404,
  692. YbMainDto = 0.26 * 1e6,
  693. YbAdjaDto = 0.25993647195 * 1e6,
  694. YbMainDfo = 0,
  695. YbAdjaDfo = 17.453698229247941,
  696. TarFreqUp = 3808 * 1e6 + 2225 * 1e6,
  697. TarFreqDown = 3808 * 1e6,
  698. RefFreqUp = 3796 * 1e6 + 2225 * 1e6,
  699. RefFreqDown = 3796 * 1e6,
  700. MainX = -18149981.873274,
  701. MainY = 38039767.675679,
  702. MainZ = -5662.335149,
  703. MainVx = -2.006064,
  704. MainVy = -1.4693,
  705. MainVz = 1.62569,
  706. AdjaX = -14770224.082665,
  707. AdjaY = 39479299.786862,
  708. AdjaZ = -53188.063002,
  709. AdjaVx = -1.764989,
  710. AdjaVy = -0.528101,
  711. AdjaVz = 1.808949,
  712. SatTxLon = 116.254567,
  713. SatTxLat = 39.65955,
  714. RefLon = 106.698,
  715. RefLat = 26.567,
  716. Snr = 19.27,//For Api Test
  717. };
  718. return X2DtoDfoPosDto;
  719. }
  720. /// <summary>
  721. /// 三星双时差定位无星历
  722. /// </summary>
  723. private X3TwoDtoNoXlPosDto X3TwoDtoNoXL()
  724. {
  725. X3TwoDtoNoXlPosDto X3TwoDtoNoXlPosDto = new X3TwoDtoNoXlPosDto()
  726. {
  727. SigTime = DateTime.Now,
  728. MainCode = 23467,
  729. Adja1Code = 39206,
  730. Adja2Code = 40892,
  731. Dto1 = -0.0037683828 * 1e6,
  732. Dto2 = 0.00411476 * 1e6,
  733. YbMainDto = 0.253339246 * 1e6,
  734. YbAdja1Dto = 0.254082015 * 1e6,
  735. YbAdja2Dto = 0.247747625 * 1e6,
  736. SatTxLon = 118.8833,
  737. SatTxLat = 32.0667,
  738. RefLon = 121.538,
  739. RefLat = 30.8385,
  740. FreqDown = 252.325e6,//For Api Test
  741. FreqUp = 310.85e6,//For Api Test
  742. Dfo1 = 1629,//For Api Test
  743. Snr1 = 27.1,//For Api Test
  744. Dfo2 = 1025,//For Api Test
  745. Snr2 = 27.4,//For Api Test
  746. };
  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. FreqDown = 252.325e6,//For Api Test
  765. FreqUp = 310.85e6,//For Api Test
  766. Dfo1 = 1629,//For Api Test
  767. Snr1 = 27.1,//For Api Test
  768. Dfo2 = 1025,//For Api Test
  769. Snr2 = 27.4,//For Api Test
  770. };
  771. return X3TwoDtoNoParPosDto;
  772. }
  773. /// <summary>
  774. /// 三星双频差定位无星历
  775. /// </summary>
  776. private X3TwoDfoNoXlPosDto X3TwoDfoNoXL()
  777. {
  778. X3TwoDfoNoXlPosDto X3TwoDfoNoXlPosDto = new X3TwoDfoNoXlPosDto()
  779. {
  780. SigTime = DateTime.Now,
  781. MainCode = 23467,
  782. Adja1Code = 39206,
  783. Adja2Code = 40892,
  784. Dfo1 = -17.601977254734404,
  785. Dfo2 = -36.885840020369514,
  786. YbMainDfo = 0,
  787. YbAdja1Dfo = 17.453698229247941,
  788. YbAdja2Dfo = 37.022577554138941,
  789. TarFreqUp = 3808 * 1e6 + 2225 * 1e6,
  790. TarFreqDown = 3808 * 1e6,
  791. RefFreqUp = 3796 * 1e6 + 2225 * 1e6,
  792. RefFreqDown = 3796 * 1e6,
  793. SatTxLon = 116.254567,
  794. SatTxLat = 39.65955,
  795. RefLon = 106.698,
  796. RefLat = 26.567,
  797. };
  798. return X3TwoDfoNoXlPosDto;
  799. }
  800. /// <summary>
  801. /// 双星时频差定位无星历
  802. /// </summary>
  803. private X2DtoDfoNoXlPosDto X2DfoNoXL()
  804. {
  805. X2DtoDfoNoXlPosDto X2DtoDfoNoXlPosDto = new X2DtoDfoNoXlPosDto()
  806. {
  807. SigTime = DateTime.Now,
  808. MainCode = 23467,
  809. AdjaCode = 39206,
  810. Dto = -3.587980198938979e-06 * 1e6,
  811. Dfo = -17.601977254734404,
  812. YbMainDto = 0.26 * 1e6,
  813. YbAdjaDto = 0.25993647195 * 1e6,
  814. YbMainDfo = 0,
  815. YbAdjaDfo = 17.453698229247941,
  816. TarFreqUp = 3808 * 1e6 + 2225 * 1e6,
  817. TarFreqDown = 3808 * 1e6,
  818. RefFreqUp = 3796 * 1e6 + 2225 * 1e6,
  819. RefFreqDown = 3796 * 1e6,
  820. SatTxLon = 116.254567,
  821. SatTxLat = 39.65955,
  822. RefLon = 106.698,
  823. RefLat = 26.567,
  824. Snr = 20 + new Random().Next(-5, 15)
  825. };
  826. return X2DtoDfoNoXlPosDto;
  827. }
  828. private void Log(string msg)
  829. {
  830. try
  831. {
  832. if (this.InvokeRequired)
  833. {
  834. this.Invoke(new Action(() =>
  835. {
  836. if (listBoxControl1.ItemCount > 5000)
  837. listBoxControl1.Items.Clear();
  838. listBoxControl1.Items.Insert(0, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}--{msg}");
  839. listBoxControl1.SelectedIndex = 0;
  840. }));
  841. }
  842. else
  843. {
  844. if (listBoxControl1.ItemCount > 5000)
  845. listBoxControl1.Items.Clear();
  846. listBoxControl1.Items.Insert(0, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}--{msg}");
  847. listBoxControl1.SelectedIndex = 0;
  848. }
  849. }
  850. catch
  851. { }
  852. }
  853. private void Log(Exception ex)
  854. {
  855. try
  856. {
  857. if (this.InvokeRequired)
  858. {
  859. this.Invoke(new Action(() =>
  860. {
  861. if (listBoxControl1.ItemCount > 5000)
  862. listBoxControl1.Items.Clear();
  863. listBoxControl1.Items.Insert(0, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}--{ex.Message}");
  864. listBoxControl1.SelectedIndex = 0;
  865. }));
  866. }
  867. else
  868. {
  869. if (listBoxControl1.ItemCount > 5000)
  870. listBoxControl1.Items.Clear();
  871. listBoxControl1.Items.Insert(0, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}--{ex.Message}");
  872. listBoxControl1.SelectedIndex = 0;
  873. }
  874. }
  875. catch
  876. { }
  877. }
  878. private void listBoxControl1_MouseClick(object sender, MouseEventArgs e)
  879. {
  880. if (e.Button == MouseButtons.Right)
  881. {
  882. popupMenu1.ShowPopup(MousePosition);
  883. }
  884. }
  885. private void btnClear_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
  886. {
  887. listBoxControl1.Items.Clear();
  888. }
  889. private void btnCopyAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
  890. {
  891. StringBuilder sb = new StringBuilder();
  892. foreach (var item in listBoxControl1.Items)
  893. {
  894. sb.AppendLine(item.ToString());
  895. }
  896. var data = sb.ToString();
  897. if (string.IsNullOrWhiteSpace(data)) return;
  898. Clipboard.SetText(sb.ToString());
  899. }
  900. }
  901. }