Skip to content

Commit

Permalink
[uss_qualifier/flight_planning/flight_intent_validation] Enhance time…
Browse files Browse the repository at this point in the history
… start/end parameter names (#685)
  • Loading branch information
mickmis authored May 8, 2024
1 parent d8b0c25 commit b0eeef4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ class ExpectedFlightIntent(object):
uas_state: Optional[UasState] = None
f3548v21_priority_higher_than: Optional[List[FlightIntentName]] = None
f3548v21_priority_equal_to: Optional[List[FlightIntentName]] = None
time_start_min_bound: Optional[StringBasedTimeDelta] = None
time_start_max_bound: Optional[StringBasedTimeDelta] = None
time_end_min_bound: Optional[StringBasedTimeDelta] = None
time_end_max_bound: Optional[StringBasedTimeDelta] = None
earliest_time_start: Optional[StringBasedTimeDelta] = None
latest_time_start: Optional[StringBasedTimeDelta] = None
earliest_time_end: Optional[StringBasedTimeDelta] = None
latest_time_end: Optional[StringBasedTimeDelta] = None
valid_uspace_flight_auth: Optional[bool] = None


Expand Down Expand Up @@ -223,42 +223,40 @@ def named_intents(

# Ensure start/end times within required bounds
if (
expected_intent.time_start_min_bound or expected_intent.time_start_max_bound
expected_intent.earliest_time_start or expected_intent.latest_time_start
) and not intent.basic_information.area.time_start:
raise ValueError(
f"Flight intent `{expected_intent.intent_id}` has a time_start bound requirement but has no time_start specified"
)
if (
expected_intent.time_end_min_bound or expected_intent.time_end_max_bound
expected_intent.earliest_time_end or expected_intent.latest_time_end
) and not intent.basic_information.area.time_end:
raise ValueError(
f"Flight intent `{expected_intent.intent_id}` has a time_end bound requirement but has no time_end specified"
)

if expected_intent.time_start_min_bound:
if expected_intent.earliest_time_start:
min_start_time = (
now.datetime + expected_intent.time_start_min_bound.timedelta
now.datetime + expected_intent.earliest_time_start.timedelta
)
if intent.basic_information.area.time_start.datetime < min_start_time:
raise ValueError(
f"Flight intent `{expected_intent.intent_id}` must have time_start ({intent.basic_information.area.time_start.datetime}) >= min_start_time ({min_start_time})"
)
if expected_intent.time_start_max_bound:
max_start_time = (
now.datetime + expected_intent.time_start_max_bound.timedelta
)
if expected_intent.latest_time_start:
max_start_time = now.datetime + expected_intent.latest_time_start.timedelta
if intent.basic_information.area.time_start.datetime > max_start_time:
raise ValueError(
f"Flight intent `{expected_intent.intent_id}` must have time_start ({intent.basic_information.area.time_start.datetime}) <= max_start_time ({max_start_time})"
)
if expected_intent.time_end_min_bound:
min_end_time = now.datetime + expected_intent.time_end_min_bound.timedelta
if expected_intent.earliest_time_end:
min_end_time = now.datetime + expected_intent.earliest_time_end.timedelta
if intent.basic_information.area.time_end.datetime < min_end_time:
raise ValueError(
f"Flight intent `{expected_intent.intent_id}` must have time_end ({intent.basic_information.area.time_end.datetime}) >= min_end_time ({min_end_time})"
)
if expected_intent.time_end_max_bound:
max_end_time = now.datetime + expected_intent.time_end_max_bound.timedelta
if expected_intent.latest_time_end:
max_end_time = now.datetime + expected_intent.latest_time_end.timedelta
if intent.basic_information.area.time_end.datetime > max_end_time:
raise ValueError(
f"Flight intent `{expected_intent.intent_id}` must have time_end ({intent.basic_information.area.time_end.datetime}) <= max_end_time ({max_end_time})"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def __init__(
"Too Far Away Flight",
usage_state=AirspaceUsageState.Planned,
uas_state=UasState.Nominal,
time_start_min_bound=StringBasedTimeDelta(
earliest_time_start=StringBasedTimeDelta(
timedelta(days=OiMaxPlanHorizonDays)
),
),
Expand All @@ -112,10 +112,10 @@ def __init__(
"Recently Ended Flight",
usage_state=AirspaceUsageState.Planned,
uas_state=UasState.Nominal,
time_end_min_bound=StringBasedTimeDelta(
earliest_time_end=StringBasedTimeDelta(
timedelta(seconds=-TimeSyncMaxDifferentialSeconds - 5)
),
time_end_max_bound=StringBasedTimeDelta(
latest_time_end=StringBasedTimeDelta(
timedelta(seconds=-TimeSyncMaxDifferentialSeconds)
),
),
Expand Down

0 comments on commit b0eeef4

Please sign in to comment.