mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Get TACAN and ILS data from pydcs.
This commit is contained in:
parent
e5074b57b8
commit
7c7d9f7066
@ -16,7 +16,6 @@ from dcs.task import Modulation
|
|||||||
from dcs.terrain import Airport
|
from dcs.terrain import Airport
|
||||||
|
|
||||||
from game.radio.radios import RadioFrequency
|
from game.radio.radios import RadioFrequency
|
||||||
from game.radio.tacan import TacanChannel
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from game.theater import ConflictTheater
|
from game.theater import ConflictTheater
|
||||||
@ -60,21 +59,12 @@ class AirfieldData:
|
|||||||
#: Runway length (in ft).
|
#: Runway length (in ft).
|
||||||
runway_length: int = 0
|
runway_length: int = 0
|
||||||
|
|
||||||
#: TACAN channel for the airfield.
|
|
||||||
tacan: Optional[TacanChannel] = None
|
|
||||||
|
|
||||||
#: TACAN callsign
|
|
||||||
tacan_callsign: Optional[str] = None
|
|
||||||
|
|
||||||
#: VOR as a tuple of (callsign, frequency).
|
#: VOR as a tuple of (callsign, frequency).
|
||||||
vor: Optional[Tuple[str, RadioFrequency]] = None
|
vor: Optional[Tuple[str, RadioFrequency]] = None
|
||||||
|
|
||||||
#: RSBN channel as a tuple of (callsign, channel).
|
#: RSBN channel as a tuple of (callsign, channel).
|
||||||
rsbn: Optional[Tuple[str, int]] = None
|
rsbn: Optional[Tuple[str, int]] = None
|
||||||
|
|
||||||
#: Dict of runway heading -> ILS tuple of (callsign, frequency).
|
|
||||||
ils: Dict[str, Tuple[str, RadioFrequency]] = field(default_factory=dict)
|
|
||||||
|
|
||||||
#: Dict of runway heading -> PRMG tuple of (callsign, channel).
|
#: Dict of runway heading -> PRMG tuple of (callsign, channel).
|
||||||
prmg: Dict[str, Tuple[str, int]] = field(default_factory=dict)
|
prmg: Dict[str, Tuple[str, int]] = field(default_factory=dict)
|
||||||
|
|
||||||
@ -86,23 +76,11 @@ class AirfieldData:
|
|||||||
|
|
||||||
_airfields: ClassVar[dict[str, dict[int, AirfieldData]]] = {}
|
_airfields: ClassVar[dict[str, dict[int, AirfieldData]]] = {}
|
||||||
|
|
||||||
def ils_freq(self, runway: str) -> Optional[RadioFrequency]:
|
|
||||||
ils = self.ils.get(runway)
|
|
||||||
if ils is not None:
|
|
||||||
return ils[1]
|
|
||||||
return None
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_file(cls, airfield_yaml: Path) -> AirfieldData:
|
def from_file(cls, airfield_yaml: Path) -> AirfieldData:
|
||||||
with airfield_yaml.open() as yaml_file:
|
with airfield_yaml.open() as yaml_file:
|
||||||
data = yaml.safe_load(yaml_file)
|
data = yaml.safe_load(yaml_file)
|
||||||
|
|
||||||
tacan_channel = None
|
|
||||||
tacan_callsign = None
|
|
||||||
if (tacan := data.get("tacan")) is not None:
|
|
||||||
tacan_channel = TacanChannel.parse(tacan["channel"])
|
|
||||||
tacan_callsign = tacan["callsign"]
|
|
||||||
|
|
||||||
vor = None
|
vor = None
|
||||||
if (vor_data := data.get("vor")) is not None:
|
if (vor_data := data.get("vor")) is not None:
|
||||||
vor = (
|
vor = (
|
||||||
@ -114,17 +92,10 @@ class AirfieldData:
|
|||||||
if (rsbn_data := data.get("rsbn")) is not None:
|
if (rsbn_data := data.get("rsbn")) is not None:
|
||||||
rsbn = (rsbn_data["callsign"], rsbn_data["channel"])
|
rsbn = (rsbn_data["callsign"], rsbn_data["channel"])
|
||||||
|
|
||||||
ils = {}
|
|
||||||
prmg = {}
|
prmg = {}
|
||||||
outer_ndb = {}
|
outer_ndb = {}
|
||||||
inner_ndb = {}
|
inner_ndb = {}
|
||||||
for name, runway_data in data.get("runways", {}).items():
|
for name, runway_data in data.get("runways", {}).items():
|
||||||
if (ils_data := runway_data.get("ils")) is not None:
|
|
||||||
ils[name] = (
|
|
||||||
ils_data["callsign"],
|
|
||||||
RadioFrequency.parse(ils_data["frequency"], Modulation.FM),
|
|
||||||
)
|
|
||||||
|
|
||||||
if (prmg_data := runway_data.get("prmg")) is not None:
|
if (prmg_data := runway_data.get("prmg")) is not None:
|
||||||
prmg[name] = (prmg_data["callsign"], prmg_data["channel"])
|
prmg[name] = (prmg_data["callsign"], prmg_data["channel"])
|
||||||
|
|
||||||
@ -146,11 +117,8 @@ class AirfieldData:
|
|||||||
data.get("icao"),
|
data.get("icao"),
|
||||||
data["elevation"],
|
data["elevation"],
|
||||||
data["runway_length"],
|
data["runway_length"],
|
||||||
tacan_channel,
|
|
||||||
tacan_callsign,
|
|
||||||
vor,
|
vor,
|
||||||
rsbn,
|
rsbn,
|
||||||
ils,
|
|
||||||
prmg,
|
prmg,
|
||||||
outer_ndb,
|
outer_ndb,
|
||||||
inner_ndb,
|
inner_ndb,
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
"""Runway information and selection."""
|
"""Runway information and selection."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Iterator, Optional, TYPE_CHECKING
|
from typing import Iterator, Optional, TYPE_CHECKING
|
||||||
|
|
||||||
from dcs.terrain.terrain import Airport, RunwayApproach
|
from dcs.terrain.terrain import Airport, RunwayApproach
|
||||||
|
|
||||||
from game.airfields import AirfieldData, AtcData
|
from game.airfields import AtcData
|
||||||
|
from game.dcs.beacons import BeaconType, Beacons
|
||||||
from game.radio.radios import RadioFrequency
|
from game.radio.radios import RadioFrequency
|
||||||
from game.radio.tacan import TacanChannel
|
from game.radio.tacan import TacanChannel
|
||||||
from game.utils import Heading
|
from game.utils import Heading
|
||||||
@ -50,13 +50,17 @@ class RunwayData:
|
|||||||
if atc_radio is not None:
|
if atc_radio is not None:
|
||||||
atc = atc_radio.uhf
|
atc = atc_radio.uhf
|
||||||
|
|
||||||
try:
|
for beacon_data in airport.beacons:
|
||||||
airfield = AirfieldData.for_airport(theater, airport)
|
beacon = Beacons.with_id(beacon_data.id, theater)
|
||||||
tacan = airfield.tacan
|
if beacon.is_tacan:
|
||||||
tacan_callsign = airfield.tacan_callsign
|
tacan = beacon.tacan_channel
|
||||||
ils = airfield.ils_freq(runway.name)
|
tacan_callsign = beacon.callsign
|
||||||
except KeyError:
|
|
||||||
logging.warning(f"No airfield data for {airport.name} ({airport.id}")
|
for beacon_data in runway.beacons:
|
||||||
|
beacon = Beacons.with_id(beacon_data.id, theater)
|
||||||
|
if beacon.beacon_type is BeaconType.BEACON_TYPE_ILS_GLIDESLOPE:
|
||||||
|
ils = beacon.frequency
|
||||||
|
|
||||||
return cls(
|
return cls(
|
||||||
airfield_name=airport.name,
|
airfield_name=airport.name,
|
||||||
runway_heading=Heading(runway.heading),
|
runway_heading=Heading(runway.heading),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user