mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Allow operation.py to ignore TACAN rules
This commit is contained in:
13
gen/tacan.py
13
gen/tacan.py
@@ -103,7 +103,12 @@ class TacanRegistry:
|
||||
except StopIteration:
|
||||
raise OutOfTacanChannelsError(band)
|
||||
|
||||
def reserve(self, channel: TacanChannel, intended_usage: TacanUsage) -> None:
|
||||
def reserve(
|
||||
self,
|
||||
channel: TacanChannel,
|
||||
intended_usage: TacanUsage,
|
||||
ignore_rules: bool = False,
|
||||
) -> None:
|
||||
"""Reserves the given channel.
|
||||
|
||||
Reserving a channel ensures that it will not be allocated in the future.
|
||||
@@ -111,13 +116,15 @@ class TacanRegistry:
|
||||
Args:
|
||||
channel: The channel to reserve.
|
||||
intended_usage: What the caller intends to use the tacan channel for.
|
||||
ignore_rules: Whether to reserve regardless of recommended rules.
|
||||
|
||||
Raises:
|
||||
TacanChannelInUseError: The given channel is already in use.
|
||||
TacanChannelForbiddenError: The given channel is forbidden.
|
||||
"""
|
||||
if channel.number in UNAVAILABLE[intended_usage][channel.band]:
|
||||
raise TacanChannelForbiddenError(channel)
|
||||
if not ignore_rules:
|
||||
if channel.number in UNAVAILABLE[intended_usage][channel.band]:
|
||||
raise TacanChannelForbiddenError(channel)
|
||||
if channel in self.allocated_channels:
|
||||
raise TacanChannelInUseError(channel)
|
||||
self.allocated_channels.add(channel)
|
||||
|
||||
Reference in New Issue
Block a user