Form1.cs 47 KB

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