public Propogation CurrentPropogation(string countryFixedName, RadioInfo.BandName band) { int hn = DateTime.UtcNow.Hour; int hf = hn == 24 ? 0 : hn + 1; try { Propogation psn = GetPropogationRel(countryFixedName, band, "S", hn); //psn = Prop Short Now Propogation pln = GetPropogationRel(countryFixedName, band, "L", hn); Propogation psf = GetPropogationRel(countryFixedName, band, "S", hf); Propogation plf = GetPropogationRel(countryFixedName, band, "L", hf); if (psn.Rel >= pln.Rel) { return(InterpolatePropogation(psn, psf)); } else { return(InterpolatePropogation(pln, plf)); } } catch (Exception) { return(new Propogation(countryFixedName, 0, "S", -1, band)); //Dont rethrow, just return the negative REL. } }
/// <summary> /// Linear interpolation between propogations. /// </summary> /// <param name="pn"></param> /// <param name="pf"></param> /// <returns></returns> private Propogation InterpolatePropogation(Propogation pn, Propogation pf) { float hfract = (float)DateTime.UtcNow.Minute / 60; float newrel = pn.Rel + ((pf.Rel - pn.Rel) * hfract); return(new Propogation(pn.Country, pn.Hour + hfract, pn.Path, newrel, pn.Band)); }