001package com.ctre.phoenix.motorcontrol;
002
003import java.util.HashMap;
004
005/**
006 * Choose the remote limit switch source for a motor controller
007 */
008public enum RemoteLimitSwitchSource {
009    /**
010     * Use the limit switch connected
011     * to a Talon
012     */
013    RemoteTalon(1),
014    /**
015     * Use the limit switch connected
016     * to a TalonSRX
017     */
018    RemoteTalonSRX(1),
019    /**
020     * Use the limit switch connected
021     * to a CANifier 
022     */ 
023    RemoteCANifier(2), 
024    /**
025     * Don't use a limit switch
026     */
027    Deactivated(3);
028
029    /**
030     * Value of RemoteLimitSwitchSource
031     */
032        public final int value;
033
034    /**
035     * Create RemoteLimitSwitchSource of specified value
036     * @param value Value of RemoteLimitSwitchSource
037     */
038        RemoteLimitSwitchSource(int value) {
039                this.value = value;
040        }
041    /** Keep singleton map to quickly lookup enum via int */
042    private static HashMap<Integer, RemoteLimitSwitchSource> _map = null;
043        /** static c'tor, prepare the map */
044    static {
045        _map = new HashMap<Integer, RemoteLimitSwitchSource>();
046                for (RemoteLimitSwitchSource type : RemoteLimitSwitchSource.values()) {
047                        _map.put(type.value, type);
048                }
049    }
050    /**
051     * Get RemoteLimitSwitchSource of specified value
052     * @param value Value of RemoteLimitSwitchSource
053     * @return RemoteLimitSwitchSource of specified value
054     */
055        public static RemoteLimitSwitchSource valueOf(int value) {
056                RemoteLimitSwitchSource retval = _map.get(value);
057                if (retval != null)
058                        return retval;
059                return Deactivated;
060        }
061    /**
062     * Get RemoteLimitSwitchSource of specified value
063     * @param value Value of RemoteLimitSwitchSource
064     * @return RemoteLimitSwitchSource of specified value
065     */
066    public static RemoteLimitSwitchSource valueOf(double value) {
067        return valueOf((int) value); 
068    }
069    /**
070     * @return String representation of RemoteLimitSwitchSource
071     */
072    public String toString() {
073        switch(value) {
074            case 1 : return "RemoteLimitSwitchSource.RemoteTalon";
075            case 2 : return "RemoteLimitSwitchSource.RemoteCANifier";
076            case 3 : return "RemoteLimitSwitchSource.Deactivated";
077            default : return "InvalidValue";
078        }
079
080    }
081
082};