123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- using KYFramework;
- using Model;
- using SimulationServer.Utils;
- using Define = SimulationServer.Utils.Define;
- namespace SimulationServer;
- public class AircraftMHWithPersion : AircraftEntity
- {
- public string NextMissionId; // 下一个任务ID
- public MissionEndPoint missionEndPoint = new MissionEndPoint();
- public int GroundPersonnel;
- public int LandingPersonnel;
- public MHRescueMission mhRescueMission;
- // 频率
- public double Frequency = 10 * 60;
- public FireGround fireGround;
- private int InterventionNumber = 0;
- private double InterventionTime;//介入时间
- private int waterTimes = 1; // 洒水次数
-
- public override void End()
- {
-
- }
- public override void Reset()
- {
- InterventionTime = 0;
- InterventionNumber = 0;
- waterTimes = 1;
- base.Reset();
- }
- public override void Start()
- {
- FXJHGenerate.FromStartToMission(FlightPlanEditor,ref TurningPoints);//生成从起点到任务段起点的航路点
-
- missionEndPoint.MissionEndPointLatitude = FlightPlanEditor.missionpoint.MissionPointLatitude;
- missionEndPoint.MissionEndPointLongitude = FlightPlanEditor.missionpoint.MissionPointLongitude;
- missionEndPoint.MissionEndPointHeight = FlightPlanEditor.missionpoint.MissionPointHeight;
-
- int TransportNumber = (int)Math.Ceiling(LandingPersonnel / FlightPlanEditor.aircraftparameter.MaxPassengerNumber);
- int j = 0;
-
-
- for (int i = 0; i < TransportNumber; i ++)
- {
- if (i == 0)
- {
- FXJHGenerate.JijiangMiehuo1(FlightPlanEditor,ref TurningPoints);
- }
- else
- {
- FXJHGenerate.JijiangMiehuo(FlightPlanEditor,ref TurningPoints);
- j += 2;
- }
-
- }
- // FXJHGenerate.InitializeVelocities(FlightPlanEditor, TurningPoints, ref Velocitys);
- // FXJHGenerate.InitializeFuelConsumptions(FlightPlanEditor, TurningPoints,ref FuelConsumptions);
-
- FXJHGenerate.FromMissionToEnd(FlightPlanEditor, missionEndPoint,ref TurningPoints);
- FXJHGenerate.FXJHTPDiedai(FlightPlanEditor,ref TurningPoints, Velocitys, FuelConsumptions);
- double TravelSpeed=5;//行进速度,km/h
- double distance = GetDistance(FlightPlanEditor.missionpoint.MissionPointLongitude, FlightPlanEditor.firepoint[0].FirePointLongitude, FlightPlanEditor.missionpoint.MissionPointLatitude, FlightPlanEditor.firepoint[0].FirePointLatitude);
- double TravelTime = distance / TravelSpeed * 3600;
-
- //Log.Info("距离:" + distance);
-
- //Log.Info($"起飞准备时间: {FlightPlanEditor.aircraftparameter.TakeoffPreparationTime}");
- InterventionTime = 600 + TravelTime ;
-
- //Log.Info($"人走到火场的时间: {InterventionTime}");
-
- for (int i = 0;i < TransportNumber;i ++)
- {
- //Log.Info($"飞行时间{i}: {turningPoints[i].SegmentFlightTime}");
- InterventionTime += TurningPoints[i].SegmentFlightTime;
- }
-
- //Log.Info($"介入时间 {InterventionTime}");
- InterventionNumber = LandingPersonnel + GroundPersonnel;
- T = InterventionTime;
-
- TotalFuelConsumption = TurningPoints[0].RemainingFuel - TurningPoints[^1].RemainingFuel;
- T += Frequency;
-
- //Log.Info($"机降 洒水之前火场面积:" + _fireGround.countArea.burnarea);
- }
-
- private double GetDistance(double lon1, double lon2, double lat1, double lat2)
- {
- double R = 6371; // 地球的半径(公里)
- double dLat = (lat2 - lat1) * Math.PI / 180.0;
- double dLon = (lon2 - lon1) * Math.PI / 180.0;
- double a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) +
- Math.Cos(lat1 * Math.PI / 180.0) * Math.Cos(lat2 * Math.PI / 180.0) *
- Math.Sin(dLon / 2) * Math.Sin(dLon / 2);
- double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
- double distance = R * c;
- return distance;
- }
-
- public override void Update(double time)
- {
- if (fireGround.countArea.burnarea > 0) // 灭火完成
- {
- if (time > T)
- {
- // 开始洒水
- fireGround.countArea = Fire.burnCalculate(Define.WIND, mhRescueMission.slope, T, fireGround.countArea.burnarea, T, mhRescueMission.tn, fireGround.countArea.burnarea);
- var currentArea = Fire.groundPersonnelWater(InterventionNumber);
- fireGround.countArea.burnarea -= currentArea;
- mhRescueMission.tn = T;
- mhRescueMission.area += currentArea; // 有效洒水面积;
-
- Log.Info($"任务 {TaskName} 地面灭火 洒水{waterTimes} 次 本次有效洒水面积 {currentArea} 用时 {T} area {mhRescueMission.area} burnarea {fireGround.countArea.burnarea}");
- waterTimes++;
-
- T += Frequency;//飞机开始飞到火场 需要多少时间 t
- }
- }
- }
- }
- [ObjectSystem]
- public class AircraftMHWithPersionAwakeSystem : AwakeSystem<AircraftMHWithPersion,FlightPlanEditor>
- {
- public override void Awake(AircraftMHWithPersion self,FlightPlanEditor flightPlanEditor)
- {
- self.FlightPlanEditor = flightPlanEditor;
- self.Awake();
- self.Reset();
- }
- }
|