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] Add generic flight_planning client #234

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
9 changes: 9 additions & 0 deletions monitoring/mock_uss/scdsc/flight_planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from monitoring.monitorlib.geotemporal import Volume4DCollection
from monitoring.monitorlib.locality import Locality
from monitoring.monitorlib.uspace import problems_with_flight_authorisation
from uas_standards.interuss.automated_testing.scd.v1.api import OperationalIntentState


class PlanningError(Exception):
Expand Down Expand Up @@ -47,6 +48,7 @@ def validate_request(req_body: scd_api.InjectFlightRequest, locality: Locality)
# Validate max planning horizon for creation
start_time = Volume4DCollection.from_interuss_scd_api(
req_body.operational_intent.volumes
+ req_body.operational_intent.off_nominal_volumes
).time_start.datetime
time_delta = start_time - datetime.now(tz=start_time.tzinfo)
if (
Expand Down Expand Up @@ -87,6 +89,13 @@ def check_for_disallowed_conflicts(
if log is None:
log = lambda msg: None

if req_body.operational_intent.state not in (
OperationalIntentState.Accepted,
OperationalIntentState.Activated,
):
# No conflicts are disallowed if the flight is not nominal
return

v1 = Volume4DCollection.from_interuss_scd_api(req_body.operational_intent.volumes)

for op_intent in op_intents:
Expand Down
6 changes: 4 additions & 2 deletions monitoring/mock_uss/scdsc/routes_injection.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,11 @@ def log(msg: str):
# Check for operational intents in the DSS
step_name = "querying for operational intents"
log("Obtaining latest operational intent information")
vol4 = Volume4DCollection.from_interuss_scd_api(
v1 = Volume4DCollection.from_interuss_scd_api(
req_body.operational_intent.volumes
).bounding_volume.to_f3548v21()
+ req_body.operational_intent.off_nominal_volumes
)
vol4 = v1.bounding_volume.to_f3548v21()
op_intents = query_operational_intents(vol4)

# Check for intersections
Expand Down
Empty file.
94 changes: 94 additions & 0 deletions monitoring/monitorlib/clients/flight_planning/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
from abc import ABC, abstractmethod
from typing import List, Optional, Union

from monitoring.monitorlib.clients.flight_planning.test_preparation import (
TestPreparationActivityResponse,
)

from monitoring.monitorlib.clients.flight_planning.flight_info import (
FlightInfo,
FlightID,
ExecutionStyle,
)
from monitoring.monitorlib.clients.flight_planning.planning import (
PlanningActivityResponse,
)
from monitoring.monitorlib.fetch import Query
from monitoring.monitorlib.geotemporal import Volume4D


class PlanningActivityError(Exception):
queries: List[Query]

def __init__(
self, message: str, queries: Optional[Union[Query, List[Query]]] = None
):
super(PlanningActivityError, self).__init__(message)
if queries is None:
self.queries = []
elif isinstance(queries, Query):
self.queries = [queries]
else:
self.queries = queries


class FlightPlannerClient(ABC):
"""Client to interact with a USS as a user performing flight planning activities and as the test director preparing for tests involving flight planning activities."""

# ===== Emulation of user actions =====

@abstractmethod
def try_plan_flight(
self, flight_info: FlightInfo, execution_style: ExecutionStyle
) -> PlanningActivityResponse:
"""Instruct the USS to emulate a normal user trying to plan the described flight.

Raises:
* PlanningActivityError
"""
raise NotImplementedError()

@abstractmethod
def try_update_flight(
self,
flight_id: FlightID,
updated_flight_info: FlightInfo,
execution_style: ExecutionStyle,
) -> PlanningActivityResponse:
"""Instruct the USS to emulate a normal user trying to update the specified flight as described.

Raises:
* PlanningActivityError
"""
raise NotImplementedError()

@abstractmethod
def try_end_flight(
self, flight_id: FlightID, execution_style: ExecutionStyle
) -> PlanningActivityResponse:
"""Instruct the USS to emulate a normal user trying to end the specified flight.

Raises:
* PlanningActivityError
"""
raise NotImplementedError()

# ===== Test preparation activities =====

@abstractmethod
def report_readiness(self) -> TestPreparationActivityResponse:
"""Acting as test director, ask the USS about its readiness to use its flight planning interface for automated testing.

Raises:
* PlanningActivityError
"""
raise NotImplementedError()

@abstractmethod
def clear_area(self, area: Volume4D) -> TestPreparationActivityResponse:
"""Acting as test director, instruct the USS to close/end/remove all flights it manages within the specified area.

Raises:
* PlanningActivityError
"""
raise NotImplementedError()
Loading
Loading