Browse Source

修改吊运和陆上搜寻飞机脚本

liyang 6 months ago
parent
commit
9bf5325028

+ 6 - 6
Models/SimulationCommon/EquationHelper.cs

@@ -449,8 +449,8 @@ namespace MuShiApp
                     m_Args = new List<string> { "centerLon", "centerLat", "visibility_date" }
                 };
                 string response = m_HttpHelper.Request(cmd, new List<string> { centerLon.ToString(), centerLat.ToString(), visibility_date });
-                Console.WriteLine(" centerLon:" + centerLon + " " + "centerLat:" + centerLat + " " + "visibility_date:" + visibility_date);
-                Console.WriteLine("response:" + response);
+                //Console.WriteLine(" centerLon:" + centerLon + " " + "centerLat:" + centerLat + " " + "visibility_date:" + visibility_date);
+                //Console.WriteLine("response:" + response);
                 R data = JsonConvert.DeserializeObject<R>(response);
                 if (data != null && data.code == 200)
                 {
@@ -459,17 +459,17 @@ namespace MuShiApp
                     if (fl.Equals(0))
                     {
                         fl = 15;
-                        Console.WriteLine("1:" + fl);
+                        //Console.WriteLine("1:" + fl);
                     }
-                    Console.WriteLine("2:" + fl);
+                    //Console.WriteLine("2:" + fl);
                     return fl;
                 }
