/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sidnet.utilityviews.statscollector;

import sidnet.core.misc.Node;

/**
 *
 * @author Oliver
 */
public class StatEntry_AverageEnergyLeftPercentage extends StatEntry{
    private double averageEnergyLeftPercentage = 0;

    public StatEntry_AverageEnergyLeftPercentage() {
        this("AverageEnergyLeftPercentage"); // default header
    }

    public StatEntry_AverageEnergyLeftPercentage(String customHeader)
    {
        super(customHeader);
    }
            
    
    /**
     * @inheridoc
     */
    public String getValueAsString()
    {
        return "" + averageEnergyLeftPercentage;
    }
    
    /**
     * @inheridoc
     */
   public void update(Node[] nodes)
   {
       averageEnergyLeftPercentage = 0;
       for (int i = 0; i < nodes.length; i++)
           averageEnergyLeftPercentage += nodes[i].getEnergyManagement().getBattery().getPercentageEnergyLevel();
       averageEnergyLeftPercentage /= nodes.length;
   }

}
