123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- using KYFramework;
- using Model;
- using MongoDB.Bson;
- using Define = SimulationServer.Utils.Define;
- namespace SimulationServer;
- public class AircraftMH : AircraftEntity
- {
- public double SprinklerArea = 1500; // 飞机速度
- public string NextMissionId; // 下一个任务ID
- public FireGround fireGround;
- public MHRescueMission mhRescueMission;
- private int waterInterval = 4; // 洒水间隔
- public int waterTimes = 1; // 洒水次数
- public List<Fire.FireGrid> FireGrids = new List<Fire.FireGrid>();
-
- //任务重置
- public override void Reset()
- {
- waterTimes = 1;
- waterInterval = 4;
- base.Reset();
- }
-
- // 任务开始
- public override void Start()
- {
- FXJHGenerate.FromStartToMission(FlightPlanEditor, ref TurningPoints);//生成从起点到任务段起点的航路点
- // 计算出第一次洒水的时间
- FXJHGenerate.MieHuo1(FlightPlanEditor,ref TurningPoints);
-
- // FXJHGenerate.InitializeVelocities(FlightPlanEditor, TurningPoints, ref Velocitys);
- // FXJHGenerate.InitializeFuelConsumptions(FlightPlanEditor, TurningPoints,ref FuelConsumptions);
-
- FXJHGenerate.FXJHTPDiedai(FlightPlanEditor, ref TurningPoints, Velocitys, FuelConsumptions);
- for (int i = 0; i < waterInterval; i++)
- {
- T += TurningPoints[i].SegmentFlightTime;
- }
-
- TaskResponseTime = T;
- if (FirstTime == 0) FirstTime = T;
- }
- // 任务结束
- public override void End()
- {
- MissionEndPoint missionEndPoint = new MissionEndPoint();
- missionEndPoint.MissionEndPointLatitude = fireGround.FirePoint.Latitude;
- missionEndPoint.MissionEndPointLongitude = fireGround.FirePoint.Longitude;
- missionEndPoint.MissionEndPointHeight = fireGround.FirePoint.Altitude;
- FXJHGenerate.FromMissionToEnd(FlightPlanEditor, missionEndPoint, ref TurningPoints);
- FXJHGenerate.FXJHTPDiedai(FlightPlanEditor,ref TurningPoints, Velocitys, FuelConsumptions);
- EffMisTime = mhRescueMission.tn - TaskResponseTime;
- TotalFuelConsumption = TurningPoints[0].RemainingFuel - TurningPoints[^1].RemainingFuel;
- }
-
-
- // 更新
- 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);
-
- // T 洒水的时间
- // 正在燃烧的网格数 向下取整
- double fireGrids = Math.Floor(fireGround.countArea.burnarea/400);
- // 已经燃尽的网格数
- double firedGrids = Math.Floor((mhRescueMission.area - fireGround.countArea.burnarea)/400);
-
- //记录洒水之前的火场
- FireGrids.Add(new Fire.FireGrid
- {
- Time = T,
- FireGrids = fireGrids,
- FiredGrids = firedGrids
- });
-
- var currentArea = Fire.SprinklerArea(Type, SprinklerArea/2, fireGround.FirePoint.Altitude) ; // 本次有效洒水面积
-
- fireGround.countArea.burnarea -= currentArea;
- mhRescueMission.area += currentArea; // 有效洒水面积
-
- Log.Info($"任务 {TaskName } {Name} 洒水{waterTimes} 次 本次有效洒水面积 {currentArea} 用时 {T} area {mhRescueMission.area} burnarea {fireGround.countArea.burnarea}");
-
- mhRescueMission.tn = T;
- waterTimes++;
-
- // 计算出下一次洒水的时间
- FXJHGenerate.MieHuo1(FlightPlanEditor, ref TurningPoints);
- FXJHGenerate.FXJHTPDiedai(FlightPlanEditor,ref TurningPoints, Velocitys, FuelConsumptions);
- for (int i = waterInterval - 2; i < waterInterval; i++)
- {
- T += TurningPoints[i].SegmentFlightTime;
- }
- waterInterval += 2;
- }
- }
- }
- }
- [ObjectSystem]
- public class AircraftAwakeSystem : AwakeSystem<AircraftMH,FlightPlanEditor>
- {
- public override void Awake(AircraftMH self, FlightPlanEditor flightPlanEditor)
- {
- self.FlightPlanEditor = flightPlanEditor;
- // 读取数据库
- self.Awake();
- if (self.Db != null)
- {
- self.Type = self.Db?.fConcreateType.ToString();
- self.SprinklerArea = (double)self.Db?.fpsmj;
- }
- self.Reset();
- }
- }
|