AircraftYLWPYS.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. using KYFramework;
  2. using MathNet.Numerics.Distributions;
  3. using Model;
  4. using MongoDB.Bson;
  5. using SimulationCommon;
  6. using SimulationServer.Utils;
  7. namespace SimulationServer;
  8. public class AircraftYLWPYS : AircraftEntity
  9. {
  10. public YLWPYSTask taskContent;
  11. public MissionEndPoint MissionEndPoint;
  12. public bool IsOver;
  13. public bool Success;
  14. public TaskParameter taskParameter;
  15. public GetNCData getNCData;
  16. public double resulttime;
  17. public bool isReadNC;
  18. Text_readNC text_ReadNC;
  19. public override void End()
  20. {
  21. TotalFuelConsumption = TurningPoints[0].RemainingFuel - TurningPoints[^1].RemainingFuel;
  22. }
  23. public override void Reset()
  24. {
  25. base.Reset();
  26. IsOver = false;
  27. Success = false;
  28. TotalTime = 0;
  29. }
  30. public override void Start()
  31. {
  32. FlightPlanEditor.missionpoint.MissionPointLatitude = FlightPlanEditor.medicalSuppliesInfo[0].TargetPointLatitude;
  33. FlightPlanEditor.missionpoint.MissionPointLongitude = FlightPlanEditor.medicalSuppliesInfo[0].TargetPointLongitude;
  34. FlightPlanEditor.missionpoint.MissionPointHeight = FlightPlanEditor.medicalSuppliesInfo[0].TargetPointHeight;
  35. Console.WriteLine("Latitude:" + FlightPlanEditor.missionpoint.MissionPointLatitude + "_" + "Longitude:" + FlightPlanEditor.missionpoint.MissionPointLongitude + "_" + "Height:" + FlightPlanEditor.missionpoint.MissionPointHeight);
  36. FXJHGenerate.FromStartToMission(FlightPlanEditor, ref TurningPoints);//生成从起点到任务段起点的航路点
  37. FXJHGenerate.JIJIU(5 * 60, FlightPlanEditor, ref TurningPoints);
  38. MissionEndPoint hospitalPoint = new MissionEndPoint()
  39. {
  40. MissionEndPointLongitude = FlightPlanEditor.missionpoint.MissionPointLongitude,
  41. MissionEndPointLatitude = FlightPlanEditor.missionpoint.MissionPointLatitude,
  42. MissionEndPointHeight = FlightPlanEditor.missionpoint.MissionPointHeight
  43. };
  44. FXJHGenerate.FromMissionToEnd(FlightPlanEditor, hospitalPoint, ref TurningPoints);
  45. FXJHGenerate.FXJHTPDiedai(FlightPlanEditor, ref TurningPoints, Velocitys, FuelConsumptions);
  46. for (int i = 0; i < TurningPoints.Count; i++) // 总飞行时间
  47. {
  48. TotalTime += TurningPoints[i].SegmentFlightTime; // 总时间 //仿真轮次1 数值1
  49. }
  50. Console.WriteLine("TotalTime:" + TotalTime);
  51. IsOver = true;
  52. End();
  53. }
  54. // 吊运函数
  55. public static handling_result get_result_time_rope(double H, int person_number, double windspeed, double vis, double upspeed, double downspeed)
  56. {
  57. handling_result result = new handling_result();
  58. if (windspeed < 8 && vis > 3)
  59. {
  60. result.time = (person_number * H) / downspeed + (person_number * H) / upspeed;
  61. result.success = true;
  62. }
  63. else
  64. {
  65. result.success = false;
  66. }
  67. return result;
  68. }
  69. public string TargetQiXiangInfoSave(string s, int hour)
  70. {
  71. string result = hour.ToString() + "-" + s;
  72. for (int i = 0; i < FlightPlanEditor.medicalTargetPoint[0].TargetQiXiangInfos.Length; i++)
  73. {
  74. }
  75. switch (s)
  76. {
  77. case "温度":
  78. break;
  79. case "湿度":
  80. break;
  81. case "能见度":
  82. break;
  83. case "风速":
  84. break;
  85. case "风向":
  86. break;
  87. case "天气":
  88. break;
  89. }
  90. return result;
  91. }
  92. public static int GetDaysInYear(int year, int month, int day)
  93. {
  94. int[] daysInMonths = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
  95. if (IsLeapYear(year))
  96. {
  97. daysInMonths[1] = 29;
  98. }
  99. int days = day;
  100. for (int i = 0; i < month - 1; i++)
  101. {
  102. days += daysInMonths[i];
  103. }
  104. return days;
  105. }
  106. public static bool IsLeapYear(int year)
  107. {
  108. return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
  109. }
  110. }
  111. [ObjectSystem]
  112. public class AircraftYLWPYSAwakeSystem : AwakeSystem<AircraftYLWPYS, FlightPlanEditor>
  113. {
  114. public override void Awake(AircraftYLWPYS self, FlightPlanEditor flightPlanEditor)
  115. {
  116. self.FlightPlanEditor = flightPlanEditor;
  117. self.Awake();
  118. }
  119. }