FXJHGenenrate.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  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. k = (editor.missionpoint.MissionPointLatitude - editor.originbase.BaseLatitude) /
  23. (editor.missionpoint.MissionPointLongitude - editor.originbase.BaseLongitude);
  24. if (editor.missionpoint.MissionPointLongitude > editor.originbase.BaseLongitude)
  25. {
  26. lat1 = 0.08544 * k / (Math.Sqrt(k * k + 1)) + editor.originbase.BaseLatitude; //经验公式
  27. lon1 = 0.08544 / (Math.Sqrt(k * k + 1)) + editor.originbase.BaseLongitude;
  28. }
  29. else
  30. {
  31. lat1 = editor.originbase.BaseLatitude - 0.08544 * k / (Math.Sqrt(k * k + 1));
  32. lon1 = editor.originbase.BaseLongitude - 0.08544 / (Math.Sqrt(k * k + 1));
  33. }
  34. turningPoints.Add(new TurningPoint
  35. {
  36. TurningPointName = "巡航",
  37. TurningPointLongitude = lon1,
  38. TurningPointLatitude = lat1,
  39. TurningPointHeight = 2000,
  40. TurningPointType = "普通",
  41. SegmentFlightFuelConsumption = 2,
  42. SegmentFlightTime = 0,
  43. RemainingFuel = 0,
  44. });
  45. }
  46. //获取油耗率
  47. public static double GetClimbFuelConsumptionRate(FlightPlanEditor editor, double height)
  48. {
  49. double temp = Util.GetTemperature(editor.originbase.BaseLongitude, editor.originbase.BaseLatitude);
  50. Fuel fuel = Util.GetFuel(editor.aircraftparameter.AircraftID, editor.aircraftparameter.AircraftSubType,
  51. "爬升", temp.ToString(), height.ToString(),
  52. editor.aircraftparameter.MaxTakeoffWeight.ToString());
  53. if (fuel == null)
  54. {
  55. return 1100;
  56. }
  57. return fuel.oilconsume;
  58. }
  59. public static double GetCruisingFuelConsumptionRate(FlightPlanEditor editor, double height)
  60. {
  61. double temp = Util.GetTemperature(editor.originbase.BaseLongitude, editor.originbase.BaseLatitude);
  62. Fuel fuel = Util.GetFuel(editor.aircraftparameter.AircraftID, editor.aircraftparameter.AircraftSubType,
  63. "平飞远航", temp.ToString(), height.ToString(),
  64. editor.aircraftparameter.MaxTakeoffWeight.ToString());
  65. if (fuel == null)
  66. {
  67. return 600;
  68. }
  69. return fuel.oilconsume;
  70. }
  71. public static double GetEnduranceFuelConsumptionRate(FlightPlanEditor editor, double height)
  72. {
  73. double temp = Util.GetTemperature(editor.originbase.BaseLongitude, editor.originbase.BaseLatitude);
  74. Fuel fuel = Util.GetFuel(editor.aircraftparameter.AircraftID, editor.aircraftparameter.AircraftSubType,
  75. "平飞久航", temp.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)
  84. {
  85. return 2 * GetCruisingFuelConsumptionRate(editor, height) - GetClimbFuelConsumptionRate(editor, height);
  86. }
  87. public static double GetHoverFuelConsumptionRate(FlightPlanEditor editor, double height)
  88. {
  89. double temp = Util.GetTemperature(editor.originbase.BaseLongitude, editor.originbase.BaseLatitude);
  90. Fuel fuel = Util.GetFuel(editor.aircraftparameter.AircraftID, editor.aircraftparameter.AircraftSubType,
  91. "悬停", temp.ToString(), height.ToString(),
  92. editor.aircraftparameter.MaxTakeoffWeight.ToString());
  93. if (fuel == null)
  94. {
  95. return 200;
  96. }
  97. return fuel.oilconsume;
  98. }
  99. //获取速度值
  100. public static double GetClimbVelocity(FlightPlanEditor editor, double height)
  101. {
  102. double temp = Util.GetTemperature(editor.originbase.BaseLongitude, editor.originbase.BaseLatitude);
  103. Fuel fuel = Util.GetFuel(editor.aircraftparameter.AircraftID, editor.aircraftparameter.AircraftSubType,
  104. "爬升", temp.ToString(), height.ToString(), editor.aircraftparameter.MaxTakeoffWeight.ToString());
  105. if (fuel == null)
  106. {
  107. return 60;
  108. }
  109. return fuel.speed;
  110. }
  111. public static double GetCruisingVelocity(FlightPlanEditor editor, double height)
  112. {
  113. double temp = Util.GetTemperature(editor.originbase.BaseLongitude, editor.originbase.BaseLatitude);
  114. Fuel fuel = Util.GetFuel(editor.aircraftparameter.AircraftID, editor.aircraftparameter.AircraftSubType,
  115. "平飞远航", temp.ToString(), height.ToString(), editor.aircraftparameter.MaxTakeoffWeight.ToString());
  116. if (fuel == null)
  117. {
  118. return 200;
  119. }
  120. return fuel.speed;
  121. }
  122. public static double GetEnduranceVelocity(FlightPlanEditor editor, double height)
  123. {
  124. double temp = Util.GetTemperature(editor.originbase.BaseLongitude, editor.originbase.BaseLatitude);
  125. Fuel fuel = Util.GetFuel(editor.aircraftparameter.AircraftID, editor.aircraftparameter.AircraftSubType,
  126. "平飞久航", temp.ToString(), height.ToString(), editor.aircraftparameter.MaxTakeoffWeight.ToString());
  127. if (fuel == null)
  128. {
  129. return 200;
  130. }
  131. return fuel.speed;
  132. }
  133. public static double GetDescentVelocity(FlightPlanEditor editor, double height)
  134. {
  135. return GetCruisingVelocity(editor, height) / 2;
  136. }
  137. public static void ZhenCha(List<double[]> SC01, FlightPlanEditor editor, ref List<TurningPoint> turningPoints) //侦查模型航路点生成
  138. {
  139. int i;
  140. for (i = 0; i < SC01.Count - 1; i++)
  141. {
  142. turningPoints.Add(new TurningPoint
  143. {
  144. TurningPointName = "巡航",
  145. TurningPointLongitude = SC01[i][0],
  146. TurningPointLatitude = SC01[i][1],
  147. TurningPointHeight = SC01[i][2],
  148. TurningPointType = "侦查",
  149. SegmentFlightFuelConsumption = 3,
  150. SegmentFlightTime = 0,
  151. RemainingFuel = 0,
  152. });
  153. }
  154. }
  155. public static void SuoHuaJiang(double resulttime, FlightPlanEditor editor,
  156. ref List<TurningPoint> turningPoints) //索滑降模型航路点生成
  157. {
  158. turningPoints.Add(new TurningPoint
  159. {
  160. TurningPointName = "索滑降",
  161. TurningPointLongitude = editor.missionpoint.MissionPointLongitude,
  162. TurningPointLatitude = editor.missionpoint.MissionPointLatitude,
  163. TurningPointHeight = editor.missionpoint.MissionPointHeight,
  164. TurningPointType = "索滑降",
  165. SegmentFlightFuelConsumption = 5,
  166. SegmentFlightTime = resulttime,
  167. RemainingFuel = 0,
  168. });
  169. }
  170. public static void XunHu(FlightPlanEditor editor,ref List<TurningPoint> turningPoints)
  171. {
  172. int i;
  173. for (i = 0; i < editor.airroute.Length; i++)
  174. {
  175. turningPoints.Add(new TurningPoint
  176. {
  177. TurningPointName = "巡航",
  178. TurningPointLongitude = editor.airroute[i].AirRouteLongitude,
  179. TurningPointLatitude = editor.airroute[i].AirRouteLatitude,
  180. TurningPointHeight = editor.airroute[i].AirRouteHeight,
  181. TurningPointType = "普通",
  182. SegmentFlightFuelConsumption = 3,
  183. SegmentFlightTime = 0,
  184. RemainingFuel = 0,
  185. });
  186. }
  187. }
  188. public static void MieHuo1(FlightPlanEditor editor,ref List<TurningPoint> turningPoints) //灭火任务从取水点到火场部分的航路点生成
  189. {
  190. turningPoints.Add(new TurningPoint
  191. {
  192. TurningPointName = "取水",
  193. TurningPointLongitude = editor.missionpoint.MissionPointLongitude,
  194. TurningPointLatitude = editor.missionpoint.MissionPointLatitude,
  195. TurningPointHeight = editor.missionpoint.MissionPointHeight,
  196. TurningPointType = "取水",
  197. SegmentFlightFuelConsumption = 3,
  198. SegmentFlightTime = 120,
  199. RemainingFuel = 0,
  200. });
  201. turningPoints.Add(new TurningPoint
  202. {
  203. TurningPointName = "洒水",
  204. TurningPointLongitude = editor.firepoint[0].FirePointLongitude,
  205. TurningPointLatitude = editor.firepoint[0].FirePointLatitude,
  206. TurningPointHeight = editor.firepoint[0].FirePointHeight,
  207. TurningPointType = "巡航",
  208. SegmentFlightFuelConsumption = 3,
  209. SegmentFlightTime = 0,
  210. RemainingFuel = 0,
  211. });
  212. }
  213. public static MissionEndPoint ZhenChaMissionEndPoint(List<double[]> SC01) //侦查模型任务终点生成
  214. {
  215. MissionEndPoint missionEndPoint = new();
  216. int length = SC01.Count - 1;
  217. missionEndPoint.MissionEndPointLongitude = SC01[length][0];
  218. missionEndPoint.MissionEndPointLatitude = SC01[length][1];
  219. missionEndPoint.MissionEndPointHeight = SC01[length][2];
  220. return missionEndPoint;
  221. }
  222. public static MissionEndPoint SuoHuaJiangMissionEndPoint(FlightPlanEditor editor) //索滑降模型任务终点生成
  223. {
  224. MissionEndPoint missionEndPoint = new();
  225. missionEndPoint.MissionEndPointLongitude = editor.missionpoint.MissionPointLongitude;
  226. missionEndPoint.MissionEndPointLatitude = editor.missionpoint.MissionPointLatitude;
  227. missionEndPoint.MissionEndPointHeight = editor.missionpoint.MissionPointHeight;
  228. return missionEndPoint;
  229. }
  230. public static void JijiangMiehuo(FlightPlanEditor editor,ref List<TurningPoint> turningPoint)
  231. {
  232. turningPoint.Add(new TurningPoint
  233. {
  234. TurningPointName = "地面灭火",
  235. TurningPointLongitude = editor.originbase.BaseLongitude,
  236. TurningPointLatitude = editor.originbase.BaseLatitude,
  237. TurningPointHeight = editor.originbase.BaseHeight,
  238. TurningPointType = "转运",
  239. SegmentFlightFuelConsumption = 2,
  240. SegmentFlightTime = 0,
  241. RemainingFuel = 0,
  242. });
  243. turningPoint.Add(new TurningPoint
  244. {
  245. TurningPointName = "地面灭火",
  246. TurningPointLongitude = editor.missionpoint.MissionPointLongitude,
  247. TurningPointLatitude = editor.missionpoint.MissionPointLongitude,
  248. TurningPointHeight = editor.missionpoint.MissionPointHeight,
  249. TurningPointType = "转运",
  250. SegmentFlightFuelConsumption = 2,
  251. SegmentFlightTime = 0,
  252. RemainingFuel = 0,
  253. });
  254. }
  255. public static void FromMissionToEnd(FlightPlanEditor editor, MissionEndPoint missionEndPoint, ref List<TurningPoint> turningPoints) //生成从任务段终点到基地的航路点
  256. {
  257. turningPoints.Add(new TurningPoint
  258. {
  259. TurningPointName = "巡航",
  260. TurningPointLongitude = missionEndPoint.MissionEndPointLongitude,
  261. TurningPointLatitude = missionEndPoint.MissionEndPointLatitude,
  262. TurningPointHeight = missionEndPoint.MissionEndPointHeight,
  263. TurningPointType = "普通",
  264. SegmentFlightFuelConsumption = 3,
  265. SegmentFlightTime = 0,
  266. RemainingFuel = 0,
  267. });
  268. double k;
  269. double lat2, lon2;
  270. k = (turningPoints[^1].TurningPointLatitude - editor.originbase.BaseLatitude) /
  271. (turningPoints[^1].TurningPointLongitude - editor.originbase.BaseLongitude);
  272. if (turningPoints[^1].TurningPointLongitude > editor.originbase.BaseLongitude)
  273. {
  274. lat2 = 0.08544 * k / (Math.Sqrt(k * k + 1)) + editor.originbase.BaseLatitude;
  275. lon2 = 0.08544 / (Math.Sqrt(k * k + 1)) + editor.originbase.BaseLongitude;
  276. }
  277. else
  278. {
  279. lat2 = editor.originbase.BaseLatitude - 0.08544 * k / (Math.Sqrt(k * k + 1));
  280. lon2 = editor.originbase.BaseLongitude - 0.08544 / (Math.Sqrt(k * k + 1));
  281. }
  282. turningPoints.Add(new TurningPoint
  283. {
  284. TurningPointName = "降高",
  285. TurningPointLongitude = lon2,
  286. TurningPointLatitude = lat2,
  287. TurningPointHeight = 2000,
  288. TurningPointType = "普通",
  289. SegmentFlightFuelConsumption = 4,
  290. SegmentFlightTime = 0,
  291. RemainingFuel = 0,
  292. });
  293. }
  294. public static void InitializeVelocities(FlightPlanEditor editor,List<TurningPoint> turningPoints, ref double[] velocitys)
  295. {
  296. velocitys[0] = GetClimbVelocity(editor, turningPoints[0].TurningPointHeight);
  297. velocitys[1] = GetCruisingVelocity(editor, turningPoints[1].TurningPointHeight);
  298. velocitys[2] = GetEnduranceVelocity(editor, turningPoints[2].TurningPointHeight);
  299. velocitys[3] = GetDescentVelocity(editor, turningPoints[0].TurningPointHeight);
  300. }
  301. public static void InitializeFuelConsumptions(FlightPlanEditor editor, List<TurningPoint> turningPoints, ref double[] fuelConsumptions)
  302. {
  303. fuelConsumptions[0] = GetClimbFuelConsumptionRate(editor, turningPoints[0].TurningPointHeight);
  304. fuelConsumptions[1] = GetCruisingFuelConsumptionRate(editor, turningPoints[1].TurningPointHeight);
  305. fuelConsumptions[2] = GetEnduranceFuelConsumptionRate(editor, turningPoints[2].TurningPointHeight);
  306. fuelConsumptions[3] = GetDescentFuelConsumptionRate(editor, turningPoints[0].TurningPointHeight);
  307. fuelConsumptions[4] = GetHoverFuelConsumptionRate(editor, turningPoints[2].TurningPointHeight);
  308. }
  309. public static void FXJHTPDiedai(FlightPlanEditor editor,ref List<TurningPoint> turningPoints,double[] velocitys, double[] fuelConsumptions) //各航段飞行时间、油耗计算和航路点油耗迭代
  310. {
  311. int i;
  312. double DEG_TO_RAD_LOCAL = 3.1415926535897932 / 180;
  313. double[] x = new double[turningPoints.Count];
  314. double[] y = new double[turningPoints.Count];
  315. double[] z = new double[turningPoints.Count];
  316. for (i = 0; i < turningPoints.Count; i++) //LLA坐标转换为ECEF坐标
  317. {
  318. double lon = turningPoints[i].TurningPointLongitude * DEG_TO_RAD_LOCAL;
  319. double lat = turningPoints[i].TurningPointLatitude * DEG_TO_RAD_LOCAL;
  320. double hei = turningPoints[i].TurningPointHeight;
  321. double a = 6378137.0;
  322. double b = 6356752.31424518;
  323. double N = a / (Math.Sqrt(1 - ((a * a - b * b) / (a * a)) * Math.Sin(lat) * Math.Sin(lat)));
  324. x[i] = (N + hei) * Math.Cos(lat) * Math.Cos(lon);
  325. y[i] = (N + hei) * Math.Cos(lat) * Math.Sin(lon);
  326. z[i] = ((b * b * N) / (a * a) + hei) * Math.Sin(lat);
  327. }
  328. for (i = 0; i < turningPoints.Count; i++)
  329. {
  330. if (turningPoints[i].SegmentFlightTime == 0)
  331. {
  332. double distanceab;
  333. if (i != turningPoints.Count - 1)
  334. {
  335. distanceab = Math.Sqrt(Math.Pow(x[i] - x[i + 1], 2) + Math.Pow(y[i] - y[i + 1], 2) +
  336. Math.Pow(z[i] - z[i + 1], 2));
  337. }
  338. else
  339. {
  340. distanceab = Math.Sqrt(Math.Pow(x[i] - x[0], 2) + Math.Pow(y[i] - y[0], 2) +
  341. Math.Pow(z[i] - z[0], 2));
  342. }
  343. double velocity;
  344. // 根据飞行段类型选择不同的燃油消耗率计算函数
  345. switch (turningPoints[i].SegmentFlightFuelConsumption)
  346. {
  347. case 1:
  348. velocity = velocitys[0];
  349. break;
  350. case 2:
  351. velocity = velocitys[1];
  352. break;
  353. case 3:
  354. velocity = velocitys[2];
  355. break;
  356. case 4:
  357. velocity = velocitys[3];
  358. break;
  359. case 5:
  360. velocity = 0;
  361. break;
  362. default:
  363. velocity = 0;
  364. break;
  365. }
  366. // 使用计算得到的速度计算飞行时间
  367. turningPoints[i].SegmentFlightTime = CalculateSegmentFlightTime(distanceab, velocity);
  368. double CalculateSegmentFlightTime(double distance, double velocity)
  369. {
  370. return distance * 3.6 / velocity; // 根据速度计算飞行时间
  371. }
  372. }
  373. else
  374. {
  375. turningPoints[i].SegmentFlightTime = turningPoints[i].SegmentFlightTime;
  376. }
  377. }
  378. for (i = 0; i < turningPoints.Count; i++)
  379. {
  380. double remainingFuel;
  381. if (i == 0)
  382. {
  383. remainingFuel = editor.aircraftparameter.MaxFuelCapacity * 0.8;
  384. }
  385. else
  386. {
  387. remainingFuel = turningPoints[i - 1].RemainingFuel;
  388. }
  389. double fuelConsumption = 0;
  390. // 根据飞行段类型选择不同的燃油消耗率计算函数,1代表爬升,2代表平飞远航,3代表平飞久航,4代表下降,5代表悬停
  391. switch (turningPoints[i].SegmentFlightFuelConsumption)
  392. {
  393. case 1:
  394. fuelConsumption = fuelConsumptions[0];
  395. break;
  396. case 2:
  397. fuelConsumption = fuelConsumptions[1];
  398. break;
  399. case 3:
  400. fuelConsumption = fuelConsumptions[2];
  401. break;
  402. case 4:
  403. fuelConsumption = fuelConsumptions[3];
  404. break;
  405. case 5:
  406. fuelConsumption = fuelConsumptions[4];
  407. break;
  408. }
  409. remainingFuel -= fuelConsumption * turningPoints[i].SegmentFlightTime / 3600; // 更新剩余燃油
  410. if (remainingFuel < 0)
  411. {
  412. remainingFuel = 0;
  413. break;
  414. }
  415. turningPoints[i].RemainingFuel = remainingFuel;
  416. }
  417. }
  418. /// <summary>
  419. /// 巡护用
  420. /// </summary>
  421. /// <param name="turningPoints"></param>
  422. /// <param name="editor"></param>
  423. /// <param name="nowtime"></param>
  424. /// <returns></returns>
  425. public static CurrentLocation GetCurrentLocation(List<TurningPoint> turningPoints, FlightPlanEditor editor,
  426. double nowtime)
  427. {
  428. CurrentLocation currentLocation = new CurrentLocation();
  429. double[] timetable = new double[editor.airroute.Length + 2]; //airroute.Length表示巡护航线中有几个航路点
  430. timetable[0] = 0; //设起飞时刻为0
  431. int segmentnumber = -1;
  432. int i;
  433. for (i = 0; i < editor.airroute.Length + 1; i++)
  434. {
  435. timetable[i + 1] = timetable[i] + turningPoints[i].SegmentFlightTime;
  436. }
  437. for (i = 0; i < editor.airroute.Length + 2; i++)
  438. {
  439. if ((nowtime - timetable[i]) >= 0)
  440. {
  441. segmentnumber += 1;
  442. }
  443. else
  444. {
  445. break;
  446. }
  447. }
  448. currentLocation.CurrentLon = turningPoints[segmentnumber].TurningPointLongitude +
  449. (turningPoints[segmentnumber + 1].TurningPointLongitude -
  450. turningPoints[segmentnumber].TurningPointLongitude) *
  451. (nowtime - timetable[segmentnumber]) /
  452. turningPoints[segmentnumber].SegmentFlightTime;
  453. currentLocation.CurrentLat = turningPoints[segmentnumber].TurningPointLatitude +
  454. (turningPoints[segmentnumber + 1].TurningPointLatitude -
  455. turningPoints[segmentnumber].TurningPointLatitude) *
  456. (nowtime - timetable[segmentnumber]) /
  457. turningPoints[segmentnumber].SegmentFlightTime;
  458. currentLocation.CurrentHei = turningPoints[segmentnumber].TurningPointHeight +
  459. (turningPoints[segmentnumber + 1].TurningPointHeight -
  460. turningPoints[segmentnumber].TurningPointHeight) *
  461. (nowtime - timetable[segmentnumber]) /
  462. turningPoints[segmentnumber].SegmentFlightTime;
  463. currentLocation.CurrentFuel = 0;
  464. currentLocation.Currentvelo = 0;
  465. currentLocation.Currentsegnum = segmentnumber + 1;
  466. currentLocation.CurrentCourse = 75;
  467. return currentLocation;
  468. }
  469. //改
  470. /// <summary>
  471. /// 计算当前位置
  472. /// </summary>
  473. /// <param name="FXJHTP"></param>
  474. /// <param name="FXJHTPLength"></param>
  475. /// <param name="nowtime"></param>
  476. /// <returns></returns>
  477. public static CurrentLocation GetAllCurrentLocation(List<TurningPoint> turningPoints, double nowtime) //飞机实时位置打印
  478. {
  479. CurrentLocation currentLocation = new CurrentLocation();
  480. double[] timetable = new double[turningPoints.Count + 1];
  481. timetable[0] = 0;
  482. int segmentnumber = -1;
  483. int i;
  484. for (i = 0; i < turningPoints.Count; i++)
  485. {
  486. timetable[i + 1] = timetable[i] + turningPoints[i].SegmentFlightTime;
  487. }
  488. for (i = 0; i < turningPoints.Count + 1; i++)
  489. {
  490. if ((nowtime - timetable[i]) >= 0)
  491. {
  492. segmentnumber += 1;
  493. }
  494. else
  495. {
  496. break;
  497. }
  498. }
  499. if (segmentnumber < turningPoints.Count - 1)
  500. {
  501. currentLocation.CurrentLon = turningPoints[segmentnumber].TurningPointLongitude +
  502. ((turningPoints[segmentnumber + 1].TurningPointLongitude -
  503. turningPoints[segmentnumber].TurningPointLongitude) /
  504. turningPoints[segmentnumber].SegmentFlightTime) *
  505. (nowtime - timetable[segmentnumber]);
  506. currentLocation.CurrentLat = turningPoints[segmentnumber].TurningPointLatitude +
  507. ((turningPoints[segmentnumber + 1].TurningPointLatitude -
  508. turningPoints[segmentnumber].TurningPointLatitude) /
  509. turningPoints[segmentnumber].SegmentFlightTime) *
  510. (nowtime - timetable[segmentnumber]);
  511. currentLocation.CurrentHei = turningPoints[segmentnumber].TurningPointHeight +
  512. ((turningPoints[segmentnumber + 1].TurningPointHeight -
  513. turningPoints[segmentnumber].TurningPointHeight) /
  514. turningPoints[segmentnumber].SegmentFlightTime) *
  515. (nowtime - timetable[segmentnumber]);
  516. currentLocation.CurrentFuel = turningPoints[segmentnumber].RemainingFuel -
  517. turningPoints[segmentnumber].SegmentFlightFuelConsumption *
  518. (nowtime - timetable[segmentnumber]);
  519. }
  520. else if (segmentnumber == turningPoints.Count - 1)
  521. {
  522. currentLocation.CurrentLon = turningPoints[segmentnumber].TurningPointLongitude +
  523. ((turningPoints[0].TurningPointLongitude -
  524. turningPoints[segmentnumber].TurningPointLongitude) /
  525. turningPoints[segmentnumber].SegmentFlightTime) *
  526. (nowtime - timetable[segmentnumber]);
  527. currentLocation.CurrentLat = turningPoints[segmentnumber].TurningPointLatitude +
  528. ((turningPoints[0].TurningPointLatitude -
  529. turningPoints[segmentnumber].TurningPointLatitude) /
  530. turningPoints[segmentnumber].SegmentFlightTime) *
  531. (nowtime - timetable[segmentnumber]);
  532. currentLocation.CurrentHei = turningPoints[segmentnumber].TurningPointHeight +
  533. ((turningPoints[0].TurningPointHeight -
  534. turningPoints[segmentnumber].TurningPointHeight) /
  535. turningPoints[segmentnumber].SegmentFlightTime) *
  536. (nowtime - timetable[segmentnumber]);
  537. currentLocation.CurrentFuel = turningPoints[segmentnumber].RemainingFuel -
  538. turningPoints[segmentnumber].SegmentFlightFuelConsumption *
  539. (nowtime - timetable[segmentnumber]);
  540. }
  541. else
  542. {
  543. currentLocation.CurrentLon = turningPoints[0].TurningPointLongitude;
  544. currentLocation.CurrentLat = turningPoints[0].TurningPointLatitude;
  545. currentLocation.CurrentHei = turningPoints[0].TurningPointHeight;
  546. currentLocation.Currentvelo = 0;
  547. currentLocation.CurrentFuel = turningPoints[segmentnumber - 1].RemainingFuel -
  548. turningPoints[segmentnumber - 1].SegmentFlightFuelConsumption *
  549. turningPoints[segmentnumber - 1].SegmentFlightTime;
  550. }
  551. return currentLocation;
  552. }
  553. }
  554. }