Real-Time Modeling and Control of a Cyber-Physical Energy System