Imlement total energy counter