Add TOT/TOS to kneeboard for AWACS & Tankers

This commit is contained in:
Raffson 2023-02-04 19:56:06 +01:00
parent 7625725fd8
commit 29d88fd61d
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
3 changed files with 30 additions and 15 deletions

View File

@ -157,8 +157,8 @@ class FlightGroupConfigurator:
callsign=callsign,
freq=channel,
depature_location=self.flight.departure.name,
end_time=self.flight.flight_plan.mission_departure_time,
start_time=self.flight.flight_plan.takeoff_time(),
start_time=self.flight.flight_plan.patrol_start_time,
end_time=self.flight.flight_plan.patrol_end_time,
blue=self.flight.departure.captured,
)
)

View File

@ -27,7 +27,6 @@ import math
import textwrap
from collections import defaultdict
from dataclasses import dataclass
from itertools import groupby
from pathlib import Path
from typing import Dict, Iterator, List, Optional, TYPE_CHECKING, Tuple
@ -514,6 +513,8 @@ class SupportPage(KneeboardPage):
writer.heading(f"{package.package_description} Package{custom}")
freq = self.format_frequency(package.frequency).replace("\n", " - ")
writer.text(f" FREQ: {freq}", font=writer.table_font)
tot = self._format_time(package.time_over_target)
writer.text(f" TOT: {tot}", font=writer.table_font)
comm_ladder = []
for comm in self.comms:
comm_ladder.append(
@ -544,30 +545,33 @@ class SupportPage(KneeboardPage):
for single_aewc in self.awacs:
if single_aewc.depature_location is None:
dep = "-"
arr = "-"
tot = "-"
tos = "-"
else:
dep = self._format_time(single_aewc.start_time)
arr = self._format_time(single_aewc.end_time)
tot = self._format_time(single_aewc.start_time)
tos = self._format_duration(
single_aewc.end_time - single_aewc.start_time
)
aewc_ladder.append(
[
str(single_aewc.callsign),
self.format_frequency(single_aewc.freq),
str(single_aewc.depature_location),
str(dep),
str(arr),
"TOT: " + tot + "\n" + "TOS: " + tos,
]
)
writer.table(
aewc_ladder,
headers=["Callsign", "FREQ", "Depature", "ETD", "ETA"],
headers=["Callsign", "FREQ", "Departure", "TOT / TOS"],
)
comm_ladder = []
writer.heading("Tankers:")
for tanker in self.tankers:
tot = self._format_time(tanker.start_time)
tos = self._format_duration(tanker.end_time - tanker.start_time)
comm_ladder.append(
[
tanker.callsign,
@ -575,10 +579,14 @@ class SupportPage(KneeboardPage):
tanker.variant,
str(tanker.tacan),
self.format_frequency(tanker.freq),
"TOT: " + tot + "\n" + "TOS: " + tos,
]
)
writer.table(comm_ladder, headers=["Callsign", "Task", "Type", "TACAN", "FREQ"])
writer.table(
comm_ladder,
headers=["Callsign", "Task", "Type", "TACAN", "FREQ", "TOT / TOS"],
)
writer.heading("JTAC")
jtacs = []
@ -616,6 +624,13 @@ class SupportPage(KneeboardPage):
local_time = self.start_time + time
return f"{local_time.strftime('%H:%M:%S')}{'Z' if local_time.tzinfo is not None else ''}"
@staticmethod
def _format_duration(time: Optional[datetime.timedelta]) -> str:
if time is None:
return ""
time -= datetime.timedelta(microseconds=time.microseconds)
return f"{time}"
class SeadTaskPage(KneeboardPage):
"""A kneeboard page containing SEAD/DEAD target information."""

View File

@ -33,8 +33,8 @@ class AwacsInfo(GroupInfo):
"""AWACS information for the kneeboard."""
depature_location: Optional[str]
start_time: Optional[timedelta]
end_time: Optional[timedelta]
start_time: timedelta
end_time: timedelta
@dataclass
@ -43,8 +43,8 @@ class TankerInfo(GroupInfo):
variant: str
tacan: TacanChannel
start_time: Optional[timedelta]
end_time: Optional[timedelta]
start_time: timedelta
end_time: timedelta
@dataclass