Add QNH and temperature to the kneeboard.

This commit is contained in:
Magnus Wolffelt 2021-07-16 00:34:58 +02:00 committed by GitHub
parent 62036a273e
commit 2b696144e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 3 deletions

View File

@ -3,6 +3,7 @@ from typing import Optional
from dcs.mission import Mission from dcs.mission import Mission
from game.weather import Clouds, Fog, Conditions, WindConditions, AtmosphericConditions from game.weather import Clouds, Fog, Conditions, WindConditions, AtmosphericConditions
from .units import inches_hg_to_mm_hg
class EnvironmentGenerator: class EnvironmentGenerator:
@ -11,8 +12,7 @@ class EnvironmentGenerator:
self.conditions = conditions self.conditions = conditions
def set_atmospheric(self, atmospheric: AtmosphericConditions) -> None: def set_atmospheric(self, atmospheric: AtmosphericConditions) -> None:
inch_to_mm = 25.400002776728 self.mission.weather.qnh = inches_hg_to_mm_hg(atmospheric.qnh_inches_mercury)
self.mission.weather.qnh = atmospheric.qnh_inches_mercury * inch_to_mm
self.mission.weather.season_temperature = atmospheric.temperature_celsius self.mission.weather.season_temperature = atmospheric.temperature_celsius
def set_clouds(self, clouds: Optional[Clouds]) -> None: def set_clouds(self, clouds: Optional[Clouds]) -> None:

View File

@ -39,6 +39,7 @@ from game.db import unit_type_from_name
from game.dcs.aircrafttype import AircraftType from game.dcs.aircrafttype import AircraftType
from game.theater import ConflictTheater, TheaterGroundObject, LatLon from game.theater import ConflictTheater, TheaterGroundObject, LatLon
from game.theater.bullseye import Bullseye from game.theater.bullseye import Bullseye
from game.weather import Weather
from game.utils import meters from game.utils import meters
from .aircraft import FlightData from .aircraft import FlightData
from .airsupportgen import AwacsInfo, TankerInfo from .airsupportgen import AwacsInfo, TankerInfo
@ -46,6 +47,7 @@ from .briefinggen import CommInfo, JtacInfo, MissionInfoGenerator
from .flights.flight import FlightWaypoint, FlightWaypointType, FlightType from .flights.flight import FlightWaypoint, FlightWaypointType, FlightType
from .radios import RadioFrequency from .radios import RadioFrequency
from .runways import RunwayData from .runways import RunwayData
from .units import inches_hg_to_mm_hg, inches_hg_to_hpa
if TYPE_CHECKING: if TYPE_CHECKING:
from game import Game from game import Game
@ -265,12 +267,14 @@ class BriefingPage(KneeboardPage):
flight: FlightData, flight: FlightData,
bullseye: Bullseye, bullseye: Bullseye,
theater: ConflictTheater, theater: ConflictTheater,
weather: Weather,
start_time: datetime.datetime, start_time: datetime.datetime,
dark_kneeboard: bool, dark_kneeboard: bool,
) -> None: ) -> None:
self.flight = flight self.flight = flight
self.bullseye = bullseye self.bullseye = bullseye
self.theater = theater self.theater = theater
self.weather = weather
self.start_time = start_time self.start_time = start_time
self.dark_kneeboard = dark_kneeboard self.dark_kneeboard = dark_kneeboard
@ -304,6 +308,18 @@ class BriefingPage(KneeboardPage):
writer.text(f"Bullseye: {self.bullseye.to_lat_lon(self.theater).format_dms()}") writer.text(f"Bullseye: {self.bullseye.to_lat_lon(self.theater).format_dms()}")
qnh_in_hg = "{:.2f}".format(self.weather.atmospheric.qnh_inches_mercury)
qnh_mm_hg = "{:.1f}".format(
inches_hg_to_mm_hg(self.weather.atmospheric.qnh_inches_mercury)
)
qnh_hpa = "{:.1f}".format(
inches_hg_to_hpa(self.weather.atmospheric.qnh_inches_mercury)
)
writer.text(
f"Temperature: {round(self.weather.atmospheric.temperature_celsius)} °C at sea level"
)
writer.text(f"QNH: {qnh_in_hg} inHg / {qnh_mm_hg} mmHg / {qnh_hpa} hPa")
writer.table( writer.table(
[ [
[ [
@ -634,6 +650,7 @@ class KneeboardGenerator(MissionInfoGenerator):
flight, flight,
self.game.bullseye_for(flight.friendly), self.game.bullseye_for(flight.friendly),
self.game.theater, self.game.theater,
self.game.conditions.weather,
self.mission.start_time, self.mission.start_time,
self.dark_kneeboard, self.dark_kneeboard,
), ),

View File

@ -2,5 +2,15 @@
def meters_to_feet(meters: float) -> float: def meters_to_feet(meters: float) -> float:
"""Convers meters to feet.""" """Converts meters to feet."""
return meters * 3.28084 return meters * 3.28084
def inches_hg_to_mm_hg(inches_hg: float) -> float:
"""Converts inches mercury to millimeters mercury."""
return inches_hg * 25.400002776728
def inches_hg_to_hpa(inches_hg: float) -> float:
"""Converts inches mercury to hectopascal."""
return inches_hg * 33.86389