mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Fix TOT-offset issues
This commit is contained in:
parent
8d56e2d3bb
commit
dad5e7c146
@ -48,7 +48,7 @@ class CustomFlightPlan(FlightPlan[CustomLayout]):
|
|||||||
|
|
||||||
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
|
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
|
||||||
if waypoint == self.tot_waypoint:
|
if waypoint == self.tot_waypoint:
|
||||||
return self.package.time_over_target + self.tot_offset
|
return self.tot
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
|
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
|
||||||
|
|||||||
@ -249,11 +249,15 @@ class FlightPlan(ABC, Generic[LayoutT]):
|
|||||||
self._travel_time_to_waypoint(self.tot_waypoint)
|
self._travel_time_to_waypoint(self.tot_waypoint)
|
||||||
+ self.estimate_startup()
|
+ self.estimate_startup()
|
||||||
+ self.estimate_ground_ops()
|
+ self.estimate_ground_ops()
|
||||||
|
+ self.estimate_takeoff_time()
|
||||||
)
|
)
|
||||||
|
|
||||||
def startup_time(self) -> datetime:
|
def startup_time(self) -> datetime:
|
||||||
return (
|
return (
|
||||||
self.takeoff_time() - self.estimate_startup() - self.estimate_ground_ops()
|
self.takeoff_time()
|
||||||
|
- self.estimate_startup()
|
||||||
|
- self.estimate_ground_ops()
|
||||||
|
- self.estimate_takeoff_time()
|
||||||
)
|
)
|
||||||
|
|
||||||
def estimate_startup(self) -> timedelta:
|
def estimate_startup(self) -> timedelta:
|
||||||
@ -273,6 +277,10 @@ class FlightPlan(ABC, Generic[LayoutT]):
|
|||||||
else:
|
else:
|
||||||
return timedelta(minutes=8)
|
return timedelta(minutes=8)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def estimate_takeoff_time() -> timedelta:
|
||||||
|
return timedelta(seconds=30)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_airassault(self) -> bool:
|
def is_airassault(self) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|||||||
@ -85,9 +85,9 @@ class FormationFlightPlan(LoiterFlightPlan, ABC):
|
|||||||
|
|
||||||
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
|
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
|
||||||
if waypoint == self.layout.join:
|
if waypoint == self.layout.join:
|
||||||
return self.join_time + self.tot_offset
|
return self.join_time
|
||||||
elif waypoint == self.layout.split:
|
elif waypoint == self.layout.split:
|
||||||
return self.split_time + self.tot_offset
|
return self.split_time
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@ -31,7 +31,7 @@ class LoiterFlightPlan(StandardFlightPlan[Any], ABC):
|
|||||||
|
|
||||||
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
|
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
|
||||||
if waypoint == self.layout.hold:
|
if waypoint == self.layout.hold:
|
||||||
return self.push_time + self.tot_offset
|
return self.push_time
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def total_time_between_waypoints(
|
def total_time_between_waypoints(
|
||||||
|
|||||||
@ -66,14 +66,14 @@ class SweepFlightPlan(LoiterFlightPlan):
|
|||||||
|
|
||||||
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
|
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
|
||||||
if waypoint == self.layout.sweep_start:
|
if waypoint == self.layout.sweep_start:
|
||||||
return self.sweep_start_time + self.tot_offset
|
return self.sweep_start_time
|
||||||
if waypoint == self.layout.sweep_end:
|
if waypoint == self.layout.sweep_end:
|
||||||
return self.sweep_end_time + self.tot_offset
|
return self.sweep_end_time
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
|
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
|
||||||
if waypoint == self.layout.hold:
|
if waypoint == self.layout.hold:
|
||||||
return self.push_time + self.tot_offset
|
return self.push_time
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@ -26,7 +26,7 @@ class FlightState(ABC):
|
|||||||
|
|
||||||
start_time = self.flight.flight_plan.startup_time()
|
start_time = self.flight.flight_plan.startup_time()
|
||||||
if start_time <= now:
|
if start_time <= now:
|
||||||
self._set_active_flight_state(now)
|
self._set_active_flight_state(start_time)
|
||||||
else:
|
else:
|
||||||
self.flight.set_state(
|
self.flight.set_state(
|
||||||
WaitingForStart(self.flight, self.settings, start_time)
|
WaitingForStart(self.flight, self.settings, start_time)
|
||||||
|
|||||||
@ -26,6 +26,7 @@ class InFlight(FlightState, ABC):
|
|||||||
settings: Settings,
|
settings: Settings,
|
||||||
waypoint_index: int,
|
waypoint_index: int,
|
||||||
has_aborted: bool = False,
|
has_aborted: bool = False,
|
||||||
|
elapsed_time: timedelta = timedelta(),
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(flight, settings)
|
super().__init__(flight, settings)
|
||||||
waypoints = self.flight.flight_plan.waypoints
|
waypoints = self.flight.flight_plan.waypoints
|
||||||
@ -35,7 +36,7 @@ class InFlight(FlightState, ABC):
|
|||||||
# TODO: Error checking for flight plans without landing waypoints.
|
# TODO: Error checking for flight plans without landing waypoints.
|
||||||
self.next_waypoint = waypoints[self.waypoint_index + 1]
|
self.next_waypoint = waypoints[self.waypoint_index + 1]
|
||||||
self.total_time_to_next_waypoint = self.travel_time_between_waypoints()
|
self.total_time_to_next_waypoint = self.travel_time_between_waypoints()
|
||||||
self.elapsed_time = timedelta()
|
self.elapsed_time = elapsed_time
|
||||||
self.current_waypoint_elapsed = False
|
self.current_waypoint_elapsed = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@ -24,7 +24,7 @@ class StartUp(AtDeparture):
|
|||||||
) -> None:
|
) -> None:
|
||||||
if time < self.completion_time:
|
if time < self.completion_time:
|
||||||
return
|
return
|
||||||
self.flight.set_state(Taxi(self.flight, self.settings, time))
|
self.flight.set_state(Taxi(self.flight, self.settings, self.completion_time))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_waiting_for_start(self) -> bool:
|
def is_waiting_for_start(self) -> bool:
|
||||||
|
|||||||
@ -19,14 +19,19 @@ class Takeoff(AtDeparture):
|
|||||||
def __init__(self, flight: Flight, settings: Settings, now: datetime) -> None:
|
def __init__(self, flight: Flight, settings: Settings, now: datetime) -> None:
|
||||||
super().__init__(flight, settings)
|
super().__init__(flight, settings)
|
||||||
# TODO: Not accounted for in FlightPlan, can cause discrepancy without loiter.
|
# TODO: Not accounted for in FlightPlan, can cause discrepancy without loiter.
|
||||||
self.completion_time = now + timedelta(seconds=30)
|
self.completion_time = now + flight.flight_plan.estimate_takeoff_time()
|
||||||
|
|
||||||
def on_game_tick(
|
def on_game_tick(
|
||||||
self, events: GameUpdateEvents, time: datetime, duration: timedelta
|
self, events: GameUpdateEvents, time: datetime, duration: timedelta
|
||||||
) -> None:
|
) -> None:
|
||||||
if time < self.completion_time:
|
if time < self.completion_time:
|
||||||
return
|
return
|
||||||
self.flight.set_state(Navigating(self.flight, self.settings, waypoint_index=0))
|
rollover = time - self.completion_time
|
||||||
|
self.flight.set_state(
|
||||||
|
Navigating(
|
||||||
|
self.flight, self.settings, waypoint_index=0, elapsed_time=rollover
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_waiting_for_start(self) -> bool:
|
def is_waiting_for_start(self) -> bool:
|
||||||
|
|||||||
@ -24,7 +24,7 @@ class Taxi(AtDeparture):
|
|||||||
) -> None:
|
) -> None:
|
||||||
if time < self.completion_time:
|
if time < self.completion_time:
|
||||||
return
|
return
|
||||||
self.flight.set_state(Takeoff(self.flight, self.settings, time))
|
self.flight.set_state(Takeoff(self.flight, self.settings, self.completion_time))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_waiting_for_start(self) -> bool:
|
def is_waiting_for_start(self) -> bool:
|
||||||
|
|||||||
@ -60,5 +60,4 @@ class TotEstimator:
|
|||||||
The earliest possible TOT for the given flight.
|
The earliest possible TOT for the given flight.
|
||||||
"""
|
"""
|
||||||
flight_time = flight.flight_plan.minimum_duration_from_start_to_tot()
|
flight_time = flight.flight_plan.minimum_duration_from_start_to_tot()
|
||||||
offset = flight.flight_plan.tot_offset
|
return now + flight_time
|
||||||
return now + flight_time - offset
|
|
||||||
|
|||||||
@ -14,9 +14,10 @@ class QFlightPlanner(QTabWidget):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.payload_tab = QFlightPayloadTab(flight, gm.game)
|
self.payload_tab = QFlightPayloadTab(flight, gm.game)
|
||||||
self.waypoint_tab = QFlightWaypointTab(gm.game, package_model.package, flight)
|
|
||||||
|
|
||||||
self.payload_tab = QFlightPayloadTab(flight, gm.game)
|
self.waypoint_tab = QFlightWaypointTab(gm.game, package_model.package, flight)
|
||||||
|
self.waypoint_tab.loadout_changed.connect(self.payload_tab.reload_from_flight)
|
||||||
|
|
||||||
self.general_settings_tab = QGeneralFlightSettingsTab(
|
self.general_settings_tab = QGeneralFlightSettingsTab(
|
||||||
gm,
|
gm,
|
||||||
package_model,
|
package_model,
|
||||||
@ -27,8 +28,6 @@ class QFlightPlanner(QTabWidget):
|
|||||||
self.general_settings_tab.flight_size_changed.connect(
|
self.general_settings_tab.flight_size_changed.connect(
|
||||||
self.payload_tab.resize_for_flight
|
self.payload_tab.resize_for_flight
|
||||||
)
|
)
|
||||||
self.waypoint_tab = QFlightWaypointTab(gm.game, package_model.package, flight)
|
|
||||||
self.waypoint_tab.loadout_changed.connect(self.payload_tab.reload_from_flight)
|
|
||||||
self.addTab(self.general_settings_tab, "General Flight settings")
|
self.addTab(self.general_settings_tab, "General Flight settings")
|
||||||
self.addTab(self.payload_tab, "Payload")
|
self.addTab(self.payload_tab, "Payload")
|
||||||
self.addTab(self.waypoint_tab, "Waypoints")
|
self.addTab(self.waypoint_tab, "Waypoints")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user