Add minimum fuel per waypoint on the kneeboard.

This commit is contained in:
Dan Albert
2021-07-17 19:51:55 -07:00
parent 3c90a92641
commit c11c6f40d5
6 changed files with 154 additions and 11 deletions

View File

@@ -105,6 +105,35 @@ class PatrolConfig:
)
@dataclass(frozen=True)
class FuelConsumption:
#: The estimated taxi fuel requirement, in pounds.
taxi: int
#: The estimated fuel consumption for a takeoff climb, in pounds per nautical mile.
climb: float
#: The estimated fuel consumption for cruising, in pounds per nautical mile.
cruise: float
#: The estimated fuel consumption for combat speeds, in pounds per nautical mile.
combat: float
#: The minimum amount of fuel that the aircraft should land with, in pounds. This is
#: a reserve amount for landing delays or emergencies.
min_safe: int
@classmethod
def from_data(cls, data: dict[str, Any]) -> FuelConsumption:
return FuelConsumption(
int(data["taxi"]),
float(data["climb_ppm"]),
float(data["cruise_ppm"]),
float(data["combat_ppm"]),
int(data["min_safe"]),
)
# TODO: Split into PlaneType and HelicopterType?
@dataclass(frozen=True)
class AircraftType(UnitType[Type[FlyingType]]):
@@ -124,6 +153,8 @@ class AircraftType(UnitType[Type[FlyingType]]):
#: planner will consider this aircraft usable for a mission.
max_mission_range: Distance
fuel_consumption: Optional[FuelConsumption]
intra_flight_radio: Optional[Radio]
channel_allocator: Optional[RadioChannelAllocator]
channel_namer: Type[ChannelNamer]
@@ -246,6 +277,14 @@ class AircraftType(UnitType[Type[FlyingType]]):
f"{mission_range.nautical_miles}NM"
)
fuel_data = data.get("fuel")
if fuel_data is not None:
fuel_consumption: Optional[FuelConsumption] = FuelConsumption.from_data(
fuel_data
)
else:
fuel_consumption = None
try:
introduction = data["introduced"]
if introduction is None:
@@ -274,6 +313,7 @@ class AircraftType(UnitType[Type[FlyingType]]):
patrol_altitude=patrol_config.altitude,
patrol_speed=patrol_config.speed,
max_mission_range=mission_range,
fuel_consumption=fuel_consumption,
intra_flight_radio=radio_config.intra_flight,
channel_allocator=radio_config.channel_allocator,
channel_namer=radio_config.channel_namer,

View File

@@ -4,7 +4,7 @@ import itertools
import math
from collections import Iterable
from dataclasses import dataclass
from typing import Union, Any
from typing import Union, Any, TypeVar
METERS_TO_FEET = 3.28084
FEET_TO_METERS = 1 / METERS_TO_FEET
@@ -205,7 +205,10 @@ def inches_hg(value: float) -> Pressure:
return Pressure(value)
def pairwise(iterable: Iterable[Any]) -> Iterable[tuple[Any, Any]]:
PairwiseT = TypeVar("PairwiseT")
def pairwise(iterable: Iterable[PairwiseT]) -> Iterable[tuple[PairwiseT, PairwiseT]]:
"""
itertools recipe
s -> (s0,s1), (s1,s2), (s2, s3), ...