#[derive(Debug, Clone, Copy, PartialEq)]
pub struct LinkBudget {
    pub distance_km: f64,
    pub tx_power_w: f64,
    pub antenna_gain_db: f64,
    pub path_loss_db: f64,
}

impl LinkBudget {
    pub fn received_margin_db(&self, required_margin_db: f64) -> f64 {
        self.tx_power_w.max(1e-6).log10() * 10.0 + self.antenna_gain_db
            - self.path_loss_db
            - required_margin_db
    }
}

pub fn mars_orbiter_relay() -> LinkBudget {
    LinkBudget {
        distance_km: 9_376_000.0 / 1_000.0,
        tx_power_w: 25.0,
        antenna_gain_db: 22.0,
        path_loss_db: 240.0,
    }
}
