Form1.cs 48 KB

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