Download env/runway.py from PunitRaveendran/Air_Traffic_Control_System: direct link, hf CLI and curl.
- Browser
- Download file 1.57 kB
-
https://huggingface.co/spaces/PunitRaveendran/Air_Traffic_Control_System/resolve/main/env/runway.py
- Command line
-
hf download hf://spaces/PunitRaveendran/Air_Traffic_Control_System/env/runway.py
-
curl -L -o runway.py https://huggingface.co/spaces/PunitRaveendran/Air_Traffic_Control_System/resolve/main/env/runway.py
1.57 kB
| """Runway models and operations.""" | |
| from enum import Enum | |
| from typing import Optional | |
| from pydantic import BaseModel | |
| class RunwayStatus(str, Enum): | |
| OPEN = "OPEN" | |
| REDUCED = "REDUCED" | |
| CLOSED = "CLOSED" | |
| class Runway(BaseModel): | |
| id: str | |
| status: RunwayStatus = RunwayStatus.OPEN | |
| next_available_step: int = 0 | |
| current_occupant: Optional[str] = None | |
| def separation_steps(self) -> int: | |
| """Separation steps required between aircraft.""" | |
| return 2 if self.status == RunwayStatus.OPEN else 4 | |
| def is_available(self) -> bool: | |
| """Check if runway is available for new assignment.""" | |
| return self.status != RunwayStatus.CLOSED | |
| def occupy(self, aircraft_id: str, current_step: int) -> None: | |
| """Assign aircraft to runway and set next available time.""" | |
| self.current_occupant = aircraft_id | |
| self.next_available_step = current_step + self.separation_steps | |
| def tick(self, current_step: int) -> None: | |
| """Update runway availability based on current step.""" | |
| if ( | |
| self.current_occupant is not None | |
| and current_step >= self.next_available_step | |
| ): | |
| self.current_occupant = None | |
| def close(self) -> None: | |
| """Close the runway.""" | |
| self.status = RunwayStatus.CLOSED | |
| self.current_occupant = None | |
| def reduce(self) -> None: | |
| """Reduce runway capacity (increase separation).""" | |
| if self.status == RunwayStatus.OPEN: | |
| self.status = RunwayStatus.REDUCED |