Form1.cs 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941
  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++}条仿真结果,时差={dto.XdDto},测向值={dto.CxRes}");
  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 = false,
  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++}条仿真结果.双星时差={X2D1PosDto.SxDto},主星超短时差={X2D1PosDto.XdDto}");
  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}]发送两星一地无参定位仿真结果.双星时差={res.SxDto},主星超短时差={res.XdDto}");
  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++}条仿真结果,时差={dto.XdDto},测向值={dto.CxRes}");
  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 = false,
  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}]发送两星一地无参定位仿真结果.双星时差={X2D1NoXlPosDto.SxDto},主星超短时差={X2D1NoXlPosDto.XdDto}");
  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}]发送两星一地无参定位仿真结果.双星时差={res.SxDto},主星超短时差={res.XdDto}");
  375. Log($"已向[{txtAddr1.Text}]发送两星一地无参定位仿真结果");
  376. }
  377. if (tskType == "RHNoXL")//融合定位无星历
  378. {
  379. var lines = File.ReadAllLines("Simulation_Data2023.dat");
  380. int idx = 1;
  381. url += "PosRhNoXlAsync";
  382. foreach (var line in lines)
  383. {
  384. if (cts1.IsCancellationRequested) break;
  385. if (string.IsNullOrWhiteSpace(line)) continue;
  386. var items = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  387. RHNoXlPosDto RHNoXlPosDto = new RHNoXlPosDto()
  388. {
  389. SigTime = DateTime.Now,
  390. MainCode = 23467,
  391. AdjaCode = 39206,
  392. SxDto = Convert.ToDouble(items[0]) * 1e6,
  393. XdDto = Convert.ToDouble(items[1]) * 1e6,
  394. MainYbDto = Convert.ToDouble(items[2]) * 1e6,
  395. AdjaYbDto = Convert.ToDouble(items[3]) * 1e6,
  396. CxRes = Convert.ToDouble(items[4]),
  397. SatTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lon"),
  398. SatTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lat"),
  399. CdbTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lon"),
  400. CdbTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lat"),
  401. CxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lon"),
  402. CxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "侧向站", "Lat"),
  403. RefLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lon"),
  404. RefLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lat"),
  405. FreqDown = 295.425e6,//For Api Test
  406. FreqUp = 260.425e6,//For Api Test
  407. XdDfo = 1529,//For Api Test
  408. XdSnr = 25,//For Api Test
  409. SxDfo = 1024,//For Api Test
  410. SxSnr = 25,//For Api Test
  411. };
  412. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, RHNoXlPosDto);
  413. if (result.code != 200)
  414. {
  415. Log($"{result.msg}");
  416. return;
  417. }
  418. Thread.Sleep(1000);
  419. Log($"已向[{txtAddr1.Text}]发送第{idx++}条仿真结果");
  420. }
  421. }
  422. if (tskType == "X3TwoDtoNoXL")//三星双时差定位无星历
  423. {
  424. url += "PosX3TwoDtoNoXlAsync";
  425. var res = X3TwoDtoNoXL();
  426. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  427. if (result.code != 200)
  428. {
  429. Log($"{result.msg}");
  430. return;
  431. }
  432. Log($"已向[{txtAddr1.Text}]发送三星双时差定位仿真结果");
  433. }
  434. if (tskType == "X3TwoDtoNoParNoXL")//三星双时差无参定位无星历
  435. {
  436. url += "PosX3TwoDtoNoXlNoParAsync";
  437. var res = X3TwoDtoNoParNoXL();
  438. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  439. if (result.code != 200)
  440. {
  441. Log($"{result.msg}");
  442. return;
  443. }
  444. Log($"已向[{txtAddr1.Text}]发送三星双时差定位仿真结果");
  445. }
  446. if (tskType == "X3TwoDfoNoXL")//三星双频差定位无星历
  447. {
  448. url += "PosX3TwoDfoNoXlAsync";
  449. var res = X3TwoDfoNoXL();
  450. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  451. if (result.code != 200)
  452. {
  453. Log($"{result.msg}");
  454. return;
  455. }
  456. Log($"已向[{txtAddr1.Text}]发送三星双频差定位仿真结果");
  457. }
  458. if (tskType == "X2DfoNoXL")//双星时频差定位无星历
  459. {
  460. url += "PosX2DtoDfoNoXlAsync";
  461. var res = X2DfoNoXL();
  462. var result = await HttpHelper.PostRequestAsync<PosResDto>(url, res);
  463. if (result.code != 200)
  464. {
  465. Log($"{result.msg}");
  466. return;
  467. }
  468. Log($"已向[{txtAddr1.Text}]发送双星时频差定位仿真结果");
  469. }
  470. }
  471. catch (Exception ex)
  472. {
  473. Log($"向[{txtAddr1.Text}]发送结果失败.{ex.Message}");
  474. }
  475. }
  476. // await Task.Delay(1000);
  477. //}
  478. });
  479. }
  480. catch (Exception ex)
  481. {
  482. Log(ex);
  483. }
  484. finally
  485. {
  486. btn1.Text = "推送";
  487. layoutControlItem1.Enabled = true;
  488. layoutControlItem7.Enabled = true;
  489. }
  490. }
  491. else
  492. {
  493. cts1?.Cancel();
  494. }
  495. }
  496. /// <summary>
  497. /// 两星一地定位无参
  498. /// </summary>
  499. private X2D1NoParPosDto X2D1NoPar()
  500. {
  501. X2D1NoParPosDto X2D1PosDto = new X2D1NoParPosDto()
  502. {
  503. SigTime = DateTime.Now,
  504. MainCode = 25630,
  505. AdjaCode = 33276,
  506. SxDto = -0.002198485309353 * 1e6,
  507. XdDto = 0.245961726007262 * 1e6,
  508. MainX = -38209016,
  509. MainY = 17858458,
  510. MainZ = 13250,
  511. AdjaX = 4750323,
  512. AdjaY = 41902879,
  513. AdjaZ = 50515,
  514. SatTxLon = 118.8833,
  515. SatTxLat = 32.0667,
  516. CdbTxLon = 109.4082,
  517. CdbTxLat = 18.3878,
  518. FreqDown = 252.325e6,//For Api Test
  519. FreqUp = 310.85e6,//For Api Test
  520. XdDfo = 1529,//For Api Test
  521. XdSnr = 25,//For Api Test
  522. SxDfo = 1024,//For Api Test
  523. SxSnr = 25,//For Api Test
  524. MainVX = 1,//For Api Test
  525. MainVY = 1,//For Api Test
  526. MainVZ = 1,//For Api Test
  527. AdjaVX = 1,//For Api Test
  528. AdjaVY = 1,//For Api Test
  529. AdjaVZ = 1,//For Api Test
  530. };
  531. return X2D1PosDto;
  532. }
  533. /// <summary>
  534. /// 两星一地定位无参无星历
  535. /// </summary>
  536. private X2D1NoXlNoParlPosDto X2D1NoParNoXL()
  537. {
  538. X2D1NoXlNoParlPosDto X2D1NoXlNoParlPosDto = new X2D1NoXlNoParlPosDto()
  539. {
  540. SigTime = DateTime.Now,
  541. MainCode = 25630,
  542. AdjaCode = 33276,
  543. SxDto = -0.002198485309353 * 1e6,
  544. XdDto = 0.245961726007262 * 1e6,
  545. SatTxLon = 118.8833,
  546. SatTxLat = 32.0667,
  547. CdbTxLon = 109.4082,
  548. CdbTxLat = 18.3878,
  549. FreqDown = 252.325e6,//For Api Test
  550. FreqUp = 310.85e6,//For Api Test
  551. XdDfo = 1529,//For Api Test
  552. XdSnr = 25,//For Api Test
  553. SxDfo = 1024,//For Api Test
  554. SxSnr = 25,//For Api Test
  555. };
  556. return X2D1NoXlNoParlPosDto;
  557. }
  558. /// <summary>
  559. /// 三星双时差定位
  560. /// </summary>
  561. private X3TwoDtoPosDto X3TwoDto()
  562. {
  563. X3TwoDtoPosDto X3TwoDtoPosDto = new X3TwoDtoPosDto()
  564. {
  565. SigTime = DateTime.Now,
  566. MainCode = 23467,
  567. Adja1Code = 39206,
  568. Adja2Code = 40892,
  569. Dto1 = -0.0037683828 * 1e6,
  570. Dto2 = 0.00411476 * 1e6,
  571. YbMainDto = 0.253339246 * 1e6,
  572. YbAdja1Dto = 0.254082015 * 1e6,
  573. YbAdja2Dto = 0.247747625 * 1e6,
  574. MainX = -38209016,
  575. MainY = 17858458,
  576. MainZ = 13250,
  577. Adja1X = 4750323,
  578. Adja1Y = 41902879,
  579. Adja1Z = 50515,
  580. Adja2X = -30932433,
  581. Adja2Y = 28638701,
  582. Adja2Z = -582065,
  583. SatTxLon = 118.8833,
  584. SatTxLat = 32.0667,
  585. RefLon = 121.538,
  586. RefLat = 30.8385,
  587. FreqDown = 252.325e6,//For Api Test
  588. FreqUp = 310.85e6,//For Api Test
  589. Dfo1 = 1629,//For Api Test
  590. Snr1 = 27.1,//For Api Test
  591. Dfo2 = 1025,//For Api Test
  592. Snr2 = 27.4,//For Api Test
  593. CalcConfidence = true,
  594. };
  595. return X3TwoDtoPosDto;
  596. }
  597. /// <summary>
  598. /// 三星双时差无参定位
  599. /// </summary>
  600. private X3TwoDtoNoParPosDto X3TwoDtoNoPar()
  601. {
  602. X3TwoDtoNoParPosDto X3TwoDtoNoParPosDto = new X3TwoDtoNoParPosDto()
  603. {
  604. SigTime = DateTime.Now,
  605. MainCode = 23467,
  606. Adja1Code = 39206,
  607. Adja2Code = 40892,
  608. Dto1 = -0.008361002956792 * 1e6,
  609. Dto2 = 0.004191941221694 * 1e6,
  610. MainX = -38214804,
  611. MainY = 17780164,
  612. MainZ = -6857,
  613. Adja1X = 4824458,
  614. Adja1Y = 41896265,
  615. Adja1Z = -55899,
  616. Adja2X = -27105105,
  617. Adja2Y = 32302912,
  618. Adja2Z = 11952,
  619. SatTxLon = 121.3555,
  620. SatTxLat = 31.3667,
  621. FreqDown = 252.325e6,//For Api Test
  622. FreqUp = 310.85e6,//For Api Test
  623. Dfo1 = 1629,//For Api Test
  624. Snr1 = 27.1,//For Api Test
  625. Dfo2 = 1025,//For Api Test
  626. Snr2 = 27.4,//For Api Test
  627. MainVX = 1,//For Api Test
  628. MainVY = 1,//For Api Test
  629. MainVZ = 1,//For Api Test
  630. Adja1VX = 1,//For Api Test
  631. Adja1VY = 1,//For Api Test
  632. Adja1VZ = 1,//For Api Test
  633. Adja2VX = 1,//For Api Test
  634. Adja2VY = 1,//For Api Test
  635. Adja2VZ = 1,//For Api Test
  636. };
  637. return X3TwoDtoNoParPosDto;
  638. }
  639. /// <summary>
  640. /// 三星双频差定位
  641. /// </summary>
  642. private X3TwoDfoPosDto X3TwoDfo()
  643. {
  644. X3TwoDfoPosDto X3TwoDfoPosDto = new X3TwoDfoPosDto()
  645. {
  646. SigTime = DateTime.Now,
  647. MainCode = 23467,
  648. Adja1Code = 39206,
  649. Adja2Code = 40892,
  650. Dfo1 = -17.601977254734404,
  651. Dfo2 = -36.885840020369514,
  652. YbMainDfo = 0,
  653. YbAdja1Dfo = 17.453698229247941,
  654. YbAdja2Dfo = 37.022577554138941,
  655. TarFreqUp = 3808 * 1e6 + 2225 * 1e6,
  656. TarFreqDown = 3808 * 1e6,
  657. RefFreqUp = 3796 * 1e6 + 2225 * 1e6,
  658. RefFreqDown = 3796 * 1e6,
  659. MainX = -18149981.873274,
  660. MainY = 38039767.675679,
  661. MainZ = -5662.335149,
  662. MainVx = -2.006064,
  663. MainVy = -1.4693,
  664. MainVz = 1.62569,
  665. Adja1X = -14770224.082665,
  666. Adja1Y = 39479299.786862,
  667. Adja1Z = -53188.063002,
  668. Adja1Vx = -1.764989,
  669. Adja1Vy = -0.528101,
  670. Adja1Vz = 1.808949,
  671. Adja2X = -33231255.13,
  672. Adja2Y = 25948042.76,
  673. Adja2Z = 27091.80,
  674. Adja2Vx = -0.607289,
  675. Adja2Vy = 0.089864,
  676. Adja2Vz = -0.069086,
  677. SatTxLon = 116.254567,
  678. SatTxLat = 39.65955,
  679. RefLon = 106.698,
  680. RefLat = 26.567,
  681. Dto1 = 829.2,//For Api Test
  682. Snr1 = 27.7,//For Api Test
  683. Dto2 = 1928.3,//For Api Test
  684. Snr2 = 27.9,//For Api Test
  685. };
  686. return X3TwoDfoPosDto;
  687. }
  688. /// <summary>
  689. /// 双星时频差定位
  690. /// </summary>
  691. private X2DtoDfoPosDto X2Dfo()
  692. {
  693. X2DtoDfoPosDto X2DtoDfoPosDto = new X2DtoDfoPosDto()
  694. {
  695. SigTime = DateTime.Now,
  696. MainCode = 23467,
  697. AdjaCode = 39206,
  698. Dto = -3.587980198938979e-06 * 1e6,
  699. Dfo = -17.601977254734404,
  700. YbMainDto = 0.26 * 1e6,
  701. YbAdjaDto = 0.25993647195 * 1e6,
  702. YbMainDfo = 0,
  703. YbAdjaDfo = 17.453698229247941,
  704. TarFreqUp = 3808 * 1e6 + 2225 * 1e6,
  705. TarFreqDown = 3808 * 1e6,
  706. RefFreqUp = 3796 * 1e6 + 2225 * 1e6,
  707. RefFreqDown = 3796 * 1e6,
  708. MainX = -18149981.873274,
  709. MainY = 38039767.675679,
  710. MainZ = -5662.335149,
  711. MainVx = -2.006064,
  712. MainVy = -1.4693,
  713. MainVz = 1.62569,
  714. AdjaX = -14770224.082665,
  715. AdjaY = 39479299.786862,
  716. AdjaZ = -53188.063002,
  717. AdjaVx = -1.764989,
  718. AdjaVy = -0.528101,
  719. AdjaVz = 1.808949,
  720. SatTxLon = 116.254567,
  721. SatTxLat = 39.65955,
  722. RefLon = 106.698,
  723. RefLat = 26.567,
  724. Snr = 19.27,//For Api Test
  725. };
  726. return X2DtoDfoPosDto;
  727. }
  728. /// <summary>
  729. /// 三星双时差定位无星历
  730. /// </summary>
  731. private X3TwoDtoNoXlPosDto X3TwoDtoNoXL()
  732. {
  733. X3TwoDtoNoXlPosDto X3TwoDtoNoXlPosDto = new X3TwoDtoNoXlPosDto()
  734. {
  735. SigTime = DateTime.Now,
  736. MainCode = 23467,
  737. Adja1Code = 39206,
  738. Adja2Code = 40892,
  739. Dto1 = -0.0037683828 * 1e6,
  740. Dto2 = 0.00411476 * 1e6,
  741. YbMainDto = 0.253339246 * 1e6,
  742. YbAdja1Dto = 0.254082015 * 1e6,
  743. YbAdja2Dto = 0.247747625 * 1e6,
  744. SatTxLon = 118.8833,
  745. SatTxLat = 32.0667,
  746. RefLon = 121.538,
  747. RefLat = 30.8385,
  748. FreqDown = 252.325e6,//For Api Test
  749. FreqUp = 310.85e6,//For Api Test
  750. Dfo1 = 1629,//For Api Test
  751. Snr1 = 27.1,//For Api Test
  752. Dfo2 = 1025,//For Api Test
  753. Snr2 = 27.4,//For Api Test
  754. CalcConfidence = true,
  755. };
  756. return X3TwoDtoNoXlPosDto;
  757. }
  758. /// <summary>
  759. /// 三星双时差无参定位无星历
  760. /// </summary>
  761. private X3TwoDtoNoXlNoParPosDto X3TwoDtoNoParNoXL()
  762. {
  763. X3TwoDtoNoXlNoParPosDto X3TwoDtoNoParPosDto = new X3TwoDtoNoXlNoParPosDto()
  764. {
  765. SigTime = DateTime.Now,
  766. MainCode = 23467,
  767. Adja1Code = 39206,
  768. Adja2Code = 40892,
  769. Dto1 = -0.008361002956792 * 1e6,
  770. Dto2 = 0.004191941221694 * 1e6,
  771. SatTxLon = 121.3555,
  772. SatTxLat = 31.3667,
  773. FreqDown = 252.325e6,//For Api Test
  774. FreqUp = 310.85e6,//For Api Test
  775. Dfo1 = 1629,//For Api Test
  776. Snr1 = 27.1,//For Api Test
  777. Dfo2 = 1025,//For Api Test
  778. Snr2 = 27.4,//For Api Test
  779. };
  780. return X3TwoDtoNoParPosDto;
  781. }
  782. /// <summary>
  783. /// 三星双频差定位无星历
  784. /// </summary>
  785. private X3TwoDfoNoXlPosDto X3TwoDfoNoXL()
  786. {
  787. X3TwoDfoNoXlPosDto X3TwoDfoNoXlPosDto = new X3TwoDfoNoXlPosDto()
  788. {
  789. SigTime = DateTime.Now,
  790. MainCode = 23467,
  791. Adja1Code = 39206,
  792. Adja2Code = 40892,
  793. Dfo1 = -17.601977254734404,
  794. Dfo2 = -36.885840020369514,
  795. YbMainDfo = 0,
  796. YbAdja1Dfo = 17.453698229247941,
  797. YbAdja2Dfo = 37.022577554138941,
  798. TarFreqUp = 3808 * 1e6 + 2225 * 1e6,
  799. TarFreqDown = 3808 * 1e6,
  800. RefFreqUp = 3796 * 1e6 + 2225 * 1e6,
  801. RefFreqDown = 3796 * 1e6,
  802. SatTxLon = 116.254567,
  803. SatTxLat = 39.65955,
  804. RefLon = 106.698,
  805. RefLat = 26.567,
  806. };
  807. return X3TwoDfoNoXlPosDto;
  808. }
  809. /// <summary>
  810. /// 双星时频差定位无星历
  811. /// </summary>
  812. private X2DtoDfoNoXlPosDto X2DfoNoXL()
  813. {
  814. X2DtoDfoNoXlPosDto X2DtoDfoNoXlPosDto = new X2DtoDfoNoXlPosDto()
  815. {
  816. SigTime = DateTime.Now,
  817. MainCode = 23467,
  818. AdjaCode = 39206,
  819. Dto = -3.587980198938979e-06 * 1e6,
  820. Dfo = -17.601977254734404,
  821. YbMainDto = 0.26 * 1e6,
  822. YbAdjaDto = 0.25993647195 * 1e6,
  823. YbMainDfo = 0,
  824. YbAdjaDfo = 17.453698229247941,
  825. TarFreqUp = 3808 * 1e6 + 2225 * 1e6,
  826. TarFreqDown = 3808 * 1e6,
  827. RefFreqUp = 3796 * 1e6 + 2225 * 1e6,
  828. RefFreqDown = 3796 * 1e6,
  829. SatTxLon = 116.254567,
  830. SatTxLat = 39.65955,
  831. RefLon = 106.698,
  832. RefLat = 26.567,
  833. Snr = 20 + new Random().Next(-5, 15)
  834. };
  835. return X2DtoDfoNoXlPosDto;
  836. }
  837. private void Log(string msg)
  838. {
  839. try
  840. {
  841. if (this.InvokeRequired)
  842. {
  843. this.Invoke(new Action(() =>
  844. {
  845. if (listBoxControl1.ItemCount > 5000)
  846. listBoxControl1.Items.Clear();
  847. listBoxControl1.Items.Insert(0, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}--{msg}");
  848. listBoxControl1.SelectedIndex = 0;
  849. }));
  850. }
  851. else
  852. {
  853. if (listBoxControl1.ItemCount > 5000)
  854. listBoxControl1.Items.Clear();
  855. listBoxControl1.Items.Insert(0, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}--{msg}");
  856. listBoxControl1.SelectedIndex = 0;
  857. }
  858. }
  859. catch
  860. { }
  861. }
  862. private void Log(Exception ex)
  863. {
  864. try
  865. {
  866. if (this.InvokeRequired)
  867. {
  868. this.Invoke(new Action(() =>
  869. {
  870. if (listBoxControl1.ItemCount > 5000)
  871. listBoxControl1.Items.Clear();
  872. listBoxControl1.Items.Insert(0, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}--{ex.Message}");
  873. listBoxControl1.SelectedIndex = 0;
  874. }));
  875. }
  876. else
  877. {
  878. if (listBoxControl1.ItemCount > 5000)
  879. listBoxControl1.Items.Clear();
  880. listBoxControl1.Items.Insert(0, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}--{ex.Message}");
  881. listBoxControl1.SelectedIndex = 0;
  882. }
  883. }
  884. catch
  885. { }
  886. }
  887. private void listBoxControl1_MouseClick(object sender, MouseEventArgs e)
  888. {
  889. if (e.Button == MouseButtons.Right)
  890. {
  891. popupMenu1.ShowPopup(MousePosition);
  892. }
  893. }
  894. private void btnClear_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
  895. {
  896. listBoxControl1.Items.Clear();
  897. }
  898. private void btnCopyAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
  899. {
  900. StringBuilder sb = new StringBuilder();
  901. foreach (var item in listBoxControl1.Items)
  902. {
  903. sb.AppendLine(item.ToString());
  904. }
  905. var data = sb.ToString();
  906. if (string.IsNullOrWhiteSpace(data)) return;
  907. Clipboard.SetText(sb.ToString());
  908. }
  909. }
  910. }