Form1.cs 49 KB

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