123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- using KYFramework;
- using MathNet.Numerics.Distributions;
- using Model;
- using MongoDB.Bson;
- using SimulationCommon;
- using SimulationServer.Utils;
- namespace SimulationServer;
- public class AircraftYLWPYS : AircraftEntity
- {
- public YLWPYSTask taskContent;
- public MissionEndPoint MissionEndPoint;
- public bool IsOver;
- public bool Success;
- public TaskParameter taskParameter;
- public GetNCData getNCData;
- public double resulttime;
- 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;
- }
- public override void Start()
- {
- if (!isReadNC)
- {
- getNCData = new GetNCData();
- getNCData.initlatitudes = FlightPlanEditor.medicalSuppliesInfo[0].TargetPointLatitude;
- getNCData.initlongitudes = FlightPlanEditor.medicalSuppliesInfo[0].TargetPointLongitude;
- bool isSuccess3 = false;
- while (!isSuccess3)
- {
- isSuccess3 = getNCData.GetData();
- }
- text_ReadNC = new Text_readNC();
- text_ReadNC.initlatitudes = FlightPlanEditor.medicalSuppliesInfo[0].TargetPointLatitude;
- text_ReadNC.initlongitudes = FlightPlanEditor.medicalSuppliesInfo[0].TargetPointLongitude;
- bool isSuccess = false;
- while (!isSuccess)
- {
- isSuccess = text_ReadNC.GetNCData();
- }
- isReadNC = true;
- }
- int hour = Convert.ToInt32(taskContent.missionInformation.StartTime.Split("时")[0]);
- int Day = Convert.ToInt32(taskContent.missionInformation.StartDate.Split("年")[1].Split("月")[1].Split("日")[0]);
- ////Console.WriteLine("hour:" + hour);
- //double windSpeed = Convert.ToDouble(TargetQiXiangInfoSave("风速", hour));
- ////Console.WriteLine("windSpeed:" + windSpeed);
- //double vis = Convert.ToDouble(TargetQiXiangInfoSave("能见度", hour));
- ////Console.WriteLine("vis:" + vis);
- FlightPlanEditor.missionpoint.MissionPointLatitude = FlightPlanEditor.medicalSuppliesInfo[0].TargetPointLatitude;
- FlightPlanEditor.missionpoint.MissionPointLongitude = FlightPlanEditor.medicalSuppliesInfo[0].TargetPointLongitude;
- FlightPlanEditor.missionpoint.MissionPointHeight = FlightPlanEditor.medicalSuppliesInfo[0].TargetPointHeight;
- Console.WriteLine("Latitude:" + FlightPlanEditor.missionpoint.MissionPointLatitude + "_" + "Longitude:" + FlightPlanEditor.missionpoint.MissionPointLongitude + "_" + "Height:" + FlightPlanEditor.missionpoint.MissionPointHeight);
- FXJHGenerate.FromStartToMission(FlightPlanEditor, ref TurningPoints);//生成从起点到任务段起点的航路点
- //// 吊运上升速度 吊运下降速度 Task文件读取 // Editor里读天气根据时间
- //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; // 判断幸存-1
- }
- //Console.WriteLine("time:" + time);
- for (int i = 0; i < TurningPoints.Count; i++) // 总飞行时间
- {
- TotalTime += TurningPoints[i].SegmentFlightTime; // 总时间 //仿真轮次1 数值1
- }
- 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;
- for (int i = 0; i < FlightPlanEditor.medicalTargetPoint[0].TargetQiXiangInfos.Length; i++)
- {
- }
- switch (s)
- {
- case "温度":
- break;
- case "湿度":
- break;
- case "能见度":
- break;
- case "风速":
- break;
- case "风向":
- break;
- case "天气":
- 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);
- }
- }
- [ObjectSystem]
- public class AircraftYLWPYSAwakeSystem : AwakeSystem<AircraftYLWPYS, FlightPlanEditor>
- {
- public override void Awake(AircraftYLWPYS self, FlightPlanEditor flightPlanEditor)
- {
- self.FlightPlanEditor = flightPlanEditor;
- self.Awake();
- }
- }
|