31 lines
849 B
Python
31 lines
849 B
Python
from __future__ import annotations
|
|
|
|
from fastapi import APIRouter, Depends
|
|
|
|
from app.models.schemas import LinkRequest, LinkResponse
|
|
from app.services.link_calculator import LinkCalculator
|
|
|
|
router = APIRouter(prefix="/v1", tags=["link"])
|
|
|
|
|
|
def get_link_calculator() -> LinkCalculator:
|
|
from app.main import link_calculator
|
|
|
|
return link_calculator
|
|
|
|
|
|
@router.post("/link", response_model=LinkResponse)
|
|
async def calculate_link(
|
|
request: LinkRequest,
|
|
calculator: LinkCalculator = Depends(get_link_calculator),
|
|
) -> LinkResponse:
|
|
return await calculator.calculate_link(
|
|
from_pt=request.from_,
|
|
to_pt=request.to,
|
|
frequency_mhz=request.frequency_mhz,
|
|
fresnel_clearance=request.fresnel_clearance,
|
|
tx_power_dbm=request.tx_power_dbm,
|
|
rx_sensitivity_dbm=request.rx_sensitivity_dbm,
|
|
sample_step_m=request.sample_step_m,
|
|
)
|