|
@@ -1,13 +1,19 @@
|
|
|
-using BHJD.DEMdll.Public;
|
|
|
-using KYFramework;
|
|
|
+using KYFramework;
|
|
|
using Model;
|
|
|
+using MuShiApp;
|
|
|
+using SimulationCommon;
|
|
|
+using SimulationSingleServer.Utils;
|
|
|
+using Unity.Mathematics;
|
|
|
+using Define = SimulationServer.Utils.Define;
|
|
|
+using Random = System.Random;
|
|
|
|
|
|
namespace SimulationServer;
|
|
|
|
|
|
public class AircraftSJ : AircraftEntity
|
|
|
{
|
|
|
- public MissionEndPoint MissionEndPoint;
|
|
|
-
|
|
|
+ public bool IsOver;
|
|
|
+
|
|
|
+ private MissionEndPoint MissionEndPoint;
|
|
|
private CurrentLocation currentLocation;
|
|
|
private double temptime = 0;
|
|
|
private double probability = 0;
|
|
@@ -15,86 +21,132 @@ public class AircraftSJ : AircraftEntity
|
|
|
private Random random = new Random();
|
|
|
private bool isseefire = false;
|
|
|
private int fireIndex = -1;
|
|
|
- public bool IsOver;
|
|
|
+ public EquationHelper helper;
|
|
|
+
|
|
|
public override void Start()
|
|
|
{
|
|
|
- FXJHGenerate.FromStartToMission(FlightPlanEditor, ref TurningPoints);
|
|
|
+
|
|
|
+
|
|
|
+ float[] longitudeArray = null;
|
|
|
+ float[] latitudeArray = null;
|
|
|
+ float[][][] u10Arrayu = null;
|
|
|
+
|
|
|
+ float[][][] v10Array = null;
|
|
|
+
|
|
|
+ float[][][] p140208Array = null;
|
|
|
+ float[][][] mwdArray = null;
|
|
|
+
|
|
|
+ WeatherResponse weatherResponse = new WeatherResponse() { };
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ FXJHGenerate.FromStartToMission(FlightPlanEditor, ref TurningPoints);
|
|
|
+
|
|
|
+ FXJHGenerate.SeaSouJiu(FlightPlanEditor, ref TurningPoints);
|
|
|
+
|
|
|
FXJHGenerate.FXJHTPDiedai(FlightPlanEditor, ref TurningPoints, Velocitys, FuelConsumptions);
|
|
|
- }
|
|
|
|
|
|
- public override void Update(double time)
|
|
|
- {
|
|
|
- if (!isseefire)
|
|
|
+ Task.Run(() =>
|
|
|
{
|
|
|
- (currentLocation, _) = FXJHGenerate.GetCurrentLocation(TurningPoints, FlightPlanEditor, temptime);
|
|
|
-
|
|
|
- probability = EquationHelper.getProbability();
|
|
|
+ bool isseefire = false;
|
|
|
+ double temptime = 0;
|
|
|
+ CurrentLocation currentLocation = new CurrentLocation();
|
|
|
+ double probability = 0;
|
|
|
+ double finalProbability = 1.0;
|
|
|
+ Random random = new Random();
|
|
|
+ int fireIndex = -1;
|
|
|
|
|
|
- finalProbability *= (1 - probability);
|
|
|
- double randomValue = random.NextDouble();
|
|
|
- if (randomValue < (1 - finalProbability))
|
|
|
+ do
|
|
|
{
|
|
|
- isseefire = true;
|
|
|
- fireIndex = currentLocation.Currentsegnum;
|
|
|
- IsOver = true;
|
|
|
- }
|
|
|
- else
|
|
|
+ (currentLocation, _) =
|
|
|
+ FXJHGenerate.GetCurrentLocation(TurningPoints, FlightPlanEditor, temptime);
|
|
|
+ double3 aricraftPoint = new double3(currentLocation.CurrentLon, currentLocation.CurrentLat,
|
|
|
+ currentLocation.CurrentHei);
|
|
|
+
|
|
|
+ double3 targetPoint = new double3(FlightPlanEditor.targetpoint[0].TargetPointLongitude,
|
|
|
+ FlightPlanEditor.targetpoint[0].TargetPointLatitude,
|
|
|
+ FlightPlanEditor.targetpoint[0].TargetPointHeight);
|
|
|
+
|
|
|
+
|
|
|
+ probability = helper.getProbability(aricraftPoint, targetPoint, currentLocation.CurrentCourse,
|
|
|
+ Define.WIND, 1, "落水人员", "陆地");
|
|
|
+
|
|
|
+ finalProbability *= (1 - probability);
|
|
|
+
|
|
|
+ Console.WriteLine($"海上任务: {Name} 当前时间:{temptime},当前位置:{currentLocation.CurrentLon},{currentLocation.CurrentLat},{currentLocation.CurrentHei},概率:{probability},最终概率:{1 -finalProbability},是否看到火点:{isseefire}");
|
|
|
+
|
|
|
+ double randomValue = random.NextDouble();
|
|
|
+ if (randomValue < (1 - finalProbability))
|
|
|
+ {
|
|
|
+ isseefire = true;
|
|
|
+ fireIndex = currentLocation.Currentsegnum;
|
|
|
+ IsOver = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ isseefire = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (temptime >= 7200) IsOver = true;
|
|
|
+
|
|
|
+ temptime += 1;
|
|
|
+ } while (!isseefire && IsOver == false);
|
|
|
+
|
|
|
+ finalProbability = 1 - finalProbability;
|
|
|
+
|
|
|
+ if (fireIndex != -1)
|
|
|
{
|
|
|
- isseefire = false;
|
|
|
+
|
|
|
+ TurningPoints.RemoveRange(fireIndex + 1, TurningPoints.Count - fireIndex - 1);
|
|
|
+
|
|
|
+
|
|
|
+ MissionPoint missionPoint = new MissionPoint
|
|
|
+ {
|
|
|
+ MissionPointLongitude = currentLocation.CurrentLon,
|
|
|
+ MissionPointLatitude = currentLocation.CurrentLat,
|
|
|
+ MissionPointHeight = currentLocation.CurrentHei
|
|
|
+ };
|
|
|
+ FXJHGenerate.SeaSouJiu2(FlightPlanEditor, missionPoint, ref TurningPoints);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ FXJHGenerate.FromMissionToEnd(FlightPlanEditor, MissionEndPoint, ref TurningPoints);
|
|
|
}
|
|
|
- temptime += 1;
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+ FXJHGenerate.FXJHTPDiedai(FlightPlanEditor, ref TurningPoints, Velocitys, FuelConsumptions);
|
|
|
+ End();
|
|
|
+ });
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
public override void End()
|
|
|
{
|
|
|
- finalProbability = 1 - finalProbability;
|
|
|
- if (fireIndex != -1)
|
|
|
- {
|
|
|
-
|
|
|
- TurningPoints.RemoveRange(fireIndex + 1, TurningPoints.Count - fireIndex - 1);
|
|
|
|
|
|
-
|
|
|
- MissionPoint missionPoint = new MissionPoint
|
|
|
- {
|
|
|
- MissionPointLongitude = currentLocation.CurrentLon,
|
|
|
- MissionPointLatitude = currentLocation.CurrentLat,
|
|
|
- MissionPointHeight = currentLocation.CurrentHei
|
|
|
- };
|
|
|
-
|
|
|
- FXJHGenerate.SeaSouJiu2(FlightPlanEditor, missionPoint, ref TurningPoints);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- FXJHGenerate.FromMissionToEnd(FlightPlanEditor, MissionEndPoint, ref TurningPoints);
|
|
|
-
|
|
|
- FXJHGenerate.FXJHTPDiedai(FlightPlanEditor, ref TurningPoints, Velocitys, Velocitys);
|
|
|
-
|
|
|
-
|
|
|
- for (int i = 0; i < currentLocation.Currentsegnum+2; i++)
|
|
|
+ for (int i = 0; i < currentLocation.Currentsegnum + 2; i++)
|
|
|
{
|
|
|
EffMisTime += TurningPoints[i].SegmentFlightTime;
|
|
|
}
|
|
|
-
|
|
|
- TotalFuelConsumption = TurningPoints[0].RemainingFuel - TurningPoints[currentLocation.Currentsegnum+1].RemainingFuel;
|
|
|
-
|
|
|
+
|
|
|
+ TotalFuelConsumption = TurningPoints[0].RemainingFuel -
|
|
|
+ TurningPoints[currentLocation.Currentsegnum + 1].RemainingFuel;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
[ObjectSystem]
|
|
|
-public class AircraftSJAwakeSystem : AwakeSystem<AircraftSJ,FlightPlanEditor>
|
|
|
+public class AircraftSJAwakeSystem : AwakeSystem<AircraftSJ, FlightPlanEditor>
|
|
|
{
|
|
|
- public override void Awake(AircraftSJ self,FlightPlanEditor flightPlanEditor)
|
|
|
+ public override void Awake(AircraftSJ self, FlightPlanEditor flightPlanEditor)
|
|
|
{
|
|
|
self.FlightPlanEditor = flightPlanEditor;
|
|
|
-
|
|
|
+ self.helper = new EquationHelper(HttpInterface.baseUrl);
|
|
|
self.Awake();
|
|
|
}
|
|
|
}
|