Text this: Energy management of microgrids in grid-connected mode with power quality constraints