package atmsdriver.network.model;

import java.util.List;

/** A LoopDetectorStation is a simulation of a station in a traffic network.
 *  
 *  A LoopDetectorStation (LDS) contains static meta data about the station, and
 *  two dynamic attributes, MLTotVol and OppTotVol. 
 * 
 *  A single LDS contains multiple LoopDetectors, which
 *  contain data for a single lane on one direction of the freeway. A LDS
 *  is specific to a single freeway, direction, and postmile.
 *
 * @author John A. Torres
 * @version 9/10/2017
 */
public class LoopDetectorStation {
    /* Static LoopDetectorStation meta data */
    final private int lineNum;
    final private int ldsID; // double check
    final private int drop;
    final private String location;
    final private List<LoopDetector> loops;
    final private int freeway;
    final private double postmile;
    final private DIRECTION direction;
    
    /* Dynamic LoopDetectorStation data */
    private int MLTotVol;
    private int OppTotVol;
    
    /* Constructor */
    public LoopDetectorStation(int lineNum, int ldsID, int drop,
            String location, List<LoopDetector> loops, int fwy, 
            DIRECTION direction, double postmile)
    {
        this.lineNum = lineNum;
        this.ldsID = ldsID;
        this.drop = drop;
        this.loops = loops;
        this.location = location;
        this.postmile = postmile;
        this.direction = direction;
        this.freeway = fwy;
        
        this.MLTotVol = 0;
        this.OppTotVol = 0;
    }
    
    /**
     * Enum for freeway direction.
     * 
     * @author John A. Torres
     * @version 9/10/2017
     */
    public static enum DIRECTION
    {
        NORTH("N"),
        SOUTH("S"),
        EAST("E"),
        WEST("W");
        
        String name;
        
        DIRECTION(String name)
        {
            this.name = name;
        }
        
        /**
         * Returns the direction enum, given a string value.
         * @param name str value for enum
         * @return enum for given str value
         */
        public static DIRECTION getEnum(String name)
        {
            switch(name)
            {
                case "S":
                    return SOUTH;
                case "N":
                    return NORTH;
                case "E":
                    return EAST;
                case "W":
                    return WEST;
                default:
                    return null;
            }
        }
    }
}
