Real-Time Simulation and Close-Loop Testing of Microgrids