-                Console.WriteLine("3:" + 15);
+                //Console.WriteLine("3:" + 15);
                 return 15;
             }
             catch (Exception ex)
             {
-                Console.WriteLine("4:" + 15);
+                //Console.WriteLine("4:" + 15);
                 Debug.Print("error!!!!!getVisibility");
                 Debug.Print(ex.ToString());
                 return 15;

+ 35 - 38
SimulationServer/Entity/AircraftDY.cs

@@ -66,51 +66,48 @@ public class AircraftDY : AircraftEntity
         {
             time += TurningPoints[i].SegmentFlightTime; // 总时间  // 判断幸存-1
         }
-        isSea = true;
-        //isLand = true;
-        if (isSea)
+        //Console.WriteLine("time:" + time);
+
+        // 类型只有人,其它不影响任务成功率 ,所有目标都影响识别成功率  任务准备时间 分钟 平均搜索时间 小时 平均救助时间 秒 总飞行时间 小时 第一列加单位
+
+        if (FlightPlanEditor.targetpoint[0].TargetType.Type == "落水人员")
         {
-            if (FlightPlanEditor.targetpoint[0].TargetType.Type == "落水人员")
+            double latitude = FlightPlanEditor.targetpoint[0].TargetPointLatitude; //落水人员纬度;数据测试用
+            double longitude = FlightPlanEditor.targetpoint[0].TargetPointLongitude; //落水人员经度,数据测试用
+            int Days;
+            int Hour;
+            int Year = Convert.ToInt32(taskContent.missionInformation.StartDate.Split("年")[0]);
+            int Month = Convert.ToInt32(taskContent.missionInformation.StartDate.Split("年")[1].Split("月")[0]);
+            int Day = Convert.ToInt32(taskContent.missionInformation.StartDate.Split("年")[1].Split("月")[1].Split("日")[0]);
+            Hour = Convert.ToInt32(taskContent.missionInformation.StartTime.Split("时")[0]);
+            Days = GetDaysInYear(Year, Month, Day);
+            double survivalTime = SurvivalTimeModel.SurvivalTime(getNCData.tempreadNC, latitude, longitude, time, text_ReadNC.times, text_ReadNC.latitudes, text_ReadNC.longitudes, Days, Hour); //幸存时间
+            //Console.WriteLine("survivalTime:" + survivalTime * 3600);
+            if (survivalTime * 3600 > time)
             {
-                double latitude = FlightPlanEditor.targetpoint[0].TargetPointLatitude; //落水人员纬度;数据测试用
-                double longitude = FlightPlanEditor.targetpoint[0].TargetPointLongitude; //落水人员经度,数据测试用
-                int Days;
-                int Hour;
-                int Year = Convert.ToInt32(taskContent.missionInformation.StartDate.Split("年")[0]);
-                int Month = Convert.ToInt32(taskContent.missionInformation.StartDate.Split("年")[1].Split("月")[0]);
-                int Day = Convert.ToInt32(taskContent.missionInformation.StartDate.Split("年")[1].Split("月")[1].Split("日")[0]);
-                Hour = Convert.ToInt32(taskContent.missionInformation.StartTime.Split("时")[0]);
-                Days = GetDaysInYear(Year, Month, Day);
-                double survivalTime = SurvivalTimeModel.SurvivalTime(getNCData.tempreadNC, latitude, longitude, time, text_ReadNC.times, text_ReadNC.latitudes, text_ReadNC.longitudes, Days, Hour); //幸存时间
-                Console.WriteLine("survivalTime:" + survivalTime);
-                if (survivalTime * 3600 > time)
-                {
-                    Success = true;
-                }
-                else
-                {
-                    Success = false;
-                }
+                Success = true;
+                //Console.WriteLine("Success:" + true);
             }
-        }else if(isLand)  //陆上搜寻预期存活时间读配置文件
-        {
-            if (FlightPlanEditor.targetpoint[0].TargetType.Type == "遇险人员")
+            else
             {
-                //Console.WriteLine("time:" + time);
-                if (FlightPlanEditor.targetpoint[0].TargetType.LiveTime > time)
-                {
-                    Success = true;
-                    //Console.WriteLine("Success:" + true);
-                }
-                else
-                {
-                    Success = false;
-                    //Console.WriteLine("Success:" + false);
-                }
+                Success = false;
+                //Console.WriteLine("Success:" + false);
             }
         }
 
-        // 类型只有人,其它不影响任务成功率 ,所有目标都影响识别成功率  任务准备时间 分钟 平均搜索时间 小时 平均救助时间 秒 总飞行时间 小时 第一列加单位
+        if (FlightPlanEditor.targetpoint[0].TargetType.Type == "遇险人员")
+        {
+            if (FlightPlanEditor.targetpoint[0].TargetType.LiveTime > time)   //陆上搜寻预期存活时间读配置文件
+            {
+                Success = true;
+                //Console.WriteLine("Success:" + true);
+            }
+            else
+            {
+                Success = false;
+                //Console.WriteLine("Success:" + false);
+            }
+        }
 
         for (int i = 0; i < TurningPoints.Count; i++) // 总飞行时间
         {

+ 74 - 4
SimulationServer/Entity/AircraftLandSJ.cs

@@ -27,6 +27,9 @@ public class AircraftLandSJ : AircraftEntity
     public SearchMissionPayload searchMissionPayload;
 
     public double resulttime;
+
+    int Days;
+    int Hour;
     public override void Reset()
     {
         base.Reset();
@@ -39,6 +42,12 @@ public class AircraftLandSJ : AircraftEntity
 
     public override void Start()
     {
+        int Year = Convert.ToInt32(taskContent.missionInformation.StartDate.Split("年")[0]);
+        int Month = Convert.ToInt32(taskContent.missionInformation.StartDate.Split("年")[1].Split("月")[0]);
+        int Day = Convert.ToInt32(taskContent.missionInformation.StartDate.Split("年")[1].Split("月")[1].Split("日")[0]);
+        Hour = Convert.ToInt32(taskContent.missionInformation.StartTime.Split("时")[0]);
+        Days = GetDaysInYear(Year, Month, Day);
+
         Velocitys = new double[5] { 220, 220, 60, 110, 0 }; // 速度
 
 
@@ -137,10 +146,10 @@ public class AircraftLandSJ : AircraftEntity
         //Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH"));
         var visibility = helper.getVisibilityByDb(targetPoint.x, targetPoint.y, date); //DateTime.Now.ToString("yyyy-MM-dd HH")
 
-        getNCData = new GetNCData();
-        getNCData.initlatitudes = FlightPlanEditor.targetpoint[0].TargetPointLatitude;
-        getNCData.initlongitudes = FlightPlanEditor.targetpoint[0].TargetPointLongitude;
-        getNCData.GetData();
+        //getNCData = new GetNCData();
+        //getNCData.initlatitudes = FlightPlanEditor.targetpoint[0].TargetPointLatitude;
+        //getNCData.initlongitudes = FlightPlanEditor.targetpoint[0].TargetPointLongitude;
+        //getNCData.GetData();
         Task.Run(() =>
         {
             bool isseePerson = false;
@@ -236,6 +245,48 @@ public class AircraftLandSJ : AircraftEntity
                 }
             } while (!isseePerson && IsOver == false);
 
+            if (isseePerson)
+            {
+
+                Text_readNC text_ReadNC = new Text_readNC();
+                text_ReadNC.initlatitudes = FlightPlanEditor.targetpoint[0].TargetPointLatitude;
+                text_ReadNC.initlongitudes = FlightPlanEditor.targetpoint[0].TargetPointLongitude;
+                //text_ReadNC = new Text_readNC();
+                text_ReadNC.GetNCData();
+                var nCread = text_ReadNC.windNCread;
+                var wind = SeaSJ.GetWindVelocityFromAPI(nCread, currentLocation.CurrentLat, currentLocation.CurrentLon,
+            temptime, text_ReadNC.times, text_ReadNC.latitudes, text_ReadNC.longitudes, text_ReadNC.times1, text_ReadNC.latitudes1, text_ReadNC.longitudes1, Days, Hour);
+
+
+                double windSpeed = Math.Sqrt(wind[0] * wind[0] + wind[1] * wind[1]);
+
+                for (int i = 0; i < TurningPoints.Count - 1; i++) // 总飞行时间
+                {
+                    TotalTime += TurningPoints[i].SegmentFlightTime; // 总时间
+                }
+
+                double time = TotalTime; //time——搜索时间,单位:秒;数据测试用
+
+                double latitude = FlightPlanEditor.targetpoint[0].TargetPointLatitude; //落水人员纬度;数据测试用
+                double longitude = FlightPlanEditor.targetpoint[0].TargetPointLongitude; //落水人员经度,数据测试用
+
+                double survivalTime = FlightPlanEditor.targetpoint[0].TargetType.LiveTime;//幸存时间
+                //  SHJParameter.person_number = Eidtor里读取   SHJParameter.windspeed Nc/Editor目标气象信息读取时间先取任务初始时间
+                resulttime = get_result_time_rope(30, FlightPlanEditor.targetpoint[0].TargetType.Count, windSpeed, visibility, 0.75, 1.38).time; //调运时间
+                Console.WriteLine("resulttime:" + resulttime);
+                //Console.WriteLine("survivalTime:" + survivalTime);
+                if (survivalTime * 3600 > time)
+                {
+                    Success = true;
+                }
+                else
+                {
+                    Success = false;
+                }
+                Log.Info("TotalTime:" + TotalTime);
+                Log.Info("幸存时间:" + survivalTime);
+            }
+
             //Console.WriteLine(
             //    $"海上任务1:{taskContent.missionInformation.MissionName} 机型: {AircraftId} 当前时间:{temptime},当前位置:{currentLocation.CurrentLon},{currentLocation.CurrentLat},{currentLocation.CurrentHei},概率:{probability},最终概率:{1 - finalProbability},是否看到落水人员:{isseePerson}");
             Log.Info(
@@ -284,6 +335,25 @@ public class AircraftLandSJ : AircraftEntity
         return result;
     }
 
+    public static int GetDaysInYear(int year, int month, int day)
+    {
+        int[] daysInMonths = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+        if (IsLeapYear(year))
+        {
+            daysInMonths[1] = 29;
+        }
+        int days = day;
+        for (int i = 0; i < month - 1; i++)
+        {
+            days += daysInMonths[i];
+        }
+        return days;
+    }
+
+    public static bool IsLeapYear(int year)
+    {
+        return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
+    }
 
     public override void End()
     {