|
@@ -618,16 +618,16 @@ ref List<TurningPoint> turningPoints) //索滑降模型航路点生成
|
|
|
fuelConsumptions[3] = GetDescentFuelConsumptionRate(editor, turningPoints[0].TurningPointHeight);
|
|
|
fuelConsumptions[4] = GetHoverFuelConsumptionRate(editor, turningPoints[2].TurningPointHeight);
|
|
|
}
|
|
|
- public static void FXJHTPDiedai(FlightPlanEditor editor,ref List<TurningPoint> turningPoints,double[] velocitys, double[] fuelConsumptions) //各航段飞行时间、油耗计算和航路点油耗迭代
|
|
|
+ public static void FXJHTPDiedai(FlightPlanEditor editor, ref List<TurningPoint> 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];
|
|
|
|
|
|
- for (i = 0; i < turningPoints.Count; i++) //LLA坐标转换为ECEF坐标
|
|
|
+ // 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;
|
|
@@ -642,6 +642,7 @@ ref List<TurningPoint> turningPoints) //索滑降模型航路点生成
|
|
|
z[i] = ((b * b * N) / (a * a) + hei) * Math.Sin(lat);
|
|
|
}
|
|
|
|
|
|
+ // 计算每个航段的飞行时间
|
|
|
for (i = 0; i < turningPoints.Count; i++)
|
|
|
{
|
|
|
if (turningPoints[i].SegmentFlightTime == 0)
|
|
@@ -649,19 +650,14 @@ ref List<TurningPoint> turningPoints) //索滑降模型航路点生成
|
|
|
double distanceab;
|
|
|
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));
|
|
|
+ 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));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- distanceab = Math.Sqrt(Math.Pow(x[i] - x[0], 2) + Math.Pow(y[i] - y[0], 2) +
|
|
|
- Math.Pow(z[i] - z[0], 2));
|
|
|
+ distanceab = Math.Sqrt(Math.Pow(x[i] - x[0], 2) + Math.Pow(y[i] - y[0], 2) + Math.Pow(z[i] - z[0], 2));
|
|
|
}
|
|
|
|
|
|
double velocity;
|
|
|
-
|
|
|
-
|
|
|
- // 根据飞行段类型选择不同的燃油消耗率计算函数
|
|
|
switch (turningPoints[i].SegmentFlightFuelConsumption)
|
|
|
{
|
|
|
case 1:
|
|
@@ -684,69 +680,165 @@ ref List<TurningPoint> turningPoints) //索滑降模型航路点生成
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- // 使用计算得到的速度计算飞行时间
|
|
|
turningPoints[i].SegmentFlightTime = CalculateSegmentFlightTime(distanceab, velocity);
|
|
|
|
|
|
- double CalculateSegmentFlightTime(double distance, double velocity)
|
|
|
+ double CalculateSegmentFlightTime(double distance, double velocit)
|
|
|
{
|
|
|
- return distance * 3.6 / velocity; // 根据速度计算飞行时间
|
|
|
+ return distance * 3.6 / velocit;
|
|
|
}
|
|
|
+
|
|
|
+ // 打印调试信息
|
|
|
+ //Console.WriteLine($"航段 {i}: 时间 = {turningPoints[i].SegmentFlightTime} s, 速度 = {velocity} km/h, 距离 = {distanceab} m");
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- turningPoints[i].SegmentFlightTime = turningPoints[i].SegmentFlightTime;
|
|
|
- }
|
|
|
- }
|
|
|
+ //Console.WriteLine($"航段 {i}: 时间 = {turningPoints[i].SegmentFlightTime} s");
|
|
|
|
|
|
|
|
|
- for (i = 0; i < turningPoints.Count; i++)
|
|
|
- {
|
|
|
- double remainingFuel;
|
|
|
- if (i == 0)
|
|
|
- {
|
|
|
- remainingFuel = editor.aircraftparameter.MaxFuelCapacity * 0.8;
|
|
|
- }
|
|
|
- else
|
|
|
+
|
|
|
+
|
|
|
+ // 计算燃油消耗,并在燃油不足时插入“返回基地”、“加油”和“返回原航路点”航路点
|
|
|
+ if (turningPoints[i].RemainingFuel == 0)
|
|
|
{
|
|
|
- remainingFuel = turningPoints[i - 1].RemainingFuel;
|
|
|
+ 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");
|
|
|
|
|
|
- double fuelConsumption = 0;
|
|
|
- // 根据飞行段类型选择不同的燃油消耗率计算函数,1代表爬升,2代表平飞远航,3代表平飞久航,4代表下降,5代表悬停
|
|
|
- switch (turningPoints[i].SegmentFlightFuelConsumption)
|
|
|
+ if (turningPoints[i].RemainingFuel < editor.aircraftparameter.MaxFuelCapacity * 0.2 && !turningPoints[i].IsRefuelPointInserted && i < turningPoints.Count - 2)
|
|
|
{
|
|
|
- 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;
|
|
|
+ // 标记当前航路点为已插入加油点
|
|
|
+ turningPoints[i].IsRefuelPointInserted = true;
|
|
|
+ turningPoints[i + 1].IsRefuelPointInserted = true;
|
|
|
+
|
|
|
+ TurningPoint returnToBase = new TurningPoint
|
|
|
+ {
|
|
|
+ TurningPointName = "返回基地",
|
|
|
+ TurningPointLongitude = editor.originbase.BaseLongitude,
|
|
|
+ TurningPointLatitude = editor.originbase.BaseLatitude,
|
|
|
+ TurningPointHeight = editor.originbase.BaseHeight,
|
|
|
+ TurningPointType = "返航",
|
|
|
+ SegmentFlightTime = 600,
|
|
|
+ SegmentFlightFuelConsumption = 0,
|
|
|
+ RemainingFuel = editor.aircraftparameter.MaxFuelCapacity,
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ TurningPoint refuelPoint = new TurningPoint
|
|
|
+ {
|
|
|
+ TurningPointName = "加油",
|
|
|
+ TurningPointLongitude = editor.originbase.BaseLongitude,
|
|
|
+ TurningPointLatitude = editor.originbase.BaseLatitude,
|
|
|
+ TurningPointHeight = editor.originbase.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;
|
|
|
}
|
|
|
|
|
|
|
|
|
- remainingFuel -= fuelConsumption * turningPoints[i].SegmentFlightTime / 3600; // 更新剩余燃油
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static double CalculateTotalFuelConsumption(FlightPlanEditor editor, List<TurningPoint> 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 (remainingFuel < 0)
|
|
|
+ // 如果当前航路点是加油点,更新燃油并记录加油量
|
|
|
+ if (turningPoints[i].TurningPointType == "加油")
|
|
|
{
|
|
|
- remainingFuel = 0;
|
|
|
- break;
|
|
|
+ double refuelAmount = editor.aircraftparameter.MaxFuelCapacity - turningPoints[i - 2].RemainingFuel;
|
|
|
+ totalRefuelAmount += refuelAmount;
|
|
|
}
|
|
|
-
|
|
|
- turningPoints[i].RemainingFuel = remainingFuel;
|
|
|
}
|
|
|
|
|
|
+ // 最终燃油消耗 = 初始燃油 + 总加油量 - 最终剩余燃油
|
|
|
+ double finalFuel = turningPoints.Last().RemainingFuel;
|
|
|
+ totalFuelConsumption = (initialFuel + totalRefuelAmount) - finalFuel;
|
|
|
+
|
|
|
+ return totalFuelConsumption;
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
public static void CalculateTrueHeading(FlightPlanEditor editor, ref List<TurningPoint> turningPoints)
|
|
|
{
|
|
|
for (int i = 0; i < turningPoints.Count - 1; i++)
|