package org.lucci.madhoc.network.monitor.measure;

import org.lucci.madhoc.network.Connection;
import org.lucci.madhoc.simulation.measure.NaturalIntegerSensor;
import org.lucci.madhoc.simulation.measure.Unit;
import org.lucci.madhoc.simulation.projection.Projection;

/*
 * Created on Jul 7, 2004
 */

/**
 * @author luc.hogie
 */

public class NumberOfManualConnections extends NaturalIntegerSensor
{
    /* (non-Javadoc)
     * @see org.lucci.madhoc.simulation.Measure#takeNewValue(org.lucci.madhoc.simulation.Simulation)
     */
    public Integer takeNewIntegerValue(Projection projection)
    {
        int n = 0;

        for (Connection c : getMonitor().getNetwork().findConnections())
        {
            if (!c.getNetworkType().isAutomatic())
            {
                ++n;
            }
        }
        
        return n;
    }

        /* (non-Javadoc)
         * @see org.lucci.madhoc.simulation.Measure#getName()
         */
        public String getName()
        {
            return "number of manual connections";
        }

        /* (non-Javadoc)
         * @see org.lucci.madhoc.simulation.NumericalMeasure#getUnit()
         */
        public Unit getUnit()
        {
            return Unit.NUMBER_OF_CONNECTION;
        }
    
}