001package com.ctre.phoenix.motorcontrol;
002
003import java.util.HashMap;
004
005/**
006 * Choose the remote sensor source for a motor controller 
007 */
008public enum RemoteSensorSource {
009        /**
010         * Don't use a sensor
011         */
012        Off(0),
013        /**
014         * Use a sensor connected to
015         * a TalonSRX and configured on
016         * the TalonSRX
017         */
018        TalonSRX_SelectedSensor(1),
019        /**
020         * Use a sensor connected to
021         * a TalonFX and configured on
022         * the TalonFX
023         */
024        TalonFX_SelectedSensor(1),
025        /**
026         * Use a CAN Pigeon's Yaw value
027         */
028        Pigeon_Yaw(2),
029        /**
030         * Use a CAN Pigeon's Pitch value
031         */
032        Pigeon_Pitch(3),
033        /**
034         * Use a CAN Pigeon's Roll value
035         */
036        Pigeon_Roll(4),
037        /**
038         * Use a quadrature sensor
039         * connected to a CANifier
040         */
041        CANifier_Quadrature(5),
042        /**
043         * Use a PWM sensor connected
044         * to CANifier's PWM0
045         */
046        CANifier_PWMInput0(6),
047        /**
048         * Use a PWM sensor connected
049         * to CANifier's PWM1
050         */
051        CANifier_PWMInput1(7),
052        /**
053         * Use a PWM sensor connected
054         * to CANifier's PWM2
055         */
056        CANifier_PWMInput2(8),
057        /**
058         * Use a PWM sensor connected
059         * to CANifier's PWM3
060         */
061        CANifier_PWMInput3(9),
062        /**
063         * Use the yaw value of a pigeon
064         * connected to a talon over ribbon cable
065         */
066        GadgeteerPigeon_Yaw(10),
067        /**
068         * Use the pitch value of a pigeon
069         * connected to a talon over ribbon cable
070         */
071        GadgeteerPigeon_Pitch(11),
072        /**
073         * Use the roll value of a pigeon
074         * connected to a talon over ribbon cable
075         */
076        GadgeteerPigeon_Roll(12),
077        /**
078         * Use CANCoder
079         */
080        CANCoder(13);
081        /**
082         * Remote Sensor Source 14 is reserved
083         */
084        
085        /**
086         * Value of RemoteSensorSource
087         */
088        public int value;
089        /**
090         * Create RemoteSensorSource of specified value
091         * @param value Value of RemoteSensorSource
092         */
093        RemoteSensorSource(int value)
094        {
095                this.value = value;
096        }
097    /** Keep singleton map to quickly lookup enum via int */
098    private static HashMap<Integer, RemoteSensorSource> _map = null;
099        /** static c'tor, prepare the map */
100    static {
101        _map = new HashMap<Integer, RemoteSensorSource>();
102                for (RemoteSensorSource type : RemoteSensorSource.values()) {
103                        _map.put(type.value, type);
104                }
105        }
106        /**
107         * Get RemoteSensorSource of specified value
108         * @param value Value of RemoteSensorSource
109         * @return RemoteSensorSource of specified value
110         */
111        public static RemoteSensorSource valueOf(int value) {
112                RemoteSensorSource retval = _map.get(value);
113                if (retval != null)
114                        return retval;
115                return Off;
116        }
117        /**
118         * Get RemoteSensorSource of specified value
119         * @param value Value of RemoteSensorSource
120         * @return RemoteSensorSource of specified value
121         */
122    public static RemoteSensorSource valueOf(double value) {
123        return valueOf((int) value); 
124        }
125        /**
126         * @return string representation of RemoteSensorSource
127         */
128    public String toString() {
129        switch(value) {
130            case 0 : return "RemoteSensorSource.Off";
131            case 1 : return "RemoteSensorSource.TalonSRX_SelectedSensor";
132            case 2 : return "RemoteSensorSource.Pigeon_Yaw";
133            case 3 : return "RemoteSensorSource.Pigeon_Pitch";
134            case 4 : return "RemoteSensorSource.Pigeon_Roll";
135            case 5 : return "RemoteSensorSource.CANifier_Quadrature";
136            case 6 : return "RemoteSensorSource.CANifier_PWMInput0";
137            case 7 : return "RemoteSensorSource.CANifier_PWMInput1";
138            case 8 : return "RemoteSensorSource.CANifier_PWMInput2";
139            case 9 : return "RemoteSensorSource.CANifier_PWMInput3";
140            case 10: return "RemoteSensorSource.GadgeteerPigeon_Yaw";
141            case 11: return "RemoteSensorSource.GadgeteerPigeon_Pitch";
142            case 12: return "RemoteSensorSource.GadgeteerPigeon_Roll";
143                        case 13: return "RemoteSensorSource.CANCoder";
144            default: return "RemoteSensorSource.InvalidValue";
145        }
146    }
147
148};