Control of distributed generation for grid-connected and intentional islanding operations