FXJHGenenrate.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873
  1. using SimulationCommon;
  2. namespace Model
  3. {
  4. public class FXJHGenerate
  5. {
  6. public static void FromStartToMission(FlightPlanEditor editor,ref List<TurningPoint> turningPoints) //生成从基地到任务段起点的航路点
  7. {
  8. turningPoints.Add(new TurningPoint
  9. {
  10. TurningPointName = "爬升",
  11. TurningPointLongitude = editor.originbase.BaseLongitude, //基地位置
  12. TurningPointLatitude = editor.originbase.BaseLatitude,
  13. TurningPointHeight = editor.originbase.BaseHeight,
  14. TurningPointType = "普通",
  15. //TurningPointVelocity = editor.climbsegment.ClimbVelocity;
  16. SegmentFlightFuelConsumption = 1,
  17. SegmentFlightTime = 0,
  18. RemainingFuel = 0,
  19. });
  20. // double k;
  21. double lat1, lon1; //直升机起飞后爬升到的航路点的经纬度,记为经纬度1
  22. lat1 = (editor.originbase.BaseLatitude + editor.missionpoint.MissionPointLatitude) / 2;
  23. lon1 = (editor.originbase.BaseLongitude + editor.missionpoint.MissionPointLongitude) / 2;
  24. // k = (editor.missionpoint.MissionPointLatitude - editor.originbase.BaseLatitude) /
  25. // (editor.missionpoint.MissionPointLongitude - editor.originbase.BaseLongitude);
  26. // if (editor.missionpoint.MissionPointLongitude > editor.originbase.BaseLongitude)
  27. // {
  28. // lat1 = 0.08544 * k / (Math.Sqrt(k * k + 1)) + editor.originbase.BaseLatitude; //经验公式
  29. // lon1 = 0.08544 / (Math.Sqrt(k * k + 1)) + editor.originbase.BaseLongitude;
  30. // }
  31. // else
  32. // {
  33. // lat1 = editor.originbase.BaseLatitude - 0.08544 * k / (Math.Sqrt(k * k + 1));
  34. // lon1 = editor.originbase.BaseLongitude - 0.08544 / (Math.Sqrt(k * k + 1));
  35. // }
  36. turningPoints.Add(new TurningPoint
  37. {
  38. TurningPointName = "平飞",
  39. TurningPointLongitude = lon1,
  40. TurningPointLatitude = lat1,
  41. TurningPointHeight = 2000,
  42. TurningPointType = "普通",
  43. SegmentFlightFuelConsumption = 2,
  44. SegmentFlightTime = 0,
  45. RemainingFuel = 0,
  46. });
  47. }
  48. //获取油耗率
  49. public static double GetClimbFuelConsumptionRate(FlightPlanEditor editor, double height)
  50. {
  51. double temp = Util.GetTemperature(editor.originbase.BaseLongitude, editor.originbase.BaseLatitude);
  52. Fuel fuel = Util.GetFuel(editor.aircraftparameter.AircraftID, editor.aircraftparameter.AircraftSubType,
  53. "爬升", temp.ToString(), height.ToString(),
  54. editor.aircraftparameter.MaxTakeoffWeight.ToString());
  55. if (fuel == null)
  56. {
  57. return 1100;
  58. }
  59. return fuel.oilconsume;
  60. }
  61. public static double GetCruisingFuelConsumptionRate(FlightPlanEditor editor, double height)
  62. {
  63. double temp = Util.GetTemperature(editor.originbase.BaseLongitude, editor.originbase.BaseLatitude);
  64. Fuel fuel = Util.GetFuel(editor.aircraftparameter.AircraftID, editor.aircraftparameter.AircraftSubType,
  65. "平飞远航", temp.ToString(), height.ToString(),
  66. editor.aircraftparameter.MaxTakeoffWeight.ToString());
  67. if (fuel == null)
  68. {
  69. return 600;
  70. }
  71. return fuel.oilconsume;
  72. }
  73. public static double GetEnduranceFuelConsumptionRate(FlightPlanEditor editor, double height)
  74. {
  75. double temp = Util.GetTemperature(editor.originbase.BaseLongitude, editor.originbase.BaseLatitude);
  76. Fuel fuel = Util.GetFuel(editor.aircraftparameter.AircraftID, editor.aircraftparameter.AircraftSubType,
  77. "平飞久航", temp.ToString(), height.ToString(),
  78. editor.aircraftparameter.MaxTakeoffWeight.ToString());
  79. if (fuel == null)
  80. {
  81. return 600;
  82. }
  83. return fuel.oilconsume;
  84. }
  85. public static double GetDescentFuelConsumptionRate(FlightPlanEditor editor, double height)
  86. {
  87. return 2 * GetCruisingFuelConsumptionRate(editor, height) - GetClimbFuelConsumptionRate(editor, height);
  88. }
  89. public static double GetHoverFuelConsumptionRate(FlightPlanEditor editor, double height)
  90. {
  91. double temp = Util.GetTemperature(editor.originbase.BaseLongitude, editor.originbase.BaseLatitude);
  92. Fuel fuel = Util.GetFuel(editor.aircraftparameter.AircraftID, editor.aircraftparameter.AircraftSubType,
  93. "悬停", temp.ToString(), height.ToString(),
  94. editor.aircraftparameter.MaxTakeoffWeight.ToString());
  95. if (fuel == null)
  96. {
  97. return 200;
  98. }
  99. return fuel.oilconsume;
  100. }
  101. //获取速度值
  102. public static double GetClimbVelocity(FlightPlanEditor editor, double height)
  103. {
  104. double temp = Util.GetTemperature(editor.originbase.BaseLongitude, editor.originbase.BaseLatitude);
  105. Fuel fuel = Util.GetFuel(editor.aircraftparameter.AircraftID, editor.aircraftparameter.AircraftSubType,
  106. "爬升", temp.ToString(), height.ToString(), editor.aircraftparameter.MaxTakeoffWeight.ToString());
  107. if (fuel == null)
  108. {
  109. return 60;
  110. }
  111. return fuel.speed;
  112. }
  113. public static double GetCruisingVelocity(FlightPlanEditor editor, double height)
  114. {
  115. double temp = Util.GetTemperature(editor.originbase.BaseLongitude, editor.originbase.BaseLatitude);
  116. Fuel fuel = Util.GetFuel(editor.aircraftparameter.AircraftID, editor.aircraftparameter.AircraftSubType,
  117. "平飞远航", temp.ToString(), height.ToString(), editor.aircraftparameter.MaxTakeoffWeight.ToString());
  118. if (fuel == null)
  119. {
  120. return 200;
  121. }
  122. return fuel.speed;
  123. }
  124. public static double GetEnduranceVelocity(FlightPlanEditor editor, double height)
  125. {
  126. double temp = Util.GetTemperature(editor.originbase.BaseLongitude, editor.originbase.BaseLatitude);
  127. Fuel fuel = Util.GetFuel(editor.aircraftparameter.AircraftID, editor.aircraftparameter.AircraftSubType,
  128. "平飞久航", temp.ToString(), height.ToString(), editor.aircraftparameter.MaxTakeoffWeight.ToString());
  129. if (fuel == null)
  130. {
  131. return 200;
  132. }
  133. return fuel.speed;
  134. }
  135. public static double GetDescentVelocity(FlightPlanEditor editor, double height)
  136. {
  137. return GetCruisingVelocity(editor, height) / 2;
  138. }
  139. public static void ZhenCha(List<double[]> SC01, FlightPlanEditor editor, ref List<TurningPoint> turningPoints) //侦查模型航路点生成
  140. {
  141. int i;
  142. for (i = 0; i < SC01.Count - 1; i++)
  143. {
  144. turningPoints.Add(new TurningPoint
  145. {
  146. TurningPointName = "平飞",
  147. TurningPointLongitude = SC01[i][0],
  148. TurningPointLatitude = SC01[i][1],
  149. TurningPointHeight = SC01[i][2],
  150. TurningPointType = "侦查",
  151. SegmentFlightFuelConsumption = 3,
  152. SegmentFlightTime = 0,
  153. RemainingFuel = 0,
  154. });
  155. }
  156. }
  157. public static void SuoHuaJiang(double resulttime, FlightPlanEditor editor,
  158. ref List<TurningPoint> turningPoints) //索滑降模型航路点生成
  159. {
  160. turningPoints.Add(new TurningPoint
  161. {
  162. TurningPointName = "索滑降",
  163. TurningPointLongitude = editor.missionpoint.MissionPointLongitude,
  164. TurningPointLatitude = editor.missionpoint.MissionPointLatitude,
  165. TurningPointHeight = editor.missionpoint.MissionPointHeight,
  166. TurningPointType = "索滑降",
  167. SegmentFlightFuelConsumption = 5,
  168. SegmentFlightTime = resulttime,
  169. RemainingFuel = 0,
  170. });
  171. turningPoints.Add(new TurningPoint
  172. {
  173. TurningPointName = "索滑降",
  174. TurningPointLongitude = editor.missionpoint.MissionPointLongitude,
  175. TurningPointLatitude = editor.missionpoint.MissionPointLatitude,
  176. TurningPointHeight = editor.missionpoint.MissionPointHeight,
  177. TurningPointType = "索滑降",
  178. SegmentFlightFuelConsumption = 2,
  179. SegmentFlightTime = 0,
  180. RemainingFuel = 0,
  181. });
  182. }
  183. public static void XunHu(FlightPlanEditor editor,ref List<TurningPoint> turningPoints)
  184. {
  185. int i;
  186. for (i = 0; i < editor.airroute.Length; i++)
  187. {
  188. turningPoints.Add(new TurningPoint
  189. {
  190. TurningPointName = "平飞",
  191. TurningPointLongitude = editor.airroute[i].AirRouteLongitude,
  192. TurningPointLatitude = editor.airroute[i].AirRouteLatitude,
  193. TurningPointHeight = editor.airroute[i].AirRouteHeight,
  194. TurningPointType = "普通",
  195. SegmentFlightFuelConsumption = 3,
  196. SegmentFlightTime = 0,
  197. RemainingFuel = 0,
  198. });
  199. }
  200. }
  201. public static void MieHuo1(FlightPlanEditor editor,ref List<TurningPoint> turningPoints) //灭火任务从取水点到火场部分的航路点生成
  202. {
  203. turningPoints.Add(new TurningPoint
  204. {
  205. TurningPointName = "取水",
  206. TurningPointLongitude = editor.missionpoint.MissionPointLongitude,
  207. TurningPointLatitude = editor.missionpoint.MissionPointLatitude,
  208. TurningPointHeight = editor.missionpoint.MissionPointHeight,
  209. TurningPointType = "取水",
  210. SegmentFlightFuelConsumption = 3,
  211. SegmentFlightTime = 120,
  212. RemainingFuel = 0,
  213. });
  214. turningPoints.Add(new TurningPoint
  215. {
  216. TurningPointName = "洒水",
  217. TurningPointLongitude = editor.firepoint[0].FirePointLongitude,
  218. TurningPointLatitude = editor.firepoint[0].FirePointLatitude,
  219. TurningPointHeight = editor.firepoint[0].FirePointHeight,
  220. TurningPointType = "巡航",
  221. SegmentFlightFuelConsumption = 3,
  222. SegmentFlightTime = 0,
  223. RemainingFuel = 0,
  224. });
  225. }
  226. public static MissionEndPoint ZhenChaMissionEndPoint(List<double[]> SC01) //侦查模型任务终点生成
  227. {
  228. MissionEndPoint missionEndPoint = new();
  229. int length = SC01.Count - 1;
  230. missionEndPoint.MissionEndPointLongitude = SC01[length][0];
  231. missionEndPoint.MissionEndPointLatitude = SC01[length][1];
  232. missionEndPoint.MissionEndPointHeight = SC01[length][2];
  233. return missionEndPoint;
  234. }
  235. public static MissionEndPoint SuoHuaJiangMissionEndPoint(FlightPlanEditor editor) //索滑降模型任务终点生成
  236. {
  237. MissionEndPoint missionEndPoint = new();
  238. missionEndPoint.MissionEndPointLongitude = editor.missionpoint.MissionPointLongitude;
  239. missionEndPoint.MissionEndPointLatitude = editor.missionpoint.MissionPointLatitude;
  240. missionEndPoint.MissionEndPointHeight = editor.missionpoint.MissionPointHeight;
  241. return missionEndPoint;
  242. }
  243. public static void JijiangMiehuo1(FlightPlanEditor editor,ref List<TurningPoint> turningPoint)
  244. {
  245. turningPoint.Add(new TurningPoint
  246. {
  247. TurningPointName = "转运",
  248. TurningPointLongitude = editor.missionpoint.MissionPointLongitude,
  249. TurningPointLatitude = editor.missionpoint.MissionPointLatitude,
  250. TurningPointHeight = editor.missionpoint.MissionPointHeight,
  251. TurningPointType = "转运",
  252. SegmentFlightFuelConsumption = 2,
  253. SegmentFlightTime = 0,
  254. RemainingFuel = 0,
  255. });
  256. }
  257. public static void JijiangMiehuo(FlightPlanEditor editor,ref List<TurningPoint> turningPoint)
  258. {
  259. turningPoint.Add(new TurningPoint
  260. {
  261. TurningPointName = "转运",
  262. TurningPointLongitude = editor.originbase.BaseLongitude,
  263. TurningPointLatitude = editor.originbase.BaseLatitude,
  264. TurningPointHeight = editor.originbase.BaseHeight,
  265. TurningPointType = "转运",
  266. SegmentFlightFuelConsumption = 2,
  267. SegmentFlightTime = 0,
  268. RemainingFuel = 0,
  269. });
  270. turningPoint.Add(new TurningPoint
  271. {
  272. TurningPointName = "转运",
  273. TurningPointLongitude = editor.missionpoint.MissionPointLongitude,
  274. TurningPointLatitude = editor.missionpoint.MissionPointLatitude,
  275. TurningPointHeight = editor.missionpoint.MissionPointHeight,
  276. TurningPointType = "转运",
  277. SegmentFlightFuelConsumption = 2,
  278. SegmentFlightTime = 0,
  279. RemainingFuel = 0,
  280. });
  281. }
  282. public static void KouTouKouSong(FlightPlanEditor editor, ref List<TurningPoint> turningPoint)
  283. {
  284. turningPoint.Add(new TurningPoint
  285. {
  286. TurningPointName = "转运",
  287. TurningPointLongitude = editor.missionpoint.MissionPointLongitude,
  288. TurningPointLatitude = editor.missionpoint.MissionPointLatitude,
  289. TurningPointHeight = editor.missionpoint.MissionPointHeight,
  290. TurningPointType = "转运",
  291. SegmentFlightFuelConsumption = 2,
  292. SegmentFlightTime = 0,
  293. RemainingFuel = 0,
  294. });
  295. }
  296. public static void KouTouKouSong1(MissionPoint missionpoint, ref List<TurningPoint> turningPoint)
  297. {
  298. turningPoint.Add(new TurningPoint
  299. {
  300. TurningPointName = "转运",
  301. TurningPointLongitude = missionpoint.MissionPointLongitude,
  302. TurningPointLatitude = missionpoint.MissionPointLatitude,
  303. TurningPointHeight = missionpoint.MissionPointHeight,
  304. TurningPointType = "转运",
  305. SegmentFlightFuelConsumption = 2,
  306. SegmentFlightTime = 0,
  307. RemainingFuel = 0,
  308. });
  309. }
  310. public static void JijiangJiuYuan1(FlightPlanEditor editor, ref List<TurningPoint> turningPoint)
  311. {
  312. turningPoint.Add(new TurningPoint
  313. {
  314. TurningPointName = "转运",
  315. TurningPointLongitude = editor.missionpoint.MissionPointLongitude,
  316. TurningPointLatitude = editor.missionpoint.MissionPointLatitude,
  317. TurningPointHeight = editor.missionpoint.MissionPointHeight,
  318. TurningPointType = "转运",
  319. SegmentFlightFuelConsumption = 2,
  320. SegmentFlightTime = 600,
  321. RemainingFuel = 0,
  322. });
  323. turningPoint.Add(new TurningPoint
  324. {
  325. TurningPointName = "转运",
  326. TurningPointLongitude = editor.missionpoint.MissionPointLongitude,
  327. TurningPointLatitude = editor.missionpoint.MissionPointLatitude,
  328. TurningPointHeight = editor.missionpoint.MissionPointHeight,
  329. TurningPointType = "转运",
  330. SegmentFlightFuelConsumption = 2,
  331. SegmentFlightTime = 0,
  332. RemainingFuel = 0,
  333. });
  334. }
  335. public static void JijiangJiuYuan(FlightPlanEditor editor, ref List<TurningPoint> turningPoint)
  336. {
  337. turningPoint.Add(new TurningPoint
  338. {
  339. TurningPointName = "转运",
  340. TurningPointLongitude = editor.originbase.BaseLongitude,
  341. TurningPointLatitude = editor.originbase.BaseLatitude,
  342. TurningPointHeight = editor.originbase.BaseHeight,
  343. TurningPointType = "转运",
  344. SegmentFlightFuelConsumption = 2,
  345. SegmentFlightTime = 0,
  346. RemainingFuel = 0,
  347. });
  348. turningPoint.Add(new TurningPoint
  349. {
  350. TurningPointName = "转运",
  351. TurningPointLongitude = editor.missionpoint.MissionPointLongitude,
  352. TurningPointLatitude = editor.missionpoint.MissionPointLatitude,
  353. TurningPointHeight = editor.missionpoint.MissionPointHeight,
  354. TurningPointType = "转运",
  355. SegmentFlightFuelConsumption = 2,
  356. SegmentFlightTime = 600,
  357. RemainingFuel = 0,
  358. });
  359. turningPoint.Add(new TurningPoint
  360. {
  361. TurningPointName = "转运",
  362. TurningPointLongitude = editor.missionpoint.MissionPointLongitude,
  363. TurningPointLatitude = editor.missionpoint.MissionPointLatitude,
  364. TurningPointHeight = editor.missionpoint.MissionPointHeight,
  365. TurningPointType = "转运",
  366. SegmentFlightFuelConsumption = 2,
  367. SegmentFlightTime = 0,
  368. RemainingFuel = 0,
  369. });
  370. }
  371. public static void ZhaoShuiJiuYuan(List<AirRoute> airRoutes, ref List<TurningPoint> turningPoint)
  372. {
  373. for (int i = 0;i < airRoutes.Count; i++)
  374. {
  375. turningPoint.Add(new TurningPoint
  376. {
  377. TurningPointName = "转运",
  378. TurningPointLongitude = airRoutes[i].AirRouteLongitude,
  379. TurningPointLatitude = airRoutes[i].AirRouteLatitude,
  380. TurningPointHeight = 1000,
  381. TurningPointType = "转运",
  382. SegmentFlightFuelConsumption = 3,
  383. SegmentFlightTime = 0,
  384. RemainingFuel = 0,
  385. });
  386. }
  387. }
  388. public static void ZhaoShuiJiuYuan1(List<AirRoute> airRoutes, ref List<TurningPoint> turningPoint)
  389. {
  390. turningPoint.Add(new TurningPoint
  391. {
  392. TurningPointName = "转运",
  393. TurningPointLongitude = airRoutes[airRoutes.Count - 1].AirRouteLongitude,
  394. TurningPointLatitude = airRoutes[airRoutes.Count - 1].AirRouteLatitude,
  395. TurningPointHeight = 1000,
  396. TurningPointType = "转运",
  397. SegmentFlightFuelConsumption = 3,
  398. SegmentFlightTime = 1800,
  399. RemainingFuel = 0,
  400. });
  401. }
  402. public static void SeaSouJiu(FlightPlanEditor editor, ref List<TurningPoint> turningPoints)
  403. {
  404. int i;
  405. for (i = 0; i < editor.airroute.Length; i++)
  406. {
  407. turningPoints.Add(new TurningPoint
  408. {
  409. TurningPointName = "巡航",
  410. TurningPointLongitude = editor.airroute[i].AirRouteLongitude,
  411. TurningPointLatitude = editor.airroute[i].AirRouteLatitude,
  412. TurningPointHeight = 150,
  413. TurningPointType = "普通",
  414. SegmentFlightFuelConsumption = 3,
  415. SegmentFlightTime = 0,
  416. RemainingFuel = 0,
  417. });
  418. }
  419. }
  420. public static void SeaSouJiu2(FlightPlanEditor editor, MissionPoint missionPoint, ref List<TurningPoint> turningPoints)
  421. {
  422. turningPoints.Add(new TurningPoint
  423. {
  424. TurningPointName = "巡航",
  425. TurningPointLongitude = missionPoint.MissionPointLongitude,
  426. TurningPointLatitude = missionPoint.MissionPointLatitude,
  427. TurningPointHeight = 0,
  428. TurningPointType = "普通",
  429. SegmentFlightFuelConsumption = 3,
  430. SegmentFlightTime = 0,
  431. RemainingFuel = 0,
  432. });
  433. }
  434. public static void LandSouJiu(FlightPlanEditor editor, ref List<TurningPoint> turningPoints)
  435. {
  436. int i;
  437. for (i = 0; i < editor.airroute.Length; i++)
  438. {
  439. turningPoints.Add(new TurningPoint
  440. {
  441. TurningPointName = "巡航",
  442. TurningPointLongitude = editor.airroute[i].AirRouteLongitude,
  443. TurningPointLatitude = editor.airroute[i].AirRouteLatitude,
  444. TurningPointHeight = editor.airroute[i].AirRouteHeight,
  445. TurningPointType = "普通",
  446. SegmentFlightFuelConsumption = 3,
  447. SegmentFlightTime = 0,
  448. RemainingFuel = 0,
  449. });
  450. }
  451. }
  452. public static void FromMissionToEnd(FlightPlanEditor editor, MissionEndPoint missionEndPoint, ref List<TurningPoint> turningPoints) //生成从任务段终点到基地的航路点
  453. {
  454. turningPoints.Add(new TurningPoint
  455. {
  456. TurningPointName = "平飞",
  457. TurningPointLongitude = missionEndPoint.MissionEndPointLongitude,
  458. TurningPointLatitude = missionEndPoint.MissionEndPointLatitude,
  459. TurningPointHeight = missionEndPoint.MissionEndPointHeight,
  460. TurningPointType = "普通",
  461. SegmentFlightFuelConsumption = 3,
  462. SegmentFlightTime = 0,
  463. RemainingFuel = 0,
  464. });
  465. //double k;
  466. double lat2, lon2;
  467. lat2 = (turningPoints[^1].TurningPointLatitude + editor.originbase.BaseLatitude) / 2;
  468. lon2 = (turningPoints[^1].TurningPointLongitude + editor.originbase.BaseLongitude) / 2;
  469. // k = (turningPoints[^1].TurningPointLatitude - editor.originbase.BaseLatitude) /
  470. // (turningPoints[^1].TurningPointLongitude - editor.originbase.BaseLongitude);
  471. // if (turningPoints[^1].TurningPointLongitude > editor.originbase.BaseLongitude)
  472. // {
  473. // lat2 = 0.08544 * k / (Math.Sqrt(k * k + 1)) + editor.originbase.BaseLatitude;
  474. // lon2 = 0.08544 / (Math.Sqrt(k * k + 1)) + editor.originbase.BaseLongitude;
  475. // }
  476. // else
  477. // {
  478. // lat2 = editor.originbase.BaseLatitude - 0.08544 * k / (Math.Sqrt(k * k + 1));
  479. // lon2 = editor.originbase.BaseLongitude - 0.08544 / (Math.Sqrt(k * k + 1));
  480. // }
  481. turningPoints.Add(new TurningPoint
  482. {
  483. TurningPointName = "降高",
  484. TurningPointLongitude = lon2,
  485. TurningPointLatitude = lat2,
  486. TurningPointHeight = 2000,
  487. TurningPointType = "普通",
  488. SegmentFlightFuelConsumption = 4,
  489. SegmentFlightTime = 0,
  490. RemainingFuel = 0,
  491. });
  492. }
  493. public static void InitializeVelocities(FlightPlanEditor editor,List<TurningPoint> turningPoints, ref double[] velocitys)
  494. {
  495. velocitys[0] = GetClimbVelocity(editor, turningPoints[0].TurningPointHeight);
  496. velocitys[1] = GetCruisingVelocity(editor, turningPoints[1].TurningPointHeight);
  497. velocitys[2] = GetEnduranceVelocity(editor, turningPoints[2].TurningPointHeight);
  498. velocitys[3] = GetDescentVelocity(editor, turningPoints[0].TurningPointHeight);
  499. }
  500. public static void InitializeFuelConsumptions(FlightPlanEditor editor, List<TurningPoint> turningPoints, ref double[] fuelConsumptions)
  501. {
  502. fuelConsumptions[0] = GetClimbFuelConsumptionRate(editor, turningPoints[0].TurningPointHeight);
  503. fuelConsumptions[1] = GetCruisingFuelConsumptionRate(editor, turningPoints[1].TurningPointHeight);
  504. fuelConsumptions[2] = GetEnduranceFuelConsumptionRate(editor, turningPoints[2].TurningPointHeight);
  505. fuelConsumptions[3] = GetDescentFuelConsumptionRate(editor, turningPoints[0].TurningPointHeight);
  506. fuelConsumptions[4] = GetHoverFuelConsumptionRate(editor, turningPoints[2].TurningPointHeight);
  507. }
  508. public static void FXJHTPDiedai(FlightPlanEditor editor,ref List<TurningPoint> turningPoints,double[] velocitys, double[] fuelConsumptions) //各航段飞行时间、油耗计算和航路点油耗迭代
  509. {
  510. int i;
  511. double DEG_TO_RAD_LOCAL = 3.1415926535897932 / 180;
  512. double[] x = new double[turningPoints.Count];
  513. double[] y = new double[turningPoints.Count];
  514. double[] z = new double[turningPoints.Count];
  515. for (i = 0; i < turningPoints.Count; i++) //LLA坐标转换为ECEF坐标
  516. {
  517. double lon = turningPoints[i].TurningPointLongitude * DEG_TO_RAD_LOCAL;
  518. double lat = turningPoints[i].TurningPointLatitude * DEG_TO_RAD_LOCAL;
  519. double hei = turningPoints[i].TurningPointHeight;
  520. double a = 6378137.0;
  521. double b = 6356752.31424518;
  522. double N = a / (Math.Sqrt(1 - ((a * a - b * b) / (a * a)) * Math.Sin(lat) * Math.Sin(lat)));
  523. x[i] = (N + hei) * Math.Cos(lat) * Math.Cos(lon);
  524. y[i] = (N + hei) * Math.Cos(lat) * Math.Sin(lon);
  525. z[i] = ((b * b * N) / (a * a) + hei) * Math.Sin(lat);
  526. }
  527. for (i = 0; i < turningPoints.Count; i++)
  528. {
  529. if (turningPoints[i].SegmentFlightTime == 0)
  530. {
  531. double distanceab;
  532. if (i != turningPoints.Count - 1)
  533. {
  534. distanceab = Math.Sqrt(Math.Pow(x[i] - x[i + 1], 2) + Math.Pow(y[i] - y[i + 1], 2) +
  535. Math.Pow(z[i] - z[i + 1], 2));
  536. }
  537. else
  538. {
  539. distanceab = Math.Sqrt(Math.Pow(x[i] - x[0], 2) + Math.Pow(y[i] - y[0], 2) +
  540. Math.Pow(z[i] - z[0], 2));
  541. }
  542. double velocity;
  543. // 根据飞行段类型选择不同的燃油消耗率计算函数
  544. switch (turningPoints[i].SegmentFlightFuelConsumption)
  545. {
  546. case 1:
  547. velocity = velocitys[0];
  548. break;
  549. case 2:
  550. velocity = velocitys[1];
  551. break;
  552. case 3:
  553. velocity = velocitys[2];
  554. break;
  555. case 4:
  556. velocity = velocitys[3];
  557. break;
  558. case 5:
  559. velocity = 0;
  560. break;
  561. default:
  562. velocity = 0;
  563. break;
  564. }
  565. // 使用计算得到的速度计算飞行时间
  566. turningPoints[i].SegmentFlightTime = CalculateSegmentFlightTime(distanceab, velocity);
  567. double CalculateSegmentFlightTime(double distance, double velocity)
  568. {
  569. return distance * 3.6 / velocity; // 根据速度计算飞行时间
  570. }
  571. }
  572. else
  573. {
  574. turningPoints[i].SegmentFlightTime = turningPoints[i].SegmentFlightTime;
  575. }
  576. }
  577. for (i = 0; i < turningPoints.Count; i++)
  578. {
  579. double remainingFuel;
  580. if (i == 0)
  581. {
  582. remainingFuel = editor.aircraftparameter.MaxFuelCapacity * 0.8;
  583. }
  584. else
  585. {
  586. remainingFuel = turningPoints[i - 1].RemainingFuel;
  587. }
  588. double fuelConsumption = 0;
  589. // 根据飞行段类型选择不同的燃油消耗率计算函数,1代表爬升,2代表平飞远航,3代表平飞久航,4代表下降,5代表悬停
  590. switch (turningPoints[i].SegmentFlightFuelConsumption)
  591. {
  592. case 1:
  593. fuelConsumption = fuelConsumptions[0];
  594. break;
  595. case 2:
  596. fuelConsumption = fuelConsumptions[1];
  597. break;
  598. case 3:
  599. fuelConsumption = fuelConsumptions[2];
  600. break;
  601. case 4:
  602. fuelConsumption = fuelConsumptions[3];
  603. break;
  604. case 5:
  605. fuelConsumption = fuelConsumptions[4];
  606. break;
  607. }
  608. remainingFuel -= fuelConsumption * turningPoints[i].SegmentFlightTime / 3600; // 更新剩余燃油
  609. if (remainingFuel < 0)
  610. {
  611. remainingFuel = 0;
  612. break;
  613. }
  614. turningPoints[i].RemainingFuel = remainingFuel;
  615. }
  616. }
  617. public static void CalculateTrueHeading(FlightPlanEditor editor, ref List<TurningPoint> turningPoints)
  618. {
  619. for (int i = 0; i < turningPoints.Count - 1; i++)
  620. {
  621. // 转换为弧度
  622. double lat1Rad = turningPoints[i].TurningPointLatitude * Math.PI / 180;
  623. double lon1Rad = turningPoints[i].TurningPointLongitude * Math.PI / 180;
  624. double lat2Rad = turningPoints[i + 1].TurningPointLatitude * Math.PI / 180;
  625. double lon2Rad = turningPoints[i + 1].TurningPointLongitude * Math.PI / 180;
  626. double deltaLon = lon2Rad - lon1Rad;
  627. double x = Math.Sin(deltaLon) * Math.Cos(lat2Rad);
  628. double y = Math.Cos(lat1Rad) * Math.Sin(lat2Rad) - Math.Sin(lat1Rad) * Math.Cos(lat2Rad) * Math.Cos(deltaLon);
  629. // 计算航向角
  630. double headingRad = Math.Atan2(x, y);
  631. // 转换为度并标准化
  632. double headingDeg = headingRad * 180 / Math.PI;
  633. headingDeg = (headingDeg + 360) % 360;
  634. turningPoints[i].HeadingAngle = headingDeg;
  635. }
  636. }
  637. /// <summary>
  638. /// 巡护用
  639. /// </summary>
  640. /// <param name="turningPoints"></param>
  641. /// <param name="editor"></param>
  642. /// <param name="nowtime"></param>
  643. /// <returns></returns>
  644. public static (CurrentLocation, bool) GetCurrentLocation(List<TurningPoint> turningPoints, FlightPlanEditor editor,
  645. double nowtime)
  646. {
  647. CurrentLocation currentLocation = new CurrentLocation();
  648. double[] timetable = new double[editor.airroute.Length + 2]; //airroute.Length表示巡护航线中有几个航路点
  649. timetable[0] = 0; //设起飞时刻为0
  650. int segmentnumber = -1;
  651. int i;
  652. for (i = 0; i < editor.airroute.Length + 1; i++)
  653. {
  654. timetable[i + 1] = timetable[i] + turningPoints[i].SegmentFlightTime;
  655. }
  656. for (i = 0; i < editor.airroute.Length + 2; i++)
  657. {
  658. if ((nowtime - timetable[i]) >= 0)
  659. {
  660. segmentnumber += 1;
  661. }
  662. else
  663. {
  664. break;
  665. }
  666. }
  667. bool isEnd = false || segmentnumber >= turningPoints.Count;
  668. currentLocation.CurrentLon = turningPoints[segmentnumber].TurningPointLongitude +
  669. (turningPoints[segmentnumber + 1].TurningPointLongitude -
  670. turningPoints[segmentnumber].TurningPointLongitude) *
  671. (nowtime - timetable[segmentnumber]) /
  672. turningPoints[segmentnumber].SegmentFlightTime;
  673. currentLocation.CurrentLat = turningPoints[segmentnumber].TurningPointLatitude +
  674. (turningPoints[segmentnumber + 1].TurningPointLatitude -
  675. turningPoints[segmentnumber].TurningPointLatitude) *
  676. (nowtime - timetable[segmentnumber]) /
  677. turningPoints[segmentnumber].SegmentFlightTime;
  678. currentLocation.CurrentHei = turningPoints[segmentnumber].TurningPointHeight +
  679. (turningPoints[segmentnumber + 1].TurningPointHeight -
  680. turningPoints[segmentnumber].TurningPointHeight) *
  681. (nowtime - timetable[segmentnumber]) /
  682. turningPoints[segmentnumber].SegmentFlightTime;
  683. currentLocation.CurrentFuel = 0;
  684. currentLocation.Currentvelo = 0;
  685. currentLocation.Currentsegnum = segmentnumber + 1;
  686. currentLocation.CurrentCourse = 75;
  687. return (currentLocation, isEnd);
  688. }
  689. //改
  690. /// <summary>
  691. /// 计算当前位置
  692. /// </summary>
  693. /// <param name="FXJHTP"></param>
  694. /// <param name="FXJHTPLength"></param>
  695. /// <param name="nowtime"></param>
  696. /// <returns></returns>
  697. public static (CurrentLocation, bool) GetAllCurrentLocation(List<TurningPoint> turningPoints, double nowtime) //飞机实时位置打印
  698. {
  699. CurrentLocation currentLocation = new CurrentLocation();
  700. double[] timetable = new double[turningPoints.Count + 1];
  701. timetable[0] = 0;
  702. int segmentnumber = -1;
  703. int i;
  704. for (i = 0; i < turningPoints.Count; i++)
  705. {
  706. timetable[i + 1] = timetable[i] + turningPoints[i].SegmentFlightTime;
  707. }
  708. for (i = 0; i < turningPoints.Count + 1; i++)
  709. {
  710. if ((nowtime - timetable[i]) >= 0)
  711. {
  712. segmentnumber += 1;
  713. }
  714. else
  715. {
  716. break;
  717. }
  718. }
  719. bool isEnd = false || segmentnumber >= turningPoints.Count;
  720. currentLocation.Currentsegnum = segmentnumber;
  721. if (segmentnumber < turningPoints.Count - 1)
  722. {
  723. currentLocation.CurrentLon = turningPoints[segmentnumber].TurningPointLongitude +
  724. ((turningPoints[segmentnumber + 1].TurningPointLongitude -
  725. turningPoints[segmentnumber].TurningPointLongitude) /
  726. turningPoints[segmentnumber].SegmentFlightTime) *
  727. (nowtime - timetable[segmentnumber]);
  728. currentLocation.CurrentLat = turningPoints[segmentnumber].TurningPointLatitude +
  729. ((turningPoints[segmentnumber + 1].TurningPointLatitude -
  730. turningPoints[segmentnumber].TurningPointLatitude) /
  731. turningPoints[segmentnumber].SegmentFlightTime) *
  732. (nowtime - timetable[segmentnumber]);
  733. currentLocation.CurrentHei = turningPoints[segmentnumber].TurningPointHeight +
  734. ((turningPoints[segmentnumber + 1].TurningPointHeight -
  735. turningPoints[segmentnumber].TurningPointHeight) /
  736. turningPoints[segmentnumber].SegmentFlightTime) *
  737. (nowtime - timetable[segmentnumber]);
  738. currentLocation.CurrentFuel = turningPoints[segmentnumber].RemainingFuel -
  739. turningPoints[segmentnumber].SegmentFlightFuelConsumption *
  740. (nowtime - timetable[segmentnumber]);
  741. currentLocation.PresentMission = turningPoints[segmentnumber].TurningPointName;
  742. }
  743. else if (segmentnumber == turningPoints.Count - 1)
  744. {
  745. currentLocation.CurrentLon = turningPoints[segmentnumber].TurningPointLongitude +
  746. ((turningPoints[0].TurningPointLongitude -
  747. turningPoints[segmentnumber].TurningPointLongitude) /
  748. turningPoints[segmentnumber].SegmentFlightTime) *
  749. (nowtime - timetable[segmentnumber]);
  750. currentLocation.CurrentLat = turningPoints[segmentnumber].TurningPointLatitude +
  751. ((turningPoints[0].TurningPointLatitude -
  752. turningPoints[segmentnumber].TurningPointLatitude) /
  753. turningPoints[segmentnumber].SegmentFlightTime) *
  754. (nowtime - timetable[segmentnumber]);
  755. currentLocation.CurrentHei = turningPoints[segmentnumber].TurningPointHeight +
  756. ((turningPoints[0].TurningPointHeight -
  757. turningPoints[segmentnumber].TurningPointHeight) /
  758. turningPoints[segmentnumber].SegmentFlightTime) *
  759. (nowtime - timetable[segmentnumber]);
  760. currentLocation.CurrentFuel = turningPoints[segmentnumber].RemainingFuel -
  761. turningPoints[segmentnumber].SegmentFlightFuelConsumption *
  762. (nowtime - timetable[segmentnumber]);
  763. currentLocation.PresentMission = turningPoints[segmentnumber].TurningPointName;
  764. }
  765. else
  766. {
  767. currentLocation.CurrentLon = turningPoints[^1].TurningPointLongitude;
  768. currentLocation.CurrentLat = turningPoints[^1].TurningPointLatitude;
  769. currentLocation.CurrentHei = turningPoints[^1].TurningPointHeight;
  770. currentLocation.Currentvelo = 0;
  771. currentLocation.CurrentFuel = turningPoints[segmentnumber - 1].RemainingFuel -
  772. turningPoints[segmentnumber - 1].SegmentFlightFuelConsumption *
  773. turningPoints[segmentnumber - 1].SegmentFlightTime;
  774. currentLocation.PresentMission = turningPoints[segmentnumber - 1].TurningPointName;
  775. isEnd = true;
  776. }
  777. return (currentLocation,isEnd);
  778. }
  779. }
  780. }