FXJHGenenrate.cs 46 KB

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