AircraftSJ.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. using KYFramework;
  2. using Model;
  3. using MongoDB.Bson;
  4. using MuShiApp;
  5. using Org.BouncyCastle.Asn1.Pkcs;
  6. using SimulationCommon;
  7. using SimulationSingleServer.Utils;
  8. using System.Threading;
  9. using Unity.Mathematics;
  10. using Point = SimulationCommon.Point;
  11. using Random = System.Random;
  12. namespace SimulationServer;
  13. public class AircraftSJ : AircraftEntity
  14. {
  15. public bool IsOver;
  16. private MissionEndPoint MissionEndPoint;
  17. private CurrentLocation currentLocation;
  18. private double temptime = 0;
  19. private double probability = 0;
  20. private double finalProbability = 1.0;
  21. public bool isseePerson = false;
  22. private int fireIndex = -1; // 记录发现火点的位置
  23. public EquationHelper helper;
  24. public SeaSouJiuTask taskContent;
  25. public bool Success = false; //本目标搜救是否成功
  26. public GetNCData getNCData;
  27. public double resulttime;
  28. public SearchMissionPayload searchMissionPayload;
  29. //private bool isbool;
  30. //private bool isbool2;
  31. //Text_readNC text_ReadNC;
  32. public SearchMissionMode SearchMode;
  33. int Days;
  34. int Hour;
  35. public int targetCount;
  36. public bool isEndWhile;
  37. public int sbCount;
  38. public double seaArea;
  39. public bool isReadNC;
  40. Text_readNC text_ReadNC;
  41. public override void Reset()
  42. {
  43. base.Reset();
  44. IsOver = false;
  45. isseePerson = false;
  46. Success = false;
  47. SearchTime = 0;
  48. TotalTime = 0;
  49. resulttime = 0;
  50. isEndWhile = false;
  51. targetCount = 0;
  52. sbCount = 0;
  53. seaArea = 0;
  54. }
  55. public override void Start()
  56. {
  57. if (FlightPlanEditor.targetpoint[0].TargetType.Type == "落水人员")
  58. {
  59. targetCount = FlightPlanEditor.targetpoint[0].TargetType.Count;
  60. sbCount = targetCount;
  61. }
  62. else
  63. sbCount = 1;
  64. int Year = Convert.ToInt32(taskContent.missionInformation.StartDate.Split("年")[0]);
  65. int Month = Convert.ToInt32(taskContent.missionInformation.StartDate.Split("年")[1].Split("月")[0]);
  66. int Day = Convert.ToInt32(taskContent.missionInformation.StartDate.Split("年")[1].Split("月")[1].Split("日")[0]);
  67. Hour = Convert.ToInt32(taskContent.missionInformation.StartTime.Split("时")[0]);
  68. Days = GetDaysInYear(Year, Month, Day);
  69. //Console.WriteLine("Day:" + Days);
  70. Velocitys = new double[5] { 220, 220, 60, 110, 0 }; // 速度
  71. //TODO 计算 AirRoute[]
  72. double[] initialPosition =
  73. {
  74. FlightPlanEditor.targetpoint[0].TargetPointLatitude, FlightPlanEditor.targetpoint[0].TargetPointLongitude
  75. };
  76. double dt = 1;
  77. double totalTime = 24.0;
  78. if (!isReadNC)
  79. {
  80. //if (!isbool2)
  81. //{
  82. text_ReadNC = new Text_readNC();
  83. text_ReadNC.initlatitudes = FlightPlanEditor.targetpoint[0].TargetPointLatitude;
  84. text_ReadNC.initlongitudes = FlightPlanEditor.targetpoint[0].TargetPointLongitude;
  85. //text_ReadNC = new Text_readNC();
  86. bool isSuccess = false;
  87. while(!isSuccess)
  88. {
  89. isSuccess = text_ReadNC.GetNCData();
  90. }
  91. bool isSuccess2 = false;
  92. while (!isSuccess2)
  93. {
  94. isSuccess2 = text_ReadNC.GetWaveHighData();
  95. }
  96. //isbool2 = true;
  97. //}
  98. getNCData = new GetNCData();
  99. getNCData.initlatitudes = FlightPlanEditor.targetpoint[0].TargetPointLatitude;
  100. getNCData.initlongitudes = FlightPlanEditor.targetpoint[0].TargetPointLongitude;
  101. bool isSuccess3 = false;
  102. while(!isSuccess3)
  103. {
  104. isSuccess3 = getNCData.GetData();
  105. }
  106. isReadNC = true;
  107. }
  108. var nCread = text_ReadNC.windNCread;
  109. //漂移轨迹
  110. List<double[]> trajectory = SeaSJ.CalculateDriftTrajectory(nCread, initialPosition, dt, totalTime, text_ReadNC.times, text_ReadNC.latitudes, text_ReadNC.longitudes, text_ReadNC.times1, text_ReadNC.latitudes1, text_ReadNC.longitudes1, text_ReadNC.times2, text_ReadNC.latitudes2, text_ReadNC.longitudes2, text_ReadNC.times3, text_ReadNC.latitudes3, text_ReadNC.longitudes3, Days, Hour, text_ReadNC.initlatitudes, text_ReadNC.initlongitudes);
  111. //foreach ( var trajectoryItem in trajectory)
  112. //{
  113. // Console.WriteLine("trajectory:" + trajectoryItem[0] + "_" + trajectoryItem[1]);
  114. //}
  115. // 生成任务终点
  116. MissionEndPoint = new MissionEndPoint
  117. {
  118. MissionEndPointLongitude = trajectory[^1][1],
  119. MissionEndPointLatitude = trajectory[^1][0],
  120. MissionEndPointHeight = 0
  121. };
  122. var temp = SeaSJ.getminEnclosingRect(trajectory); //
  123. seaArea = Rectangular_Area_Search_Function.min_area;
  124. // temp 转成 List<Point>
  125. List<Point> points = new List<Point>();
  126. foreach (var item in temp)
  127. {
  128. points.Add(new Point(item[0], item[1]));
  129. }
  130. //foreach (var item in points)
  131. //{
  132. // Console.WriteLine("item:" + item.lat + "-" + item.lon);
  133. //}
  134. Point basePoint = new Point(FlightPlanEditor.originbase.BaseLatitude,
  135. FlightPlanEditor.originbase.BaseLongitude);
  136. List<Point> waypoints = new List<Point>();
  137. //*******
  138. if (SearchMode.SearchMode == "平行线搜索")
  139. {
  140. waypoints = ParallellineSearch.parallellineSearch(basePoint, points, SearchMode.SearchWidth);
  141. }
  142. if (SearchMode.SearchMode == "扇形搜索")
  143. {
  144. // 求 points 的中心点
  145. var startPoint1 = new Point
  146. {
  147. lat = points[0].lat / 2 + points[1].lat / 2,
  148. lon = points[0].lon / 2 + points[1].lon / 2
  149. };
  150. var startPoint2 = new Point
  151. {
  152. lat = points[2].lat / 2 + points[3].lat / 2,
  153. lon = points[2].lon / 2 + points[3].lon / 2
  154. };
  155. var centerPoint = new Point
  156. {
  157. lat = startPoint1.lat / 2 + startPoint2.lat / 2,
  158. lon = startPoint1.lon / 2 + startPoint2.lon / 2
  159. };
  160. waypoints = SectorSearch.sectorSearch(centerPoint, 30, SearchMode.SearchWidth);
  161. }
  162. if (SearchMode.SearchMode == "扩展矩形搜索")
  163. {
  164. // 求 points 的中心点
  165. var startPoint1 = new Point
  166. {
  167. lat = points[0].lat / 2 + points[1].lat / 2,
  168. lon = points[0].lon / 2 + points[1].lon / 2
  169. };
  170. //Console.WriteLine("startPoint1:" + startPoint1.lat + "-" + startPoint1.lon);
  171. var startPoint2 = new Point
  172. {
  173. lat = points[2].lat / 2 + points[3].lat / 2,
  174. lon = points[2].lon / 2 + points[3].lon / 2
  175. };
  176. //Console.WriteLine("startPoint2:" + startPoint2.lat + "-" + startPoint2.lon);
  177. var centerPoint = new Point
  178. {
  179. lat = startPoint1.lat / 2 + startPoint2.lat / 2,
  180. lon = startPoint1.lon / 2 + startPoint2.lon / 2
  181. };
  182. //Console.WriteLine("centerPoint:" + centerPoint.lat + "-" + centerPoint.lon);
  183. // 以 centerPoint 为中心,生成正方形区域
  184. var lonD = Math.Abs(points[0].lon - points[1].lon);
  185. var latD1 = Math.Abs(points[1].lat - points[2].lat);
  186. var max = Math.Max(lonD, latD1);
  187. //Console.WriteLine("max:" + max);
  188. // 以 distance 为边长 以 centerPoint 为中心点的正方形
  189. var temp0 = new Point(centerPoint.lat + max / 2, centerPoint.lon - max / 2);
  190. var temp1 = new Point(centerPoint.lat + max / 2, centerPoint.lon + max / 2);
  191. var temp2 = new Point(centerPoint.lat - max / 2, centerPoint.lon + max / 2);
  192. var temp3 = new Point(centerPoint.lat - max / 2, centerPoint.lon - max / 2);
  193. //Console.WriteLine("temp0:" + temp0.lat + "-" + temp0.lon);
  194. //Console.WriteLine("temp1:" + temp1.lat + "-" + temp1.lon);
  195. //Console.WriteLine("temp2:" + temp2.lat + "-" + temp2.lon);
  196. //Console.WriteLine("temp3:" + temp3.lat + "-" + temp3.lon);
  197. //Console.WriteLine("SearchWidth:" + SearchMode.SearchWidth);
  198. waypoints = TZFX.GenerateWaypoints(temp0, temp1, temp2, temp3, max, SearchMode.SearchWidth);
  199. }
  200. //foreach (var item in waypoints)
  201. //{
  202. // Console.WriteLine("item.lat :" + item.lat + "-" + "item.lon:" + item.lon);
  203. //}
  204. // List<Point> 转成 List<AirRoute>
  205. List<AirRoute> airRoutes = new List<AirRoute>();
  206. foreach (var item in waypoints)
  207. {
  208. airRoutes.Add(new AirRoute
  209. {
  210. AirRouteLatitude = item.lat,
  211. AirRouteLongitude = item.lon
  212. });
  213. }
  214. FlightPlanEditor.airroute = airRoutes.ToArray();
  215. MissionPoint missionPoint = new MissionPoint();
  216. missionPoint.MissionPointLatitude = waypoints[0].lat;
  217. missionPoint.MissionPointLongitude = waypoints[0].lon;
  218. FlightPlanEditor.missionpoint = missionPoint;
  219. FXJHGenerate.FromStartToMission(FlightPlanEditor, ref TurningPoints); //生成从起点到任务段起点的航路点
  220. FXJHGenerate.SeaSouJiu(FlightPlanEditor, ref TurningPoints);
  221. FXJHGenerate.FXJHTPDiedai(FlightPlanEditor, ref TurningPoints, Velocitys, FuelConsumptions);
  222. //foreach (var item in TurningPoints)
  223. //{
  224. // Console.WriteLine("TurningPointLatitude:" + item.TurningPointLatitude + "_" + "TurningPointLongitude:" + item.TurningPointLongitude);
  225. //}
  226. double time = 0; // 第一次 搜寻结束
  227. for (int i = 0; i < TurningPoints.Count - 2; i++)
  228. {
  229. time += TurningPoints[i].SegmentFlightTime;
  230. }
  231. double3 targetPoint = new double3(FlightPlanEditor.targetpoint[0].TargetPointLongitude,
  232. FlightPlanEditor.targetpoint[0].TargetPointLatitude,
  233. FlightPlanEditor.targetpoint[0].TargetPointHeight);
  234. string cityName = helper.getCityName(targetPoint.x, targetPoint.y);
  235. //var vis = helper.getVisibility(cityName, DateTime.Now.ToString("yyyy-MM-dd HH"));
  236. string year = taskContent.missionInformation.StartDate.Split("年")[0];
  237. string month = taskContent.missionInformation.StartDate.Split("年")[1].Split("月")[0];
  238. if (Convert.ToInt32(month) < 10) month = "0" + month;
  239. string day = taskContent.missionInformation.StartDate.Split("年")[1].Split("月")[1].Split("日")[0];
  240. if (Convert.ToInt32(day) < 10) day = "0" + day;
  241. //string hour = taskContent.missionInformation.StartTime.Split("时")[0];
  242. string date = year + "-" + month + "-" + day;// + " " + hour;
  243. //Console.Write(date);
  244. //Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH"));
  245. var vis = helper.getVisibilityByDb(targetPoint.x, targetPoint.y, date); //DateTime.Now.ToString("yyyy-MM-dd HH")
  246. //if (!isbool)
  247. //{
  248. //getNCData = new GetNCData();
  249. //getNCData.initlatitudes = FlightPlanEditor.targetpoint[0].TargetPointLatitude;
  250. //getNCData.initlongitudes = FlightPlanEditor.targetpoint[0].TargetPointLongitude;
  251. //getNCData.GetData();
  252. //isbool = true;
  253. //}
  254. Task.Run(() =>
  255. {
  256. bool isseePerson = false; // 输出表格平均救助时间没看到人是0看到人调用下面get_result_time_rope方法 //人员存活率需要重新算读取Editor搜救目标点初始坐标人数 //任务准备时间取值所有任务最小
  257. double temptime = 0; // 自增时间,每次增加1s
  258. CurrentLocation currentLocation = new CurrentLocation();
  259. double probability = 0;
  260. double finalProbability = 1.0;
  261. Random random = new Random();
  262. int fireIndex = -1; // 记录发现火点的位置
  263. double windSpeed = 0;
  264. do
  265. {
  266. if (!isseePerson && temptime >= time)
  267. {
  268. FXJHGenerate.SeaSouJiu(FlightPlanEditor, ref TurningPoints);
  269. FXJHGenerate.FXJHTPDiedai(FlightPlanEditor, ref TurningPoints, Velocitys, FuelConsumptions);
  270. time = 0;
  271. for (int i = 0; i < TurningPoints.Count - 2; i++)
  272. {
  273. time += TurningPoints[i].SegmentFlightTime;
  274. }
  275. Log.Info($"+++++++++++搜寻结束 TurningPoints Count: {TurningPoints.Count} 下次结束的时间 {time}++++++++++++++++");
  276. }
  277. (currentLocation, _) =
  278. FXJHGenerate.GetAllCurrentLocation(TurningPoints, temptime); // 获取飞机当前位置
  279. double3 aricraftPoint = new double3(currentLocation.CurrentLon, currentLocation.CurrentLat,
  280. currentLocation.CurrentHei);
  281. double3 targetPoint = new double3(FlightPlanEditor.targetpoint[0].TargetPointLongitude,
  282. FlightPlanEditor.targetpoint[0].TargetPointLatitude,
  283. FlightPlanEditor.targetpoint[0].TargetPointHeight);
  284. var wind = SeaSJ.GetWindVelocityFromAPI(nCread, currentLocation.CurrentLat, currentLocation.CurrentLon,
  285. temptime, text_ReadNC.times, text_ReadNC.latitudes, text_ReadNC.longitudes, text_ReadNC.times1, text_ReadNC.latitudes1, text_ReadNC.longitudes1, Days, Hour);
  286. windSpeed = Math.Sqrt(wind[0] * wind[0] + wind[1] * wind[1]);
  287. var waveHigh = SeaSJ.GetWaveHeightFromAPI(nCread, currentLocation.CurrentLon,
  288. currentLocation.CurrentLat, temptime, text_ReadNC.times4, text_ReadNC.latitudes4, text_ReadNC.longitudes4, Days, Hour);
  289. var distance = Utils.Util.GetDistance(currentLocation.CurrentLon, targetPoint.x,
  290. currentLocation.CurrentLat,
  291. targetPoint.y);
  292. //Console.WriteLine("targetPoint:" + targetPoint.x + "-" + targetPoint.y + "-" + targetPoint.z);
  293. Log.Info("距离:====================" + distance);
  294. //Console.WriteLine("searchMissionPayload.SearchPayload:" + searchMissionPayload.SearchPayload);
  295. if (searchMissionPayload.SearchPayload == "雷达搜索")
  296. {
  297. // Pd0 = 0.5 / Pf0 = Math.Pow(10,-6) / Pf = Math.Pow(10,-6) / R0 = 23645 / sigma0 = 5000 / sigma = Editor雷达截面面积 // R 单位m
  298. probability = helper.GetRadarPossibility(0.5, Math.Pow(10, -6), Math.Pow(10, -6), 23645, aricraftPoint, FlightPlanEditor.targetpoint[0], FlightPlanEditor.targetpoint[0].TargetType.RadarArea, 5000, vis);
  299. }
  300. else if (searchMissionPayload.SearchPayload == "目视搜索")
  301. {
  302. probability = helper.GetMushiSeaProbability(aricraftPoint, vis, waveHigh, FlightPlanEditor.targetpoint[0]);
  303. }
  304. else if (searchMissionPayload.SearchPayload == "光电(红外)搜索")
  305. {
  306. // Lt = 探测目标亮度 Editor / At = 探测目标面积 Editor / τa = 1 / Lb = 3 / A0 = 1 / D0 = 0.075 / Dstar = 3 / τo = 0.8 / Ad = 0.0073728 / Δf = 0.125 / δ = 0.5 / Pf0 = Math.Pow(10, -6);
  307. probability = helper.GetInfraredDetectionProbability(FlightPlanEditor.targetpoint[0].TargetType.TargetBrightness, FlightPlanEditor.targetpoint[0].TargetType.TargetArea, 1, 3, 1, aricraftPoint, FlightPlanEditor.targetpoint[0], 0.075, 3, 0.8, 0073728, 0.125, 0.5, Math.Pow(10, -6));
  308. }
  309. // probability = helper.getProbability(aricraftPoint, targetPoint,pb, currentLocation.CurrentCourse,
  310. // windSpeed, waveHigh, "落水人员", "海上"); // 计算发现概率,需要其他模型输入 // 计算发现概率,需要其他模型输入
  311. //finalProbability *= (1 - probability);
  312. // 到搜寻航路点的最后一个点 (?)
  313. Log.Info(
  314. $"海上任务:{taskContent.missionInformation.MissionName} 机型: {AircraftId} 当前时间:{temptime},当前位置:{currentLocation.CurrentLon},{currentLocation.CurrentLat},{currentLocation.CurrentHei},概率:{probability},是否看到目标:{isseePerson}");
  315. double randomValue = random.NextInt64(9006, 10000); // 生成随机数比较概率 //0.05 第一个参数越高概率越低 / 8985 0.212 100 / 9000 0.16 100 / 8995 0.14 100 / 8997 0.12 100 / 8999 0.18 100 / 9006 0.11 100 / 9010 0.12 100 / 9030 0.03 100 / 9026 0.07 0.04 100 / 9028 0.03 100 / 9027 0.04 100 / 9025 0.05 100 /
  316. //9025 0.02 100 / 9015 0.02 100 / 9020 0.04 100 / 9022 0.05 100 / 9022 0.04 100 / 9022 0 100 /9018 0.01 100 / 9021 0.01 100 / 9023 0.03 100 / 9000 0.08 100 / 9006
  317. randomValue /= 10000;
  318. //randomValue = 0.8;
  319. if (randomValue < probability) // 1 - finalProbability
  320. {
  321. isseePerson = true;
  322. this.isseePerson = true;
  323. fireIndex = currentLocation.Currentsegnum; // 记录当前航路点位置
  324. //IsOver = true;
  325. isEndWhile = true;
  326. }
  327. else
  328. {
  329. isseePerson = false;
  330. }
  331. if (temptime >= taskContent.missionInformation.TaskEndConditions.TaskTime)
  332. {
  333. //IsOver = true;
  334. isEndWhile = true;
  335. isseePerson = false;
  336. fireIndex = currentLocation.Currentsegnum;
  337. }
  338. temptime += 10;
  339. } while (!isseePerson && !isEndWhile); //IsOver == false
  340. //finalProbability = 1 - finalProbability;
  341. if (fireIndex != -1)
  342. {
  343. // 删除目标点位置开始的所有后续航路点
  344. TurningPoints.RemoveRange(fireIndex + 1, TurningPoints.Count - fireIndex - 1);
  345. MissionPoint missionPoint = new MissionPoint
  346. {
  347. MissionPointLongitude = currentLocation.CurrentLon,
  348. MissionPointLatitude = currentLocation.CurrentLat,
  349. MissionPointHeight = currentLocation.CurrentHei
  350. };
  351. FXJHGenerate.SeaSouJiu2(FlightPlanEditor, missionPoint, ref TurningPoints);
  352. //发现的目标坐标,需要其他模型输入
  353. FXJHGenerate.FromMissionToEnd(FlightPlanEditor, MissionEndPoint, ref TurningPoints);
  354. }
  355. if (isseePerson)
  356. {
  357. double seeTime = 0;
  358. if (FlightPlanEditor.targetpoint[0].TargetType.Type == "落水人员")
  359. {
  360. for (int i = 0; i < TurningPoints.Count - 1; i++)
  361. {
  362. seeTime += TurningPoints[i].SegmentFlightTime;
  363. }
  364. //time = TotalTime; //time——搜索时间,单位:秒;数据测试用
  365. double latitude = FlightPlanEditor.targetpoint[0].TargetPointLatitude; //落水人员纬度;数据测试用
  366. double longitude = FlightPlanEditor.targetpoint[0].TargetPointLongitude; //落水人员经度,数据测试用
  367. double survivalTime = SurvivalTimeModel.SurvivalTime(getNCData.tempreadNC, latitude, longitude, time, text_ReadNC.times, text_ReadNC.latitudes, text_ReadNC.longitudes, Days, Hour); //幸存时间
  368. // SHJParameter.person_number = Eidtor里读取 SHJParameter.windspeed Nc/Editor目标气象信息读取时间先取任务初始时间
  369. resulttime = get_result_time_rope(30, FlightPlanEditor.targetpoint[0].TargetType.Count, windSpeed, vis, 0.75, 1.38).time; //调运时间
  370. Console.WriteLine("resulttime:" + resulttime);
  371. if (survivalTime * 3600 > seeTime)
  372. {
  373. Success = true;
  374. }
  375. //Log.Info("TotalTime:" + TotalTime);
  376. //Log.Info("幸存时间:" + survivalTime);
  377. }
  378. }
  379. //Console.WriteLine(
  380. // $"海上任务1:{taskContent.missionInformation.MissionName} 机型: {AircraftId} 当前时间:{temptime},当前位置:{currentLocation.CurrentLon},{currentLocation.CurrentLat},{currentLocation.CurrentHei},概率:{probability},最终概率:{1 - finalProbability},是否看到落水人员:{isseePerson}");
  381. Log.Info(
  382. $"海上任务:{taskContent.missionInformation.MissionName} 机型: {AircraftId} 当前时间:{temptime},当前位置:{currentLocation.CurrentLon},{currentLocation.CurrentLat},{currentLocation.CurrentHei},概率:{probability},是否看到目标:{isseePerson},人员是否幸存:{Success}");
  383. FXJHGenerate.FXJHTPDiedai(FlightPlanEditor, ref TurningPoints, Velocitys, FuelConsumptions);
  384. End();
  385. });
  386. }
  387. public static handling_result get_result_time_rope(double H, int person_number, double windspeed, double vis, double upspeed, double downspeed)
  388. {
  389. handling_result result = new handling_result();
  390. if (windspeed < 8 && vis > 3)
  391. {
  392. result.time = (person_number * H) / downspeed + (person_number * H) / upspeed;
  393. result.success = true;
  394. }
  395. else
  396. {
  397. result.success = false;
  398. }
  399. return result;
  400. }
  401. public static int GetDaysInYear(int year, int month, int day)
  402. {
  403. int[] daysInMonths = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
  404. if (IsLeapYear(year))
  405. {
  406. daysInMonths[1] = 29;
  407. }
  408. int days = day;
  409. for (int i = 0; i < month - 1; i++)
  410. {
  411. days += daysInMonths[i];
  412. }
  413. return days;
  414. }
  415. public static bool IsLeapYear(int year)
  416. {
  417. return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
  418. }
  419. public override void End()
  420. {
  421. for (int i = 0; i < TurningPoints.Count - 2; i++)
  422. {
  423. EffMisTime += TurningPoints[i].SegmentFlightTime;
  424. }
  425. for (int i = 0; i < TurningPoints.Count - 3; i++)
  426. {
  427. SearchTime += TurningPoints[i].SegmentFlightTime; //搜索时间
  428. }
  429. for (int i = 0; i < TurningPoints.Count; i++)
  430. {
  431. TotalTime += TurningPoints[i].SegmentFlightTime; // 总时间
  432. }
  433. TotalFuelConsumption = TurningPoints[0].RemainingFuel -
  434. TurningPoints[TurningPoints.Count - 1].RemainingFuel;
  435. //GetNCData getNCData = new GetNCData();
  436. ////getNCData.GetData();
  437. IsOver = true;
  438. }
  439. }
  440. [ObjectSystem]
  441. public class AircraftSJAwakeSystem : AwakeSystem<AircraftSJ, FlightPlanEditor>
  442. {
  443. public override void Awake(AircraftSJ self, FlightPlanEditor flightPlanEditor)
  444. {
  445. self.FlightPlanEditor = flightPlanEditor;
  446. self.helper = new EquationHelper(HttpInterface.baseUrl);
  447. self.Awake();
  448. }
  449. }