use uom::si::f64::{Length, RadiantExposure};
use crate::equations::{intermediate_afb_from_e, interpolate};
use crate::{Cubicle, EAfb, NominalVoltage};
pub fn multistep_e_and_afb(c: &Cubicle, calc_steps: &[EAfb]) -> (RadiantExposure, Length) {
let total_e = calc_steps.iter().map(|e_afb| e_afb.e()).sum();
let total_afb = if c.hv {
let total_e_600 = calc_steps.iter().map(|e_afb| e_afb.hv().e_600).sum();
let total_e_2700 = calc_steps.iter().map(|e_afb| e_afb.hv().e_2700).sum();
let total_e_14300 = calc_steps.iter().map(|e_afb| e_afb.hv().e_14300).sum();
let afb_600 = intermediate_afb_from_e(c, NominalVoltage::V600, total_e_600);
let afb_2700 = intermediate_afb_from_e(c, NominalVoltage::V2700, total_e_2700);
let afb_14300 = intermediate_afb_from_e(c, NominalVoltage::V14300, total_e_14300);
interpolate!(c, afb_600, afb_2700, afb_14300)
} else {
intermediate_afb_from_e(c, NominalVoltage::V600, total_e)
};
(total_e, total_afb)
}