Development of Control Algorithms for Energy Storage Systems in a Distribution Network