Flexible, secure energy management system