Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[monitorlib] Clean up geotemporal business objects #316

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions monitoring/mock_uss/f3548v21/flight_planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
from monitoring.mock_uss.config import KEY_BASE_URL
from monitoring.monitorlib.clients.flight_planning.flight_info import (
FlightInfo,
AirspaceUsageState,
UasState,
)
from monitoring.uss_qualifier.resources.overrides import apply_overrides
from uas_standards.astm.f3548.v21 import api as f3548_v21
Expand Down Expand Up @@ -235,7 +233,7 @@ def op_intent_from_flightinfo(
off_nominal_volumes = volumes
volumes = []

v4c = Volume4DCollection(volumes=flight_info.basic_information.area)
v4c = flight_info.basic_information.area

reference = f3548_v21.OperationalIntentReference(
id=f3548_v21.EntityID(flight_id),
Expand Down
8 changes: 5 additions & 3 deletions monitoring/monitorlib/clients/flight_planning/flight_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class BasicFlightPlanInformation(ImplicitDict):
uas_state: UasState
"""State of the user's UAS associated with this flight plan."""

area: List[Volume4D]
area: Volume4DCollection
"""User intends to or may fly anywhere in this entire area."""

@staticmethod
Expand All @@ -219,7 +219,9 @@ def from_flight_planning_api(
return BasicFlightPlanInformation(
usage_state=AirspaceUsageState(info.usage_state),
uas_state=UasState(info.uas_state),
area=[Volume4D.from_flight_planning_api(v) for v in info.area],
area=Volume4DCollection(
[Volume4D.from_flight_planning_api(v) for v in info.area]
),
)

def to_flight_planning_api(self) -> fp_api.BasicFlightPlanInformation:
Expand Down Expand Up @@ -339,7 +341,7 @@ def from_scd_inject_flight_request(
basic_information = BasicFlightPlanInformation(
usage_state=usage_states[request.operational_intent.state],
uas_state=uas_states[request.operational_intent.state],
area=v4c.volumes,
area=v4c,
)
astm_f3548v21 = ASTMF354821OpIntentInformation(
priority=request.operational_intent.priority
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from datetime import datetime
from typing import List, Optional
from typing import Optional

from implicitdict import ImplicitDict

Expand All @@ -12,7 +11,11 @@
BasicFlightPlanInformation,
FlightInfo,
)
from monitoring.monitorlib.geotemporal import Volume4DTemplate, resolve_volume4d
from monitoring.monitorlib.geotemporal import (
Volume4DTemplateCollection,
Volume4DCollection,
)
from monitoring.monitorlib.temporal import Time
from uas_standards.interuss.automated_testing.scd.v1 import api as scd_api


Expand All @@ -25,12 +28,14 @@ class BasicFlightPlanInformationTemplate(ImplicitDict):
uas_state: UasState
"""State of the user's UAS associated with this flight plan."""

area: List[Volume4DTemplate]
area: Volume4DTemplateCollection
"""User intends to or may fly anywhere in this entire area."""

def resolve(self, start_of_test: datetime) -> BasicFlightPlanInformation:
def resolve(self, start_of_test: Time) -> BasicFlightPlanInformation:
kwargs = {k: v for k, v in self.items()}
kwargs["area"] = [resolve_volume4d(t, start_of_test) for t in self.area]
kwargs["area"] = Volume4DCollection(
[t.resolve(start_of_test) for t in self.area]
)
return ImplicitDict.parse(kwargs, BasicFlightPlanInformation)


Expand All @@ -48,14 +53,12 @@ class FlightInfoTemplate(ImplicitDict):
additional_information: Optional[dict]
"""Any information relevant to a particular jurisdiction or use case not described in the standard schema. The keys and values must be agreed upon between the test designers and USSs under test."""

def resolve(self, start_of_test: datetime) -> FlightInfo:
def resolve(self, start_of_test: Time) -> FlightInfo:
kwargs = {k: v for k, v in self.items()}
kwargs["basic_information"] = self.basic_information.resolve(start_of_test)
return ImplicitDict.parse(kwargs, FlightInfo)

def scd_inject_request(
self, start_of_test: datetime
) -> scd_api.InjectFlightRequest:
def to_scd_inject_request(self, start_of_test: Time) -> scd_api.InjectFlightRequest:
"""Render a legacy SCD injection API request object from this object."""

info = self.resolve(start_of_test)
Expand Down
Loading
Loading