Browse Source

添加机降救援与着水救援部分代码

liyang 6 months ago
parent
commit
d4e8dfedbf

+ 83 - 0
Models/SimulationCommon/FXJHGenenrate.cs

@@ -305,6 +305,89 @@ namespace Model
             });
         }
 
+        public static void JijiangJiuYuan1(FlightPlanEditor editor, ref List<TurningPoint> turningPoint)
+        {
+            turningPoint.Add(new TurningPoint
+            {
+                TurningPointName = "转运",
+                TurningPointLongitude = editor.missionpoint.MissionPointLongitude,
+                TurningPointLatitude = editor.missionpoint.MissionPointLatitude,
+                TurningPointHeight = editor.missionpoint.MissionPointHeight,
+                TurningPointType = "转运",
+                SegmentFlightFuelConsumption = 2,
+                SegmentFlightTime = 600,
+                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 JijiangJiuYuan(FlightPlanEditor editor, ref List<TurningPoint> 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 = 600,
+                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 ZhaoShuiJiuYuan(List<AirRoute> airRoutes, ref List<TurningPoint> turningPoint)
+        {
+            for (int i = 0;i < airRoutes.Count; i++)
+            {
+                turningPoint.Add(new TurningPoint
+                {
+                    TurningPointName = "转运",
+                    TurningPointLongitude = airRoutes[i].AirRouteLongitude,
+                    TurningPointLatitude = airRoutes[i].AirRouteLatitude,
+                    TurningPointHeight = 1000,
+                    TurningPointType = "转运",
+                    SegmentFlightFuelConsumption = 3,
+                    SegmentFlightTime = 0,
+                    RemainingFuel = 0,
+                });
+            }
+        }
+
         public static void SeaSouJiu(FlightPlanEditor editor, ref List<TurningPoint> turningPoints)
         {
             int i;

+ 28 - 0
Models/SimulationCommon/TaskConfig.cs

@@ -179,6 +179,34 @@ public class DMMHTask
     public string NextTaskId;
 }
 
+public class JJJYTask //机降救援
+{
+    [JsonProperty("任务信息")]
+    public MissionInformation missionInformation;
+    [JsonProperty("应用航空器")]
+    public AircraftInfo[] aircraftInfos;
+    [JsonProperty("单机总机降人数")]
+    public double LandingPersonnel;
+    [JsonProperty("机降点")]
+    public MissionPoint[] MissionPoints;
+    [JsonProperty("下一个任务ID")]
+    public string NextTaskId;
+}
+
+public class ZSJYTask //着水救援
+{
+    [JsonProperty("任务信息")]
+    public MissionInformation missionInformation;
+    [JsonProperty("应用航空器")]
+    public AircraftInfo[] aircraftInfos;
+    [JsonProperty("单机总机降人数")]
+    public double LandingPersonnel;
+    [JsonProperty("机降点")]
+    public MissionPoint[] MissionPoints;
+    [JsonProperty("下一个任务ID")]
+    public string NextTaskId;
+}
+
 public class AirRoute
 {
     [JsonProperty("巡护航线名称")]

+ 0 - 1
Models/SimulationCommon/Text_readNC.cs

@@ -275,7 +275,6 @@ public class Text_readNC
                 // Determine the dimensions of the data array
                 times4 = dataArray1.Count;
                 latitudes4 = ((JArray)dataArray1[0]).Count;
-                Console.WriteLine("latitudes2:" + latitudes);
                 longitudes4 = ((JArray)dataArray1[0][0]).Count;
 
                 // Initialize float[][][] array

+ 90 - 0
SimulationServer/Entity/AircraftJJ.cs

@@ -0,0 +1,90 @@
+using KYFramework;
+using Model;
+using SimulationServer.Utils;
+using Define = SimulationServer.Utils.Define;
+
+namespace SimulationServer;
+
+public class AircraftJJ : AircraftEntity
+{
+    public string NextMissionId; // 下一个任务ID
+    public MissionEndPoint missionEndPoint = new MissionEndPoint();
+
+    public int LandingPersonnel; //personCount
+    public MHRescueMission mhRescueMission;
+
+    public int landingPoint = 0; // 任务文件获取
+    
+    public override void End()
+    {
+        
+    }
+
+    public override void Reset()
+    {
+        base.Reset();       
+    }
+    public override void Start()
+    {
+        FXJHGenerate.FromStartToMission(FlightPlanEditor,ref TurningPoints);//生成从起点到任务段起点的航路点
+        
+        missionEndPoint.MissionEndPointLatitude = FlightPlanEditor.missionpoint.MissionPointLatitude;
+        missionEndPoint.MissionEndPointLongitude = FlightPlanEditor.missionpoint.MissionPointLongitude;
+        missionEndPoint.MissionEndPointHeight = FlightPlanEditor.missionpoint.MissionPointHeight;
+        
+        int TransportNumber = (int)Math.Ceiling(LandingPersonnel / FlightPlanEditor.aircraftparameter.MaxPassengerNumber);
+
+        int j = 0;
+        
+        
+        for (int i = 0; i < TransportNumber; i ++)
+        {
+            if (i == 0)
+            {
+                FXJHGenerate.JijiangJiuYuan1(FlightPlanEditor,ref TurningPoints);
+            }
+            else
+            {
+                FXJHGenerate.JijiangJiuYuan(FlightPlanEditor,ref TurningPoints);
+                j += 2;
+            }
+            
+        }
+        // FXJHGenerate.InitializeVelocities(FlightPlanEditor, TurningPoints, ref Velocitys);
+        // FXJHGenerate.InitializeFuelConsumptions(FlightPlanEditor, TurningPoints,ref FuelConsumptions);
+        
+        FXJHGenerate.FromMissionToEnd(FlightPlanEditor, missionEndPoint,ref TurningPoints);
+        FXJHGenerate.FXJHTPDiedai(FlightPlanEditor,ref TurningPoints, Velocitys, FuelConsumptions); // 更新了 计算油耗的方法
+    }
+    
+    //private double GetDistance(double lon1, double lon2, double lat1, double lat2)
+    //{
+    //    double R = 6371; // 地球的半径(公里)
+    //    double dLat = (lat2 - lat1) * Math.PI / 180.0;
+    //    double dLon = (lon2 - lon1) * Math.PI / 180.0;
+    //    double a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) +
+    //               Math.Cos(lat1 * Math.PI / 180.0) * Math.Cos(lat2 * Math.PI / 180.0) *
+    //               Math.Sin(dLon / 2) * Math.Sin(dLon / 2);
+    //    double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
+    //    double distance = R * c;
+
+    //    return distance;
+    //}
+    
+    public override void Update(double time)
+    {
+
+    }
+}
+
+
+[ObjectSystem]
+public class AircraftJJAwakeSystem : AwakeSystem<AircraftJJ,FlightPlanEditor>
+{
+    public override void Awake(AircraftJJ self,FlightPlanEditor flightPlanEditor)
+    {
+        self.FlightPlanEditor = flightPlanEditor;
+        self.Awake();
+        self.Reset();
+    }
+}

+ 125 - 0
SimulationServer/Entity/AircraftZS.cs

@@ -0,0 +1,125 @@
+using KYFramework;
+using Model;
+using SimulationServer.Utils;
+using Define = SimulationServer.Utils.Define;
+
+namespace SimulationServer;
+
+public class AircraftZS : AircraftEntity
+{
+    public string NextMissionId; // 下一个任务ID
+    public MissionEndPoint missionEndPoint = new MissionEndPoint();
+
+    public int LandingPersonnel; //personCount
+    public MHRescueMission mhRescueMission;
+
+    public int 单次救援人数 = 80; // 任务文件读取
+    public int 观察盘旋圈数 = 3; //任务文件读取
+
+    public int landingPoint = 0;
+
+    public List<AirRoute> airRoutes = new List<AirRoute>();
+
+    public override void End()
+    {
+
+    }
+
+    public override void Reset()
+    {
+        base.Reset();
+    }
+    public override void Start()
+    {
+        FXJHGenerate.FromStartToMission(FlightPlanEditor, ref TurningPoints);//生成从起点到任务段起点的航路点
+
+        missionEndPoint.MissionEndPointLatitude = FlightPlanEditor.targetpoint[0].TargetPointLatitude;
+        missionEndPoint.MissionEndPointLongitude = FlightPlanEditor.targetpoint[0].TargetPointLongitude;
+        missionEndPoint.MissionEndPointHeight = FlightPlanEditor.targetpoint[0].TargetPointHeight;
+
+        List<double> list = GenerateCircleTrajectory(FlightPlanEditor.targetpoint[0].TargetPointLatitude, FlightPlanEditor.targetpoint[0].TargetPointLongitude, 1, 360);
+        //airRoutes = list
+
+        for (int i = 0; i < 观察盘旋圈数; i++)
+        {
+            FXJHGenerate.ZhaoShuiJiuYuan(airRoutes, ref TurningPoints);
+
+        }
+        // FXJHGenerate.InitializeVelocities(FlightPlanEditor, TurningPoints, ref Velocitys);
+        // FXJHGenerate.InitializeFuelConsumptions(FlightPlanEditor, TurningPoints,ref FuelConsumptions);
+
+        FXJHGenerate.FromMissionToEnd(FlightPlanEditor, missionEndPoint, ref TurningPoints);
+        FXJHGenerate.FXJHTPDiedai(FlightPlanEditor, ref TurningPoints, Velocitys, FuelConsumptions); // 更新了 计算油耗的方法
+    }
+
+    // centerLat centerLon 想定里目标点的经纬度 radiusKm = 1 numPoints = 360  返回的airRoutes  // 
+
+    // 生成圆形轨迹点,并以 double 列表形式返回(按经度-纬度顺序存储)
+    public static List<double> GenerateCircleTrajectory(double centerLat, double centerLon, double radiusKm, int numPoints)
+    {
+        var points = new List<double>();
+        double earthRadius = 6371.0; // 地球半径,单位:公里
+
+        for (int i = 0; i < numPoints; i++)
+        {
+            double angle = 2 * Math.PI * i / numPoints;  // 当前点的角度(弧度)
+
+            // 计算偏移量
+            double offsetLat = radiusKm / earthRadius; // 纬度的偏移量(弧度)
+            double offsetLon = offsetLat / Math.Cos(ToRadians(centerLat)); // 经度的偏移量(弧度)
+
+            // 计算该角度下的点的经纬度
+            double newLat = centerLat + ToDegrees(offsetLat * Math.Cos(angle));
+            double newLon = centerLon + ToDegrees(offsetLon * Math.Sin(angle));
+
+            // 按经度在前,纬度在后顺序存储
+            points.Add(newLon);
+            points.Add(newLat);
+        }
+
+        return points;
+    }
+
+    // 弧度转换为角度
+    static double ToDegrees(double radians)
+    {
+        return radians * 180.0 / Math.PI;
+    }
+
+    // 角度转换为弧度
+    static double ToRadians(double degrees)
+    {
+        return degrees * Math.PI / 180.0;
+    }
+
+    //private double GetDistance(double lon1, double lon2, double lat1, double lat2)
+    //{
+    //    double R = 6371; // 地球的半径(公里)
+    //    double dLat = (lat2 - lat1) * Math.PI / 180.0;
+    //    double dLon = (lon2 - lon1) * Math.PI / 180.0;
+    //    double a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) +
+    //               Math.Cos(lat1 * Math.PI / 180.0) * Math.Cos(lat2 * Math.PI / 180.0) *
+    //               Math.Sin(dLon / 2) * Math.Sin(dLon / 2);
+    //    double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
+    //    double distance = R * c;
+
+    //    return distance;
+    //}
+
+    public override void Update(double time)
+    {
+
+    }
+}
+
+
+[ObjectSystem]
+public class AircraftZSAwakeSystem : AwakeSystem<AircraftZS, FlightPlanEditor>
+{
+    public override void Awake(AircraftZS self, FlightPlanEditor flightPlanEditor)
+    {
+        self.FlightPlanEditor = flightPlanEditor;
+        self.Awake();
+        self.Reset();
+    }
+}

+ 1 - 1
SimulationServer/bin/Debug/net7.0/Missions/editor_config.json

@@ -1,5 +1,5 @@
 {
-    "仿真次数": 1,
+    "仿真次数": 10,
     "想定信息": {
         "想定日期": "2024年4月10日",
         "想定时间": "00时00分00秒"

BIN
SimulationServer/bin/Debug/net7.0/Reports/SSJ/2024-09-11/海上搜救任务总体指标报告.xls


BIN
SimulationServer/bin/Debug/net7.0/Reports/SSJ/2024-09-11/海上搜索救援任务 海上搜救任务1/3-1搜救任务单机指标报告.xls


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


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


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