FXJHGenenrate.cs 45 KB

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