A component-based design approach for energy flexibility management in cyber-physical systems