Browse Source

医疗场景各子任务添加报告需要飞行相关参数值

liyang 3 months ago
parent
commit
3e4e04c56c

+ 1 - 1
Models/SimulationCommon/Define.cs

@@ -13,7 +13,7 @@ public class TurningPoint //类中删除了转弯半径
     public double SegmentFlightTime;
     public double RemainingFuel; //新添加了当前剩余油量
     public double HeadingAngle;
-
+    public bool IsRefuelPointInserted { get; set; } = false; // 新增字段
     public TurningPoint[] turningpoint;
 }
 //

+ 143 - 51
Models/SimulationCommon/FXJHGenenrate.cs

@@ -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++)

+ 3 - 1
SimulationServer/Entity/AircraftEntity.cs

@@ -33,7 +33,7 @@ public class AircraftEntity : Entity
 
     public double[] Velocitys = new double[5] { 220, 220, 220, 110, 0 }; // 速度
 
-    public double[] FuelConsumptions = new double[5] { 2800, 2800, 2800, 1000, 132 }; // 燃油消耗
+    public double[] FuelConsumptions = new double[5] { 200, 200, 200, 1000, 132 }; // 燃油消耗
 
     public List<TurningPoint> TurningPoints = new List<TurningPoint>(); // 航路点
 
@@ -50,6 +50,8 @@ public class AircraftEntity : Entity
             FlightPlanEditor.aircraftparameter.MaxPassengerNumber = double.Parse(Db.f_zdzkl.ToString());
         else
             FlightPlanEditor.aircraftparameter.MaxPassengerNumber = 20;
+
+        FlightPlanEditor.aircraftparameter.MaxFuelCapacity = 8000;
     }
 
     public virtual void Reset()

+ 12 - 5
SimulationServer/Entity/AircraftXCJJ.cs

@@ -146,11 +146,11 @@ public class AircraftXCJJ : AircraftEntity
         reportInfo.Add("准备时间", TaskReadyTime.ToString());
 
         double reachTime = 0;
-        for (int i = 2; i < 4; i++)
+        for (int i = 0; i < 2; i++)
         {
             reachTime += TurningPoints[i].SegmentFlightTime;
         }
-        reportInfo.Add("到达时间", reachTime.ToString()); // 基地 -> 目标点
+        reportInfo.Add("到达时间", reachTime.ToString()); // 基地 -> 目标点
 
         reportInfo.Add("任务周期时间", TotalTime.ToString());
         reportInfo.Add("执行任务飞机型号", Name);
@@ -161,15 +161,22 @@ public class AircraftXCJJ : AircraftEntity
         reportInfo.Add("单机重症监护护理人员人数", taskParameter.nurseSeverePersonnel.ToString());
         reportInfo.Add("单机地面保障人数", taskParameter.groundSupportPersonnel.ToString());
         reportInfo.Add("单机总任务时长", TotalTime.ToString());
-        reportInfo.Add("单机总油耗", "60"); // ?
+        reportInfo.Add("单机总油耗", FXJHGenerate.CalculateTotalFuelConsumption(FlightPlanEditor, TurningPoints).ToString());
         reportInfo.Add("单机机场使用情况", Airport + "\r\n" + hospitalAirport);
