using SimulationCommon; namespace Model { public class FXJHGenerate { public static void FromStartToMission(FlightPlanEditor editor, ref List turningPoints) //生成从基地到任务段起点的航路点 { turningPoints.Add(new TurningPoint { TurningPointName = "爬升", TurningPointLongitude = editor.originbase.BaseLongitude, //基地位置 TurningPointLatitude = editor.originbase.BaseLatitude, TurningPointHeight = editor.originbase.BaseHeight, TurningPointType = "普通", //TurningPointVelocity = editor.climbsegment.ClimbVelocity; SegmentFlightFuelConsumption = 1, SegmentFlightTime = 0, RemainingFuel = 0, }); // double k; double lat1, lon1; //直升机起飞后爬升到的航路点的经纬度,记为经纬度1 lat1 = (editor.originbase.BaseLatitude + editor.missionpoint.MissionPointLatitude) / 2; lon1 = (editor.originbase.BaseLongitude + editor.missionpoint.MissionPointLongitude) / 2; // k = (editor.missionpoint.MissionPointLatitude - editor.originbase.BaseLatitude) / // (editor.missionpoint.MissionPointLongitude - editor.originbase.BaseLongitude); // if (editor.missionpoint.MissionPointLongitude > editor.originbase.BaseLongitude) // { // lat1 = 0.08544 * k / (Math.Sqrt(k * k + 1)) + editor.originbase.BaseLatitude; //经验公式 // lon1 = 0.08544 / (Math.Sqrt(k * k + 1)) + editor.originbase.BaseLongitude; // } // else // { // lat1 = editor.originbase.BaseLatitude - 0.08544 * k / (Math.Sqrt(k * k + 1)); // lon1 = editor.originbase.BaseLongitude - 0.08544 / (Math.Sqrt(k * k + 1)); // } turningPoints.Add(new TurningPoint { TurningPointName = "平飞", TurningPointLongitude = lon1, TurningPointLatitude = lat1, TurningPointHeight = 2000, TurningPointType = "普通", SegmentFlightFuelConsumption = 2, SegmentFlightTime = 0, RemainingFuel = 0, }); } //获取油耗率 public static double GetClimbFuelConsumptionRate(FlightPlanEditor editor, double height, double t) { Fuel fuel = Util.GetFuel(editor.aircraftparameter.AircraftID, editor.aircraftparameter.AircraftSubType, "爬升", t.ToString(), height.ToString(), editor.aircraftparameter.MaxTakeoffWeight.ToString()); if (fuel == null) { return 1100; } return fuel.oilconsume; } public static double GetCruisingFuelConsumptionRate(FlightPlanEditor editor, double height, double t) { Fuel fuel = Util.GetFuel(editor.aircraftparameter.AircraftID, editor.aircraftparameter.AircraftSubType, "平飞远航", t.ToString(), height.ToString(), editor.aircraftparameter.MaxTakeoffWeight.ToString()); if (fuel == null) { return 600; } return fuel.oilconsume; } public static double GetEnduranceFuelConsumptionRate(FlightPlanEditor editor, double height, double t) { Fuel fuel = Util.GetFuel(editor.aircraftparameter.AircraftID, editor.aircraftparameter.AircraftSubType, "平飞久航", t.ToString(), height.ToString(), editor.aircraftparameter.MaxTakeoffWeight.ToString()); if (fuel == null) { return 600; } return fuel.oilconsume; } public static double GetDescentFuelConsumptionRate(FlightPlanEditor editor, double height, double t) { return 2 * GetCruisingFuelConsumptionRate(editor, height,t) - GetClimbFuelConsumptionRate(editor, height,t); } public static double GetHoverFuelConsumptionRate(FlightPlanEditor editor, double height, double t) { Fuel fuel = Util.GetFuel(editor.aircraftparameter.AircraftID, editor.aircraftparameter.AircraftSubType, "悬停", t.ToString(), height.ToString(), editor.aircraftparameter.MaxTakeoffWeight.ToString()); if (fuel == null) { return 200; } return fuel.oilconsume; } //获取速度值 public static double GetClimbVelocity(FlightPlanEditor editor, double height, double t) { Fuel fuel = Util.GetFuel(editor.aircraftparameter.AircraftID, editor.aircraftparameter.AircraftSubType, "爬升", t.ToString(), height.ToString(), editor.aircraftparameter.MaxTakeoffWeight.ToString()); if (fuel == null) { return 60; } return fuel.speed; } public static double GetCruisingVelocity(FlightPlanEditor editor, double height, double t) { Fuel fuel = Util.GetFuel(editor.aircraftparameter.AircraftID, editor.aircraftparameter.AircraftSubType, "平飞远航", t.ToString(), height.ToString(), editor.aircraftparameter.MaxTakeoffWeight.ToString()); if (fuel == null) { return 200; } return fuel.speed; } public static double GetEnduranceVelocity(FlightPlanEditor editor, double height, double t) { Fuel fuel = Util.GetFuel(editor.aircraftparameter.AircraftID, editor.aircraftparameter.AircraftSubType, "平飞久航", t.ToString(), height.ToString(), editor.aircraftparameter.MaxTakeoffWeight.ToString()); if (fuel == null) { return 200; } return fuel.speed; } public static double GetDescentVelocity(FlightPlanEditor editor, double height, double t) { return GetCruisingVelocity(editor, height,t) / 2; } public static void ZhenCha(List SC01, FlightPlanEditor editor, ref List turningPoints) //侦查模型航路点生成 { int i; for (i = 0; i < SC01.Count - 1; i++) { turningPoints.Add(new TurningPoint { TurningPointName = "平飞", TurningPointLongitude = SC01[i][0], TurningPointLatitude = SC01[i][1], TurningPointHeight = SC01[i][2], TurningPointType = "侦查", SegmentFlightFuelConsumption = 3, SegmentFlightTime = 0, RemainingFuel = 0, }); } } public static void SuoHuaJiang(double resulttime, FlightPlanEditor editor, ref List turningPoints) //索滑降模型航路点生成 { turningPoints.Add(new TurningPoint { TurningPointName = "索滑降", TurningPointLongitude = editor.missionpoint.MissionPointLongitude, TurningPointLatitude = editor.missionpoint.MissionPointLatitude, TurningPointHeight = editor.missionpoint.MissionPointHeight, TurningPointType = "索滑降", SegmentFlightFuelConsumption = 5, SegmentFlightTime = resulttime, RemainingFuel = 0, }); } public static void XunHu(FlightPlanEditor editor, ref List turningPoints) { int i; for (i = 0; i < editor.airroute.Length; i++) { turningPoints.Add(new TurningPoint { TurningPointName = "平飞", TurningPointLongitude = editor.airroute[i].AirRouteLongitude, TurningPointLatitude = editor.airroute[i].AirRouteLatitude, TurningPointHeight = 3000, TurningPointType = "普通", SegmentFlightFuelConsumption = 3, SegmentFlightTime = 0, RemainingFuel = 0, }); } } public static void TongXin(FlightPlanEditor editor, ref List turningPoints) { int i; for (i = 0; i < editor.airroute.Length; i++) { turningPoints.Add(new TurningPoint { TurningPointName = "平飞", TurningPointLongitude = editor.airroute[i].AirRouteLongitude, TurningPointLatitude = editor.airroute[i].AirRouteLatitude, TurningPointHeight = editor.airroute[i].AirRouteHeight, TurningPointType = "普通", SegmentFlightFuelConsumption = 3, SegmentFlightTime = 0, RemainingFuel = 0, }); } } public static void MieHuo1(FlightPlanEditor editor, ref List turningPoints) //灭火任务从取水点到火场部分的航路点生成 { turningPoints.Add(new TurningPoint { TurningPointName = "取水", TurningPointLongitude = editor.missionpoint.MissionPointLongitude, TurningPointLatitude = editor.missionpoint.MissionPointLatitude, TurningPointHeight = editor.missionpoint.MissionPointHeight + 1000, TurningPointType = "取水", SegmentFlightFuelConsumption = 5, SegmentFlightTime = 60, RemainingFuel = 0, }); turningPoints.Add(new TurningPoint { TurningPointName = "取水", TurningPointLongitude = editor.missionpoint.MissionPointLongitude, TurningPointLatitude = editor.missionpoint.MissionPointLatitude, TurningPointHeight = editor.missionpoint.MissionPointHeight, TurningPointType = "取水", SegmentFlightFuelConsumption = 3, SegmentFlightTime = 0, RemainingFuel = 0, }); turningPoints.Add(new TurningPoint { TurningPointName = "洒水", TurningPointLongitude = editor.firepoint[0].FirePointLongitude, TurningPointLatitude = editor.firepoint[0].FirePointLatitude, TurningPointHeight = editor.firepoint[0].FirePointHeight + 1000, TurningPointType = "巡航", SegmentFlightFuelConsumption = 5, SegmentFlightTime = 120, RemainingFuel = 0, }); turningPoints.Add(new TurningPoint { TurningPointName = "洒水", TurningPointLongitude = editor.firepoint[0].FirePointLongitude, TurningPointLatitude = editor.firepoint[0].FirePointLatitude, TurningPointHeight = editor.firepoint[0].FirePointHeight, TurningPointType = "巡航", SegmentFlightFuelConsumption = 3, SegmentFlightTime = 0, RemainingFuel = 0, }); } public static MissionEndPoint ZhenChaMissionEndPoint(List SC01) //侦查模型任务终点生成 { MissionEndPoint missionEndPoint = new(); int length = SC01.Count - 1; missionEndPoint.MissionEndPointLongitude = SC01[length][0]; missionEndPoint.MissionEndPointLatitude = SC01[length][1]; missionEndPoint.MissionEndPointHeight = SC01[length][2]; return missionEndPoint; } public static MissionEndPoint SuoHuaJiangMissionEndPoint(FlightPlanEditor editor) //索滑降模型任务终点生成 { MissionEndPoint missionEndPoint = new(); missionEndPoint.MissionEndPointLongitude = editor.missionpoint.MissionPointLongitude; missionEndPoint.MissionEndPointLatitude = editor.missionpoint.MissionPointLatitude; missionEndPoint.MissionEndPointHeight = editor.missionpoint.MissionPointHeight; return missionEndPoint; } public static void JijiangMiehuo1(FlightPlanEditor editor, ref List turningPoint) { turningPoint.Add(new TurningPoint { TurningPointName = "转运", TurningPointLongitude = editor.missionpoint.MissionPointLongitude, TurningPointLatitude = editor.missionpoint.MissionPointLatitude, TurningPointHeight = editor.missionpoint.MissionPointHeight, TurningPointType = "转运", SegmentFlightFuelConsumption = 2, SegmentFlightTime = 0, RemainingFuel = 0, }); } public static void JijiangMiehuo(FlightPlanEditor editor, ref List turningPoint) { turningPoint.Add(new TurningPoint { TurningPointName = "转运", TurningPointLongitude = editor.originbase.BaseLongitude, TurningPointLatitude = editor.originbase.BaseLatitude, TurningPointHeight = editor.originbase.BaseHeight, TurningPointType = "转运", SegmentFlightFuelConsumption = 2, SegmentFlightTime = 0, RemainingFuel = 0, }); turningPoint.Add(new TurningPoint { TurningPointName = "转运", TurningPointLongitude = editor.missionpoint.MissionPointLongitude, TurningPointLatitude = editor.missionpoint.MissionPointLatitude, TurningPointHeight = editor.missionpoint.MissionPointHeight, TurningPointType = "转运", SegmentFlightFuelConsumption = 2, SegmentFlightTime = 0, RemainingFuel = 0, }); } public static void SeaSouJiu(FlightPlanEditor editor, ref List turningPoints) { int i; for (i = 0; i < editor.airroute.Length; i++) { turningPoints.Add(new TurningPoint { TurningPointName = "巡航", TurningPointLongitude = editor.airroute[i].AirRouteLongitude, TurningPointLatitude = editor.airroute[i].AirRouteLatitude, TurningPointHeight = 2000, TurningPointType = "普通", SegmentFlightFuelConsumption = 3, SegmentFlightTime = 0, RemainingFuel = 0, }); } } public static void SeaSouJiu2(FlightPlanEditor editor, MissionPoint missionPoint, ref List turningPoints) { turningPoints.Add(new TurningPoint { TurningPointName = "巡航", TurningPointLongitude = missionPoint.MissionPointLongitude, TurningPointLatitude = missionPoint.MissionPointLatitude, TurningPointHeight = 0, TurningPointType = "普通", SegmentFlightFuelConsumption = 3, SegmentFlightTime = 0, RemainingFuel = 0, }); } public static void LandSouJiu(FlightPlanEditor editor, ref List turningPoints) { int i; for (i = 0; i < editor.airroute.Length; i++) { turningPoints.Add(new TurningPoint { TurningPointName = "巡航", TurningPointLongitude = editor.airroute[i].AirRouteLongitude, TurningPointLatitude = editor.airroute[i].AirRouteLatitude, TurningPointHeight = editor.airroute[i].AirRouteHeight, TurningPointType = "普通", SegmentFlightFuelConsumption = 3, SegmentFlightTime = 0, RemainingFuel = 0, }); } } public static void FromMissionToEnd(FlightPlanEditor editor, MissionEndPoint missionEndPoint, ref List turningPoints) //生成从任务段终点到基地的航路点 { turningPoints.Add(new TurningPoint { TurningPointName = "平飞", TurningPointLongitude = missionEndPoint.MissionEndPointLongitude, TurningPointLatitude = missionEndPoint.MissionEndPointLatitude, TurningPointHeight = missionEndPoint.MissionEndPointHeight, TurningPointType = "普通", SegmentFlightFuelConsumption = 3, SegmentFlightTime = 0, RemainingFuel = 0, }); //double k; double lat2, lon2; lat2 = (turningPoints[^1].TurningPointLatitude + editor.endbase.BaseLatitude) / 2; lon2 = (turningPoints[^1].TurningPointLongitude + editor.endbase.BaseLongitude) / 2; // k = (turningPoints[^1].TurningPointLatitude - editor.originbase.BaseLatitude) / // (turningPoints[^1].TurningPointLongitude - editor.originbase.BaseLongitude); // if (turningPoints[^1].TurningPointLongitude > editor.originbase.BaseLongitude) // { // lat2 = 0.08544 * k / (Math.Sqrt(k * k + 1)) + editor.originbase.BaseLatitude; // lon2 = 0.08544 / (Math.Sqrt(k * k + 1)) + editor.originbase.BaseLongitude; // } // else // { // lat2 = editor.originbase.BaseLatitude - 0.08544 * k / (Math.Sqrt(k * k + 1)); // lon2 = editor.originbase.BaseLongitude - 0.08544 / (Math.Sqrt(k * k + 1)); // } turningPoints.Add(new TurningPoint { TurningPointName = "降高", TurningPointLongitude = lon2, TurningPointLatitude = lat2, TurningPointHeight = 2000, TurningPointType = "普通", SegmentFlightFuelConsumption = 4, SegmentFlightTime = 0, RemainingFuel = 0, }); turningPoints.Add(new TurningPoint { TurningPointName = "返回基地", TurningPointLongitude = editor.endbase.BaseLongitude, TurningPointLatitude = editor.endbase.BaseLatitude, TurningPointHeight = editor.endbase.BaseHeight, TurningPointType = "普通", SegmentFlightFuelConsumption = 4, SegmentFlightTime = 0, RemainingFuel = 0, }); } public static void InitializeVelocities(FlightPlanEditor editor, List turningPoints, ref double[] velocitys,double t) { velocitys[0] = GetClimbVelocity(editor, turningPoints[0].TurningPointHeight,t); velocitys[1] = GetCruisingVelocity(editor, turningPoints[1].TurningPointHeight,t); velocitys[2] = GetEnduranceVelocity(editor, turningPoints[2].TurningPointHeight,t); velocitys[3] = GetDescentVelocity(editor, turningPoints[0].TurningPointHeight,t); } public static void InitializeFuelConsumptions(FlightPlanEditor editor, List turningPoints, ref double[] fuelConsumptions,double t) { fuelConsumptions[0] = GetClimbFuelConsumptionRate(editor, turningPoints[0].TurningPointHeight,t); fuelConsumptions[1] = GetCruisingFuelConsumptionRate(editor, turningPoints[1].TurningPointHeight,t); fuelConsumptions[2] = GetEnduranceFuelConsumptionRate(editor, turningPoints[2].TurningPointHeight,t); fuelConsumptions[3] = GetDescentFuelConsumptionRate(editor, turningPoints[0].TurningPointHeight,t); fuelConsumptions[4] = GetHoverFuelConsumptionRate(editor, turningPoints[2].TurningPointHeight,t); } public static void CalculateTrueHeading(FlightPlanEditor editor,ref List turningPoints) { for (int i=0;i turningPoints, double[] velocitys, double[] fuelConsumptions) { int i; double DEG_TO_RAD_LOCAL = 3.1415926535897932 / 180; double[] x = new double[turningPoints.Count]; double[] y = new double[turningPoints.Count]; double[] z = new double[turningPoints.Count]; // LLA坐标转换为ECEF坐标 for (i = 0; i < turningPoints.Count; i++) { double lon = turningPoints[i].TurningPointLongitude * DEG_TO_RAD_LOCAL; double lat = turningPoints[i].TurningPointLatitude * DEG_TO_RAD_LOCAL; double hei = turningPoints[i].TurningPointHeight; double a = 6378137.0; double b = 6356752.31424518; double N = a / (Math.Sqrt(1 - ((a * a - b * b) / (a * a)) * Math.Sin(lat) * Math.Sin(lat))); x[i] = (N + hei) * Math.Cos(lat) * Math.Cos(lon); y[i] = (N + hei) * Math.Cos(lat) * Math.Sin(lon); z[i] = ((b * b * N) / (a * a) + hei) * Math.Sin(lat); } // 计算每个航段的飞行时间 for (i = 0; i < turningPoints.Count; i++) { if (turningPoints[i].SegmentFlightTime == 0) { double distanceab = 0; if (i != turningPoints.Count - 1) { 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)); } double velocity; switch (turningPoints[i].SegmentFlightFuelConsumption) { case 1: velocity = velocitys[0]; break; case 2: velocity = velocitys[1]; break; case 3: velocity = velocitys[2]; break; case 4: velocity = velocitys[3]; break; case 5: velocity = 0; break; default: velocity = 0; break; } turningPoints[i].SegmentFlightTime = CalculateSegmentFlightTime(distanceab, velocity); double CalculateSegmentFlightTime(double distance, double velocit) { return distance * 3.6 / velocit; } // 打印调试信息 //Console.WriteLine($"航段 {i}: 时间 = {turningPoints[i].SegmentFlightTime} s, 速度 = {velocity} km/h, 距离 = {distanceab} m"); } //Console.WriteLine($"航段 {i}: 时间 = {turningPoints[i].SegmentFlightTime} s"); // 计算燃油消耗,并在燃油不足时插入“返回基地”、“加油”和“返回原航路点”航路点 if (turningPoints[i].RemainingFuel == 0) { double remainingFuel; if (i == 0) { remainingFuel = editor.aircraftparameter.MaxFuelCapacity * 0.8; } else { remainingFuel = turningPoints[i - 1].RemainingFuel; } double fuelConsumption = 0; switch (turningPoints[i].SegmentFlightFuelConsumption) { case 1: fuelConsumption = fuelConsumptions[0]; break; case 2: fuelConsumption = fuelConsumptions[1]; break; case 3: fuelConsumption = fuelConsumptions[2]; break; case 4: fuelConsumption = fuelConsumptions[3]; break; case 5: fuelConsumption = fuelConsumptions[4]; break; default: fuelConsumption = 0; break; } remainingFuel -= fuelConsumption * turningPoints[i].SegmentFlightTime / 3600; turningPoints[i].RemainingFuel = remainingFuel; // 打印调试信息 //Console.WriteLine($"航段 {i}: 油耗率 = {fuelConsumption} kg/h, 剩余燃油 = {turningPoints[i].RemainingFuel} kg"); } //Console.WriteLine($"航段 {i}: 剩余燃油 = {turningPoints[i].RemainingFuel} kg"); if (turningPoints[i].RemainingFuel < editor.aircraftparameter.MaxFuelCapacity * 0.2 && !turningPoints[i].IsRefuelPointInserted && i < turningPoints.Count - 2) { // 标记当前航路点为已插入加油点 turningPoints[i].IsRefuelPointInserted = true; turningPoints[i + 1].IsRefuelPointInserted = true; TurningPoint returnToBase = new TurningPoint { TurningPointName = "返回基地", TurningPointLongitude = editor.fuelbase.BaseLongitude, TurningPointLatitude = editor.fuelbase.BaseLatitude, TurningPointHeight = editor.fuelbase.BaseHeight, TurningPointType = "返航", SegmentFlightTime = 600, SegmentFlightFuelConsumption = 0, RemainingFuel = editor.aircraftparameter.MaxFuelCapacity, }; TurningPoint refuelPoint = new TurningPoint { TurningPointName = "加油", TurningPointLongitude = editor.fuelbase.BaseLongitude, TurningPointLatitude = editor.fuelbase.BaseLatitude, TurningPointHeight = editor.fuelbase.BaseHeight, TurningPointType = "加油", SegmentFlightTime = 0, SegmentFlightFuelConsumption = 2, RemainingFuel = 0, }; TurningPoint returnToPrevious = new TurningPoint { TurningPointName = "返回原航路点", TurningPointLongitude = turningPoints[i + 1].TurningPointLongitude, TurningPointLatitude = turningPoints[i + 1].TurningPointLatitude, TurningPointHeight = turningPoints[i + 1].TurningPointHeight, TurningPointType = "返航", SegmentFlightTime = 0, SegmentFlightFuelConsumption = 2, RemainingFuel = 0, }; // 插入新航路点到当前位置 turningPoints.Insert(i + 2, returnToBase); turningPoints.Insert(i + 3, refuelPoint); turningPoints.Insert(i + 4, returnToPrevious); // 重新计算插入的航路点的飞行时间和燃油消耗 FXJHTPDiedai(editor, ref turningPoints, velocitys, fuelConsumptions); // 退出当前方法,避免重复计算 return; } } } public static void BackToEnd(FlightPlanEditor editor, MissionEndPoint missionEndPoint, ref List turningPoints, int index) { turningPoints.Insert(index,new TurningPoint { TurningPointName = "平飞", TurningPointLongitude = missionEndPoint.MissionEndPointLongitude, TurningPointLatitude = missionEndPoint.MissionEndPointLatitude, TurningPointHeight = missionEndPoint.MissionEndPointHeight, TurningPointType = "普通", SegmentFlightFuelConsumption = 3, SegmentFlightTime = 0, RemainingFuel = 0, }); //double k; double lat2, lon2; lat2 = (turningPoints[^1].TurningPointLatitude + editor.endbase.BaseLatitude) / 2; lon2 = (turningPoints[^1].TurningPointLongitude + editor.endbase.BaseLongitude) / 2; turningPoints.Insert(index + 1,new TurningPoint { TurningPointName = "降高", TurningPointLongitude = lon2, TurningPointLatitude = lat2, TurningPointHeight = 2000, TurningPointType = "普通", SegmentFlightFuelConsumption = 4, SegmentFlightTime = 0, RemainingFuel = 0, }); turningPoints.Insert(index+2,new TurningPoint { TurningPointName = "返回基地", TurningPointLongitude = editor.endbase.BaseLongitude, TurningPointLatitude = editor.endbase.BaseLatitude, TurningPointHeight = editor.endbase.BaseHeight, TurningPointType = "普通", SegmentFlightFuelConsumption = 4, SegmentFlightTime = 0, RemainingFuel = 0, }); } public static double CalculateTotalFuelConsumption(FlightPlanEditor editor, List turningPoints) { double initialFuel = editor.aircraftparameter.MaxFuelCapacity; // 起始燃油量 double totalFuelConsumption = 0; // 总燃油消耗量 double totalRefuelAmount = 0; // 总加油量 for (int i = 0; i < turningPoints.Count; i++) { //// 更新飞行过程中的燃油消耗 //if (i ==0) //{ // double segmentFuelConsumed = initialFuel - turningPoints[i].RemainingFuel; //} //else //{ // double segmentFuelConsumed = (turningPoints[i - 1].RemainingFuel - turningPoints[i].RemainingFuel); // totalFuelConsumption += segmentFuelConsumed; //} // 如果当前航路点是加油点,更新燃油并记录加油量 if (turningPoints[i].TurningPointType == "加油") { double refuelAmount = editor.aircraftparameter.MaxFuelCapacity - turningPoints[i - 2].RemainingFuel; totalRefuelAmount += refuelAmount; } } // 最终燃油消耗 = 初始燃油 + 总加油量 - 最终剩余燃油 double finalFuel = turningPoints.Last().RemainingFuel; totalFuelConsumption = (initialFuel + totalRefuelAmount) - finalFuel; return totalFuelConsumption; } /// /// 巡护用 /// /// /// /// /// public static (CurrentLocation, bool) GetCurrentLocation(List turningPoints, FlightPlanEditor editor, double nowtime) { CurrentLocation currentLocation = new CurrentLocation(); double[] timetable = new double[editor.airroute.Length + 2]; //airroute.Length表示巡护航线中有几个航路点 timetable[0] = 0; //设起飞时刻为0 int segmentnumber = -1; int i; for (i = 0; i < editor.airroute.Length + 1; i++) { timetable[i + 1] = timetable[i] + turningPoints[i].SegmentFlightTime; } for (i = 0; i < editor.airroute.Length + 2; i++) { if ((nowtime - timetable[i]) >= 0) { segmentnumber += 1; } else { break; } } bool isEnd = false || segmentnumber >= turningPoints.Count; currentLocation.CurrentLon = turningPoints[segmentnumber].TurningPointLongitude + (turningPoints[segmentnumber + 1].TurningPointLongitude - turningPoints[segmentnumber].TurningPointLongitude) * (nowtime - timetable[segmentnumber]) / turningPoints[segmentnumber].SegmentFlightTime; currentLocation.CurrentLat = turningPoints[segmentnumber].TurningPointLatitude + (turningPoints[segmentnumber + 1].TurningPointLatitude - turningPoints[segmentnumber].TurningPointLatitude) * (nowtime - timetable[segmentnumber]) / turningPoints[segmentnumber].SegmentFlightTime; currentLocation.CurrentHei = turningPoints[segmentnumber].TurningPointHeight + (turningPoints[segmentnumber + 1].TurningPointHeight - turningPoints[segmentnumber].TurningPointHeight) * (nowtime - timetable[segmentnumber]) / turningPoints[segmentnumber].SegmentFlightTime; currentLocation.CurrentFuel = 0; currentLocation.Currentvelo = 0; currentLocation.Currentsegnum = segmentnumber + 1; currentLocation.CurrentCourse = 75; return (currentLocation, isEnd); } //改 /// /// 计算当前位置 /// /// /// /// /// public static (CurrentLocation, bool, int) GetAllCurrentLocation(List turningPoints, double nowtime) //飞机实时位置打印 { CurrentLocation currentLocation = new CurrentLocation(); double[] timetable = new double[turningPoints.Count + 1]; timetable[0] = 0; int segmentnumber = -1; int i; for (i = 0; i < turningPoints.Count; i++) { timetable[i + 1] = timetable[i] + turningPoints[i].SegmentFlightTime; } for (i = 0; i < turningPoints.Count + 1; i++) { if ((nowtime - timetable[i]) >= 0) { segmentnumber += 1; } else { break; } } bool isEnd = false || segmentnumber >= turningPoints.Count; currentLocation.Currentsegnum = segmentnumber; if (segmentnumber < turningPoints.Count - 1) { currentLocation.CurrentLon = turningPoints[segmentnumber].TurningPointLongitude + ((turningPoints[segmentnumber + 1].TurningPointLongitude - turningPoints[segmentnumber].TurningPointLongitude) / turningPoints[segmentnumber].SegmentFlightTime) * (nowtime - timetable[segmentnumber]); currentLocation.CurrentLat = turningPoints[segmentnumber].TurningPointLatitude + ((turningPoints[segmentnumber + 1].TurningPointLatitude - turningPoints[segmentnumber].TurningPointLatitude) / turningPoints[segmentnumber].SegmentFlightTime) * (nowtime - timetable[segmentnumber]); currentLocation.CurrentHei = turningPoints[segmentnumber].TurningPointHeight + ((turningPoints[segmentnumber + 1].TurningPointHeight - turningPoints[segmentnumber].TurningPointHeight) / turningPoints[segmentnumber].SegmentFlightTime) * (nowtime - timetable[segmentnumber]); currentLocation.CurrentFuel = turningPoints[segmentnumber].RemainingFuel - turningPoints[segmentnumber].SegmentFlightFuelConsumption * (nowtime - timetable[segmentnumber]); currentLocation.PresentMission = turningPoints[segmentnumber].TurningPointName; } else if (segmentnumber == turningPoints.Count - 1) { currentLocation.CurrentLon = turningPoints[segmentnumber].TurningPointLongitude + ((turningPoints[0].TurningPointLongitude - turningPoints[segmentnumber].TurningPointLongitude) / turningPoints[segmentnumber].SegmentFlightTime) * (nowtime - timetable[segmentnumber]); currentLocation.CurrentLat = turningPoints[segmentnumber].TurningPointLatitude + ((turningPoints[0].TurningPointLatitude - turningPoints[segmentnumber].TurningPointLatitude) / turningPoints[segmentnumber].SegmentFlightTime) * (nowtime - timetable[segmentnumber]); currentLocation.CurrentHei = turningPoints[segmentnumber].TurningPointHeight + ((turningPoints[0].TurningPointHeight - turningPoints[segmentnumber].TurningPointHeight) / turningPoints[segmentnumber].SegmentFlightTime) * (nowtime - timetable[segmentnumber]); currentLocation.CurrentFuel = turningPoints[segmentnumber].RemainingFuel - turningPoints[segmentnumber].SegmentFlightFuelConsumption * (nowtime - timetable[segmentnumber]); currentLocation.PresentMission = turningPoints[segmentnumber].TurningPointName; } else { currentLocation.CurrentLon = turningPoints[^1].TurningPointLongitude; currentLocation.CurrentLat = turningPoints[^1].TurningPointLatitude; currentLocation.CurrentHei = turningPoints[^1].TurningPointHeight; currentLocation.Currentvelo = 0; currentLocation.CurrentFuel = turningPoints[segmentnumber - 1].RemainingFuel - turningPoints[segmentnumber - 1].SegmentFlightFuelConsumption * turningPoints[segmentnumber - 1].SegmentFlightTime; currentLocation.PresentMission = turningPoints[segmentnumber - 1].TurningPointName; isEnd = true; } return (currentLocation, isEnd,segmentnumber); } } }