Form1.cs 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934
  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. SigTime = DateTime.Now,
  69. FileName = "test",
  70. StartSamp = 1,
  71. SampCount = 2,
  72. DetectionWay = DmcTypeDto.DAMA| DmcTypeDto.Ky5758,
  73. };
  74. X1D1PosDto dto = new X1D1PosDto()
  75. {
  76. SigTime = DateTime.Now,
  77. MainCode = 23467,
  78. XdDto = Convert.ToDouble(items[1]) * 1e6,
  79. MainYbDto = Convert.ToDouble(items[2]) * 1e6,
  80. CxRes = Convert.ToDouble(items[4]),
  81. MainX = Convert.ToDouble(items[7]),
  82. MainY = Convert.ToDouble(items[8]),
  83. MainZ = Convert.ToDouble(items[9]),
  84. FreqDown = 295.425e6,//For Api Test
  85. FreqUp = 260.425e6,//For Api Test
  86. XdDfo = 1529,//For Api Test
  87. XdSnr = 25,//For Api Test
  88. SatTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lon"),
  89. SatTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lat"),
  90. CdbTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lon"),
  91. CdbTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lat"),
  92. CxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lon"),
  93. CxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lat"),
  94. RefLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lon"),
  95. RefLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lat"),
  96. CheckRes= checkResDto
  97. };
  98. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, dto);
  99. if (result.code != 200)
  100. {
  101. Log($"{result.msg}");
  102. return;
  103. }
  104. // Thread.Sleep(1000);
  105. Log($"已向[{txtAddr1.Text}]发送第{idx++}条仿真结果");
  106. }
  107. }
  108. if (tskType == "X2D1")//两星一地定位
  109. {
  110. var lines = File.ReadAllLines("Simulation_Data2023.dat");
  111. int idx = 1;
  112. url += "PosX2D1Async";
  113. foreach (var line in lines)
  114. {
  115. if (cts1.IsCancellationRequested) break;
  116. if (string.IsNullOrWhiteSpace(line)) continue;
  117. var items = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  118. X2D1PosDto X2D1PosDto = new X2D1PosDto()
  119. {
  120. SigTime = DateTime.Now,
  121. MainCode = 23467,
  122. AdjaCode = 39206,
  123. FreqDown = 295.425e6,//For Api Test
  124. FreqUp = 260.425e6,//For Api Test
  125. XdDfo = 1529,//For Api Test
  126. XdSnr = 25,//For Api Test
  127. SxDfo = 1024,//For Api Test
  128. SxSnr = 25,//For Api Test
  129. MainVX = 1,//For Api Test
  130. MainVY = 1,//For Api Test
  131. MainVZ = 1,//For Api Test
  132. AdjaVX = 1,//For Api Test
  133. AdjaVY = 1,//For Api Test
  134. AdjaVZ = 1,//For Api Test
  135. SxDto = Convert.ToDouble(items[0]) * 1e6,
  136. XdDto = Convert.ToDouble(items[1]) * 1e6,
  137. MainYbDto = Convert.ToDouble(items[2]) * 1e6,
  138. AdjaYbDto = Convert.ToDouble(items[3]) * 1e6,
  139. MainX = Convert.ToDouble(items[7]),
  140. MainY = Convert.ToDouble(items[8]),
  141. MainZ = Convert.ToDouble(items[9]),
  142. AdjaX = Convert.ToDouble(items[10]),
  143. AdjaY = Convert.ToDouble(items[11]),
  144. AdjaZ = Convert.ToDouble(items[12]),
  145. SatTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lon"),
  146. SatTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lat"),
  147. CdbTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lon"),
  148. CdbTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lat"),
  149. RefLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lon"),
  150. RefLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lat"),
  151. };
  152. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, X2D1PosDto);
  153. if (result.code != 200)
  154. {
  155. Log($"{result.msg}");
  156. return;
  157. }
  158. Thread.Sleep(1000);
  159. Log($"已向[{txtAddr1.Text}]发送第{idx++}条仿真结果");
  160. }
  161. }
  162. if (tskType == "X2D1NoPar")//两星一地无参定位
  163. {
  164. url += "PosX2D1NoParAsync";
  165. var res = X2D1NoPar();
  166. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  167. if (result.code != 200)
  168. {
  169. Log($"{result.msg}");
  170. return;
  171. }
  172. Log($"已向[{txtAddr1.Text}]发送两星一地无参定位仿真结果");
  173. }
  174. if (tskType == "RH")//融合定位
  175. {
  176. var lines = File.ReadAllLines("Simulation_Data2023.dat");
  177. int idx = 1;
  178. url += "PosRHAsync";
  179. foreach (var line in lines)
  180. {
  181. if (cts1.IsCancellationRequested) break;
  182. if (string.IsNullOrWhiteSpace(line)) continue;
  183. var items = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  184. RHPosDto RHPosDto = new RHPosDto()
  185. {
  186. SigTime = DateTime.Now,
  187. MainCode = 23467,
  188. AdjaCode = 39206,
  189. SxDto = Convert.ToDouble(items[0]) * 1e6,
  190. XdDto = Convert.ToDouble(items[1]) * 1e6,
  191. MainYbDto = Convert.ToDouble(items[2]) * 1e6,
  192. AdjaYbDto = Convert.ToDouble(items[3]) * 1e6,
  193. CxRes = Convert.ToDouble(items[4]),
  194. MainX = Convert.ToDouble(items[7]),
  195. MainY = Convert.ToDouble(items[8]),
  196. MainZ = Convert.ToDouble(items[9]),
  197. AdjaX = Convert.ToDouble(items[10]),
  198. AdjaY = Convert.ToDouble(items[11]),
  199. AdjaZ = Convert.ToDouble(items[12]),
  200. FreqDown = 295.425e6,//For Api Test
  201. FreqUp = 260.425e6,//For Api Test
  202. XdDfo = 1529,//For Api Test
  203. XdSnr = 25,//For Api Test
  204. SxDfo = 1024,//For Api Test
  205. SxSnr = 25,//For Api Test
  206. SatTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lon"),
  207. SatTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lat"),
  208. CdbTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lon"),
  209. CdbTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lat"),
  210. CxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lon"),
  211. CxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lat"),
  212. RefLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lon"),
  213. RefLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lat"),
  214. };
  215. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, RHPosDto);
  216. if (result.code != 200)
  217. {
  218. Log($"{result.msg}");
  219. return;
  220. }
  221. Thread.Sleep(1000);
  222. Log($"已向[{txtAddr1.Text}]发送第{idx++}条仿真结果");
  223. }
  224. }
  225. if (tskType == "X3TwoDto")//三星双时差定位
  226. {
  227. url += "PosX3TwoDtoAsync";
  228. var res = X3TwoDto();
  229. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  230. if (result.code != 200)
  231. {
  232. Log($"{result.msg}");
  233. return;
  234. }
  235. Log($"已向[{txtAddr1.Text}]发送三星双时差定位仿真结果");
  236. }
  237. if (tskType == "X3TwoDtoNoPar")//三星双时差无参定位
  238. {
  239. url += "PosX3TwoDtoNoParAsync";
  240. var res = X3TwoDtoNoPar();
  241. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  242. if (result.code != 200)
  243. {
  244. Log($"{result.msg}");
  245. return;
  246. }
  247. Log($"已向[{txtAddr1.Text}]发送三星双时差定位仿真结果");
  248. }
  249. if (tskType == "X3TwoDfo")//三星双频差定位
  250. {
  251. url += "PosX3TwoDfoAsync";
  252. var res = X3TwoDfo();
  253. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  254. if (result.code != 200)
  255. {
  256. Log($"{result.msg}");
  257. return;
  258. }
  259. Log($"已向[{txtAddr1.Text}]发送三星双频差定位仿真结果");
  260. }
  261. if (tskType == "X2Dfo")//双星时频差定位
  262. {
  263. url += "PosX2DtoDfoAsync";
  264. var res = X2Dfo();
  265. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  266. if (result.code != 200)
  267. {
  268. Log($"{result.msg}");
  269. return;
  270. }
  271. Log($"已向[{txtAddr1.Text}]发送双星时频差定位仿真结果");
  272. }
  273. if (tskType == "X1D1CXNoXL")//一星一地测向定位无星厉
  274. {
  275. var lines = File.ReadAllLines("Simulation_Data2023.dat");
  276. int idx = 1;
  277. url += "PosX1D1NoXlAsync";
  278. foreach (var line in lines)
  279. {
  280. if (cts1.IsCancellationRequested) break;
  281. if (string.IsNullOrWhiteSpace(line)) continue;
  282. var items = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  283. X1D1NoXlPosDto dto = new X1D1NoXlPosDto()
  284. {
  285. SigTime = DateTime.Now,
  286. MainCode = 23467,
  287. XdDto = Convert.ToDouble(items[1]) * 1e6,
  288. MainYbDto = Convert.ToDouble(items[2]) * 1e6,
  289. CxRes = Convert.ToDouble(items[4]),
  290. SatTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lon"),
  291. SatTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lat"),
  292. CdbTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lon"),
  293. CdbTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lat"),
  294. CxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lon"),
  295. CxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lat"),
  296. RefLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lon"),
  297. RefLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lat"),
  298. FreqDown = 295.425e6,//For Api Test
  299. FreqUp = 260.425e6,//For Api Test
  300. XdDfo = 1529,//For Api Test
  301. XdSnr = 25,//For Api Test
  302. };
  303. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, dto);
  304. if (result.code != 200)
  305. {
  306. Log($"{result.msg}");
  307. return;
  308. }
  309. Thread.Sleep(1000);
  310. Log($"已向[{txtAddr1.Text}]发送第{idx++}条仿真结果");
  311. }
  312. }
  313. if (tskType == "X2D1NoXL")//两星一地定位无星厉
  314. {
  315. var lines = File.ReadAllLines("Simulation_Data2023.dat");
  316. int idx = 1;
  317. url += "PosX2D1NoXlAsync";
  318. foreach (var line in lines)
  319. {
  320. if (cts1.IsCancellationRequested) break;
  321. if (string.IsNullOrWhiteSpace(line)) continue;
  322. var items = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  323. X2D1NoXlPosDto X2D1NoXlPosDto = new X2D1NoXlPosDto()
  324. {
  325. SigTime = DateTime.Now,
  326. MainCode = 23467,
  327. AdjaCode = 39206,
  328. SxDto = Convert.ToDouble(items[0]) * 1e6,
  329. XdDto = Convert.ToDouble(items[1]) * 1e6,
  330. MainYbDto = Convert.ToDouble(items[2]) * 1e6,
  331. AdjaYbDto = Convert.ToDouble(items[3]) * 1e6,
  332. SatTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lon"),
  333. SatTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lat"),
  334. CdbTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lon"),
  335. CdbTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lat"),
  336. RefLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lon"),
  337. RefLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lat"),
  338. FreqDown = 295.425e6,//For Api Test
  339. FreqUp = 260.425e6,//For Api Test
  340. XdDfo = 1529,//For Api Test
  341. XdSnr = 25,//For Api Test
  342. SxDfo = 1024,//For Api Test
  343. SxSnr = 25,//For Api Test
  344. };
  345. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, X2D1NoXlPosDto);
  346. if (result.code != 200)
  347. {
  348. Log($"{result.msg}");
  349. return;
  350. }
  351. Thread.Sleep(1000);
  352. Log($"已向[{txtAddr1.Text}]发送第{idx++}条仿真结果");
  353. }
  354. }
  355. if (tskType == "X2D1NoParNoXL")//两星一地无参定位无星厉
  356. {
  357. url += "PosX2D1NoXlNoParAsync";
  358. var res = X2D1NoParNoXL();
  359. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  360. if (result.code != 200)
  361. {
  362. Log($"{result.msg}");
  363. return;
  364. }
  365. Log($"已向[{txtAddr1.Text}]发送两星一地无参定位仿真结果");
  366. }
  367. if (tskType == "RHNoXL")//融合定位无星厉
  368. {
  369. var lines = File.ReadAllLines("Simulation_Data2023.dat");
  370. int idx = 1;
  371. url += "PosRhNoXlAsync";
  372. foreach (var line in lines)
  373. {
  374. if (cts1.IsCancellationRequested) break;
  375. if (string.IsNullOrWhiteSpace(line)) continue;
  376. var items = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  377. RHNoXlPosDto RHNoXlPosDto = new RHNoXlPosDto()
  378. {
  379. SigTime = DateTime.Now,
  380. MainCode = 23467,
  381. AdjaCode = 39206,
  382. SxDto = Convert.ToDouble(items[0]) * 1e6,
  383. XdDto = Convert.ToDouble(items[1]) * 1e6,
  384. MainYbDto = Convert.ToDouble(items[2]) * 1e6,
  385. AdjaYbDto = Convert.ToDouble(items[3]) * 1e6,
  386. CxRes = Convert.ToDouble(items[4]),
  387. SatTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lon"),
  388. SatTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lat"),
  389. CdbTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lon"),
  390. CdbTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lat"),
  391. CxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lon"),
  392. CxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lat"),
  393. RefLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lon"),
  394. RefLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lat"),
  395. FreqDown = 295.425e6,//For Api Test
  396. FreqUp = 260.425e6,//For Api Test
  397. XdDfo = 1529,//For Api Test
  398. XdSnr = 25,//For Api Test
  399. SxDfo = 1024,//For Api Test
  400. SxSnr = 25,//For Api Test
  401. };
  402. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, RHNoXlPosDto);
  403. if (result.code != 200)
  404. {
  405. Log($"{result.msg}");
  406. return;
  407. }
  408. Thread.Sleep(1000);
  409. Log($"已向[{txtAddr1.Text}]发送第{idx++}条仿真结果");
  410. }
  411. }
  412. if (tskType == "X3TwoDtoNoXL")//三星双时差定位无星厉
  413. {
  414. url += "PosX3TwoDtoNoXlAsync";
  415. var res = X3TwoDtoNoXL();
  416. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  417. if (result.code != 200)
  418. {
  419. Log($"{result.msg}");
  420. return;
  421. }
  422. Log($"已向[{txtAddr1.Text}]发送三星双时差定位仿真结果");
  423. }
  424. if (tskType == "X3TwoDtoNoParNoXL")//三星双时差无参定位无星厉
  425. {
  426. url += "PosX3TwoDtoNoXlNoParAsync";
  427. var res = X3TwoDtoNoParNoXL();
  428. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  429. if (result.code != 200)
  430. {
  431. Log($"{result.msg}");
  432. return;
  433. }
  434. Log($"已向[{txtAddr1.Text}]发送三星双时差定位仿真结果");
  435. }
  436. if (tskType == "X3TwoDfoNoXL")//三星双频差定位无星厉
  437. {
  438. url += "PosX3TwoDfoNoXlAsync";
  439. var res = X3TwoDfoNoXL();
  440. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  441. if (result.code != 200)
  442. {
  443. Log($"{result.msg}");
  444. return;
  445. }
  446. Log($"已向[{txtAddr1.Text}]发送三星双频差定位仿真结果");
  447. }
  448. if (tskType == "X2DfoNoXL")//双星时频差定位无星厉
  449. {
  450. url += "PosX2DtoDfoNoXlAsync";
  451. var res = X2DfoNoXL();
  452. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  453. if (result.code != 200)
  454. {
  455. Log($"{result.msg}");
  456. return;
  457. }
  458. Log($"已向[{txtAddr1.Text}]发送双星时频差定位仿真结果");
  459. }
  460. }
  461. catch (Exception ex)
  462. {
  463. Log($"向[{txtAddr1.Text}]发送结果失败.{ex.Message}");
  464. }
  465. }
  466. // await Task.Delay(1000);
  467. //}
  468. });
  469. }
  470. catch (Exception ex)
  471. {
  472. Log(ex);
  473. }
  474. finally
  475. {
  476. btn1.Text = "推送";
  477. layoutControlItem1.Enabled = true;
  478. layoutControlItem7.Enabled = true;
  479. }
  480. }
  481. else
  482. {
  483. cts1?.Cancel();
  484. }
  485. }
  486. /// <summary>
  487. /// 两星一地定位
  488. /// </summary>
  489. /// <returns></returns>
  490. private X2D1PosDto X2D1()
  491. {
  492. X2D1PosDto X2D1PosDto = new X2D1PosDto();
  493. X2D1PosDto.SigTime = DateTime.Now;
  494. X2D1PosDto.MainCode = 23467;
  495. X2D1PosDto.AdjaCode = 39206;
  496. X2D1PosDto.SxDto = 5507.5653;
  497. X2D1PosDto.XdDto = 240292.558;
  498. X2D1PosDto.MainYbDto = 0;
  499. X2D1PosDto.AdjaYbDto = 0;
  500. X2D1PosDto.MainX = 0;
  501. X2D1PosDto.MainY = 0;
  502. X2D1PosDto.MainZ = 0;
  503. X2D1PosDto.AdjaX = 0;
  504. X2D1PosDto.AdjaY = 0;
  505. X2D1PosDto.AdjaZ = 0;
  506. X2D1PosDto.SatTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lon");
  507. X2D1PosDto.SatTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lat");
  508. X2D1PosDto.CdbTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lon");
  509. X2D1PosDto.CdbTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lat");
  510. X2D1PosDto.RefLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lon");
  511. X2D1PosDto.RefLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lat");
  512. return X2D1PosDto;
  513. }
  514. /// <summary>
  515. /// 两星一地定位无参
  516. /// </summary>
  517. private X2D1NoParPosDto X2D1NoPar()
  518. {
  519. X2D1NoParPosDto X2D1PosDto = new X2D1NoParPosDto()
  520. {
  521. SigTime = DateTime.Now,
  522. MainCode = 25630,
  523. AdjaCode = 33276,
  524. SxDto = -0.002198485309353 * 1e6,
  525. XdDto = 0.245961726007262 * 1e6,
  526. MainX = -38209016,
  527. MainY = 17858458,
  528. MainZ = 13250,
  529. AdjaX = 4750323,
  530. AdjaY = 41902879,
  531. AdjaZ = 50515,
  532. SatTxLon = 118.8833,
  533. SatTxLat = 32.0667,
  534. CdbTxLon = 109.4082,
  535. CdbTxLat = 18.3878,
  536. FreqDown = 295.425e6,//For Api Test
  537. FreqUp = 260.425e6,//For Api Test
  538. XdDfo = 1529,//For Api Test
  539. XdSnr = 25,//For Api Test
  540. SxDfo = 1024,//For Api Test
  541. SxSnr = 25,//For Api Test
  542. MainVX = 1,//For Api Test
  543. MainVY = 1,//For Api Test
  544. MainVZ = 1,//For Api Test
  545. AdjaVX = 1,//For Api Test
  546. AdjaVY = 1,//For Api Test
  547. AdjaVZ = 1,//For Api Test
  548. };
  549. return X2D1PosDto;
  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 = 295.425e6,//For Api Test
  581. FreqUp = 260.425e6,//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 = 295.425e6,//For Api Test
  614. FreqUp = 260.425e6,//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 X2D1NoXlNoParlPosDto X2D1NoParNoXL()
  724. {
  725. X2D1NoXlNoParlPosDto X2D1NoXlNoParlPosDto = new X2D1NoXlNoParlPosDto();
  726. X2D1NoXlNoParlPosDto.SigTime = DateTime.Now;
  727. X2D1NoXlNoParlPosDto.MainCode = 25630;
  728. X2D1NoXlNoParlPosDto.AdjaCode = 33276;
  729. X2D1NoXlNoParlPosDto.SxDto = -0.002198485309353 * 1e6;
  730. X2D1NoXlNoParlPosDto.XdDto = 0.245961726007262 * 1e6;
  731. X2D1NoXlNoParlPosDto.SatTxLon = 118.8833;
  732. X2D1NoXlNoParlPosDto.SatTxLat = 32.0667;
  733. X2D1NoXlNoParlPosDto.CdbTxLon = 109.4082;
  734. X2D1NoXlNoParlPosDto.CdbTxLat = 18.3878;
  735. return X2D1NoXlNoParlPosDto;
  736. }
  737. /// <summary>
  738. /// 三星双时差定位无星厉
  739. /// </summary>
  740. private X3TwoDtoNoXlPosDto X3TwoDtoNoXL()
  741. {
  742. X3TwoDtoNoXlPosDto X3TwoDtoNoXlPosDto = new X3TwoDtoNoXlPosDto();
  743. X3TwoDtoNoXlPosDto.SigTime = DateTime.Now;
  744. X3TwoDtoNoXlPosDto.MainCode = 23467;
  745. X3TwoDtoNoXlPosDto.Adja1Code = 39206;
  746. X3TwoDtoNoXlPosDto.Adja2Code = 40892;
  747. X3TwoDtoNoXlPosDto.Dto1 = -0.0037683828 * 1e6;
  748. X3TwoDtoNoXlPosDto.Dto2 = 0.00411476 * 1e6;
  749. X3TwoDtoNoXlPosDto.YbMainDto = 0.253339246 * 1e6;
  750. X3TwoDtoNoXlPosDto.YbAdja1Dto = 0.254082015 * 1e6;
  751. X3TwoDtoNoXlPosDto.YbAdja2Dto = 0.247747625 * 1e6;
  752. X3TwoDtoNoXlPosDto.SatTxLon = 118.8833;
  753. X3TwoDtoNoXlPosDto.SatTxLat = 32.0667;
  754. X3TwoDtoNoXlPosDto.RefLon = 121.538;
  755. X3TwoDtoNoXlPosDto.RefLat = 30.8385;
  756. return X3TwoDtoNoXlPosDto;
  757. }
  758. /// <summary>
  759. /// 三星双时差无参定位无星厉
  760. /// </summary>
  761. private X3TwoDtoNoXlNoParPosDto X3TwoDtoNoParNoXL()
  762. {
  763. X3TwoDtoNoXlNoParPosDto X3TwoDtoNoParPosDto = new X3TwoDtoNoXlNoParPosDto()
  764. {
  765. SigTime = DateTime.Now,
  766. MainCode = 23467,
  767. Adja1Code = 39206,
  768. Adja2Code = 40892,
  769. Dto1 = -0.008361002956792 * 1e6,
  770. Dto2 = 0.004191941221694 * 1e6,
  771. SatTxLon = 121.3555,
  772. SatTxLat = 31.3667,
  773. };
  774. return X3TwoDtoNoParPosDto;
  775. }
  776. /// <summary>
  777. /// 三星双频差定位无星厉
  778. /// </summary>
  779. private X3TwoDfoNoXlPosDto X3TwoDfoNoXL()
  780. {
  781. X3TwoDfoNoXlPosDto X3TwoDfoNoXlPosDto = new X3TwoDfoNoXlPosDto()
  782. {
  783. SigTime = DateTime.Now,
  784. MainCode = 23467,
  785. Adja1Code = 39206,
  786. Adja2Code = 40892,
  787. Dfo1 = -17.601977254734404,
  788. Dfo2 = -36.885840020369514,
  789. YbMainDfo = 0,
  790. YbAdja1Dfo = 17.453698229247941,
  791. YbAdja2Dfo = 37.022577554138941,
  792. TarFreqUp = 3808 * 1e6 + 2225 * 1e6,
  793. TarFreqDown = 3808 * 1e6,
  794. RefFreqUp = 3796 * 1e6 + 2225 * 1e6,
  795. RefFreqDown = 3796 * 1e6,
  796. SatTxLon = 116.254567,
  797. SatTxLat = 39.65955,
  798. RefLon = 106.698,
  799. RefLat = 26.567,
  800. };
  801. return X3TwoDfoNoXlPosDto;
  802. }
  803. /// <summary>
  804. /// 双星时频差定位无星厉
  805. /// </summary>
  806. private X2DtoDfoNoXlPosDto X2DfoNoXL()
  807. {
  808. X2DtoDfoNoXlPosDto X2DtoDfoNoXlPosDto = new X2DtoDfoNoXlPosDto()
  809. {
  810. SigTime = DateTime.Now,
  811. MainCode = 23467,
  812. AdjaCode = 39206,
  813. Dto = -3.587980198938979e-06 * 1e6,
  814. Dfo = -17.601977254734404,
  815. YbMainDto = 0.26 * 1e6,
  816. YbAdjaDto = 0.25993647195 * 1e6,
  817. YbMainDfo = 0,
  818. YbAdjaDfo = 17.453698229247941,
  819. TarFreqUp = 3808 * 1e6 + 2225 * 1e6,
  820. TarFreqDown = 3808 * 1e6,
  821. RefFreqUp = 3796 * 1e6 + 2225 * 1e6,
  822. RefFreqDown = 3796 * 1e6,
  823. SatTxLon = 116.254567,
  824. SatTxLat = 39.65955,
  825. RefLon = 106.698,
  826. RefLat = 26.567,
  827. Snr = 20 + new Random().Next(-5, 15)
  828. };
  829. return X2DtoDfoNoXlPosDto;
  830. }
  831. private void Log(string msg)
  832. {
  833. try
  834. {
  835. if (this.InvokeRequired)
  836. {
  837. this.Invoke(new Action(() =>
  838. {
  839. if (listBoxControl1.ItemCount > 5000)
  840. listBoxControl1.Items.Clear();
  841. listBoxControl1.Items.Insert(0, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}--{msg}");
  842. listBoxControl1.SelectedIndex = 0;
  843. }));
  844. }
  845. else
  846. {
  847. if (listBoxControl1.ItemCount > 5000)
  848. listBoxControl1.Items.Clear();
  849. listBoxControl1.Items.Insert(0, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}--{msg}");
  850. listBoxControl1.SelectedIndex = 0;
  851. }
  852. }
  853. catch
  854. { }
  855. }
  856. private void Log(Exception ex)
  857. {
  858. try
  859. {
  860. if (this.InvokeRequired)
  861. {
  862. this.Invoke(new Action(() =>
  863. {
  864. if (listBoxControl1.ItemCount > 5000)
  865. listBoxControl1.Items.Clear();
  866. listBoxControl1.Items.Insert(0, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}--{ex.Message}");
  867. listBoxControl1.SelectedIndex = 0;
  868. }));
  869. }
  870. else
  871. {
  872. if (listBoxControl1.ItemCount > 5000)
  873. listBoxControl1.Items.Clear();
  874. listBoxControl1.Items.Insert(0, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}--{ex.Message}");
  875. listBoxControl1.SelectedIndex = 0;
  876. }
  877. }
  878. catch
  879. { }
  880. }
  881. private void listBoxControl1_MouseClick(object sender, MouseEventArgs e)
  882. {
  883. if (e.Button == MouseButtons.Right)
  884. {
  885. popupMenu1.ShowPopup(MousePosition);
  886. }
  887. }
  888. private void btnClear_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
  889. {
  890. listBoxControl1.Items.Clear();
  891. }
  892. private void btnCopyAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
  893. {
  894. StringBuilder sb = new StringBuilder();
  895. foreach (var item in listBoxControl1.Items)
  896. {
  897. sb.AppendLine(item.ToString());
  898. }
  899. var data = sb.ToString();
  900. if (string.IsNullOrWhiteSpace(data)) return;
  901. Clipboard.SetText(sb.ToString());
  902. }
  903. }
  904. }