-        reportInfo.Add("单机导航使用情况", "1000"); //飞行总距离 ?
+
+        double zhc = 0;
+        for (int i = 0; i < TurningPoints.Count - 1; i++)
+        {
+            zhc += Utils.Util.GetDistance(TurningPoints[i].TurningPointLongitude,
+                    TurningPoints[i + 1].TurningPointLongitude, TurningPoints[i].TurningPointLatitude, TurningPoints[i + 1].TurningPointLatitude);
+        }
+        reportInfo.Add("单机导航使用情况", zhc.ToString()); //飞行总距离
         for (int i = 0; i < load.Count; i++)
         {
             if (load[i].Split(":")[0].Contains("装备"))
             {
                 device += load[i].Split(":")[1];
-                if(i != load.Count - 1)
+                if (i != load.Count - 1)
                 {
                     device += "\r\n";
                 }

+ 9 - 3
SimulationServer/Entity/AircraftYLWPYS.cs

@@ -65,7 +65,7 @@ public class AircraftYLWPYS : AircraftEntity
 
         reportInfo.Add("准备时间", TaskReadyTime.ToString());
         double reachTime = 0;
-        for (int i = 2; i < 4; i++)
+        for (int i = 0; i < 2; i++)
         {
             reachTime += TurningPoints[i].SegmentFlightTime;
         }
@@ -76,8 +76,14 @@ public class AircraftYLWPYS : AircraftEntity
         reportInfo.Add("单机操作员人数", taskParameter.operatorPersonnel.ToString());
         reportInfo.Add("单机地面保障人数", taskParameter.groundSupportPersonnel.ToString());
         reportInfo.Add("单机总任务时长", TotalTime.ToString());
-        reportInfo.Add("单机总油耗", "60"); // ?
-        reportInfo.Add("单机导航使用情况", "1000"); //飞行总距离 ?
+        reportInfo.Add("单机总油耗", FXJHGenerate.CalculateTotalFuelConsumption(FlightPlanEditor, TurningPoints).ToString());
+        double zhc = 0;
+        for (int i = 0; i < TurningPoints.Count - 1; i++)
+        {
+            zhc += Utils.Util.GetDistance(TurningPoints[i].TurningPointLongitude,
+                    TurningPoints[i + 1].TurningPointLongitude, TurningPoints[i].TurningPointLatitude, TurningPoints[i + 1].TurningPointLatitude);
+        }
+        reportInfo.Add("单机导航使用情况", zhc.ToString());
         for (int i = 0; i < load.Count; i++)
         {
             if (load[i].Split(":")[0].Contains("装备"))

+ 9 - 3
SimulationServer/Entity/AircraftYLZY.cs

@@ -119,7 +119,7 @@ public class AircraftYLZY : AircraftEntity
 
         reportInfo.Add("准备时间", TaskReadyTime.ToString());
         double reachTime = 0;
-        for (int i = 2; i < 4; i++)
+        for (int i = 0; i < 2; i++)
         {
             reachTime += TurningPoints[i].SegmentFlightTime;
         }
@@ -133,9 +133,15 @@ public class AircraftYLZY : AircraftEntity
         reportInfo.Add("单机重症监护护理人员人数", taskParameter.nurseSeverePersonnel.ToString());
         reportInfo.Add("单机地面保障人数", taskParameter.groundSupportPersonnel.ToString());
         reportInfo.Add("单机总任务时长", TotalTime.ToString());
-        reportInfo.Add("单机总油耗", "60"); // ?
+        reportInfo.Add("单机总油耗", FXJHGenerate.CalculateTotalFuelConsumption(FlightPlanEditor, TurningPoints).ToString());
         reportInfo.Add("单机机场使用情况", Airport + "\r\n" + hospitalAirport);
-        reportInfo.Add("单机导航使用情况", "1000"); //飞行总距离 ?
+        double zhc = 0;
+        for (int i = 0; i < TurningPoints.Count - 1; i++)
+        {
+            zhc += Utils.Util.GetDistance(TurningPoints[i].TurningPointLongitude,
+                    TurningPoints[i + 1].TurningPointLongitude, TurningPoints[i].TurningPointLatitude, TurningPoints[i + 1].TurningPointLatitude);
+        }
+        reportInfo.Add("单机导航使用情况", zhc.ToString()); //飞行总距离
         for (int i = 0; i < load.Count; i++)
         {
             if (load[i].Split(":")[0].Contains("装备"))

+ 1 - 1
SimulationServer/Utils/Util.cs

@@ -74,7 +74,7 @@ public class Util
             "fType","fSubtype","fName","limit"
         }, new List<string>
         {
-            aircraftType,aircraftSubType,aircraftID,"1"
+            "航空医疗",aircraftSubType,aircraftID,"1"
         });
 
         var yl = JsonHelper.FromJson<YLDB>(content);

BIN
SimulationServer/bin/Debug/net7.0/SimulationCommon.dll


BIN
SimulationServer/bin/Debug/net7.0/SimulationCommon.pdb


BIN
SimulationServer/bin/Debug/net7.0/SimulationServer.dll


BIN
SimulationServer/bin/Debug/net7.0/SimulationServer.exe


BIN
SimulationServer/bin/Debug/net7.0/SimulationServer.pdb