123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- using KYFramework;
- using Model;
- using MongoDB.Bson;
- using SimulationCommon;
- namespace SimulationServer;
- public class AircraftDY : AircraftEntity
- {
- public TaskParameter SHJParameter;
- public KZDYTask taskContent;
- public MissionEndPoint MissionEndPoint;
- public bool IsOver;
- public bool Success;
- public TaskParameter taskParameter;
- public GetNCData getNCData;
- public double resulttime;
- public int targetCount;
- public bool isReadNC;
- Text_readNC text_ReadNC;
- public override void End()
- {
- TotalFuelConsumption = TurningPoints[0].RemainingFuel - TurningPoints[^1].RemainingFuel;
- }
- public override void Reset()
- {
- base.Reset();
- IsOver = false;
- Success = false;
- TotalTime = 0;
- targetCount = 0;
- }
- public override void Start()
- {
- targetCount = FlightPlanEditor.targetpoint[0].TargetType.Count;
- if (!isReadNC)
- {
- getNCData = new GetNCData();
- getNCData.initlatitudes = FlightPlanEditor.targetpoint[0].TargetPointLatitude;
- getNCData.initlongitudes = FlightPlanEditor.targetpoint[0].TargetPointLongitude;
- bool isSuccess3 = false;
- while (!isSuccess3)
- {
- isSuccess3 = getNCData.GetData();
- }
- text_ReadNC = new Text_readNC();
- text_ReadNC.initlatitudes = FlightPlanEditor.targetpoint[0].TargetPointLatitude;
- text_ReadNC.initlongitudes = FlightPlanEditor.targetpoint[0].TargetPointLongitude;
-
- bool isSuccess = false;
- while (!isSuccess)
- {
- isSuccess = text_ReadNC.GetNCData();
- }
- isReadNC = true;
- }
- int hour = Convert.ToInt32(taskContent.missionInformation.StartTime.Split("时")[0]);
-
- double windSpeed = Convert.ToDouble(TargetQiXiangInfoSave("风速", hour));
-
- double vis = Convert.ToDouble(TargetQiXiangInfoSave("能见度", hour));
-
- FlightPlanEditor.missionpoint.MissionPointLatitude = FlightPlanEditor.targetpoint[0].TargetPointLatitude;
- FlightPlanEditor.missionpoint.MissionPointLongitude = FlightPlanEditor.targetpoint[0].TargetPointLongitude;
- FlightPlanEditor.missionpoint.MissionPointHeight = FlightPlanEditor.targetpoint[0].TargetPointHeight;
-
- FXJHGenerate.FromStartToMission(FlightPlanEditor, ref TurningPoints);
-
- resulttime = get_result_time_rope(taskParameter.Height, taskParameter.liftPersonnel, windSpeed, vis, taskParameter.liftUpSpeed, taskParameter.liftDownSpeed).time;
- Console.WriteLine("resulttime:" + resulttime);
- FXJHGenerate.SuoHuaJiang(resulttime, FlightPlanEditor, ref TurningPoints);
- FXJHGenerate.FromMissionToEnd(FlightPlanEditor, FXJHGenerate.SuoHuaJiangMissionEndPoint(FlightPlanEditor), ref TurningPoints);
- FXJHGenerate.FXJHTPDiedai(FlightPlanEditor, ref TurningPoints, Velocitys, FuelConsumptions);
-
- double time = 0;
- for (int i = 0; i < TurningPoints.Count - 1; i++)
- {
- time += TurningPoints[i].SegmentFlightTime;
- }
-
-
- 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);
-
- if (survivalTime * 3600 > time)
- {
- Success = true;
-
- }
- }
- if (FlightPlanEditor.targetpoint[0].TargetType.Type == "遇险人员")
- {
- if (FlightPlanEditor.targetpoint[0].TargetType.LiveTime > time)
- {
- Success = true;
-
- }
- }
- for (int i = 0; i < TurningPoints.Count; i++)
- {
- TotalTime += TurningPoints[i].SegmentFlightTime;
- }
- Console.WriteLine("TotalTime:" + TotalTime);
- IsOver = true;
- End();
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public static handling_result get_result_time_rope(double H, int person_number, double windspeed, double vis, double upspeed, double downspeed)
- {
- handling_result result = new handling_result();
- if (windspeed < 8 && vis > 3)
- {
- result.time = (person_number * H) / downspeed + (person_number * H) / upspeed;
- result.success = true;
- }
- else
- {
- result.success = false;
- }
- return result;
- }
- public string TargetQiXiangInfoSave(string s, int hour)
- {
- string result = hour.ToString() + "-" + s;
- switch (s)
- {
- case "温度":
- if (hour >= 0 && hour < 8)
- result = FlightPlanEditor.targetpoint[0].TargetQiXiangInfo.Temperature_00_08.ToString();
- else if (hour >= 8 && hour < 19)
- result = FlightPlanEditor.targetpoint[0].TargetQiXiangInfo.Temperature_08_19.ToString();
- else if (hour >= 19 && hour <= 24)
- result = FlightPlanEditor.targetpoint[0].TargetQiXiangInfo.Temperature_19_24.ToString();
- break;
- case "湿度":
- if (hour >= 0 && hour < 8)
- result = FlightPlanEditor.targetpoint[0].TargetQiXiangInfo.Humidity_00_08.ToString();
- else if (hour >= 8 && hour < 19)
- result = FlightPlanEditor.targetpoint[0].TargetQiXiangInfo.Humidity_08_19.ToString();
- else if (hour >= 19 && hour <= 24)
- result = FlightPlanEditor.targetpoint[0].TargetQiXiangInfo.Humidity_19_24.ToString();
- break;
- case "能见度":
- if (hour >= 0 && hour < 8)
- result = FlightPlanEditor.targetpoint[0].TargetQiXiangInfo.Visibility_00_08.ToString();
- else if (hour >= 8 && hour < 19)
- result = FlightPlanEditor.targetpoint[0].TargetQiXiangInfo.Visibility_08_19.ToString();
- else if (hour >= 19 && hour <= 24)
- result = FlightPlanEditor.targetpoint[0].TargetQiXiangInfo.Visibility_19_24.ToString();
- break;
- case "风速":
- if (hour >= 0 && hour < 8)
- result = FlightPlanEditor.targetpoint[0].TargetQiXiangInfo.WindSpeed_00_08.ToString();
- else if (hour >= 8 && hour < 19)
- result = FlightPlanEditor.targetpoint[0].TargetQiXiangInfo.WindSpeed_08_19.ToString();
- else if (hour >= 19 && hour <= 24)
- result = FlightPlanEditor.targetpoint[0].TargetQiXiangInfo.WindSpeed_19_24.ToString();
- break;
- case "风向":
- if (hour >= 0 && hour < 8)
- result = FlightPlanEditor.targetpoint[0].TargetQiXiangInfo.WindDirection_00_08.ToString();
- else if (hour >= 8 && hour < 19)
- result = FlightPlanEditor.targetpoint[0].TargetQiXiangInfo.WindDirection_08_19.ToString();
- else if (hour >= 19 && hour <= 24)
- result = FlightPlanEditor.targetpoint[0].TargetQiXiangInfo.WindDirection_19_24.ToString();
- break;
- case "天气":
- if (hour >= 0 && hour < 8)
- result = FlightPlanEditor.targetpoint[0].TargetQiXiangInfo.Weather_00_08;
- else if (hour >= 8 && hour < 19)
- result = FlightPlanEditor.targetpoint[0].TargetQiXiangInfo.Weather_08_19;
- else if (hour >= 19 && hour <= 24)
- result = FlightPlanEditor.targetpoint[0].TargetQiXiangInfo.Weather_19_24;
- break;
- }
- 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 class handling_result
- {
- public bool success { get; set; }
- public double time { get; set; }
- }
- [ObjectSystem]
- public class AircraftDYAwakeSystem : AwakeSystem<AircraftDY, FlightPlanEditor>
- {
- public override void Awake(AircraftDY self, FlightPlanEditor flightPlanEditor)
- {
- self.FlightPlanEditor = flightPlanEditor;
- self.Awake();
- }
- }
|