Form1.cs 48 KB

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