Function generation and regulation libraries and their application to the control of the new main power converters (POPS) at the CERN CPS