Spaces:
Sleeping
Sleeping
Upload schemas.py
Browse files- schemas.py +35 -0
schemas.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pydantic import BaseModel, Field, field_validator
|
| 2 |
+
from typing import Optional, Literal
|
| 3 |
+
|
| 4 |
+
class TakeoffRequest(BaseModel):
|
| 5 |
+
altitude_ft: Optional[float] = Field(None, description="Indicated altitude in feet")
|
| 6 |
+
qnh_hpa: Optional[float] = Field(1013.25, description="QNH pressure setting in hPa")
|
| 7 |
+
temperature_c: Optional[float] = Field(None, description="Outside air temperature in Celsius")
|
| 8 |
+
weight_kg: Optional[float] = Field(None, description="Aircraft mass in kg")
|
| 9 |
+
wind_type: Literal["Headwind", "Tailwind"] = Field("Headwind", description="Direction of wind component")
|
| 10 |
+
wind_speed_kt: Optional[float] = Field(None, description="Wind speed in knots")
|
| 11 |
+
safety_factor: float = Field(1.0, description="Safety factor multiplier (usually 1.0 to 1.5)")
|
| 12 |
+
|
| 13 |
+
@field_validator('weight_kg')
|
| 14 |
+
def check_weight(cls, v):
|
| 15 |
+
if v is not None and (v < 800 or v > 1500):
|
| 16 |
+
# Soft warning logic could go here, but for now we just validate bounds roughly
|
| 17 |
+
pass
|
| 18 |
+
return v
|
| 19 |
+
|
| 20 |
+
def is_complete(self) -> bool:
|
| 21 |
+
"""Checks if all mandatory fields are present."""
|
| 22 |
+
return all(x is not None for x in [
|
| 23 |
+
self.altitude_ft,
|
| 24 |
+
self.temperature_c,
|
| 25 |
+
self.weight_kg,
|
| 26 |
+
self.wind_speed_kt
|
| 27 |
+
])
|
| 28 |
+
|
| 29 |
+
def get_missing_fields(self) -> list[str]:
|
| 30 |
+
missing = []
|
| 31 |
+
if self.altitude_ft is None: missing.append("Altitude")
|
| 32 |
+
if self.temperature_c is None: missing.append("Temperature")
|
| 33 |
+
if self.weight_kg is None: missing.append("Aircraft Weight")
|
| 34 |
+
if self.wind_speed_kt is None: missing.append("Wind Speed")
|
| 35 |
+
return missing
|